google_cloudkms1/
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    /// View and manage your keys and secrets stored in Cloud Key Management Service
20    Full,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::Full => "https://www.googleapis.com/auth/cloudkms",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Full
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all CloudKMS related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_cloudkms1 as cloudkms1;
53/// use cloudkms1::{Result, Error};
54/// # async fn dox() {
55/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace  `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66///     .with_native_roots()
67///     .unwrap()
68///     .https_only()
69///     .enable_http2()
70///     .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74///     secret,
75///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76///     yup_oauth2::client::CustomHyperClientBuilder::from(
77///         hyper_util::client::legacy::Client::builder(executor).build(connector),
78///     ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82///     hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85///     hyper_rustls::HttpsConnectorBuilder::new()
86///         .with_native_roots()
87///         .unwrap()
88///         .https_or_http()
89///         .enable_http2()
90///         .build()
91/// );
92/// let mut hub = CloudKMS::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.projects().locations_ekm_config_get_iam_policy("resource")
97///              .options_requested_policy_version(-27)
98///              .doit().await;
99///
100/// match result {
101///     Err(e) => match e {
102///         // The Error enum provides details about what exactly happened.
103///         // You can also just use its `Debug`, `Display` or `Error` traits
104///          Error::HttpError(_)
105///         |Error::Io(_)
106///         |Error::MissingAPIKey
107///         |Error::MissingToken(_)
108///         |Error::Cancelled
109///         |Error::UploadSizeLimitExceeded(_, _)
110///         |Error::Failure(_)
111///         |Error::BadRequest(_)
112///         |Error::FieldClash(_)
113///         |Error::JsonDecodeError(_, _) => println!("{}", e),
114///     },
115///     Ok(res) => println!("Success: {:?}", res),
116/// }
117/// # }
118/// ```
119#[derive(Clone)]
120pub struct CloudKMS<C> {
121    pub client: common::Client<C>,
122    pub auth: Box<dyn common::GetToken>,
123    _user_agent: String,
124    _base_url: String,
125    _root_url: String,
126}
127
128impl<C> common::Hub for CloudKMS<C> {}
129
130impl<'a, C> CloudKMS<C> {
131    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudKMS<C> {
132        CloudKMS {
133            client,
134            auth: Box::new(auth),
135            _user_agent: "google-api-rust-client/7.0.0".to_string(),
136            _base_url: "https://cloudkms.googleapis.com/".to_string(),
137            _root_url: "https://cloudkms.googleapis.com/".to_string(),
138        }
139    }
140
141    pub fn folders(&'a self) -> FolderMethods<'a, C> {
142        FolderMethods { hub: self }
143    }
144    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
145        OrganizationMethods { hub: self }
146    }
147    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148        ProjectMethods { hub: self }
149    }
150
151    /// Set the user-agent header field to use in all requests to the server.
152    /// It defaults to `google-api-rust-client/7.0.0`.
153    ///
154    /// Returns the previously set user-agent.
155    pub fn user_agent(&mut self, agent_name: String) -> String {
156        std::mem::replace(&mut self._user_agent, agent_name)
157    }
158
159    /// Set the base url to use in all requests to the server.
160    /// It defaults to `https://cloudkms.googleapis.com/`.
161    ///
162    /// Returns the previously set base url.
163    pub fn base_url(&mut self, new_base_url: String) -> String {
164        std::mem::replace(&mut self._base_url, new_base_url)
165    }
166
167    /// Set the root url to use in all requests to the server.
168    /// It defaults to `https://cloudkms.googleapis.com/`.
169    ///
170    /// Returns the previously set root url.
171    pub fn root_url(&mut self, new_root_url: String) -> String {
172        std::mem::replace(&mut self._root_url, new_root_url)
173    }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// Request message for KeyManagementService.AsymmetricDecrypt.
180///
181/// # Activities
182///
183/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
184/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
185///
186/// * [locations key rings crypto keys crypto key versions asymmetric decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall) (request)
187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
188#[serde_with::serde_as]
189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
190pub struct AsymmetricDecryptRequest {
191    /// Required. The data encrypted with the named CryptoKeyVersion's public key using OAEP.
192    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
193    pub ciphertext: Option<Vec<u8>>,
194    /// Optional. An optional CRC32C checksum of the AsymmetricDecryptRequest.ciphertext. If specified, KeyManagementService will verify the integrity of the received AsymmetricDecryptRequest.ciphertext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(AsymmetricDecryptRequest.ciphertext) is equal to AsymmetricDecryptRequest.ciphertext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
195    #[serde(rename = "ciphertextCrc32c")]
196    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
197    pub ciphertext_crc32c: Option<i64>,
198}
199
200impl common::RequestValue for AsymmetricDecryptRequest {}
201
202/// Response message for KeyManagementService.AsymmetricDecrypt.
203///
204/// # Activities
205///
206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
208///
209/// * [locations key rings crypto keys crypto key versions asymmetric decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall) (response)
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct AsymmetricDecryptResponse {
214    /// The decrypted data originally encrypted with the matching public key.
215    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
216    pub plaintext: Option<Vec<u8>>,
217    /// Integrity verification field. A CRC32C checksum of the returned AsymmetricDecryptResponse.plaintext. An integrity check of AsymmetricDecryptResponse.plaintext can be performed by computing the CRC32C checksum of AsymmetricDecryptResponse.plaintext and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
218    #[serde(rename = "plaintextCrc32c")]
219    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
220    pub plaintext_crc32c: Option<i64>,
221    /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
222    #[serde(rename = "protectionLevel")]
223    pub protection_level: Option<String>,
224    /// Integrity verification field. A flag indicating whether AsymmetricDecryptRequest.ciphertext_crc32c was received by KeyManagementService and used for the integrity verification of the ciphertext. A false value of this field indicates either that AsymmetricDecryptRequest.ciphertext_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set AsymmetricDecryptRequest.ciphertext_crc32c but this field is still false, discard the response and perform a limited number of retries.
225    #[serde(rename = "verifiedCiphertextCrc32c")]
226    pub verified_ciphertext_crc32c: Option<bool>,
227}
228
229impl common::ResponseResult for AsymmetricDecryptResponse {}
230
231/// Request message for KeyManagementService.AsymmetricSign.
232///
233/// # Activities
234///
235/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
236/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
237///
238/// * [locations key rings crypto keys crypto key versions asymmetric sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall) (request)
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct AsymmetricSignRequest {
243    /// Optional. The data to sign. It can't be supplied if AsymmetricSignRequest.digest is supplied.
244    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
245    pub data: Option<Vec<u8>>,
246    /// Optional. An optional CRC32C checksum of the AsymmetricSignRequest.data. If specified, KeyManagementService will verify the integrity of the received AsymmetricSignRequest.data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(AsymmetricSignRequest.data) is equal to AsymmetricSignRequest.data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
247    #[serde(rename = "dataCrc32c")]
248    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
249    pub data_crc32c: Option<i64>,
250    /// Optional. The digest of the data to sign. The digest must be produced with the same digest algorithm as specified by the key version's algorithm. This field may not be supplied if AsymmetricSignRequest.data is supplied.
251    pub digest: Option<Digest>,
252    /// Optional. An optional CRC32C checksum of the AsymmetricSignRequest.digest. If specified, KeyManagementService will verify the integrity of the received AsymmetricSignRequest.digest using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(AsymmetricSignRequest.digest) is equal to AsymmetricSignRequest.digest_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
253    #[serde(rename = "digestCrc32c")]
254    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
255    pub digest_crc32c: Option<i64>,
256}
257
258impl common::RequestValue for AsymmetricSignRequest {}
259
260/// Response message for KeyManagementService.AsymmetricSign.
261///
262/// # Activities
263///
264/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
265/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
266///
267/// * [locations key rings crypto keys crypto key versions asymmetric sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall) (response)
268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
269#[serde_with::serde_as]
270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
271pub struct AsymmetricSignResponse {
272    /// The resource name of the CryptoKeyVersion used for signing. Check this field to verify that the intended resource was used for signing.
273    pub name: Option<String>,
274    /// The ProtectionLevel of the CryptoKeyVersion used for signing.
275    #[serde(rename = "protectionLevel")]
276    pub protection_level: Option<String>,
277    /// The created signature.
278    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
279    pub signature: Option<Vec<u8>>,
280    /// Integrity verification field. A CRC32C checksum of the returned AsymmetricSignResponse.signature. An integrity check of AsymmetricSignResponse.signature can be performed by computing the CRC32C checksum of AsymmetricSignResponse.signature and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
281    #[serde(rename = "signatureCrc32c")]
282    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
283    pub signature_crc32c: Option<i64>,
284    /// Integrity verification field. A flag indicating whether AsymmetricSignRequest.data_crc32c was received by KeyManagementService and used for the integrity verification of the data. A false value of this field indicates either that AsymmetricSignRequest.data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set AsymmetricSignRequest.data_crc32c but this field is still false, discard the response and perform a limited number of retries.
285    #[serde(rename = "verifiedDataCrc32c")]
286    pub verified_data_crc32c: Option<bool>,
287    /// Integrity verification field. A flag indicating whether AsymmetricSignRequest.digest_crc32c was received by KeyManagementService and used for the integrity verification of the digest. A false value of this field indicates either that AsymmetricSignRequest.digest_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set AsymmetricSignRequest.digest_crc32c but this field is still false, discard the response and perform a limited number of retries.
288    #[serde(rename = "verifiedDigestCrc32c")]
289    pub verified_digest_crc32c: Option<bool>,
290}
291
292impl common::ResponseResult for AsymmetricSignResponse {}
293
294/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
295///
296/// This type is not used in any activity, and only used as *part* of another schema.
297///
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct AuditConfig {
302    /// The configuration for logging of each type of permission.
303    #[serde(rename = "auditLogConfigs")]
304    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
305    /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
306    pub service: Option<String>,
307}
308
309impl common::Part for AuditConfig {}
310
311/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
312///
313/// This type is not used in any activity, and only used as *part* of another schema.
314///
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct AuditLogConfig {
319    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
320    #[serde(rename = "exemptedMembers")]
321    pub exempted_members: Option<Vec<String>>,
322    /// The log type that this config enables.
323    #[serde(rename = "logType")]
324    pub log_type: Option<String>,
325}
326
327impl common::Part for AuditLogConfig {}
328
329/// Cloud KMS Autokey configuration for a folder.
330///
331/// # Activities
332///
333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
335///
336/// * [get autokey config folders](FolderGetAutokeyConfigCall) (response)
337/// * [update autokey config folders](FolderUpdateAutokeyConfigCall) (request|response)
338#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
339#[serde_with::serde_as]
340#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
341pub struct AutokeyConfig {
342    /// Optional. A checksum computed by the server based on the value of other fields. This may be sent on update requests to ensure that the client has an up-to-date value before proceeding. The request will be rejected with an ABORTED error on a mismatched etag.
343    pub etag: Option<String>,
344    /// Optional. Name of the key project, e.g. `projects/{PROJECT_ID}` or `projects/{PROJECT_NUMBER}`, where Cloud KMS Autokey will provision a new CryptoKey when a KeyHandle is created. On UpdateAutokeyConfig, the caller will require `cloudkms.cryptoKeys.setIamPolicy` permission on this key project. Once configured, for Cloud KMS Autokey to function properly, this key project must have the Cloud KMS API activated and the Cloud KMS Service Agent for this key project must be granted the `cloudkms.admin` role (or pertinent permissions). A request with an empty key project field will clear the configuration.
345    #[serde(rename = "keyProject")]
346    pub key_project: Option<String>,
347    /// Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`
348    pub name: Option<String>,
349    /// Output only. The state for the AutokeyConfig.
350    pub state: Option<String>,
351}
352
353impl common::RequestValue for AutokeyConfig {}
354impl common::ResponseResult for AutokeyConfig {}
355
356/// Associates `members`, or principals, with a `role`.
357///
358/// This type is not used in any activity, and only used as *part* of another schema.
359///
360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
361#[serde_with::serde_as]
362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
363pub struct Binding {
364    /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
365    pub condition: Option<Expr>,
366    /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
367    pub members: Option<Vec<String>>,
368    /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
369    pub role: Option<String>,
370}
371
372impl common::Part for Binding {}
373
374/// A Certificate represents an X.509 certificate used to authenticate HTTPS connections to EKM replicas.
375///
376/// This type is not used in any activity, and only used as *part* of another schema.
377///
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct Certificate {
382    /// Output only. The issuer distinguished name in RFC 2253 format. Only present if parsed is true.
383    pub issuer: Option<String>,
384    /// Output only. The certificate is not valid after this time. Only present if parsed is true.
385    #[serde(rename = "notAfterTime")]
386    pub not_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
387    /// Output only. The certificate is not valid before this time. Only present if parsed is true.
388    #[serde(rename = "notBeforeTime")]
389    pub not_before_time: Option<chrono::DateTime<chrono::offset::Utc>>,
390    /// Output only. True if the certificate was parsed successfully.
391    pub parsed: Option<bool>,
392    /// Required. The raw certificate bytes in DER format.
393    #[serde(rename = "rawDer")]
394    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
395    pub raw_der: Option<Vec<u8>>,
396    /// Output only. The certificate serial number as a hex string. Only present if parsed is true.
397    #[serde(rename = "serialNumber")]
398    pub serial_number: Option<String>,
399    /// Output only. The SHA-256 certificate fingerprint as a hex string. Only present if parsed is true.
400    #[serde(rename = "sha256Fingerprint")]
401    pub sha256_fingerprint: Option<String>,
402    /// Output only. The subject distinguished name in RFC 2253 format. Only present if parsed is true.
403    pub subject: Option<String>,
404    /// Output only. The subject Alternative DNS names. Only present if parsed is true.
405    #[serde(rename = "subjectAlternativeDnsNames")]
406    pub subject_alternative_dns_names: Option<Vec<String>>,
407}
408
409impl common::Part for Certificate {}
410
411/// Certificate chains needed to verify the attestation. Certificates in chains are PEM-encoded and are ordered based on https://tools.ietf.org/html/rfc5246#section-7.4.2.
412///
413/// This type is not used in any activity, and only used as *part* of another schema.
414///
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct CertificateChains {
419    /// Cavium certificate chain corresponding to the attestation.
420    #[serde(rename = "caviumCerts")]
421    pub cavium_certs: Option<Vec<String>>,
422    /// Google card certificate chain corresponding to the attestation.
423    #[serde(rename = "googleCardCerts")]
424    pub google_card_certs: Option<Vec<String>>,
425    /// Google partition certificate chain corresponding to the attestation.
426    #[serde(rename = "googlePartitionCerts")]
427    pub google_partition_certs: Option<Vec<String>>,
428}
429
430impl common::Part for CertificateChains {}
431
432/// Data with integrity verification field.
433///
434/// This type is not used in any activity, and only used as *part* of another schema.
435///
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct ChecksummedData {
440    /// Integrity verification field. A CRC32C checksum of the returned ChecksummedData.data. An integrity check of ChecksummedData.data can be performed by computing the CRC32C checksum of ChecksummedData.data and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed `2^32-1`, and can be safely downconverted to uint32 in languages that support this type.
441    #[serde(rename = "crc32cChecksum")]
442    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
443    pub crc32c_checksum: Option<i64>,
444    /// Raw Data.
445    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
446    pub data: Option<Vec<u8>>,
447}
448
449impl common::Part for ChecksummedData {}
450
451/// A CryptoKey represents a logical key that can be used for cryptographic operations. A CryptoKey is made up of zero or more versions, which represent the actual key material used in cryptographic operations.
452///
453/// # Activities
454///
455/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
456/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
457///
458/// * [locations key rings crypto keys create projects](ProjectLocationKeyRingCryptoKeyCreateCall) (request|response)
459/// * [locations key rings crypto keys get projects](ProjectLocationKeyRingCryptoKeyGetCall) (response)
460/// * [locations key rings crypto keys patch projects](ProjectLocationKeyRingCryptoKeyPatchCall) (request|response)
461/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (response)
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct CryptoKey {
466    /// Output only. The time at which this CryptoKey was created.
467    #[serde(rename = "createTime")]
468    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
469    /// Immutable. The resource name of the backend environment where the key material for all CryptoKeyVersions associated with this CryptoKey reside and where all related cryptographic operations are performed. Only applicable if CryptoKeyVersions have a ProtectionLevel of EXTERNAL_VPC, with the resource name in the format `projects/*/locations/*/ekmConnections/*`. Only applicable if CryptoKeyVersions have a ProtectionLevel of HSM_SINGLE_TENANT, with the resource name in the format `projects/*/locations/*/singleTenantHsmInstances/*`. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.
470    #[serde(rename = "cryptoKeyBackend")]
471    pub crypto_key_backend: Option<String>,
472    /// Immutable. The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. If not specified at creation time, the default duration is 30 days.
473    #[serde(rename = "destroyScheduledDuration")]
474    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
475    pub destroy_scheduled_duration: Option<chrono::Duration>,
476    /// Immutable. Whether this key may contain imported versions only.
477    #[serde(rename = "importOnly")]
478    pub import_only: Option<bool>,
479    /// Optional. The policy used for Key Access Justifications Policy Enforcement. If this field is present and this key is enrolled in Key Access Justifications Policy Enforcement, the policy will be evaluated in encrypt, decrypt, and sign operations, and the operation will fail if rejected by the policy. The policy is defined by specifying zero or more allowed justification codes. https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes By default, this field is absent, and all justification codes are allowed.
480    #[serde(rename = "keyAccessJustificationsPolicy")]
481    pub key_access_justifications_policy: Option<KeyAccessJustificationsPolicy>,
482    /// Labels with user-defined metadata. For more information, see [Labeling Keys](https://cloud.google.com/kms/docs/labeling-keys).
483    pub labels: Option<HashMap<String, String>>,
484    /// Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
485    pub name: Option<String>,
486    /// At next_rotation_time, the Key Management Service will automatically: 1. Create a new version of this CryptoKey. 2. Mark the new version as primary. Key rotations performed manually via CreateCryptoKeyVersion and UpdateCryptoKeyPrimaryVersion do not affect next_rotation_time. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.
487    #[serde(rename = "nextRotationTime")]
488    pub next_rotation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
489    /// Output only. A copy of the "primary" CryptoKeyVersion that will be used by Encrypt when this CryptoKey is given in EncryptRequest.name. The CryptoKey's primary version can be updated via UpdateCryptoKeyPrimaryVersion. Keys with purpose ENCRYPT_DECRYPT may have a primary. For other keys, this field will be omitted.
490    pub primary: Option<CryptoKeyVersion>,
491    /// Immutable. The immutable purpose of this CryptoKey.
492    pub purpose: Option<String>,
493    /// next_rotation_time will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If rotation_period is set, next_rotation_time must also be set. Keys with purpose ENCRYPT_DECRYPT support automatic rotation. For other keys, this field must be omitted.
494    #[serde(rename = "rotationPeriod")]
495    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
496    pub rotation_period: Option<chrono::Duration>,
497    /// A template describing settings for new CryptoKeyVersion instances. The properties of new CryptoKeyVersion instances created by either CreateCryptoKeyVersion or auto-rotation are controlled by this template.
498    #[serde(rename = "versionTemplate")]
499    pub version_template: Option<CryptoKeyVersionTemplate>,
500}
501
502impl common::RequestValue for CryptoKey {}
503impl common::ResponseResult for CryptoKey {}
504
505/// A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS.
506///
507/// # Activities
508///
509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
511///
512/// * [locations key rings crypto keys crypto key versions create projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall) (request|response)
513/// * [locations key rings crypto keys crypto key versions destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (response)
514/// * [locations key rings crypto keys crypto key versions get projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall) (response)
515/// * [locations key rings crypto keys crypto key versions import projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall) (response)
516/// * [locations key rings crypto keys crypto key versions patch projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall) (request|response)
517/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (response)
518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
519#[serde_with::serde_as]
520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
521pub struct CryptoKeyVersion {
522    /// Output only. The CryptoKeyVersionAlgorithm that this CryptoKeyVersion supports.
523    pub algorithm: Option<String>,
524    /// Output only. Statement that was generated and signed by the HSM at key creation time. Use this statement to verify attributes of the key as stored on the HSM, independently of Google. Only provided for key versions with protection_level HSM.
525    pub attestation: Option<KeyOperationAttestation>,
526    /// Output only. The time at which this CryptoKeyVersion was created.
527    #[serde(rename = "createTime")]
528    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
529    /// Output only. The time this CryptoKeyVersion's key material was destroyed. Only present if state is DESTROYED.
530    #[serde(rename = "destroyEventTime")]
531    pub destroy_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
532    /// Output only. The time this CryptoKeyVersion's key material is scheduled for destruction. Only present if state is DESTROY_SCHEDULED.
533    #[serde(rename = "destroyTime")]
534    pub destroy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
535    /// Output only. The root cause of the most recent external destruction failure. Only present if state is EXTERNAL_DESTRUCTION_FAILED.
536    #[serde(rename = "externalDestructionFailureReason")]
537    pub external_destruction_failure_reason: Option<String>,
538    /// ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
539    #[serde(rename = "externalProtectionLevelOptions")]
540    pub external_protection_level_options: Option<ExternalProtectionLevelOptions>,
541    /// Output only. The time this CryptoKeyVersion's key material was generated.
542    #[serde(rename = "generateTime")]
543    pub generate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
544    /// Output only. The root cause of the most recent generation failure. Only present if state is GENERATION_FAILED.
545    #[serde(rename = "generationFailureReason")]
546    pub generation_failure_reason: Option<String>,
547    /// Output only. The root cause of the most recent import failure. Only present if state is IMPORT_FAILED.
548    #[serde(rename = "importFailureReason")]
549    pub import_failure_reason: Option<String>,
550    /// Output only. The name of the ImportJob used in the most recent import of this CryptoKeyVersion. Only present if the underlying key material was imported.
551    #[serde(rename = "importJob")]
552    pub import_job: Option<String>,
553    /// Output only. The time at which this CryptoKeyVersion's key material was most recently imported.
554    #[serde(rename = "importTime")]
555    pub import_time: Option<chrono::DateTime<chrono::offset::Utc>>,
556    /// Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
557    pub name: Option<String>,
558    /// Output only. The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion.
559    #[serde(rename = "protectionLevel")]
560    pub protection_level: Option<String>,
561    /// Output only. Whether or not this key version is eligible for reimport, by being specified as a target in ImportCryptoKeyVersionRequest.crypto_key_version.
562    #[serde(rename = "reimportEligible")]
563    pub reimport_eligible: Option<bool>,
564    /// The current state of the CryptoKeyVersion.
565    pub state: Option<String>,
566}
567
568impl common::RequestValue for CryptoKeyVersion {}
569impl common::ResponseResult for CryptoKeyVersion {}
570
571/// A CryptoKeyVersionTemplate specifies the properties to use when creating a new CryptoKeyVersion, either manually with CreateCryptoKeyVersion or automatically as a result of auto-rotation.
572///
573/// This type is not used in any activity, and only used as *part* of another schema.
574///
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct CryptoKeyVersionTemplate {
579    /// Required. Algorithm to use when creating a CryptoKeyVersion based on this template. For backwards compatibility, GOOGLE_SYMMETRIC_ENCRYPTION is implied if both this field is omitted and CryptoKey.purpose is ENCRYPT_DECRYPT.
580    pub algorithm: Option<String>,
581    /// ProtectionLevel to use when creating a CryptoKeyVersion based on this template. Immutable. Defaults to SOFTWARE.
582    #[serde(rename = "protectionLevel")]
583    pub protection_level: Option<String>,
584}
585
586impl common::Part for CryptoKeyVersionTemplate {}
587
588/// Request message for KeyManagementService.Decapsulate.
589///
590/// # Activities
591///
592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
594///
595/// * [locations key rings crypto keys crypto key versions decapsulate projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall) (request)
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct DecapsulateRequest {
600    /// Required. The ciphertext produced from encapsulation with the named CryptoKeyVersion public key(s).
601    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
602    pub ciphertext: Option<Vec<u8>>,
603    /// Optional. A CRC32C checksum of the DecapsulateRequest.ciphertext. If specified, KeyManagementService will verify the integrity of the received DecapsulateRequest.ciphertext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(DecapsulateRequest.ciphertext) is equal to DecapsulateRequest.ciphertext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
604    #[serde(rename = "ciphertextCrc32c")]
605    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
606    pub ciphertext_crc32c: Option<i64>,
607}
608
609impl common::RequestValue for DecapsulateRequest {}
610
611/// Response message for KeyManagementService.Decapsulate.
612///
613/// # Activities
614///
615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
617///
618/// * [locations key rings crypto keys crypto key versions decapsulate projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall) (response)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct DecapsulateResponse {
623    /// The resource name of the CryptoKeyVersion used for decapsulation. Check this field to verify that the intended resource was used for decapsulation.
624    pub name: Option<String>,
625    /// The ProtectionLevel of the CryptoKeyVersion used in decapsulation.
626    #[serde(rename = "protectionLevel")]
627    pub protection_level: Option<String>,
628    /// The decapsulated shared_secret originally encapsulated with the matching public key.
629    #[serde(rename = "sharedSecret")]
630    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
631    pub shared_secret: Option<Vec<u8>>,
632    /// Integrity verification field. A CRC32C checksum of the returned DecapsulateResponse.shared_secret. An integrity check of DecapsulateResponse.shared_secret can be performed by computing the CRC32C checksum of DecapsulateResponse.shared_secret and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: receiving this response message indicates that KeyManagementService is able to successfully decrypt the ciphertext. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
633    #[serde(rename = "sharedSecretCrc32c")]
634    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
635    pub shared_secret_crc32c: Option<i64>,
636    /// Integrity verification field. A flag indicating whether DecapsulateRequest.ciphertext_crc32c was received by KeyManagementService and used for the integrity verification of the ciphertext. A false value of this field indicates either that DecapsulateRequest.ciphertext_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set DecapsulateRequest.ciphertext_crc32c but this field is still false, discard the response and perform a limited number of retries.
637    #[serde(rename = "verifiedCiphertextCrc32c")]
638    pub verified_ciphertext_crc32c: Option<bool>,
639}
640
641impl common::ResponseResult for DecapsulateResponse {}
642
643/// Request message for KeyManagementService.Decrypt.
644///
645/// # Activities
646///
647/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
648/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
649///
650/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (request)
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct DecryptRequest {
655    /// Optional. Optional data that must match the data originally supplied in EncryptRequest.additional_authenticated_data.
656    #[serde(rename = "additionalAuthenticatedData")]
657    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
658    pub additional_authenticated_data: Option<Vec<u8>>,
659    /// Optional. An optional CRC32C checksum of the DecryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received DecryptRequest.additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(DecryptRequest.additional_authenticated_data) is equal to DecryptRequest.additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
660    #[serde(rename = "additionalAuthenticatedDataCrc32c")]
661    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
662    pub additional_authenticated_data_crc32c: Option<i64>,
663    /// Required. The encrypted data originally returned in EncryptResponse.ciphertext.
664    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
665    pub ciphertext: Option<Vec<u8>>,
666    /// Optional. An optional CRC32C checksum of the DecryptRequest.ciphertext. If specified, KeyManagementService will verify the integrity of the received DecryptRequest.ciphertext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(DecryptRequest.ciphertext) is equal to DecryptRequest.ciphertext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
667    #[serde(rename = "ciphertextCrc32c")]
668    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
669    pub ciphertext_crc32c: Option<i64>,
670}
671
672impl common::RequestValue for DecryptRequest {}
673
674/// Response message for KeyManagementService.Decrypt.
675///
676/// # Activities
677///
678/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
679/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
680///
681/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (response)
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct DecryptResponse {
686    /// The decrypted data originally supplied in EncryptRequest.plaintext.
687    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
688    pub plaintext: Option<Vec<u8>>,
689    /// Integrity verification field. A CRC32C checksum of the returned DecryptResponse.plaintext. An integrity check of DecryptResponse.plaintext can be performed by computing the CRC32C checksum of DecryptResponse.plaintext and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: receiving this response message indicates that KeyManagementService is able to successfully decrypt the ciphertext. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
690    #[serde(rename = "plaintextCrc32c")]
691    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
692    pub plaintext_crc32c: Option<i64>,
693    /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
694    #[serde(rename = "protectionLevel")]
695    pub protection_level: Option<String>,
696    /// Whether the Decryption was performed using the primary key version.
697    #[serde(rename = "usedPrimary")]
698    pub used_primary: Option<bool>,
699}
700
701impl common::ResponseResult for DecryptResponse {}
702
703/// Request message for KeyManagementService.DestroyCryptoKeyVersion.
704///
705/// # Activities
706///
707/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
709///
710/// * [locations key rings crypto keys crypto key versions destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (request)
711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
712#[serde_with::serde_as]
713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
714pub struct DestroyCryptoKeyVersionRequest {
715    _never_set: Option<bool>,
716}
717
718impl common::RequestValue for DestroyCryptoKeyVersionRequest {}
719
720/// A Digest holds a cryptographic message digest.
721///
722/// This type is not used in any activity, and only used as *part* of another schema.
723///
724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
725#[serde_with::serde_as]
726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
727pub struct Digest {
728    /// A message digest produced with the SHA-256 algorithm.
729    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
730    pub sha256: Option<Vec<u8>>,
731    /// A message digest produced with the SHA-384 algorithm.
732    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
733    pub sha384: Option<Vec<u8>>,
734    /// A message digest produced with the SHA-512 algorithm.
735    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
736    pub sha512: Option<Vec<u8>>,
737}
738
739impl common::Part for Digest {}
740
741/// An EkmConfig is a singleton resource that represents configuration parameters that apply to all CryptoKeys and CryptoKeyVersions with a ProtectionLevel of EXTERNAL_VPC in a given project and location.
742///
743/// # Activities
744///
745/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
746/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
747///
748/// * [locations get ekm config projects](ProjectLocationGetEkmConfigCall) (response)
749/// * [locations update ekm config projects](ProjectLocationUpdateEkmConfigCall) (request|response)
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct EkmConfig {
754    /// Optional. Resource name of the default EkmConnection. Setting this field to the empty string removes the default.
755    #[serde(rename = "defaultEkmConnection")]
756    pub default_ekm_connection: Option<String>,
757    /// Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
758    pub name: Option<String>,
759}
760
761impl common::RequestValue for EkmConfig {}
762impl common::ResponseResult for EkmConfig {}
763
764/// An EkmConnection represents an individual EKM connection. It can be used for creating CryptoKeys and CryptoKeyVersions with a ProtectionLevel of EXTERNAL_VPC, as well as performing cryptographic operations using keys created within the EkmConnection.
765///
766/// # Activities
767///
768/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
769/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
770///
771/// * [locations ekm connections create projects](ProjectLocationEkmConnectionCreateCall) (request|response)
772/// * [locations ekm connections get projects](ProjectLocationEkmConnectionGetCall) (response)
773/// * [locations ekm connections patch projects](ProjectLocationEkmConnectionPatchCall) (request|response)
774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
775#[serde_with::serde_as]
776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
777pub struct EkmConnection {
778    /// Output only. The time at which the EkmConnection was created.
779    #[serde(rename = "createTime")]
780    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
781    /// Optional. Identifies the EKM Crypto Space that this EkmConnection maps to. Note: This field is required if KeyManagementMode is CLOUD_KMS.
782    #[serde(rename = "cryptoSpacePath")]
783    pub crypto_space_path: Option<String>,
784    /// Optional. Etag of the currently stored EkmConnection.
785    pub etag: Option<String>,
786    /// Optional. Describes who can perform control plane operations on the EKM. If unset, this defaults to MANUAL.
787    #[serde(rename = "keyManagementMode")]
788    pub key_management_mode: Option<String>,
789    /// Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
790    pub name: Option<String>,
791    /// Optional. A list of ServiceResolvers where the EKM can be reached. There should be one ServiceResolver per EKM replica. Currently, only a single ServiceResolver is supported.
792    #[serde(rename = "serviceResolvers")]
793    pub service_resolvers: Option<Vec<ServiceResolver>>,
794}
795
796impl common::RequestValue for EkmConnection {}
797impl common::ResponseResult for EkmConnection {}
798
799/// Request message for KeyManagementService.Encrypt.
800///
801/// # Activities
802///
803/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
804/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
805///
806/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (request)
807#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
808#[serde_with::serde_as]
809#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
810pub struct EncryptRequest {
811    /// Optional. Optional data that, if specified, must also be provided during decryption through DecryptRequest.additional_authenticated_data. The maximum size depends on the key version's protection_level. For SOFTWARE, EXTERNAL, and EXTERNAL_VPC keys the AAD must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
812    #[serde(rename = "additionalAuthenticatedData")]
813    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
814    pub additional_authenticated_data: Option<Vec<u8>>,
815    /// Optional. An optional CRC32C checksum of the EncryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received EncryptRequest.additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(EncryptRequest.additional_authenticated_data) is equal to EncryptRequest.additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
816    #[serde(rename = "additionalAuthenticatedDataCrc32c")]
817    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
818    pub additional_authenticated_data_crc32c: Option<i64>,
819    /// Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE, EXTERNAL, and EXTERNAL_VPC keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
820    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
821    pub plaintext: Option<Vec<u8>>,
822    /// Optional. An optional CRC32C checksum of the EncryptRequest.plaintext. If specified, KeyManagementService will verify the integrity of the received EncryptRequest.plaintext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(EncryptRequest.plaintext) is equal to EncryptRequest.plaintext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
823    #[serde(rename = "plaintextCrc32c")]
824    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
825    pub plaintext_crc32c: Option<i64>,
826}
827
828impl common::RequestValue for EncryptRequest {}
829
830/// Response message for KeyManagementService.Encrypt.
831///
832/// # Activities
833///
834/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
835/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
836///
837/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (response)
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct EncryptResponse {
842    /// The encrypted data.
843    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
844    pub ciphertext: Option<Vec<u8>>,
845    /// Integrity verification field. A CRC32C checksum of the returned EncryptResponse.ciphertext. An integrity check of EncryptResponse.ciphertext can be performed by computing the CRC32C checksum of EncryptResponse.ciphertext and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
846    #[serde(rename = "ciphertextCrc32c")]
847    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
848    pub ciphertext_crc32c: Option<i64>,
849    /// The resource name of the CryptoKeyVersion used in encryption. Check this field to verify that the intended resource was used for encryption.
850    pub name: Option<String>,
851    /// The ProtectionLevel of the CryptoKeyVersion used in encryption.
852    #[serde(rename = "protectionLevel")]
853    pub protection_level: Option<String>,
854    /// Integrity verification field. A flag indicating whether EncryptRequest.additional_authenticated_data_crc32c was received by KeyManagementService and used for the integrity verification of the AAD. A false value of this field indicates either that EncryptRequest.additional_authenticated_data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set EncryptRequest.additional_authenticated_data_crc32c but this field is still false, discard the response and perform a limited number of retries.
855    #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
856    pub verified_additional_authenticated_data_crc32c: Option<bool>,
857    /// Integrity verification field. A flag indicating whether EncryptRequest.plaintext_crc32c was received by KeyManagementService and used for the integrity verification of the plaintext. A false value of this field indicates either that EncryptRequest.plaintext_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set EncryptRequest.plaintext_crc32c but this field is still false, discard the response and perform a limited number of retries.
858    #[serde(rename = "verifiedPlaintextCrc32c")]
859    pub verified_plaintext_crc32c: Option<bool>,
860}
861
862impl common::ResponseResult for EncryptResponse {}
863
864/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
865///
866/// This type is not used in any activity, and only used as *part* of another schema.
867///
868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
869#[serde_with::serde_as]
870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
871pub struct Expr {
872    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
873    pub description: Option<String>,
874    /// Textual representation of an expression in Common Expression Language syntax.
875    pub expression: Option<String>,
876    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
877    pub location: Option<String>,
878    /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
879    pub title: Option<String>,
880}
881
882impl common::Part for Expr {}
883
884/// ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
885///
886/// This type is not used in any activity, and only used as *part* of another schema.
887///
888#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
889#[serde_with::serde_as]
890#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
891pub struct ExternalProtectionLevelOptions {
892    /// The path to the external key material on the EKM when using EkmConnection e.g., "v0/my/key". Set this field instead of external_key_uri when using an EkmConnection.
893    #[serde(rename = "ekmConnectionKeyPath")]
894    pub ekm_connection_key_path: Option<String>,
895    /// The URI for an external resource that this CryptoKeyVersion represents.
896    #[serde(rename = "externalKeyUri")]
897    pub external_key_uri: Option<String>,
898}
899
900impl common::Part for ExternalProtectionLevelOptions {}
901
902/// Request message for KeyManagementService.GenerateRandomBytes.
903///
904/// # Activities
905///
906/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
907/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
908///
909/// * [locations generate random bytes projects](ProjectLocationGenerateRandomByteCall) (request)
910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
911#[serde_with::serde_as]
912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
913pub struct GenerateRandomBytesRequest {
914    /// The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes.
915    #[serde(rename = "lengthBytes")]
916    pub length_bytes: Option<i32>,
917    /// The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported.
918    #[serde(rename = "protectionLevel")]
919    pub protection_level: Option<String>,
920}
921
922impl common::RequestValue for GenerateRandomBytesRequest {}
923
924/// Response message for KeyManagementService.GenerateRandomBytes.
925///
926/// # Activities
927///
928/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
929/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
930///
931/// * [locations generate random bytes projects](ProjectLocationGenerateRandomByteCall) (response)
932#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
933#[serde_with::serde_as]
934#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
935pub struct GenerateRandomBytesResponse {
936    /// The generated data.
937    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
938    pub data: Option<Vec<u8>>,
939    /// Integrity verification field. A CRC32C checksum of the returned GenerateRandomBytesResponse.data. An integrity check of GenerateRandomBytesResponse.data can be performed by computing the CRC32C checksum of GenerateRandomBytesResponse.data and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
940    #[serde(rename = "dataCrc32c")]
941    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
942    pub data_crc32c: Option<i64>,
943}
944
945impl common::ResponseResult for GenerateRandomBytesResponse {}
946
947/// Request message for KeyManagementService.ImportCryptoKeyVersion.
948///
949/// # Activities
950///
951/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
952/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
953///
954/// * [locations key rings crypto keys crypto key versions import projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall) (request)
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct ImportCryptoKeyVersionRequest {
959    /// Required. The algorithm of the key being imported. This does not need to match the version_template of the CryptoKey this version imports into.
960    pub algorithm: Option<String>,
961    /// Optional. The optional name of an existing CryptoKeyVersion to target for an import operation. If this field is not present, a new CryptoKeyVersion containing the supplied key material is created. If this field is present, the supplied key material is imported into the existing CryptoKeyVersion. To import into an existing CryptoKeyVersion, the CryptoKeyVersion must be a child of ImportCryptoKeyVersionRequest.parent, have been previously created via ImportCryptoKeyVersion, and be in DESTROYED or IMPORT_FAILED state. The key material and algorithm must match the previous CryptoKeyVersion exactly if the CryptoKeyVersion has ever contained key material.
962    #[serde(rename = "cryptoKeyVersion")]
963    pub crypto_key_version: Option<String>,
964    /// Required. The name of the ImportJob that was used to wrap this key material.
965    #[serde(rename = "importJob")]
966    pub import_job: Option<String>,
967    /// Optional. This field has the same meaning as wrapped_key. Prefer to use that field in new work. Either that field or this field (but not both) must be specified.
968    #[serde(rename = "rsaAesWrappedKey")]
969    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
970    pub rsa_aes_wrapped_key: Option<Vec<u8>>,
971    /// Optional. The wrapped key material to import. Before wrapping, key material must be formatted. If importing symmetric key material, the expected key material format is plain bytes. If importing asymmetric key material, the expected key material format is PKCS#8-encoded DER (the PrivateKeyInfo structure from RFC 5208). When wrapping with import methods (RSA_OAEP_3072_SHA1_AES_256 or RSA_OAEP_4096_SHA1_AES_256 or RSA_OAEP_3072_SHA256_AES_256 or RSA_OAEP_4096_SHA256_AES_256), this field must contain the concatenation of: 1. An ephemeral AES-256 wrapping key wrapped with the public_key using RSAES-OAEP with SHA-1/SHA-256, MGF1 with SHA-1/SHA-256, and an empty label. 2. The formatted key to be imported, wrapped with the ephemeral AES-256 key using AES-KWP (RFC 5649). This format is the same as the format produced by PKCS#11 mechanism CKM_RSA_AES_KEY_WRAP. When wrapping with import methods (RSA_OAEP_3072_SHA256 or RSA_OAEP_4096_SHA256), this field must contain the formatted key to be imported, wrapped with the public_key using RSAES-OAEP with SHA-256, MGF1 with SHA-256, and an empty label.
972    #[serde(rename = "wrappedKey")]
973    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
974    pub wrapped_key: Option<Vec<u8>>,
975}
976
977impl common::RequestValue for ImportCryptoKeyVersionRequest {}
978
979/// An ImportJob can be used to create CryptoKeys and CryptoKeyVersions using pre-existing key material, generated outside of Cloud KMS. When an ImportJob is created, Cloud KMS will generate a “wrapping key”, which is a public/private key pair. You use the wrapping key to encrypt (also known as wrap) the pre-existing key material to protect it during the import process. The nature of the wrapping key depends on the choice of import_method. When the wrapping key generation is complete, the state will be set to ACTIVE and the public_key can be fetched. The fetched public key can then be used to wrap your pre-existing key material. Once the key material is wrapped, it can be imported into a new CryptoKeyVersion in an existing CryptoKey by calling ImportCryptoKeyVersion. Multiple CryptoKeyVersions can be imported with a single ImportJob. Cloud KMS uses the private key portion of the wrapping key to unwrap the key material. Only Cloud KMS has access to the private key. An ImportJob expires 3 days after it is created. Once expired, Cloud KMS will no longer be able to import or unwrap any key material that was wrapped with the ImportJob’s public key. For more information, see [Importing a key](https://cloud.google.com/kms/docs/importing-a-key).
980///
981/// # Activities
982///
983/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
984/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
985///
986/// * [locations key rings import jobs create projects](ProjectLocationKeyRingImportJobCreateCall) (request|response)
987/// * [locations key rings import jobs get projects](ProjectLocationKeyRingImportJobGetCall) (response)
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct ImportJob {
992    /// Output only. Statement that was generated and signed by the key creator (for example, an HSM) at key creation time. Use this statement to verify attributes of the key as stored on the HSM, independently of Google. Only present if the chosen ImportMethod is one with a protection level of HSM.
993    pub attestation: Option<KeyOperationAttestation>,
994    /// Output only. The time at which this ImportJob was created.
995    #[serde(rename = "createTime")]
996    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
997    /// Immutable. The resource name of the backend environment where the key material for the wrapping key resides and where all related cryptographic operations are performed. Currently, this field is only populated for keys stored in HSM_SINGLE_TENANT. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.
998    #[serde(rename = "cryptoKeyBackend")]
999    pub crypto_key_backend: Option<String>,
1000    /// Output only. The time this ImportJob expired. Only present if state is EXPIRED.
1001    #[serde(rename = "expireEventTime")]
1002    pub expire_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1003    /// Output only. The time at which this ImportJob is scheduled for expiration and can no longer be used to import key material.
1004    #[serde(rename = "expireTime")]
1005    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1006    /// Output only. The time this ImportJob's key material was generated.
1007    #[serde(rename = "generateTime")]
1008    pub generate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1009    /// Required. Immutable. The wrapping method to be used for incoming key material.
1010    #[serde(rename = "importMethod")]
1011    pub import_method: Option<String>,
1012    /// Output only. The resource name for this ImportJob in the format `projects/*/locations/*/keyRings/*/importJobs/*`.
1013    pub name: Option<String>,
1014    /// Required. Immutable. The protection level of the ImportJob. This must match the protection_level of the version_template on the CryptoKey you attempt to import into.
1015    #[serde(rename = "protectionLevel")]
1016    pub protection_level: Option<String>,
1017    /// Output only. The public key with which to wrap key material prior to import. Only returned if state is ACTIVE.
1018    #[serde(rename = "publicKey")]
1019    pub public_key: Option<WrappingPublicKey>,
1020    /// Output only. The current state of the ImportJob, indicating if it can be used.
1021    pub state: Option<String>,
1022}
1023
1024impl common::RequestValue for ImportJob {}
1025impl common::ResponseResult for ImportJob {}
1026
1027/// The configuration of a protection level for a project's Key Access Justifications enrollment.
1028///
1029/// This type is not used in any activity, and only used as *part* of another schema.
1030///
1031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1032#[serde_with::serde_as]
1033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1034pub struct KeyAccessJustificationsEnrollmentConfig {
1035    /// Whether the project has KAJ logging enabled.
1036    #[serde(rename = "auditLogging")]
1037    pub audit_logging: Option<bool>,
1038    /// Whether the project is enrolled in KAJ policy enforcement.
1039    #[serde(rename = "policyEnforcement")]
1040    pub policy_enforcement: Option<bool>,
1041}
1042
1043impl common::Part for KeyAccessJustificationsEnrollmentConfig {}
1044
1045/// A KeyAccessJustificationsPolicy specifies zero or more allowed AccessReason values for encrypt, decrypt, and sign operations on a CryptoKey.
1046///
1047/// This type is not used in any activity, and only used as *part* of another schema.
1048///
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct KeyAccessJustificationsPolicy {
1053    /// The list of allowed reasons for access to a CryptoKey. Zero allowed access reasons means all encrypt, decrypt, and sign operations for the CryptoKey associated with this policy will fail.
1054    #[serde(rename = "allowedAccessReasons")]
1055    pub allowed_access_reasons: Option<Vec<String>>,
1056}
1057
1058impl common::Part for KeyAccessJustificationsPolicy {}
1059
1060/// A singleton configuration for Key Access Justifications policies.
1061///
1062/// # Activities
1063///
1064/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1065/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1066///
1067/// * [get kaj policy config folders](FolderGetKajPolicyConfigCall) (response)
1068/// * [update kaj policy config folders](FolderUpdateKajPolicyConfigCall) (request|response)
1069/// * [get kaj policy config organizations](OrganizationGetKajPolicyConfigCall) (response)
1070/// * [update kaj policy config organizations](OrganizationUpdateKajPolicyConfigCall) (request|response)
1071/// * [get kaj policy config projects](ProjectGetKajPolicyConfigCall) (response)
1072/// * [update kaj policy config projects](ProjectUpdateKajPolicyConfigCall) (request|response)
1073#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1074#[serde_with::serde_as]
1075#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1076pub struct KeyAccessJustificationsPolicyConfig {
1077    /// Optional. The default key access justification policy used when a CryptoKey is created in this folder. This is only used when a Key Access Justifications policy is not provided in the CreateCryptoKeyRequest. This overrides any default policies in its ancestry.
1078    #[serde(rename = "defaultKeyAccessJustificationPolicy")]
1079    pub default_key_access_justification_policy: Option<KeyAccessJustificationsPolicy>,
1080    /// Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
1081    pub name: Option<String>,
1082}
1083
1084impl common::RequestValue for KeyAccessJustificationsPolicyConfig {}
1085impl common::ResponseResult for KeyAccessJustificationsPolicyConfig {}
1086
1087/// Resource-oriented representation of a request to Cloud KMS Autokey and the resulting provisioning of a CryptoKey.
1088///
1089/// # Activities
1090///
1091/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1092/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1093///
1094/// * [locations key handles create projects](ProjectLocationKeyHandleCreateCall) (request)
1095/// * [locations key handles get projects](ProjectLocationKeyHandleGetCall) (response)
1096#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1097#[serde_with::serde_as]
1098#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1099pub struct KeyHandle {
1100    /// Output only. Name of a CryptoKey that has been provisioned for Customer Managed Encryption Key (CMEK) use in the KeyHandle project and location for the requested resource type. The CryptoKey project will reflect the value configured in the AutokeyConfig on the resource project's ancestor folder at the time of the KeyHandle creation. If more than one ancestor folder has a configured AutokeyConfig, the nearest of these configurations is used.
1101    #[serde(rename = "kmsKey")]
1102    pub kms_key: Option<String>,
1103    /// Identifier. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
1104    pub name: Option<String>,
1105    /// Required. Indicates the resource type that the resulting CryptoKey is meant to protect, e.g. `{SERVICE}.googleapis.com/{TYPE}`. See documentation for supported resource types.
1106    #[serde(rename = "resourceTypeSelector")]
1107    pub resource_type_selector: Option<String>,
1108}
1109
1110impl common::RequestValue for KeyHandle {}
1111impl common::ResponseResult for KeyHandle {}
1112
1113/// Contains an HSM-generated attestation about a key operation. For more information, see [Verifying attestations] (https://cloud.google.com/kms/docs/attest-key).
1114///
1115/// This type is not used in any activity, and only used as *part* of another schema.
1116///
1117#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1118#[serde_with::serde_as]
1119#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1120pub struct KeyOperationAttestation {
1121    /// Output only. The certificate chains needed to validate the attestation
1122    #[serde(rename = "certChains")]
1123    pub cert_chains: Option<CertificateChains>,
1124    /// Output only. The attestation data provided by the HSM when the key operation was performed.
1125    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1126    pub content: Option<Vec<u8>>,
1127    /// Output only. The format of the attestation data.
1128    pub format: Option<String>,
1129}
1130
1131impl common::Part for KeyOperationAttestation {}
1132
1133/// A KeyRing is a toplevel logical grouping of CryptoKeys.
1134///
1135/// # Activities
1136///
1137/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1138/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1139///
1140/// * [locations key rings create projects](ProjectLocationKeyRingCreateCall) (request|response)
1141/// * [locations key rings get projects](ProjectLocationKeyRingGetCall) (response)
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct KeyRing {
1146    /// Output only. The time at which this KeyRing was created.
1147    #[serde(rename = "createTime")]
1148    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1149    /// Output only. The resource name for the KeyRing in the format `projects/*/locations/*/keyRings/*`.
1150    pub name: Option<String>,
1151}
1152
1153impl common::RequestValue for KeyRing {}
1154impl common::ResponseResult for KeyRing {}
1155
1156/// Response message for KeyManagementService.ListCryptoKeyVersions.
1157///
1158/// # Activities
1159///
1160/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1161/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1162///
1163/// * [locations key rings crypto keys crypto key versions list projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall) (response)
1164#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1165#[serde_with::serde_as]
1166#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1167pub struct ListCryptoKeyVersionsResponse {
1168    /// The list of CryptoKeyVersions.
1169    #[serde(rename = "cryptoKeyVersions")]
1170    pub crypto_key_versions: Option<Vec<CryptoKeyVersion>>,
1171    /// A token to retrieve next page of results. Pass this value in ListCryptoKeyVersionsRequest.page_token to retrieve the next page of results.
1172    #[serde(rename = "nextPageToken")]
1173    pub next_page_token: Option<String>,
1174    /// The total number of CryptoKeyVersions that matched the query. This field is not populated if ListCryptoKeyVersionsRequest.filter is applied.
1175    #[serde(rename = "totalSize")]
1176    pub total_size: Option<i32>,
1177}
1178
1179impl common::ResponseResult for ListCryptoKeyVersionsResponse {}
1180
1181/// Response message for KeyManagementService.ListCryptoKeys.
1182///
1183/// # Activities
1184///
1185/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1186/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1187///
1188/// * [locations key rings crypto keys list projects](ProjectLocationKeyRingCryptoKeyListCall) (response)
1189#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1190#[serde_with::serde_as]
1191#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1192pub struct ListCryptoKeysResponse {
1193    /// The list of CryptoKeys.
1194    #[serde(rename = "cryptoKeys")]
1195    pub crypto_keys: Option<Vec<CryptoKey>>,
1196    /// A token to retrieve next page of results. Pass this value in ListCryptoKeysRequest.page_token to retrieve the next page of results.
1197    #[serde(rename = "nextPageToken")]
1198    pub next_page_token: Option<String>,
1199    /// The total number of CryptoKeys that matched the query. This field is not populated if ListCryptoKeysRequest.filter is applied.
1200    #[serde(rename = "totalSize")]
1201    pub total_size: Option<i32>,
1202}
1203
1204impl common::ResponseResult for ListCryptoKeysResponse {}
1205
1206/// Response message for EkmService.ListEkmConnections.
1207///
1208/// # Activities
1209///
1210/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1211/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1212///
1213/// * [locations ekm connections list projects](ProjectLocationEkmConnectionListCall) (response)
1214#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1215#[serde_with::serde_as]
1216#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1217pub struct ListEkmConnectionsResponse {
1218    /// The list of EkmConnections.
1219    #[serde(rename = "ekmConnections")]
1220    pub ekm_connections: Option<Vec<EkmConnection>>,
1221    /// A token to retrieve next page of results. Pass this value in ListEkmConnectionsRequest.page_token to retrieve the next page of results.
1222    #[serde(rename = "nextPageToken")]
1223    pub next_page_token: Option<String>,
1224    /// The total number of EkmConnections that matched the query. This field is not populated if ListEkmConnectionsRequest.filter is applied.
1225    #[serde(rename = "totalSize")]
1226    pub total_size: Option<i32>,
1227}
1228
1229impl common::ResponseResult for ListEkmConnectionsResponse {}
1230
1231/// Response message for KeyManagementService.ListImportJobs.
1232///
1233/// # Activities
1234///
1235/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1236/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1237///
1238/// * [locations key rings import jobs list projects](ProjectLocationKeyRingImportJobListCall) (response)
1239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1240#[serde_with::serde_as]
1241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1242pub struct ListImportJobsResponse {
1243    /// The list of ImportJobs.
1244    #[serde(rename = "importJobs")]
1245    pub import_jobs: Option<Vec<ImportJob>>,
1246    /// A token to retrieve next page of results. Pass this value in ListImportJobsRequest.page_token to retrieve the next page of results.
1247    #[serde(rename = "nextPageToken")]
1248    pub next_page_token: Option<String>,
1249    /// The total number of ImportJobs that matched the query. This field is not populated if ListImportJobsRequest.filter is applied.
1250    #[serde(rename = "totalSize")]
1251    pub total_size: Option<i32>,
1252}
1253
1254impl common::ResponseResult for ListImportJobsResponse {}
1255
1256/// Response message for Autokey.ListKeyHandles.
1257///
1258/// # Activities
1259///
1260/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1261/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1262///
1263/// * [locations key handles list projects](ProjectLocationKeyHandleListCall) (response)
1264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1265#[serde_with::serde_as]
1266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1267pub struct ListKeyHandlesResponse {
1268    /// Resulting KeyHandles.
1269    #[serde(rename = "keyHandles")]
1270    pub key_handles: Option<Vec<KeyHandle>>,
1271    /// A token to retrieve next page of results. Pass this value in ListKeyHandlesRequest.page_token to retrieve the next page of results.
1272    #[serde(rename = "nextPageToken")]
1273    pub next_page_token: Option<String>,
1274}
1275
1276impl common::ResponseResult for ListKeyHandlesResponse {}
1277
1278/// Response message for KeyManagementService.ListKeyRings.
1279///
1280/// # Activities
1281///
1282/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1283/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1284///
1285/// * [locations key rings list projects](ProjectLocationKeyRingListCall) (response)
1286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1287#[serde_with::serde_as]
1288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1289pub struct ListKeyRingsResponse {
1290    /// The list of KeyRings.
1291    #[serde(rename = "keyRings")]
1292    pub key_rings: Option<Vec<KeyRing>>,
1293    /// A token to retrieve next page of results. Pass this value in ListKeyRingsRequest.page_token to retrieve the next page of results.
1294    #[serde(rename = "nextPageToken")]
1295    pub next_page_token: Option<String>,
1296    /// The total number of KeyRings that matched the query. This field is not populated if ListKeyRingsRequest.filter is applied.
1297    #[serde(rename = "totalSize")]
1298    pub total_size: Option<i32>,
1299}
1300
1301impl common::ResponseResult for ListKeyRingsResponse {}
1302
1303/// The response message for Locations.ListLocations.
1304///
1305/// # Activities
1306///
1307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1309///
1310/// * [locations list projects](ProjectLocationListCall) (response)
1311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1312#[serde_with::serde_as]
1313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1314pub struct ListLocationsResponse {
1315    /// A list of locations that matches the specified filter in the request.
1316    pub locations: Option<Vec<Location>>,
1317    /// The standard List next-page token.
1318    #[serde(rename = "nextPageToken")]
1319    pub next_page_token: Option<String>,
1320}
1321
1322impl common::ResponseResult for ListLocationsResponse {}
1323
1324/// A resource that represents a Google Cloud location.
1325///
1326/// # Activities
1327///
1328/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1329/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1330///
1331/// * [locations get projects](ProjectLocationGetCall) (response)
1332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1333#[serde_with::serde_as]
1334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1335pub struct Location {
1336    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1337    #[serde(rename = "displayName")]
1338    pub display_name: Option<String>,
1339    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1340    pub labels: Option<HashMap<String, String>>,
1341    /// The canonical id for this location. For example: `"us-east1"`.
1342    #[serde(rename = "locationId")]
1343    pub location_id: Option<String>,
1344    /// Service-specific metadata. For example the available capacity at the given location.
1345    pub metadata: Option<HashMap<String, serde_json::Value>>,
1346    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1347    pub name: Option<String>,
1348}
1349
1350impl common::ResponseResult for Location {}
1351
1352/// Request message for KeyManagementService.MacSign.
1353///
1354/// # Activities
1355///
1356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1358///
1359/// * [locations key rings crypto keys crypto key versions mac sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall) (request)
1360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1361#[serde_with::serde_as]
1362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1363pub struct MacSignRequest {
1364    /// Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm.
1365    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1366    pub data: Option<Vec<u8>>,
1367    /// Optional. An optional CRC32C checksum of the MacSignRequest.data. If specified, KeyManagementService will verify the integrity of the received MacSignRequest.data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(MacSignRequest.data) is equal to MacSignRequest.data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1368    #[serde(rename = "dataCrc32c")]
1369    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1370    pub data_crc32c: Option<i64>,
1371}
1372
1373impl common::RequestValue for MacSignRequest {}
1374
1375/// Response message for KeyManagementService.MacSign.
1376///
1377/// # Activities
1378///
1379/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1380/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1381///
1382/// * [locations key rings crypto keys crypto key versions mac sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall) (response)
1383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1384#[serde_with::serde_as]
1385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1386pub struct MacSignResponse {
1387    /// The created signature.
1388    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1389    pub mac: Option<Vec<u8>>,
1390    /// Integrity verification field. A CRC32C checksum of the returned MacSignResponse.mac. An integrity check of MacSignResponse.mac can be performed by computing the CRC32C checksum of MacSignResponse.mac and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1391    #[serde(rename = "macCrc32c")]
1392    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1393    pub mac_crc32c: Option<i64>,
1394    /// The resource name of the CryptoKeyVersion used for signing. Check this field to verify that the intended resource was used for signing.
1395    pub name: Option<String>,
1396    /// The ProtectionLevel of the CryptoKeyVersion used for signing.
1397    #[serde(rename = "protectionLevel")]
1398    pub protection_level: Option<String>,
1399    /// Integrity verification field. A flag indicating whether MacSignRequest.data_crc32c was received by KeyManagementService and used for the integrity verification of the data. A false value of this field indicates either that MacSignRequest.data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set MacSignRequest.data_crc32c but this field is still false, discard the response and perform a limited number of retries.
1400    #[serde(rename = "verifiedDataCrc32c")]
1401    pub verified_data_crc32c: Option<bool>,
1402}
1403
1404impl common::ResponseResult for MacSignResponse {}
1405
1406/// Request message for KeyManagementService.MacVerify.
1407///
1408/// # Activities
1409///
1410/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1411/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1412///
1413/// * [locations key rings crypto keys crypto key versions mac verify projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall) (request)
1414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1415#[serde_with::serde_as]
1416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1417pub struct MacVerifyRequest {
1418    /// Required. The data used previously as a MacSignRequest.data to generate the MAC tag.
1419    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1420    pub data: Option<Vec<u8>>,
1421    /// Optional. An optional CRC32C checksum of the MacVerifyRequest.data. If specified, KeyManagementService will verify the integrity of the received MacVerifyRequest.data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(MacVerifyRequest.data) is equal to MacVerifyRequest.data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1422    #[serde(rename = "dataCrc32c")]
1423    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1424    pub data_crc32c: Option<i64>,
1425    /// Required. The signature to verify.
1426    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1427    pub mac: Option<Vec<u8>>,
1428    /// Optional. An optional CRC32C checksum of the MacVerifyRequest.mac. If specified, KeyManagementService will verify the integrity of the received MacVerifyRequest.mac using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(MacVerifyRequest.mac) is equal to MacVerifyRequest.mac_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1429    #[serde(rename = "macCrc32c")]
1430    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1431    pub mac_crc32c: Option<i64>,
1432}
1433
1434impl common::RequestValue for MacVerifyRequest {}
1435
1436/// Response message for KeyManagementService.MacVerify.
1437///
1438/// # Activities
1439///
1440/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1441/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1442///
1443/// * [locations key rings crypto keys crypto key versions mac verify projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall) (response)
1444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1445#[serde_with::serde_as]
1446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1447pub struct MacVerifyResponse {
1448    /// The resource name of the CryptoKeyVersion used for verification. Check this field to verify that the intended resource was used for verification.
1449    pub name: Option<String>,
1450    /// The ProtectionLevel of the CryptoKeyVersion used for verification.
1451    #[serde(rename = "protectionLevel")]
1452    pub protection_level: Option<String>,
1453    /// This field indicates whether or not the verification operation for MacVerifyRequest.mac over MacVerifyRequest.data was successful.
1454    pub success: Option<bool>,
1455    /// Integrity verification field. A flag indicating whether MacVerifyRequest.data_crc32c was received by KeyManagementService and used for the integrity verification of the data. A false value of this field indicates either that MacVerifyRequest.data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set MacVerifyRequest.data_crc32c but this field is still false, discard the response and perform a limited number of retries.
1456    #[serde(rename = "verifiedDataCrc32c")]
1457    pub verified_data_crc32c: Option<bool>,
1458    /// Integrity verification field. A flag indicating whether MacVerifyRequest.mac_crc32c was received by KeyManagementService and used for the integrity verification of the data. A false value of this field indicates either that MacVerifyRequest.mac_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set MacVerifyRequest.mac_crc32c but this field is still false, discard the response and perform a limited number of retries.
1459    #[serde(rename = "verifiedMacCrc32c")]
1460    pub verified_mac_crc32c: Option<bool>,
1461    /// Integrity verification field. This value is used for the integrity verification of [MacVerifyResponse.success]. If the value of this field contradicts the value of [MacVerifyResponse.success], discard the response and perform a limited number of retries.
1462    #[serde(rename = "verifiedSuccessIntegrity")]
1463    pub verified_success_integrity: Option<bool>,
1464}
1465
1466impl common::ResponseResult for MacVerifyResponse {}
1467
1468/// This resource represents a long-running operation that is the result of a network API call.
1469///
1470/// # Activities
1471///
1472/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1473/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1474///
1475/// * [locations key handles create projects](ProjectLocationKeyHandleCreateCall) (response)
1476/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1477#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1478#[serde_with::serde_as]
1479#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1480pub struct Operation {
1481    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1482    pub done: Option<bool>,
1483    /// The error result of the operation in case of failure or cancellation.
1484    pub error: Option<Status>,
1485    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1486    pub metadata: Option<HashMap<String, serde_json::Value>>,
1487    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1488    pub name: Option<String>,
1489    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1490    pub response: Option<HashMap<String, serde_json::Value>>,
1491}
1492
1493impl common::ResponseResult for Operation {}
1494
1495/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
1496///
1497/// # Activities
1498///
1499/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1500/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1501///
1502/// * [locations ekm config get iam policy projects](ProjectLocationEkmConfigGetIamPolicyCall) (response)
1503/// * [locations ekm config set iam policy projects](ProjectLocationEkmConfigSetIamPolicyCall) (response)
1504/// * [locations ekm connections get iam policy projects](ProjectLocationEkmConnectionGetIamPolicyCall) (response)
1505/// * [locations ekm connections set iam policy projects](ProjectLocationEkmConnectionSetIamPolicyCall) (response)
1506/// * [locations key rings crypto keys get iam policy projects](ProjectLocationKeyRingCryptoKeyGetIamPolicyCall) (response)
1507/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (response)
1508/// * [locations key rings import jobs get iam policy projects](ProjectLocationKeyRingImportJobGetIamPolicyCall) (response)
1509/// * [locations key rings import jobs set iam policy projects](ProjectLocationKeyRingImportJobSetIamPolicyCall) (response)
1510/// * [locations key rings get iam policy projects](ProjectLocationKeyRingGetIamPolicyCall) (response)
1511/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (response)
1512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1513#[serde_with::serde_as]
1514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1515pub struct Policy {
1516    /// Specifies cloud audit logging configuration for this policy.
1517    #[serde(rename = "auditConfigs")]
1518    pub audit_configs: Option<Vec<AuditConfig>>,
1519    /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
1520    pub bindings: Option<Vec<Binding>>,
1521    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
1522    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1523    pub etag: Option<Vec<u8>>,
1524    /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
1525    pub version: Option<i32>,
1526}
1527
1528impl common::ResponseResult for Policy {}
1529
1530/// The public keys for a given CryptoKeyVersion. Obtained via GetPublicKey.
1531///
1532/// # Activities
1533///
1534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1536///
1537/// * [locations key rings crypto keys crypto key versions get public key projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall) (response)
1538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1539#[serde_with::serde_as]
1540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1541pub struct PublicKey {
1542    /// The Algorithm associated with this key.
1543    pub algorithm: Option<String>,
1544    /// The name of the CryptoKeyVersion public key. Provided here for verification. NOTE: This field is in Beta.
1545    pub name: Option<String>,
1546    /// The public key, encoded in PEM format. For more information, see the [RFC 7468](https://tools.ietf.org/html/rfc7468) sections for [General Considerations](https://tools.ietf.org/html/rfc7468#section-2) and [Textual Encoding of Subject Public Key Info] (https://tools.ietf.org/html/rfc7468#section-13).
1547    pub pem: Option<String>,
1548    /// Integrity verification field. A CRC32C checksum of the returned PublicKey.pem. An integrity check of PublicKey.pem can be performed by computing the CRC32C checksum of PublicKey.pem and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed `2^32-1`, and can be safely downconverted to uint32 in languages that support this type. NOTE: This field is in Beta.
1549    #[serde(rename = "pemCrc32c")]
1550    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1551    pub pem_crc32c: Option<i64>,
1552    /// The ProtectionLevel of the CryptoKeyVersion public key.
1553    #[serde(rename = "protectionLevel")]
1554    pub protection_level: Option<String>,
1555    /// This field contains the public key (with integrity verification), formatted according to the public_key_format field.
1556    #[serde(rename = "publicKey")]
1557    pub public_key: Option<ChecksummedData>,
1558    /// The PublicKey format specified by the customer through the public_key_format field.
1559    #[serde(rename = "publicKeyFormat")]
1560    pub public_key_format: Option<String>,
1561}
1562
1563impl common::ResponseResult for PublicKey {}
1564
1565/// Request message for KeyManagementService.RawDecrypt.
1566///
1567/// # Activities
1568///
1569/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1570/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1571///
1572/// * [locations key rings crypto keys crypto key versions raw decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall) (request)
1573#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1574#[serde_with::serde_as]
1575#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1576pub struct RawDecryptRequest {
1577    /// Optional. Optional data that must match the data originally supplied in RawEncryptRequest.additional_authenticated_data.
1578    #[serde(rename = "additionalAuthenticatedData")]
1579    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1580    pub additional_authenticated_data: Option<Vec<u8>>,
1581    /// Optional. An optional CRC32C checksum of the RawDecryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(additional_authenticated_data) is equal to additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1582    #[serde(rename = "additionalAuthenticatedDataCrc32c")]
1583    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1584    pub additional_authenticated_data_crc32c: Option<i64>,
1585    /// Required. The encrypted data originally returned in RawEncryptResponse.ciphertext.
1586    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1587    pub ciphertext: Option<Vec<u8>>,
1588    /// Optional. An optional CRC32C checksum of the RawDecryptRequest.ciphertext. If specified, KeyManagementService will verify the integrity of the received ciphertext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(ciphertext) is equal to ciphertext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1589    #[serde(rename = "ciphertextCrc32c")]
1590    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1591    pub ciphertext_crc32c: Option<i64>,
1592    /// Required. The initialization vector (IV) used during encryption, which must match the data originally provided in RawEncryptResponse.initialization_vector.
1593    #[serde(rename = "initializationVector")]
1594    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1595    pub initialization_vector: Option<Vec<u8>>,
1596    /// Optional. An optional CRC32C checksum of the RawDecryptRequest.initialization_vector. If specified, KeyManagementService will verify the integrity of the received initialization_vector using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1597    #[serde(rename = "initializationVectorCrc32c")]
1598    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1599    pub initialization_vector_crc32c: Option<i64>,
1600    /// The length of the authentication tag that is appended to the end of the ciphertext. If unspecified (0), the default value for the key's algorithm will be used (for AES-GCM, the default value is 16).
1601    #[serde(rename = "tagLength")]
1602    pub tag_length: Option<i32>,
1603}
1604
1605impl common::RequestValue for RawDecryptRequest {}
1606
1607/// Response message for KeyManagementService.RawDecrypt.
1608///
1609/// # Activities
1610///
1611/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1612/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1613///
1614/// * [locations key rings crypto keys crypto key versions raw decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall) (response)
1615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1616#[serde_with::serde_as]
1617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1618pub struct RawDecryptResponse {
1619    /// The decrypted data.
1620    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1621    pub plaintext: Option<Vec<u8>>,
1622    /// Integrity verification field. A CRC32C checksum of the returned RawDecryptResponse.plaintext. An integrity check of plaintext can be performed by computing the CRC32C checksum of plaintext and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: receiving this response message indicates that KeyManagementService is able to successfully decrypt the ciphertext. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1623    #[serde(rename = "plaintextCrc32c")]
1624    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1625    pub plaintext_crc32c: Option<i64>,
1626    /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
1627    #[serde(rename = "protectionLevel")]
1628    pub protection_level: Option<String>,
1629    /// Integrity verification field. A flag indicating whether RawDecryptRequest.additional_authenticated_data_crc32c was received by KeyManagementService and used for the integrity verification of additional_authenticated_data. A false value of this field indicates either that // RawDecryptRequest.additional_authenticated_data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawDecryptRequest.additional_authenticated_data_crc32c but this field is still false, discard the response and perform a limited number of retries.
1630    #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
1631    pub verified_additional_authenticated_data_crc32c: Option<bool>,
1632    /// Integrity verification field. A flag indicating whether RawDecryptRequest.ciphertext_crc32c was received by KeyManagementService and used for the integrity verification of the ciphertext. A false value of this field indicates either that RawDecryptRequest.ciphertext_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawDecryptRequest.ciphertext_crc32c but this field is still false, discard the response and perform a limited number of retries.
1633    #[serde(rename = "verifiedCiphertextCrc32c")]
1634    pub verified_ciphertext_crc32c: Option<bool>,
1635    /// Integrity verification field. A flag indicating whether RawDecryptRequest.initialization_vector_crc32c was received by KeyManagementService and used for the integrity verification of initialization_vector. A false value of this field indicates either that RawDecryptRequest.initialization_vector_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawDecryptRequest.initialization_vector_crc32c but this field is still false, discard the response and perform a limited number of retries.
1636    #[serde(rename = "verifiedInitializationVectorCrc32c")]
1637    pub verified_initialization_vector_crc32c: Option<bool>,
1638}
1639
1640impl common::ResponseResult for RawDecryptResponse {}
1641
1642/// Request message for KeyManagementService.RawEncrypt.
1643///
1644/// # Activities
1645///
1646/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1647/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1648///
1649/// * [locations key rings crypto keys crypto key versions raw encrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall) (request)
1650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1651#[serde_with::serde_as]
1652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1653pub struct RawEncryptRequest {
1654    /// Optional. Optional data that, if specified, must also be provided during decryption through RawDecryptRequest.additional_authenticated_data. This field may only be used in conjunction with an algorithm that accepts additional authenticated data (for example, AES-GCM). The maximum size depends on the key version's protection_level. For SOFTWARE keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
1655    #[serde(rename = "additionalAuthenticatedData")]
1656    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1657    pub additional_authenticated_data: Option<Vec<u8>>,
1658    /// Optional. An optional CRC32C checksum of the RawEncryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(additional_authenticated_data) is equal to additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1659    #[serde(rename = "additionalAuthenticatedDataCrc32c")]
1660    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1661    pub additional_authenticated_data_crc32c: Option<i64>,
1662    /// Optional. A customer-supplied initialization vector that will be used for encryption. If it is not provided for AES-CBC and AES-CTR, one will be generated. It will be returned in RawEncryptResponse.initialization_vector.
1663    #[serde(rename = "initializationVector")]
1664    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1665    pub initialization_vector: Option<Vec<u8>>,
1666    /// Optional. An optional CRC32C checksum of the RawEncryptRequest.initialization_vector. If specified, KeyManagementService will verify the integrity of the received initialization_vector using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1667    #[serde(rename = "initializationVectorCrc32c")]
1668    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1669    pub initialization_vector_crc32c: Option<i64>,
1670    /// Required. The data to encrypt. Must be no larger than 64KiB. The maximum size depends on the key version's protection_level. For SOFTWARE keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.
1671    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1672    pub plaintext: Option<Vec<u8>>,
1673    /// Optional. An optional CRC32C checksum of the RawEncryptRequest.plaintext. If specified, KeyManagementService will verify the integrity of the received plaintext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(plaintext) is equal to plaintext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1674    #[serde(rename = "plaintextCrc32c")]
1675    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1676    pub plaintext_crc32c: Option<i64>,
1677}
1678
1679impl common::RequestValue for RawEncryptRequest {}
1680
1681/// Response message for KeyManagementService.RawEncrypt.
1682///
1683/// # Activities
1684///
1685/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1686/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1687///
1688/// * [locations key rings crypto keys crypto key versions raw encrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall) (response)
1689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1690#[serde_with::serde_as]
1691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1692pub struct RawEncryptResponse {
1693    /// The encrypted data. In the case of AES-GCM, the authentication tag is the tag_length bytes at the end of this field.
1694    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1695    pub ciphertext: Option<Vec<u8>>,
1696    /// Integrity verification field. A CRC32C checksum of the returned RawEncryptResponse.ciphertext. An integrity check of ciphertext can be performed by computing the CRC32C checksum of ciphertext and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1697    #[serde(rename = "ciphertextCrc32c")]
1698    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1699    pub ciphertext_crc32c: Option<i64>,
1700    /// The initialization vector (IV) generated by the service during encryption. This value must be stored and provided in RawDecryptRequest.initialization_vector at decryption time.
1701    #[serde(rename = "initializationVector")]
1702    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1703    pub initialization_vector: Option<Vec<u8>>,
1704    /// Integrity verification field. A CRC32C checksum of the returned RawEncryptResponse.initialization_vector. An integrity check of initialization_vector can be performed by computing the CRC32C checksum of initialization_vector and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.
1705    #[serde(rename = "initializationVectorCrc32c")]
1706    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1707    pub initialization_vector_crc32c: Option<i64>,
1708    /// The resource name of the CryptoKeyVersion used in encryption. Check this field to verify that the intended resource was used for encryption.
1709    pub name: Option<String>,
1710    /// The ProtectionLevel of the CryptoKeyVersion used in encryption.
1711    #[serde(rename = "protectionLevel")]
1712    pub protection_level: Option<String>,
1713    /// The length of the authentication tag that is appended to the end of the ciphertext.
1714    #[serde(rename = "tagLength")]
1715    pub tag_length: Option<i32>,
1716    /// Integrity verification field. A flag indicating whether RawEncryptRequest.additional_authenticated_data_crc32c was received by KeyManagementService and used for the integrity verification of additional_authenticated_data. A false value of this field indicates either that // RawEncryptRequest.additional_authenticated_data_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawEncryptRequest.additional_authenticated_data_crc32c but this field is still false, discard the response and perform a limited number of retries.
1717    #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
1718    pub verified_additional_authenticated_data_crc32c: Option<bool>,
1719    /// Integrity verification field. A flag indicating whether RawEncryptRequest.initialization_vector_crc32c was received by KeyManagementService and used for the integrity verification of initialization_vector. A false value of this field indicates either that RawEncryptRequest.initialization_vector_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawEncryptRequest.initialization_vector_crc32c but this field is still false, discard the response and perform a limited number of retries.
1720    #[serde(rename = "verifiedInitializationVectorCrc32c")]
1721    pub verified_initialization_vector_crc32c: Option<bool>,
1722    /// Integrity verification field. A flag indicating whether RawEncryptRequest.plaintext_crc32c was received by KeyManagementService and used for the integrity verification of the plaintext. A false value of this field indicates either that RawEncryptRequest.plaintext_crc32c was left unset or that it was not delivered to KeyManagementService. If you've set RawEncryptRequest.plaintext_crc32c but this field is still false, discard the response and perform a limited number of retries.
1723    #[serde(rename = "verifiedPlaintextCrc32c")]
1724    pub verified_plaintext_crc32c: Option<bool>,
1725}
1726
1727impl common::ResponseResult for RawEncryptResponse {}
1728
1729/// Request message for KeyManagementService.RestoreCryptoKeyVersion.
1730///
1731/// # Activities
1732///
1733/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1734/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1735///
1736/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (request)
1737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1738#[serde_with::serde_as]
1739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1740pub struct RestoreCryptoKeyVersionRequest {
1741    _never_set: Option<bool>,
1742}
1743
1744impl common::RequestValue for RestoreCryptoKeyVersionRequest {}
1745
1746/// A ServiceResolver represents an EKM replica that can be reached within an EkmConnection.
1747///
1748/// This type is not used in any activity, and only used as *part* of another schema.
1749///
1750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1751#[serde_with::serde_as]
1752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1753pub struct ServiceResolver {
1754    /// Optional. The filter applied to the endpoints of the resolved service. If no filter is specified, all endpoints will be considered. An endpoint will be chosen arbitrarily from the filtered list for each request. For endpoint filter syntax and examples, see https://cloud.google.com/service-directory/docs/reference/rpc/google.cloud.servicedirectory.v1#resolveservicerequest.
1755    #[serde(rename = "endpointFilter")]
1756    pub endpoint_filter: Option<String>,
1757    /// Required. The hostname of the EKM replica used at TLS and HTTP layers.
1758    pub hostname: Option<String>,
1759    /// Required. A list of leaf server certificates used to authenticate HTTPS connections to the EKM replica. Currently, a maximum of 10 Certificate is supported.
1760    #[serde(rename = "serverCertificates")]
1761    pub server_certificates: Option<Vec<Certificate>>,
1762    /// Required. The resource name of the Service Directory service pointing to an EKM replica, in the format `projects/*/locations/*/namespaces/*/services/*`.
1763    #[serde(rename = "serviceDirectoryService")]
1764    pub service_directory_service: Option<String>,
1765}
1766
1767impl common::Part for ServiceResolver {}
1768
1769/// Request message for `SetIamPolicy` method.
1770///
1771/// # Activities
1772///
1773/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1774/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1775///
1776/// * [locations ekm config set iam policy projects](ProjectLocationEkmConfigSetIamPolicyCall) (request)
1777/// * [locations ekm connections set iam policy projects](ProjectLocationEkmConnectionSetIamPolicyCall) (request)
1778/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (request)
1779/// * [locations key rings import jobs set iam policy projects](ProjectLocationKeyRingImportJobSetIamPolicyCall) (request)
1780/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (request)
1781#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1782#[serde_with::serde_as]
1783#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1784pub struct SetIamPolicyRequest {
1785    /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
1786    pub policy: Option<Policy>,
1787    /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
1788    #[serde(rename = "updateMask")]
1789    pub update_mask: Option<common::FieldMask>,
1790}
1791
1792impl common::RequestValue for SetIamPolicyRequest {}
1793
1794/// Response message for ShowEffectiveAutokeyConfig.
1795///
1796/// # Activities
1797///
1798/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1799/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1800///
1801/// * [show effective autokey config projects](ProjectShowEffectiveAutokeyConfigCall) (response)
1802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1803#[serde_with::serde_as]
1804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1805pub struct ShowEffectiveAutokeyConfigResponse {
1806    /// Name of the key project configured in the resource project's folder ancestry.
1807    #[serde(rename = "keyProject")]
1808    pub key_project: Option<String>,
1809}
1810
1811impl common::ResponseResult for ShowEffectiveAutokeyConfigResponse {}
1812
1813/// Response message for KeyAccessJustificationsConfig.ShowEffectiveKeyAccessJustificationsEnrollmentConfig
1814///
1815/// # Activities
1816///
1817/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1818/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1819///
1820/// * [show effective key access justifications enrollment config projects](ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall) (response)
1821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1822#[serde_with::serde_as]
1823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1824pub struct ShowEffectiveKeyAccessJustificationsEnrollmentConfigResponse {
1825    /// The effective KeyAccessJustificationsEnrollmentConfig for external keys.
1826    #[serde(rename = "externalConfig")]
1827    pub external_config: Option<KeyAccessJustificationsEnrollmentConfig>,
1828    /// The effective KeyAccessJustificationsEnrollmentConfig for hardware keys.
1829    #[serde(rename = "hardwareConfig")]
1830    pub hardware_config: Option<KeyAccessJustificationsEnrollmentConfig>,
1831    /// The effective KeyAccessJustificationsEnrollmentConfig for software keys.
1832    #[serde(rename = "softwareConfig")]
1833    pub software_config: Option<KeyAccessJustificationsEnrollmentConfig>,
1834}
1835
1836impl common::ResponseResult for ShowEffectiveKeyAccessJustificationsEnrollmentConfigResponse {}
1837
1838/// Response message for KeyAccessJustificationsConfig.ShowEffectiveKeyAccessJustificationsPolicyConfig.
1839///
1840/// # Activities
1841///
1842/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1843/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1844///
1845/// * [show effective key access justifications policy config projects](ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall) (response)
1846#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1847#[serde_with::serde_as]
1848#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1849pub struct ShowEffectiveKeyAccessJustificationsPolicyConfigResponse {
1850    /// The effective KeyAccessJustificationsPolicyConfig.
1851    #[serde(rename = "effectiveKajPolicy")]
1852    pub effective_kaj_policy: Option<KeyAccessJustificationsPolicyConfig>,
1853}
1854
1855impl common::ResponseResult for ShowEffectiveKeyAccessJustificationsPolicyConfigResponse {}
1856
1857/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1858///
1859/// This type is not used in any activity, and only used as *part* of another schema.
1860///
1861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1862#[serde_with::serde_as]
1863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1864pub struct Status {
1865    /// The status code, which should be an enum value of google.rpc.Code.
1866    pub code: Option<i32>,
1867    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1868    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1869    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1870    pub message: Option<String>,
1871}
1872
1873impl common::Part for Status {}
1874
1875/// Request message for `TestIamPermissions` method.
1876///
1877/// # Activities
1878///
1879/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1880/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1881///
1882/// * [locations ekm config test iam permissions projects](ProjectLocationEkmConfigTestIamPermissionCall) (request)
1883/// * [locations ekm connections test iam permissions projects](ProjectLocationEkmConnectionTestIamPermissionCall) (request)
1884/// * [locations key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (request)
1885/// * [locations key rings import jobs test iam permissions projects](ProjectLocationKeyRingImportJobTestIamPermissionCall) (request)
1886/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (request)
1887#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1888#[serde_with::serde_as]
1889#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1890pub struct TestIamPermissionsRequest {
1891    /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1892    pub permissions: Option<Vec<String>>,
1893}
1894
1895impl common::RequestValue for TestIamPermissionsRequest {}
1896
1897/// Response message for `TestIamPermissions` method.
1898///
1899/// # Activities
1900///
1901/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1902/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1903///
1904/// * [locations ekm config test iam permissions projects](ProjectLocationEkmConfigTestIamPermissionCall) (response)
1905/// * [locations ekm connections test iam permissions projects](ProjectLocationEkmConnectionTestIamPermissionCall) (response)
1906/// * [locations key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (response)
1907/// * [locations key rings import jobs test iam permissions projects](ProjectLocationKeyRingImportJobTestIamPermissionCall) (response)
1908/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (response)
1909#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1910#[serde_with::serde_as]
1911#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1912pub struct TestIamPermissionsResponse {
1913    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1914    pub permissions: Option<Vec<String>>,
1915}
1916
1917impl common::ResponseResult for TestIamPermissionsResponse {}
1918
1919/// Request message for KeyManagementService.UpdateCryptoKeyPrimaryVersion.
1920///
1921/// # Activities
1922///
1923/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1924/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1925///
1926/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (request)
1927#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1928#[serde_with::serde_as]
1929#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1930pub struct UpdateCryptoKeyPrimaryVersionRequest {
1931    /// Required. The id of the child CryptoKeyVersion to use as primary.
1932    #[serde(rename = "cryptoKeyVersionId")]
1933    pub crypto_key_version_id: Option<String>,
1934}
1935
1936impl common::RequestValue for UpdateCryptoKeyPrimaryVersionRequest {}
1937
1938/// Response message for EkmService.VerifyConnectivity.
1939///
1940/// # Activities
1941///
1942/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1943/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1944///
1945/// * [locations ekm connections verify connectivity projects](ProjectLocationEkmConnectionVerifyConnectivityCall) (response)
1946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1947#[serde_with::serde_as]
1948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1949pub struct VerifyConnectivityResponse {
1950    _never_set: Option<bool>,
1951}
1952
1953impl common::ResponseResult for VerifyConnectivityResponse {}
1954
1955/// The public key component of the wrapping key. For details of the type of key this public key corresponds to, see the ImportMethod.
1956///
1957/// This type is not used in any activity, and only used as *part* of another schema.
1958///
1959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1960#[serde_with::serde_as]
1961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1962pub struct WrappingPublicKey {
1963    /// The public key, encoded in PEM format. For more information, see the [RFC 7468](https://tools.ietf.org/html/rfc7468) sections for [General Considerations](https://tools.ietf.org/html/rfc7468#section-2) and [Textual Encoding of Subject Public Key Info] (https://tools.ietf.org/html/rfc7468#section-13).
1964    pub pem: Option<String>,
1965}
1966
1967impl common::Part for WrappingPublicKey {}
1968
1969// ###################
1970// MethodBuilders ###
1971// #################
1972
1973/// A builder providing access to all methods supported on *folder* resources.
1974/// It is not used directly, but through the [`CloudKMS`] hub.
1975///
1976/// # Example
1977///
1978/// Instantiate a resource builder
1979///
1980/// ```test_harness,no_run
1981/// extern crate hyper;
1982/// extern crate hyper_rustls;
1983/// extern crate google_cloudkms1 as cloudkms1;
1984///
1985/// # async fn dox() {
1986/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1987///
1988/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1989/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1990///     .with_native_roots()
1991///     .unwrap()
1992///     .https_only()
1993///     .enable_http2()
1994///     .build();
1995///
1996/// let executor = hyper_util::rt::TokioExecutor::new();
1997/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1998///     secret,
1999///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2000///     yup_oauth2::client::CustomHyperClientBuilder::from(
2001///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2002///     ),
2003/// ).build().await.unwrap();
2004///
2005/// let client = hyper_util::client::legacy::Client::builder(
2006///     hyper_util::rt::TokioExecutor::new()
2007/// )
2008/// .build(
2009///     hyper_rustls::HttpsConnectorBuilder::new()
2010///         .with_native_roots()
2011///         .unwrap()
2012///         .https_or_http()
2013///         .enable_http2()
2014///         .build()
2015/// );
2016/// let mut hub = CloudKMS::new(client, auth);
2017/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2018/// // like `get_autokey_config(...)`, `get_kaj_policy_config(...)`, `update_autokey_config(...)` and `update_kaj_policy_config(...)`
2019/// // to build up your call.
2020/// let rb = hub.folders();
2021/// # }
2022/// ```
2023pub struct FolderMethods<'a, C>
2024where
2025    C: 'a,
2026{
2027    hub: &'a CloudKMS<C>,
2028}
2029
2030impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
2031
2032impl<'a, C> FolderMethods<'a, C> {
2033    /// Create a builder to help you perform the following task:
2034    ///
2035    /// Returns the AutokeyConfig for a folder.
2036    ///
2037    /// # Arguments
2038    ///
2039    /// * `name` - Required. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
2040    pub fn get_autokey_config(&self, name: &str) -> FolderGetAutokeyConfigCall<'a, C> {
2041        FolderGetAutokeyConfigCall {
2042            hub: self.hub,
2043            _name: name.to_string(),
2044            _delegate: Default::default(),
2045            _additional_params: Default::default(),
2046            _scopes: Default::default(),
2047        }
2048    }
2049
2050    /// Create a builder to help you perform the following task:
2051    ///
2052    /// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
2053    ///
2054    /// # Arguments
2055    ///
2056    /// * `name` - Required. The name of the KeyAccessJustificationsPolicyConfig to get.
2057    pub fn get_kaj_policy_config(&self, name: &str) -> FolderGetKajPolicyConfigCall<'a, C> {
2058        FolderGetKajPolicyConfigCall {
2059            hub: self.hub,
2060            _name: name.to_string(),
2061            _delegate: Default::default(),
2062            _additional_params: Default::default(),
2063            _scopes: Default::default(),
2064        }
2065    }
2066
2067    /// Create a builder to help you perform the following task:
2068    ///
2069    /// Updates the AutokeyConfig for a folder. The caller must have both `cloudkms.autokeyConfigs.update` permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy` permission on the provided key project. A KeyHandle creation in the folder's descendant projects will use this configuration to determine where to create the resulting CryptoKey.
2070    ///
2071    /// # Arguments
2072    ///
2073    /// * `request` - No description provided.
2074    /// * `name` - Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`
2075    pub fn update_autokey_config(
2076        &self,
2077        request: AutokeyConfig,
2078        name: &str,
2079    ) -> FolderUpdateAutokeyConfigCall<'a, C> {
2080        FolderUpdateAutokeyConfigCall {
2081            hub: self.hub,
2082            _request: request,
2083            _name: name.to_string(),
2084            _update_mask: Default::default(),
2085            _delegate: Default::default(),
2086            _additional_params: Default::default(),
2087            _scopes: Default::default(),
2088        }
2089    }
2090
2091    /// Create a builder to help you perform the following task:
2092    ///
2093    /// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
2094    ///
2095    /// # Arguments
2096    ///
2097    /// * `request` - No description provided.
2098    /// * `name` - Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
2099    pub fn update_kaj_policy_config(
2100        &self,
2101        request: KeyAccessJustificationsPolicyConfig,
2102        name: &str,
2103    ) -> FolderUpdateKajPolicyConfigCall<'a, C> {
2104        FolderUpdateKajPolicyConfigCall {
2105            hub: self.hub,
2106            _request: request,
2107            _name: name.to_string(),
2108            _update_mask: Default::default(),
2109            _delegate: Default::default(),
2110            _additional_params: Default::default(),
2111            _scopes: Default::default(),
2112        }
2113    }
2114}
2115
2116/// A builder providing access to all methods supported on *organization* resources.
2117/// It is not used directly, but through the [`CloudKMS`] hub.
2118///
2119/// # Example
2120///
2121/// Instantiate a resource builder
2122///
2123/// ```test_harness,no_run
2124/// extern crate hyper;
2125/// extern crate hyper_rustls;
2126/// extern crate google_cloudkms1 as cloudkms1;
2127///
2128/// # async fn dox() {
2129/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2130///
2131/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2132/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2133///     .with_native_roots()
2134///     .unwrap()
2135///     .https_only()
2136///     .enable_http2()
2137///     .build();
2138///
2139/// let executor = hyper_util::rt::TokioExecutor::new();
2140/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2141///     secret,
2142///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2143///     yup_oauth2::client::CustomHyperClientBuilder::from(
2144///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2145///     ),
2146/// ).build().await.unwrap();
2147///
2148/// let client = hyper_util::client::legacy::Client::builder(
2149///     hyper_util::rt::TokioExecutor::new()
2150/// )
2151/// .build(
2152///     hyper_rustls::HttpsConnectorBuilder::new()
2153///         .with_native_roots()
2154///         .unwrap()
2155///         .https_or_http()
2156///         .enable_http2()
2157///         .build()
2158/// );
2159/// let mut hub = CloudKMS::new(client, auth);
2160/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2161/// // like `get_kaj_policy_config(...)` and `update_kaj_policy_config(...)`
2162/// // to build up your call.
2163/// let rb = hub.organizations();
2164/// # }
2165/// ```
2166pub struct OrganizationMethods<'a, C>
2167where
2168    C: 'a,
2169{
2170    hub: &'a CloudKMS<C>,
2171}
2172
2173impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
2174
2175impl<'a, C> OrganizationMethods<'a, C> {
2176    /// Create a builder to help you perform the following task:
2177    ///
2178    /// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
2179    ///
2180    /// # Arguments
2181    ///
2182    /// * `name` - Required. The name of the KeyAccessJustificationsPolicyConfig to get.
2183    pub fn get_kaj_policy_config(&self, name: &str) -> OrganizationGetKajPolicyConfigCall<'a, C> {
2184        OrganizationGetKajPolicyConfigCall {
2185            hub: self.hub,
2186            _name: name.to_string(),
2187            _delegate: Default::default(),
2188            _additional_params: Default::default(),
2189            _scopes: Default::default(),
2190        }
2191    }
2192
2193    /// Create a builder to help you perform the following task:
2194    ///
2195    /// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
2196    ///
2197    /// # Arguments
2198    ///
2199    /// * `request` - No description provided.
2200    /// * `name` - Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
2201    pub fn update_kaj_policy_config(
2202        &self,
2203        request: KeyAccessJustificationsPolicyConfig,
2204        name: &str,
2205    ) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
2206        OrganizationUpdateKajPolicyConfigCall {
2207            hub: self.hub,
2208            _request: request,
2209            _name: name.to_string(),
2210            _update_mask: Default::default(),
2211            _delegate: Default::default(),
2212            _additional_params: Default::default(),
2213            _scopes: Default::default(),
2214        }
2215    }
2216}
2217
2218/// A builder providing access to all methods supported on *project* resources.
2219/// It is not used directly, but through the [`CloudKMS`] hub.
2220///
2221/// # Example
2222///
2223/// Instantiate a resource builder
2224///
2225/// ```test_harness,no_run
2226/// extern crate hyper;
2227/// extern crate hyper_rustls;
2228/// extern crate google_cloudkms1 as cloudkms1;
2229///
2230/// # async fn dox() {
2231/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2232///
2233/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2234/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2235///     .with_native_roots()
2236///     .unwrap()
2237///     .https_only()
2238///     .enable_http2()
2239///     .build();
2240///
2241/// let executor = hyper_util::rt::TokioExecutor::new();
2242/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2243///     secret,
2244///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2245///     yup_oauth2::client::CustomHyperClientBuilder::from(
2246///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2247///     ),
2248/// ).build().await.unwrap();
2249///
2250/// let client = hyper_util::client::legacy::Client::builder(
2251///     hyper_util::rt::TokioExecutor::new()
2252/// )
2253/// .build(
2254///     hyper_rustls::HttpsConnectorBuilder::new()
2255///         .with_native_roots()
2256///         .unwrap()
2257///         .https_or_http()
2258///         .enable_http2()
2259///         .build()
2260/// );
2261/// let mut hub = CloudKMS::new(client, auth);
2262/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2263/// // like `get_kaj_policy_config(...)`, `locations_ekm_config_get_iam_policy(...)`, `locations_ekm_config_set_iam_policy(...)`, `locations_ekm_config_test_iam_permissions(...)`, `locations_ekm_connections_create(...)`, `locations_ekm_connections_get(...)`, `locations_ekm_connections_get_iam_policy(...)`, `locations_ekm_connections_list(...)`, `locations_ekm_connections_patch(...)`, `locations_ekm_connections_set_iam_policy(...)`, `locations_ekm_connections_test_iam_permissions(...)`, `locations_ekm_connections_verify_connectivity(...)`, `locations_generate_random_bytes(...)`, `locations_get(...)`, `locations_get_ekm_config(...)`, `locations_key_handles_create(...)`, `locations_key_handles_get(...)`, `locations_key_handles_list(...)`, `locations_key_rings_create(...)`, `locations_key_rings_crypto_keys_create(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_decrypt(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_sign(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_create(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_decapsulate(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_destroy(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_get(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_get_public_key(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_import(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_list(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_mac_sign(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_mac_verify(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_patch(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_raw_decrypt(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_raw_encrypt(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_restore(...)`, `locations_key_rings_crypto_keys_decrypt(...)`, `locations_key_rings_crypto_keys_encrypt(...)`, `locations_key_rings_crypto_keys_get(...)`, `locations_key_rings_crypto_keys_get_iam_policy(...)`, `locations_key_rings_crypto_keys_list(...)`, `locations_key_rings_crypto_keys_patch(...)`, `locations_key_rings_crypto_keys_set_iam_policy(...)`, `locations_key_rings_crypto_keys_test_iam_permissions(...)`, `locations_key_rings_crypto_keys_update_primary_version(...)`, `locations_key_rings_get(...)`, `locations_key_rings_get_iam_policy(...)`, `locations_key_rings_import_jobs_create(...)`, `locations_key_rings_import_jobs_get(...)`, `locations_key_rings_import_jobs_get_iam_policy(...)`, `locations_key_rings_import_jobs_list(...)`, `locations_key_rings_import_jobs_set_iam_policy(...)`, `locations_key_rings_import_jobs_test_iam_permissions(...)`, `locations_key_rings_list(...)`, `locations_key_rings_set_iam_policy(...)`, `locations_key_rings_test_iam_permissions(...)`, `locations_list(...)`, `locations_operations_get(...)`, `locations_update_ekm_config(...)`, `show_effective_autokey_config(...)`, `show_effective_key_access_justifications_enrollment_config(...)`, `show_effective_key_access_justifications_policy_config(...)` and `update_kaj_policy_config(...)`
2264/// // to build up your call.
2265/// let rb = hub.projects();
2266/// # }
2267/// ```
2268pub struct ProjectMethods<'a, C>
2269where
2270    C: 'a,
2271{
2272    hub: &'a CloudKMS<C>,
2273}
2274
2275impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2276
2277impl<'a, C> ProjectMethods<'a, C> {
2278    /// Create a builder to help you perform the following task:
2279    ///
2280    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2281    ///
2282    /// # Arguments
2283    ///
2284    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2285    pub fn locations_ekm_config_get_iam_policy(
2286        &self,
2287        resource: &str,
2288    ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
2289        ProjectLocationEkmConfigGetIamPolicyCall {
2290            hub: self.hub,
2291            _resource: resource.to_string(),
2292            _options_requested_policy_version: Default::default(),
2293            _delegate: Default::default(),
2294            _additional_params: Default::default(),
2295            _scopes: Default::default(),
2296        }
2297    }
2298
2299    /// Create a builder to help you perform the following task:
2300    ///
2301    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2302    ///
2303    /// # Arguments
2304    ///
2305    /// * `request` - No description provided.
2306    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2307    pub fn locations_ekm_config_set_iam_policy(
2308        &self,
2309        request: SetIamPolicyRequest,
2310        resource: &str,
2311    ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
2312        ProjectLocationEkmConfigSetIamPolicyCall {
2313            hub: self.hub,
2314            _request: request,
2315            _resource: resource.to_string(),
2316            _delegate: Default::default(),
2317            _additional_params: Default::default(),
2318            _scopes: Default::default(),
2319        }
2320    }
2321
2322    /// Create a builder to help you perform the following task:
2323    ///
2324    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2325    ///
2326    /// # Arguments
2327    ///
2328    /// * `request` - No description provided.
2329    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2330    pub fn locations_ekm_config_test_iam_permissions(
2331        &self,
2332        request: TestIamPermissionsRequest,
2333        resource: &str,
2334    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
2335        ProjectLocationEkmConfigTestIamPermissionCall {
2336            hub: self.hub,
2337            _request: request,
2338            _resource: resource.to_string(),
2339            _delegate: Default::default(),
2340            _additional_params: Default::default(),
2341            _scopes: Default::default(),
2342        }
2343    }
2344
2345    /// Create a builder to help you perform the following task:
2346    ///
2347    /// Creates a new EkmConnection in a given Project and Location.
2348    ///
2349    /// # Arguments
2350    ///
2351    /// * `request` - No description provided.
2352    /// * `parent` - Required. The resource name of the location associated with the EkmConnection, in the format `projects/*/locations/*`.
2353    pub fn locations_ekm_connections_create(
2354        &self,
2355        request: EkmConnection,
2356        parent: &str,
2357    ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
2358        ProjectLocationEkmConnectionCreateCall {
2359            hub: self.hub,
2360            _request: request,
2361            _parent: parent.to_string(),
2362            _ekm_connection_id: Default::default(),
2363            _delegate: Default::default(),
2364            _additional_params: Default::default(),
2365            _scopes: Default::default(),
2366        }
2367    }
2368
2369    /// Create a builder to help you perform the following task:
2370    ///
2371    /// Returns metadata for a given EkmConnection.
2372    ///
2373    /// # Arguments
2374    ///
2375    /// * `name` - Required. The name of the EkmConnection to get.
2376    pub fn locations_ekm_connections_get(
2377        &self,
2378        name: &str,
2379    ) -> ProjectLocationEkmConnectionGetCall<'a, C> {
2380        ProjectLocationEkmConnectionGetCall {
2381            hub: self.hub,
2382            _name: name.to_string(),
2383            _delegate: Default::default(),
2384            _additional_params: Default::default(),
2385            _scopes: Default::default(),
2386        }
2387    }
2388
2389    /// Create a builder to help you perform the following task:
2390    ///
2391    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2392    ///
2393    /// # Arguments
2394    ///
2395    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2396    pub fn locations_ekm_connections_get_iam_policy(
2397        &self,
2398        resource: &str,
2399    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
2400        ProjectLocationEkmConnectionGetIamPolicyCall {
2401            hub: self.hub,
2402            _resource: resource.to_string(),
2403            _options_requested_policy_version: Default::default(),
2404            _delegate: Default::default(),
2405            _additional_params: Default::default(),
2406            _scopes: Default::default(),
2407        }
2408    }
2409
2410    /// Create a builder to help you perform the following task:
2411    ///
2412    /// Lists EkmConnections.
2413    ///
2414    /// # Arguments
2415    ///
2416    /// * `parent` - Required. The resource name of the location associated with the EkmConnections to list, in the format `projects/*/locations/*`.
2417    pub fn locations_ekm_connections_list(
2418        &self,
2419        parent: &str,
2420    ) -> ProjectLocationEkmConnectionListCall<'a, C> {
2421        ProjectLocationEkmConnectionListCall {
2422            hub: self.hub,
2423            _parent: parent.to_string(),
2424            _page_token: Default::default(),
2425            _page_size: Default::default(),
2426            _order_by: Default::default(),
2427            _filter: Default::default(),
2428            _delegate: Default::default(),
2429            _additional_params: Default::default(),
2430            _scopes: Default::default(),
2431        }
2432    }
2433
2434    /// Create a builder to help you perform the following task:
2435    ///
2436    /// Updates an EkmConnection's metadata.
2437    ///
2438    /// # Arguments
2439    ///
2440    /// * `request` - No description provided.
2441    /// * `name` - Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
2442    pub fn locations_ekm_connections_patch(
2443        &self,
2444        request: EkmConnection,
2445        name: &str,
2446    ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
2447        ProjectLocationEkmConnectionPatchCall {
2448            hub: self.hub,
2449            _request: request,
2450            _name: name.to_string(),
2451            _update_mask: Default::default(),
2452            _delegate: Default::default(),
2453            _additional_params: Default::default(),
2454            _scopes: Default::default(),
2455        }
2456    }
2457
2458    /// Create a builder to help you perform the following task:
2459    ///
2460    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2461    ///
2462    /// # Arguments
2463    ///
2464    /// * `request` - No description provided.
2465    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2466    pub fn locations_ekm_connections_set_iam_policy(
2467        &self,
2468        request: SetIamPolicyRequest,
2469        resource: &str,
2470    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
2471        ProjectLocationEkmConnectionSetIamPolicyCall {
2472            hub: self.hub,
2473            _request: request,
2474            _resource: resource.to_string(),
2475            _delegate: Default::default(),
2476            _additional_params: Default::default(),
2477            _scopes: Default::default(),
2478        }
2479    }
2480
2481    /// Create a builder to help you perform the following task:
2482    ///
2483    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2484    ///
2485    /// # Arguments
2486    ///
2487    /// * `request` - No description provided.
2488    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2489    pub fn locations_ekm_connections_test_iam_permissions(
2490        &self,
2491        request: TestIamPermissionsRequest,
2492        resource: &str,
2493    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
2494        ProjectLocationEkmConnectionTestIamPermissionCall {
2495            hub: self.hub,
2496            _request: request,
2497            _resource: resource.to_string(),
2498            _delegate: Default::default(),
2499            _additional_params: Default::default(),
2500            _scopes: Default::default(),
2501        }
2502    }
2503
2504    /// Create a builder to help you perform the following task:
2505    ///
2506    /// Verifies that Cloud KMS can successfully connect to the external key manager specified by an EkmConnection. If there is an error connecting to the EKM, this method returns a FAILED_PRECONDITION status containing structured information as described at https://cloud.google.com/kms/docs/reference/ekm_errors.
2507    ///
2508    /// # Arguments
2509    ///
2510    /// * `name` - Required. The name of the EkmConnection to verify.
2511    pub fn locations_ekm_connections_verify_connectivity(
2512        &self,
2513        name: &str,
2514    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
2515        ProjectLocationEkmConnectionVerifyConnectivityCall {
2516            hub: self.hub,
2517            _name: name.to_string(),
2518            _delegate: Default::default(),
2519            _additional_params: Default::default(),
2520            _scopes: Default::default(),
2521        }
2522    }
2523
2524    /// Create a builder to help you perform the following task:
2525    ///
2526    /// Creates a new KeyHandle, triggering the provisioning of a new CryptoKey for CMEK use with the given resource type in the configured key project and the same location. GetOperation should be used to resolve the resulting long-running operation and get the resulting KeyHandle and CryptoKey.
2527    ///
2528    /// # Arguments
2529    ///
2530    /// * `request` - No description provided.
2531    /// * `parent` - Required. Name of the resource project and location to create the KeyHandle in, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
2532    pub fn locations_key_handles_create(
2533        &self,
2534        request: KeyHandle,
2535        parent: &str,
2536    ) -> ProjectLocationKeyHandleCreateCall<'a, C> {
2537        ProjectLocationKeyHandleCreateCall {
2538            hub: self.hub,
2539            _request: request,
2540            _parent: parent.to_string(),
2541            _key_handle_id: Default::default(),
2542            _delegate: Default::default(),
2543            _additional_params: Default::default(),
2544            _scopes: Default::default(),
2545        }
2546    }
2547
2548    /// Create a builder to help you perform the following task:
2549    ///
2550    /// Returns the KeyHandle.
2551    ///
2552    /// # Arguments
2553    ///
2554    /// * `name` - Required. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
2555    pub fn locations_key_handles_get(&self, name: &str) -> ProjectLocationKeyHandleGetCall<'a, C> {
2556        ProjectLocationKeyHandleGetCall {
2557            hub: self.hub,
2558            _name: name.to_string(),
2559            _delegate: Default::default(),
2560            _additional_params: Default::default(),
2561            _scopes: Default::default(),
2562        }
2563    }
2564
2565    /// Create a builder to help you perform the following task:
2566    ///
2567    /// Lists KeyHandles.
2568    ///
2569    /// # Arguments
2570    ///
2571    /// * `parent` - Required. Name of the resource project and location from which to list KeyHandles, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
2572    pub fn locations_key_handles_list(
2573        &self,
2574        parent: &str,
2575    ) -> ProjectLocationKeyHandleListCall<'a, C> {
2576        ProjectLocationKeyHandleListCall {
2577            hub: self.hub,
2578            _parent: parent.to_string(),
2579            _page_token: Default::default(),
2580            _page_size: Default::default(),
2581            _filter: Default::default(),
2582            _delegate: Default::default(),
2583            _additional_params: Default::default(),
2584            _scopes: Default::default(),
2585        }
2586    }
2587
2588    /// Create a builder to help you perform the following task:
2589    ///
2590    /// Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.
2591    ///
2592    /// # Arguments
2593    ///
2594    /// * `request` - No description provided.
2595    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for decryption.
2596    pub fn locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_decrypt(
2597        &self,
2598        request: AsymmetricDecryptRequest,
2599        name: &str,
2600    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
2601        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall {
2602            hub: self.hub,
2603            _request: request,
2604            _name: name.to_string(),
2605            _delegate: Default::default(),
2606            _additional_params: Default::default(),
2607            _scopes: Default::default(),
2608        }
2609    }
2610
2611    /// Create a builder to help you perform the following task:
2612    ///
2613    /// Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.
2614    ///
2615    /// # Arguments
2616    ///
2617    /// * `request` - No description provided.
2618    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for signing.
2619    pub fn locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_sign(
2620        &self,
2621        request: AsymmetricSignRequest,
2622        name: &str,
2623    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
2624        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall {
2625            hub: self.hub,
2626            _request: request,
2627            _name: name.to_string(),
2628            _delegate: Default::default(),
2629            _additional_params: Default::default(),
2630            _scopes: Default::default(),
2631        }
2632    }
2633
2634    /// Create a builder to help you perform the following task:
2635    ///
2636    /// Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next sequential id. If unset, state will be set to ENABLED.
2637    ///
2638    /// # Arguments
2639    ///
2640    /// * `request` - No description provided.
2641    /// * `parent` - Required. The name of the CryptoKey associated with the CryptoKeyVersions.
2642    pub fn locations_key_rings_crypto_keys_crypto_key_versions_create(
2643        &self,
2644        request: CryptoKeyVersion,
2645        parent: &str,
2646    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2647        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall {
2648            hub: self.hub,
2649            _request: request,
2650            _parent: parent.to_string(),
2651            _delegate: Default::default(),
2652            _additional_params: Default::default(),
2653            _scopes: Default::default(),
2654        }
2655    }
2656
2657    /// Create a builder to help you perform the following task:
2658    ///
2659    /// Decapsulates data that was encapsulated with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose KEY_ENCAPSULATION.
2660    ///
2661    /// # Arguments
2662    ///
2663    /// * `request` - No description provided.
2664    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for decapsulation.
2665    pub fn locations_key_rings_crypto_keys_crypto_key_versions_decapsulate(
2666        &self,
2667        request: DecapsulateRequest,
2668        name: &str,
2669    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C> {
2670        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall {
2671            hub: self.hub,
2672            _request: request,
2673            _name: name.to_string(),
2674            _delegate: Default::default(),
2675            _additional_params: Default::default(),
2676            _scopes: Default::default(),
2677        }
2678    }
2679
2680    /// Create a builder to help you perform the following task:
2681    ///
2682    /// Schedule a CryptoKeyVersion for destruction. Upon calling this method, CryptoKeyVersion.state will be set to DESTROY_SCHEDULED, and destroy_time will be set to the time destroy_scheduled_duration in the future. At that time, the state will automatically change to DESTROYED, and the key material will be irrevocably destroyed. Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process.
2683    ///
2684    /// # Arguments
2685    ///
2686    /// * `request` - No description provided.
2687    /// * `name` - Required. The resource name of the CryptoKeyVersion to destroy.
2688    pub fn locations_key_rings_crypto_keys_crypto_key_versions_destroy(
2689        &self,
2690        request: DestroyCryptoKeyVersionRequest,
2691        name: &str,
2692    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2693        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall {
2694            hub: self.hub,
2695            _request: request,
2696            _name: name.to_string(),
2697            _delegate: Default::default(),
2698            _additional_params: Default::default(),
2699            _scopes: Default::default(),
2700        }
2701    }
2702
2703    /// Create a builder to help you perform the following task:
2704    ///
2705    /// Returns metadata for a given CryptoKeyVersion.
2706    ///
2707    /// # Arguments
2708    ///
2709    /// * `name` - Required. The name of the CryptoKeyVersion to get.
2710    pub fn locations_key_rings_crypto_keys_crypto_key_versions_get(
2711        &self,
2712        name: &str,
2713    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
2714        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall {
2715            hub: self.hub,
2716            _name: name.to_string(),
2717            _delegate: Default::default(),
2718            _additional_params: Default::default(),
2719            _scopes: Default::default(),
2720        }
2721    }
2722
2723    /// Create a builder to help you perform the following task:
2724    ///
2725    /// Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.
2726    ///
2727    /// # Arguments
2728    ///
2729    /// * `name` - Required. The name of the CryptoKeyVersion public key to get.
2730    pub fn locations_key_rings_crypto_keys_crypto_key_versions_get_public_key(
2731        &self,
2732        name: &str,
2733    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
2734        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall {
2735            hub: self.hub,
2736            _name: name.to_string(),
2737            _public_key_format: Default::default(),
2738            _delegate: Default::default(),
2739            _additional_params: Default::default(),
2740            _scopes: Default::default(),
2741        }
2742    }
2743
2744    /// Create a builder to help you perform the following task:
2745    ///
2746    /// Import wrapped key material into a CryptoKeyVersion. All requests must specify a CryptoKey. If a CryptoKeyVersion is additionally specified in the request, key material will be reimported into that version. Otherwise, a new version will be created, and will be assigned the next sequential id within the CryptoKey.
2747    ///
2748    /// # Arguments
2749    ///
2750    /// * `request` - No description provided.
2751    /// * `parent` - Required. The name of the CryptoKey to be imported into. The create permission is only required on this key when creating a new CryptoKeyVersion.
2752    pub fn locations_key_rings_crypto_keys_crypto_key_versions_import(
2753        &self,
2754        request: ImportCryptoKeyVersionRequest,
2755        parent: &str,
2756    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
2757        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall {
2758            hub: self.hub,
2759            _request: request,
2760            _parent: parent.to_string(),
2761            _delegate: Default::default(),
2762            _additional_params: Default::default(),
2763            _scopes: Default::default(),
2764        }
2765    }
2766
2767    /// Create a builder to help you perform the following task:
2768    ///
2769    /// Lists CryptoKeyVersions.
2770    ///
2771    /// # Arguments
2772    ///
2773    /// * `parent` - Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
2774    pub fn locations_key_rings_crypto_keys_crypto_key_versions_list(
2775        &self,
2776        parent: &str,
2777    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
2778        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall {
2779            hub: self.hub,
2780            _parent: parent.to_string(),
2781            _view: Default::default(),
2782            _page_token: Default::default(),
2783            _page_size: Default::default(),
2784            _order_by: Default::default(),
2785            _filter: Default::default(),
2786            _delegate: Default::default(),
2787            _additional_params: Default::default(),
2788            _scopes: Default::default(),
2789        }
2790    }
2791
2792    /// Create a builder to help you perform the following task:
2793    ///
2794    /// Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key.
2795    ///
2796    /// # Arguments
2797    ///
2798    /// * `request` - No description provided.
2799    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for signing.
2800    pub fn locations_key_rings_crypto_keys_crypto_key_versions_mac_sign(
2801        &self,
2802        request: MacSignRequest,
2803        name: &str,
2804    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
2805        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall {
2806            hub: self.hub,
2807            _request: request,
2808            _name: name.to_string(),
2809            _delegate: Default::default(),
2810            _additional_params: Default::default(),
2811            _scopes: Default::default(),
2812        }
2813    }
2814
2815    /// Create a builder to help you perform the following task:
2816    ///
2817    /// Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful.
2818    ///
2819    /// # Arguments
2820    ///
2821    /// * `request` - No description provided.
2822    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for verification.
2823    pub fn locations_key_rings_crypto_keys_crypto_key_versions_mac_verify(
2824        &self,
2825        request: MacVerifyRequest,
2826        name: &str,
2827    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
2828        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall {
2829            hub: self.hub,
2830            _request: request,
2831            _name: name.to_string(),
2832            _delegate: Default::default(),
2833            _additional_params: Default::default(),
2834            _scopes: Default::default(),
2835        }
2836    }
2837
2838    /// Create a builder to help you perform the following task:
2839    ///
2840    /// Update a CryptoKeyVersion's metadata. state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states.
2841    ///
2842    /// # Arguments
2843    ///
2844    /// * `request` - No description provided.
2845    /// * `name` - Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
2846    pub fn locations_key_rings_crypto_keys_crypto_key_versions_patch(
2847        &self,
2848        request: CryptoKeyVersion,
2849        name: &str,
2850    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
2851        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall {
2852            hub: self.hub,
2853            _request: request,
2854            _name: name.to_string(),
2855            _update_mask: Default::default(),
2856            _delegate: Default::default(),
2857            _additional_params: Default::default(),
2858            _scopes: Default::default(),
2859        }
2860    }
2861
2862    /// Create a builder to help you perform the following task:
2863    ///
2864    /// Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
2865    ///
2866    /// # Arguments
2867    ///
2868    /// * `request` - No description provided.
2869    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for decryption.
2870    pub fn locations_key_rings_crypto_keys_crypto_key_versions_raw_decrypt(
2871        &self,
2872        request: RawDecryptRequest,
2873        name: &str,
2874    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
2875        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall {
2876            hub: self.hub,
2877            _request: request,
2878            _name: name.to_string(),
2879            _delegate: Default::default(),
2880            _additional_params: Default::default(),
2881            _scopes: Default::default(),
2882        }
2883    }
2884
2885    /// Create a builder to help you perform the following task:
2886    ///
2887    /// Encrypts data using portable cryptographic primitives. Most users should choose Encrypt and Decrypt rather than their raw counterparts. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
2888    ///
2889    /// # Arguments
2890    ///
2891    /// * `request` - No description provided.
2892    /// * `name` - Required. The resource name of the CryptoKeyVersion to use for encryption.
2893    pub fn locations_key_rings_crypto_keys_crypto_key_versions_raw_encrypt(
2894        &self,
2895        request: RawEncryptRequest,
2896        name: &str,
2897    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
2898        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall {
2899            hub: self.hub,
2900            _request: request,
2901            _name: name.to_string(),
2902            _delegate: Default::default(),
2903            _additional_params: Default::default(),
2904            _scopes: Default::default(),
2905        }
2906    }
2907
2908    /// Create a builder to help you perform the following task:
2909    ///
2910    /// Restore a CryptoKeyVersion in the DESTROY_SCHEDULED state. Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared.
2911    ///
2912    /// # Arguments
2913    ///
2914    /// * `request` - No description provided.
2915    /// * `name` - Required. The resource name of the CryptoKeyVersion to restore.
2916    pub fn locations_key_rings_crypto_keys_crypto_key_versions_restore(
2917        &self,
2918        request: RestoreCryptoKeyVersionRequest,
2919        name: &str,
2920    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
2921        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall {
2922            hub: self.hub,
2923            _request: request,
2924            _name: name.to_string(),
2925            _delegate: Default::default(),
2926            _additional_params: Default::default(),
2927            _scopes: Default::default(),
2928        }
2929    }
2930
2931    /// Create a builder to help you perform the following task:
2932    ///
2933    /// Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required.
2934    ///
2935    /// # Arguments
2936    ///
2937    /// * `request` - No description provided.
2938    /// * `parent` - Required. The name of the KeyRing associated with the CryptoKeys.
2939    pub fn locations_key_rings_crypto_keys_create(
2940        &self,
2941        request: CryptoKey,
2942        parent: &str,
2943    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
2944        ProjectLocationKeyRingCryptoKeyCreateCall {
2945            hub: self.hub,
2946            _request: request,
2947            _parent: parent.to_string(),
2948            _skip_initial_version_creation: Default::default(),
2949            _crypto_key_id: Default::default(),
2950            _delegate: Default::default(),
2951            _additional_params: Default::default(),
2952            _scopes: Default::default(),
2953        }
2954    }
2955
2956    /// Create a builder to help you perform the following task:
2957    ///
2958    /// Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
2959    ///
2960    /// # Arguments
2961    ///
2962    /// * `request` - No description provided.
2963    /// * `name` - Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version.
2964    pub fn locations_key_rings_crypto_keys_decrypt(
2965        &self,
2966        request: DecryptRequest,
2967        name: &str,
2968    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
2969        ProjectLocationKeyRingCryptoKeyDecryptCall {
2970            hub: self.hub,
2971            _request: request,
2972            _name: name.to_string(),
2973            _delegate: Default::default(),
2974            _additional_params: Default::default(),
2975            _scopes: Default::default(),
2976        }
2977    }
2978
2979    /// Create a builder to help you perform the following task:
2980    ///
2981    /// Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
2982    ///
2983    /// # Arguments
2984    ///
2985    /// * `request` - No description provided.
2986    /// * `name` - Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its primary version.
2987    pub fn locations_key_rings_crypto_keys_encrypt(
2988        &self,
2989        request: EncryptRequest,
2990        name: &str,
2991    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
2992        ProjectLocationKeyRingCryptoKeyEncryptCall {
2993            hub: self.hub,
2994            _request: request,
2995            _name: name.to_string(),
2996            _delegate: Default::default(),
2997            _additional_params: Default::default(),
2998            _scopes: Default::default(),
2999        }
3000    }
3001
3002    /// Create a builder to help you perform the following task:
3003    ///
3004    /// Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
3005    ///
3006    /// # Arguments
3007    ///
3008    /// * `name` - Required. The name of the CryptoKey to get.
3009    pub fn locations_key_rings_crypto_keys_get(
3010        &self,
3011        name: &str,
3012    ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
3013        ProjectLocationKeyRingCryptoKeyGetCall {
3014            hub: self.hub,
3015            _name: name.to_string(),
3016            _delegate: Default::default(),
3017            _additional_params: Default::default(),
3018            _scopes: Default::default(),
3019        }
3020    }
3021
3022    /// Create a builder to help you perform the following task:
3023    ///
3024    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3025    ///
3026    /// # Arguments
3027    ///
3028    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3029    pub fn locations_key_rings_crypto_keys_get_iam_policy(
3030        &self,
3031        resource: &str,
3032    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
3033        ProjectLocationKeyRingCryptoKeyGetIamPolicyCall {
3034            hub: self.hub,
3035            _resource: resource.to_string(),
3036            _options_requested_policy_version: Default::default(),
3037            _delegate: Default::default(),
3038            _additional_params: Default::default(),
3039            _scopes: Default::default(),
3040        }
3041    }
3042
3043    /// Create a builder to help you perform the following task:
3044    ///
3045    /// Lists CryptoKeys.
3046    ///
3047    /// # Arguments
3048    ///
3049    /// * `parent` - Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
3050    pub fn locations_key_rings_crypto_keys_list(
3051        &self,
3052        parent: &str,
3053    ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
3054        ProjectLocationKeyRingCryptoKeyListCall {
3055            hub: self.hub,
3056            _parent: parent.to_string(),
3057            _version_view: Default::default(),
3058            _page_token: Default::default(),
3059            _page_size: Default::default(),
3060            _order_by: Default::default(),
3061            _filter: Default::default(),
3062            _delegate: Default::default(),
3063            _additional_params: Default::default(),
3064            _scopes: Default::default(),
3065        }
3066    }
3067
3068    /// Create a builder to help you perform the following task:
3069    ///
3070    /// Update a CryptoKey.
3071    ///
3072    /// # Arguments
3073    ///
3074    /// * `request` - No description provided.
3075    /// * `name` - Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
3076    pub fn locations_key_rings_crypto_keys_patch(
3077        &self,
3078        request: CryptoKey,
3079        name: &str,
3080    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
3081        ProjectLocationKeyRingCryptoKeyPatchCall {
3082            hub: self.hub,
3083            _request: request,
3084            _name: name.to_string(),
3085            _update_mask: Default::default(),
3086            _delegate: Default::default(),
3087            _additional_params: Default::default(),
3088            _scopes: Default::default(),
3089        }
3090    }
3091
3092    /// Create a builder to help you perform the following task:
3093    ///
3094    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3095    ///
3096    /// # Arguments
3097    ///
3098    /// * `request` - No description provided.
3099    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3100    pub fn locations_key_rings_crypto_keys_set_iam_policy(
3101        &self,
3102        request: SetIamPolicyRequest,
3103        resource: &str,
3104    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
3105        ProjectLocationKeyRingCryptoKeySetIamPolicyCall {
3106            hub: self.hub,
3107            _request: request,
3108            _resource: resource.to_string(),
3109            _delegate: Default::default(),
3110            _additional_params: Default::default(),
3111            _scopes: Default::default(),
3112        }
3113    }
3114
3115    /// Create a builder to help you perform the following task:
3116    ///
3117    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
3118    ///
3119    /// # Arguments
3120    ///
3121    /// * `request` - No description provided.
3122    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3123    pub fn locations_key_rings_crypto_keys_test_iam_permissions(
3124        &self,
3125        request: TestIamPermissionsRequest,
3126        resource: &str,
3127    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
3128        ProjectLocationKeyRingCryptoKeyTestIamPermissionCall {
3129            hub: self.hub,
3130            _request: request,
3131            _resource: resource.to_string(),
3132            _delegate: Default::default(),
3133            _additional_params: Default::default(),
3134            _scopes: Default::default(),
3135        }
3136    }
3137
3138    /// Create a builder to help you perform the following task:
3139    ///
3140    /// Update the version of a CryptoKey that will be used in Encrypt. Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT.
3141    ///
3142    /// # Arguments
3143    ///
3144    /// * `request` - No description provided.
3145    /// * `name` - Required. The resource name of the CryptoKey to update.
3146    pub fn locations_key_rings_crypto_keys_update_primary_version(
3147        &self,
3148        request: UpdateCryptoKeyPrimaryVersionRequest,
3149        name: &str,
3150    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
3151        ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall {
3152            hub: self.hub,
3153            _request: request,
3154            _name: name.to_string(),
3155            _delegate: Default::default(),
3156            _additional_params: Default::default(),
3157            _scopes: Default::default(),
3158        }
3159    }
3160
3161    /// Create a builder to help you perform the following task:
3162    ///
3163    /// Create a new ImportJob within a KeyRing. ImportJob.import_method is required.
3164    ///
3165    /// # Arguments
3166    ///
3167    /// * `request` - No description provided.
3168    /// * `parent` - Required. The name of the KeyRing associated with the ImportJobs.
3169    pub fn locations_key_rings_import_jobs_create(
3170        &self,
3171        request: ImportJob,
3172        parent: &str,
3173    ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
3174        ProjectLocationKeyRingImportJobCreateCall {
3175            hub: self.hub,
3176            _request: request,
3177            _parent: parent.to_string(),
3178            _import_job_id: Default::default(),
3179            _delegate: Default::default(),
3180            _additional_params: Default::default(),
3181            _scopes: Default::default(),
3182        }
3183    }
3184
3185    /// Create a builder to help you perform the following task:
3186    ///
3187    /// Returns metadata for a given ImportJob.
3188    ///
3189    /// # Arguments
3190    ///
3191    /// * `name` - Required. The name of the ImportJob to get.
3192    pub fn locations_key_rings_import_jobs_get(
3193        &self,
3194        name: &str,
3195    ) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
3196        ProjectLocationKeyRingImportJobGetCall {
3197            hub: self.hub,
3198            _name: name.to_string(),
3199            _delegate: Default::default(),
3200            _additional_params: Default::default(),
3201            _scopes: Default::default(),
3202        }
3203    }
3204
3205    /// Create a builder to help you perform the following task:
3206    ///
3207    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3208    ///
3209    /// # Arguments
3210    ///
3211    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3212    pub fn locations_key_rings_import_jobs_get_iam_policy(
3213        &self,
3214        resource: &str,
3215    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
3216        ProjectLocationKeyRingImportJobGetIamPolicyCall {
3217            hub: self.hub,
3218            _resource: resource.to_string(),
3219            _options_requested_policy_version: Default::default(),
3220            _delegate: Default::default(),
3221            _additional_params: Default::default(),
3222            _scopes: Default::default(),
3223        }
3224    }
3225
3226    /// Create a builder to help you perform the following task:
3227    ///
3228    /// Lists ImportJobs.
3229    ///
3230    /// # Arguments
3231    ///
3232    /// * `parent` - Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
3233    pub fn locations_key_rings_import_jobs_list(
3234        &self,
3235        parent: &str,
3236    ) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
3237        ProjectLocationKeyRingImportJobListCall {
3238            hub: self.hub,
3239            _parent: parent.to_string(),
3240            _page_token: Default::default(),
3241            _page_size: Default::default(),
3242            _order_by: Default::default(),
3243            _filter: Default::default(),
3244            _delegate: Default::default(),
3245            _additional_params: Default::default(),
3246            _scopes: Default::default(),
3247        }
3248    }
3249
3250    /// Create a builder to help you perform the following task:
3251    ///
3252    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3253    ///
3254    /// # Arguments
3255    ///
3256    /// * `request` - No description provided.
3257    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3258    pub fn locations_key_rings_import_jobs_set_iam_policy(
3259        &self,
3260        request: SetIamPolicyRequest,
3261        resource: &str,
3262    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
3263        ProjectLocationKeyRingImportJobSetIamPolicyCall {
3264            hub: self.hub,
3265            _request: request,
3266            _resource: resource.to_string(),
3267            _delegate: Default::default(),
3268            _additional_params: Default::default(),
3269            _scopes: Default::default(),
3270        }
3271    }
3272
3273    /// Create a builder to help you perform the following task:
3274    ///
3275    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
3276    ///
3277    /// # Arguments
3278    ///
3279    /// * `request` - No description provided.
3280    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3281    pub fn locations_key_rings_import_jobs_test_iam_permissions(
3282        &self,
3283        request: TestIamPermissionsRequest,
3284        resource: &str,
3285    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
3286        ProjectLocationKeyRingImportJobTestIamPermissionCall {
3287            hub: self.hub,
3288            _request: request,
3289            _resource: resource.to_string(),
3290            _delegate: Default::default(),
3291            _additional_params: Default::default(),
3292            _scopes: Default::default(),
3293        }
3294    }
3295
3296    /// Create a builder to help you perform the following task:
3297    ///
3298    /// Create a new KeyRing in a given Project and Location.
3299    ///
3300    /// # Arguments
3301    ///
3302    /// * `request` - No description provided.
3303    /// * `parent` - Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
3304    pub fn locations_key_rings_create(
3305        &self,
3306        request: KeyRing,
3307        parent: &str,
3308    ) -> ProjectLocationKeyRingCreateCall<'a, C> {
3309        ProjectLocationKeyRingCreateCall {
3310            hub: self.hub,
3311            _request: request,
3312            _parent: parent.to_string(),
3313            _key_ring_id: Default::default(),
3314            _delegate: Default::default(),
3315            _additional_params: Default::default(),
3316            _scopes: Default::default(),
3317        }
3318    }
3319
3320    /// Create a builder to help you perform the following task:
3321    ///
3322    /// Returns metadata for a given KeyRing.
3323    ///
3324    /// # Arguments
3325    ///
3326    /// * `name` - Required. The name of the KeyRing to get.
3327    pub fn locations_key_rings_get(&self, name: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
3328        ProjectLocationKeyRingGetCall {
3329            hub: self.hub,
3330            _name: name.to_string(),
3331            _delegate: Default::default(),
3332            _additional_params: Default::default(),
3333            _scopes: Default::default(),
3334        }
3335    }
3336
3337    /// Create a builder to help you perform the following task:
3338    ///
3339    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3340    ///
3341    /// # Arguments
3342    ///
3343    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3344    pub fn locations_key_rings_get_iam_policy(
3345        &self,
3346        resource: &str,
3347    ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
3348        ProjectLocationKeyRingGetIamPolicyCall {
3349            hub: self.hub,
3350            _resource: resource.to_string(),
3351            _options_requested_policy_version: Default::default(),
3352            _delegate: Default::default(),
3353            _additional_params: Default::default(),
3354            _scopes: Default::default(),
3355        }
3356    }
3357
3358    /// Create a builder to help you perform the following task:
3359    ///
3360    /// Lists KeyRings.
3361    ///
3362    /// # Arguments
3363    ///
3364    /// * `parent` - Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
3365    pub fn locations_key_rings_list(&self, parent: &str) -> ProjectLocationKeyRingListCall<'a, C> {
3366        ProjectLocationKeyRingListCall {
3367            hub: self.hub,
3368            _parent: parent.to_string(),
3369            _page_token: Default::default(),
3370            _page_size: Default::default(),
3371            _order_by: Default::default(),
3372            _filter: Default::default(),
3373            _delegate: Default::default(),
3374            _additional_params: Default::default(),
3375            _scopes: Default::default(),
3376        }
3377    }
3378
3379    /// Create a builder to help you perform the following task:
3380    ///
3381    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3382    ///
3383    /// # Arguments
3384    ///
3385    /// * `request` - No description provided.
3386    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3387    pub fn locations_key_rings_set_iam_policy(
3388        &self,
3389        request: SetIamPolicyRequest,
3390        resource: &str,
3391    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
3392        ProjectLocationKeyRingSetIamPolicyCall {
3393            hub: self.hub,
3394            _request: request,
3395            _resource: resource.to_string(),
3396            _delegate: Default::default(),
3397            _additional_params: Default::default(),
3398            _scopes: Default::default(),
3399        }
3400    }
3401
3402    /// Create a builder to help you perform the following task:
3403    ///
3404    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
3405    ///
3406    /// # Arguments
3407    ///
3408    /// * `request` - No description provided.
3409    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3410    pub fn locations_key_rings_test_iam_permissions(
3411        &self,
3412        request: TestIamPermissionsRequest,
3413        resource: &str,
3414    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
3415        ProjectLocationKeyRingTestIamPermissionCall {
3416            hub: self.hub,
3417            _request: request,
3418            _resource: resource.to_string(),
3419            _delegate: Default::default(),
3420            _additional_params: Default::default(),
3421            _scopes: Default::default(),
3422        }
3423    }
3424
3425    /// Create a builder to help you perform the following task:
3426    ///
3427    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3428    ///
3429    /// # Arguments
3430    ///
3431    /// * `name` - The name of the operation resource.
3432    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3433        ProjectLocationOperationGetCall {
3434            hub: self.hub,
3435            _name: name.to_string(),
3436            _delegate: Default::default(),
3437            _additional_params: Default::default(),
3438            _scopes: Default::default(),
3439        }
3440    }
3441
3442    /// Create a builder to help you perform the following task:
3443    ///
3444    /// Generate random bytes using the Cloud KMS randomness source in the provided location.
3445    ///
3446    /// # Arguments
3447    ///
3448    /// * `request` - No description provided.
3449    /// * `location` - The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".
3450    pub fn locations_generate_random_bytes(
3451        &self,
3452        request: GenerateRandomBytesRequest,
3453        location: &str,
3454    ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
3455        ProjectLocationGenerateRandomByteCall {
3456            hub: self.hub,
3457            _request: request,
3458            _location: location.to_string(),
3459            _delegate: Default::default(),
3460            _additional_params: Default::default(),
3461            _scopes: Default::default(),
3462        }
3463    }
3464
3465    /// Create a builder to help you perform the following task:
3466    ///
3467    /// Gets information about a location.
3468    ///
3469    /// # Arguments
3470    ///
3471    /// * `name` - Resource name for the location.
3472    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3473        ProjectLocationGetCall {
3474            hub: self.hub,
3475            _name: name.to_string(),
3476            _delegate: Default::default(),
3477            _additional_params: Default::default(),
3478            _scopes: Default::default(),
3479        }
3480    }
3481
3482    /// Create a builder to help you perform the following task:
3483    ///
3484    /// Returns the EkmConfig singleton resource for a given project and location.
3485    ///
3486    /// # Arguments
3487    ///
3488    /// * `name` - Required. The name of the EkmConfig to get.
3489    pub fn locations_get_ekm_config(&self, name: &str) -> ProjectLocationGetEkmConfigCall<'a, C> {
3490        ProjectLocationGetEkmConfigCall {
3491            hub: self.hub,
3492            _name: name.to_string(),
3493            _delegate: Default::default(),
3494            _additional_params: Default::default(),
3495            _scopes: Default::default(),
3496        }
3497    }
3498
3499    /// Create a builder to help you perform the following task:
3500    ///
3501    /// Lists information about the supported locations for this service.
3502    ///
3503    /// # Arguments
3504    ///
3505    /// * `name` - The resource that owns the locations collection, if applicable.
3506    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3507        ProjectLocationListCall {
3508            hub: self.hub,
3509            _name: name.to_string(),
3510            _page_token: Default::default(),
3511            _page_size: Default::default(),
3512            _filter: Default::default(),
3513            _extra_location_types: Default::default(),
3514            _delegate: Default::default(),
3515            _additional_params: Default::default(),
3516            _scopes: Default::default(),
3517        }
3518    }
3519
3520    /// Create a builder to help you perform the following task:
3521    ///
3522    /// Updates the EkmConfig singleton resource for a given project and location.
3523    ///
3524    /// # Arguments
3525    ///
3526    /// * `request` - No description provided.
3527    /// * `name` - Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
3528    pub fn locations_update_ekm_config(
3529        &self,
3530        request: EkmConfig,
3531        name: &str,
3532    ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
3533        ProjectLocationUpdateEkmConfigCall {
3534            hub: self.hub,
3535            _request: request,
3536            _name: name.to_string(),
3537            _update_mask: Default::default(),
3538            _delegate: Default::default(),
3539            _additional_params: Default::default(),
3540            _scopes: Default::default(),
3541        }
3542    }
3543
3544    /// Create a builder to help you perform the following task:
3545    ///
3546    /// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
3547    ///
3548    /// # Arguments
3549    ///
3550    /// * `name` - Required. The name of the KeyAccessJustificationsPolicyConfig to get.
3551    pub fn get_kaj_policy_config(&self, name: &str) -> ProjectGetKajPolicyConfigCall<'a, C> {
3552        ProjectGetKajPolicyConfigCall {
3553            hub: self.hub,
3554            _name: name.to_string(),
3555            _delegate: Default::default(),
3556            _additional_params: Default::default(),
3557            _scopes: Default::default(),
3558        }
3559    }
3560
3561    /// Create a builder to help you perform the following task:
3562    ///
3563    /// Returns the effective Cloud KMS Autokey configuration for a given project.
3564    ///
3565    /// # Arguments
3566    ///
3567    /// * `parent` - Required. Name of the resource project to the show effective Cloud KMS Autokey configuration for. This may be helpful for interrogating the effect of nested folder configurations on a given resource project.
3568    pub fn show_effective_autokey_config(
3569        &self,
3570        parent: &str,
3571    ) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
3572        ProjectShowEffectiveAutokeyConfigCall {
3573            hub: self.hub,
3574            _parent: parent.to_string(),
3575            _delegate: Default::default(),
3576            _additional_params: Default::default(),
3577            _scopes: Default::default(),
3578        }
3579    }
3580
3581    /// Create a builder to help you perform the following task:
3582    ///
3583    /// Returns the KeyAccessJustificationsEnrollmentConfig of the resource closest to the given project in hierarchy.
3584    ///
3585    /// # Arguments
3586    ///
3587    /// * `project` - Required. The number or id of the project to get the effective KeyAccessJustificationsEnrollmentConfig for.
3588    pub fn show_effective_key_access_justifications_enrollment_config(
3589        &self,
3590        project: &str,
3591    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C> {
3592        ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall {
3593            hub: self.hub,
3594            _project: project.to_string(),
3595            _delegate: Default::default(),
3596            _additional_params: Default::default(),
3597            _scopes: Default::default(),
3598        }
3599    }
3600
3601    /// Create a builder to help you perform the following task:
3602    ///
3603    /// Returns the KeyAccessJustificationsPolicyConfig of the resource closest to the given project in hierarchy.
3604    ///
3605    /// # Arguments
3606    ///
3607    /// * `project` - Required. The number or id of the project to get the effective KeyAccessJustificationsPolicyConfig. In the format of "projects/{|}"
3608    pub fn show_effective_key_access_justifications_policy_config(
3609        &self,
3610        project: &str,
3611    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C> {
3612        ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall {
3613            hub: self.hub,
3614            _project: project.to_string(),
3615            _delegate: Default::default(),
3616            _additional_params: Default::default(),
3617            _scopes: Default::default(),
3618        }
3619    }
3620
3621    /// Create a builder to help you perform the following task:
3622    ///
3623    /// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
3624    ///
3625    /// # Arguments
3626    ///
3627    /// * `request` - No description provided.
3628    /// * `name` - Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
3629    pub fn update_kaj_policy_config(
3630        &self,
3631        request: KeyAccessJustificationsPolicyConfig,
3632        name: &str,
3633    ) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
3634        ProjectUpdateKajPolicyConfigCall {
3635            hub: self.hub,
3636            _request: request,
3637            _name: name.to_string(),
3638            _update_mask: Default::default(),
3639            _delegate: Default::default(),
3640            _additional_params: Default::default(),
3641            _scopes: Default::default(),
3642        }
3643    }
3644}
3645
3646// ###################
3647// CallBuilders   ###
3648// #################
3649
3650/// Returns the AutokeyConfig for a folder.
3651///
3652/// A builder for the *getAutokeyConfig* method supported by a *folder* resource.
3653/// It is not used directly, but through a [`FolderMethods`] instance.
3654///
3655/// # Example
3656///
3657/// Instantiate a resource method builder
3658///
3659/// ```test_harness,no_run
3660/// # extern crate hyper;
3661/// # extern crate hyper_rustls;
3662/// # extern crate google_cloudkms1 as cloudkms1;
3663/// # async fn dox() {
3664/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3665///
3666/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3667/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3668/// #     .with_native_roots()
3669/// #     .unwrap()
3670/// #     .https_only()
3671/// #     .enable_http2()
3672/// #     .build();
3673///
3674/// # let executor = hyper_util::rt::TokioExecutor::new();
3675/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3676/// #     secret,
3677/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3678/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3679/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3680/// #     ),
3681/// # ).build().await.unwrap();
3682///
3683/// # let client = hyper_util::client::legacy::Client::builder(
3684/// #     hyper_util::rt::TokioExecutor::new()
3685/// # )
3686/// # .build(
3687/// #     hyper_rustls::HttpsConnectorBuilder::new()
3688/// #         .with_native_roots()
3689/// #         .unwrap()
3690/// #         .https_or_http()
3691/// #         .enable_http2()
3692/// #         .build()
3693/// # );
3694/// # let mut hub = CloudKMS::new(client, auth);
3695/// // You can configure optional parameters by calling the respective setters at will, and
3696/// // execute the final call using `doit()`.
3697/// // Values shown here are possibly random and not representative !
3698/// let result = hub.folders().get_autokey_config("name")
3699///              .doit().await;
3700/// # }
3701/// ```
3702pub struct FolderGetAutokeyConfigCall<'a, C>
3703where
3704    C: 'a,
3705{
3706    hub: &'a CloudKMS<C>,
3707    _name: String,
3708    _delegate: Option<&'a mut dyn common::Delegate>,
3709    _additional_params: HashMap<String, String>,
3710    _scopes: BTreeSet<String>,
3711}
3712
3713impl<'a, C> common::CallBuilder for FolderGetAutokeyConfigCall<'a, C> {}
3714
3715impl<'a, C> FolderGetAutokeyConfigCall<'a, C>
3716where
3717    C: common::Connector,
3718{
3719    /// Perform the operation you have build so far.
3720    pub async fn doit(mut self) -> common::Result<(common::Response, AutokeyConfig)> {
3721        use std::borrow::Cow;
3722        use std::io::{Read, Seek};
3723
3724        use common::{url::Params, ToParts};
3725        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3726
3727        let mut dd = common::DefaultDelegate;
3728        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3729        dlg.begin(common::MethodInfo {
3730            id: "cloudkms.folders.getAutokeyConfig",
3731            http_method: hyper::Method::GET,
3732        });
3733
3734        for &field in ["alt", "name"].iter() {
3735            if self._additional_params.contains_key(field) {
3736                dlg.finished(false);
3737                return Err(common::Error::FieldClash(field));
3738            }
3739        }
3740
3741        let mut params = Params::with_capacity(3 + self._additional_params.len());
3742        params.push("name", self._name);
3743
3744        params.extend(self._additional_params.iter());
3745
3746        params.push("alt", "json");
3747        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3748        if self._scopes.is_empty() {
3749            self._scopes
3750                .insert(Scope::CloudPlatform.as_ref().to_string());
3751        }
3752
3753        #[allow(clippy::single_element_loop)]
3754        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3755            url = params.uri_replacement(url, param_name, find_this, true);
3756        }
3757        {
3758            let to_remove = ["name"];
3759            params.remove_params(&to_remove);
3760        }
3761
3762        let url = params.parse_with_url(&url);
3763
3764        loop {
3765            let token = match self
3766                .hub
3767                .auth
3768                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3769                .await
3770            {
3771                Ok(token) => token,
3772                Err(e) => match dlg.token(e) {
3773                    Ok(token) => token,
3774                    Err(e) => {
3775                        dlg.finished(false);
3776                        return Err(common::Error::MissingToken(e));
3777                    }
3778                },
3779            };
3780            let mut req_result = {
3781                let client = &self.hub.client;
3782                dlg.pre_request();
3783                let mut req_builder = hyper::Request::builder()
3784                    .method(hyper::Method::GET)
3785                    .uri(url.as_str())
3786                    .header(USER_AGENT, self.hub._user_agent.clone());
3787
3788                if let Some(token) = token.as_ref() {
3789                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3790                }
3791
3792                let request = req_builder
3793                    .header(CONTENT_LENGTH, 0_u64)
3794                    .body(common::to_body::<String>(None));
3795
3796                client.request(request.unwrap()).await
3797            };
3798
3799            match req_result {
3800                Err(err) => {
3801                    if let common::Retry::After(d) = dlg.http_error(&err) {
3802                        sleep(d).await;
3803                        continue;
3804                    }
3805                    dlg.finished(false);
3806                    return Err(common::Error::HttpError(err));
3807                }
3808                Ok(res) => {
3809                    let (mut parts, body) = res.into_parts();
3810                    let mut body = common::Body::new(body);
3811                    if !parts.status.is_success() {
3812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3813                        let error = serde_json::from_str(&common::to_string(&bytes));
3814                        let response = common::to_response(parts, bytes.into());
3815
3816                        if let common::Retry::After(d) =
3817                            dlg.http_failure(&response, error.as_ref().ok())
3818                        {
3819                            sleep(d).await;
3820                            continue;
3821                        }
3822
3823                        dlg.finished(false);
3824
3825                        return Err(match error {
3826                            Ok(value) => common::Error::BadRequest(value),
3827                            _ => common::Error::Failure(response),
3828                        });
3829                    }
3830                    let response = {
3831                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3832                        let encoded = common::to_string(&bytes);
3833                        match serde_json::from_str(&encoded) {
3834                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3835                            Err(error) => {
3836                                dlg.response_json_decode_error(&encoded, &error);
3837                                return Err(common::Error::JsonDecodeError(
3838                                    encoded.to_string(),
3839                                    error,
3840                                ));
3841                            }
3842                        }
3843                    };
3844
3845                    dlg.finished(true);
3846                    return Ok(response);
3847                }
3848            }
3849        }
3850    }
3851
3852    /// Required. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
3853    ///
3854    /// Sets the *name* path property to the given value.
3855    ///
3856    /// Even though the property as already been set when instantiating this call,
3857    /// we provide this method for API completeness.
3858    pub fn name(mut self, new_value: &str) -> FolderGetAutokeyConfigCall<'a, C> {
3859        self._name = new_value.to_string();
3860        self
3861    }
3862    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3863    /// while executing the actual API request.
3864    ///
3865    /// ````text
3866    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3867    /// ````
3868    ///
3869    /// Sets the *delegate* property to the given value.
3870    pub fn delegate(
3871        mut self,
3872        new_value: &'a mut dyn common::Delegate,
3873    ) -> FolderGetAutokeyConfigCall<'a, C> {
3874        self._delegate = Some(new_value);
3875        self
3876    }
3877
3878    /// Set any additional parameter of the query string used in the request.
3879    /// It should be used to set parameters which are not yet available through their own
3880    /// setters.
3881    ///
3882    /// Please note that this method must not be used to set any of the known parameters
3883    /// which have their own setter method. If done anyway, the request will fail.
3884    ///
3885    /// # Additional Parameters
3886    ///
3887    /// * *$.xgafv* (query-string) - V1 error format.
3888    /// * *access_token* (query-string) - OAuth access token.
3889    /// * *alt* (query-string) - Data format for response.
3890    /// * *callback* (query-string) - JSONP
3891    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3892    /// * *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.
3893    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3894    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3895    /// * *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.
3896    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3897    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3898    pub fn param<T>(mut self, name: T, value: T) -> FolderGetAutokeyConfigCall<'a, C>
3899    where
3900        T: AsRef<str>,
3901    {
3902        self._additional_params
3903            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3904        self
3905    }
3906
3907    /// Identifies the authorization scope for the method you are building.
3908    ///
3909    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3910    /// [`Scope::CloudPlatform`].
3911    ///
3912    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3913    /// tokens for more than one scope.
3914    ///
3915    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3916    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3917    /// sufficient, a read-write scope will do as well.
3918    pub fn add_scope<St>(mut self, scope: St) -> FolderGetAutokeyConfigCall<'a, C>
3919    where
3920        St: AsRef<str>,
3921    {
3922        self._scopes.insert(String::from(scope.as_ref()));
3923        self
3924    }
3925    /// Identifies the authorization scope(s) for the method you are building.
3926    ///
3927    /// See [`Self::add_scope()`] for details.
3928    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetAutokeyConfigCall<'a, C>
3929    where
3930        I: IntoIterator<Item = St>,
3931        St: AsRef<str>,
3932    {
3933        self._scopes
3934            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3935        self
3936    }
3937
3938    /// Removes all scopes, and no default scope will be used either.
3939    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3940    /// for details).
3941    pub fn clear_scopes(mut self) -> FolderGetAutokeyConfigCall<'a, C> {
3942        self._scopes.clear();
3943        self
3944    }
3945}
3946
3947/// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
3948///
3949/// A builder for the *getKajPolicyConfig* method supported by a *folder* resource.
3950/// It is not used directly, but through a [`FolderMethods`] instance.
3951///
3952/// # Example
3953///
3954/// Instantiate a resource method builder
3955///
3956/// ```test_harness,no_run
3957/// # extern crate hyper;
3958/// # extern crate hyper_rustls;
3959/// # extern crate google_cloudkms1 as cloudkms1;
3960/// # async fn dox() {
3961/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3962///
3963/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3964/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3965/// #     .with_native_roots()
3966/// #     .unwrap()
3967/// #     .https_only()
3968/// #     .enable_http2()
3969/// #     .build();
3970///
3971/// # let executor = hyper_util::rt::TokioExecutor::new();
3972/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3973/// #     secret,
3974/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3975/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3976/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3977/// #     ),
3978/// # ).build().await.unwrap();
3979///
3980/// # let client = hyper_util::client::legacy::Client::builder(
3981/// #     hyper_util::rt::TokioExecutor::new()
3982/// # )
3983/// # .build(
3984/// #     hyper_rustls::HttpsConnectorBuilder::new()
3985/// #         .with_native_roots()
3986/// #         .unwrap()
3987/// #         .https_or_http()
3988/// #         .enable_http2()
3989/// #         .build()
3990/// # );
3991/// # let mut hub = CloudKMS::new(client, auth);
3992/// // You can configure optional parameters by calling the respective setters at will, and
3993/// // execute the final call using `doit()`.
3994/// // Values shown here are possibly random and not representative !
3995/// let result = hub.folders().get_kaj_policy_config("name")
3996///              .doit().await;
3997/// # }
3998/// ```
3999pub struct FolderGetKajPolicyConfigCall<'a, C>
4000where
4001    C: 'a,
4002{
4003    hub: &'a CloudKMS<C>,
4004    _name: String,
4005    _delegate: Option<&'a mut dyn common::Delegate>,
4006    _additional_params: HashMap<String, String>,
4007    _scopes: BTreeSet<String>,
4008}
4009
4010impl<'a, C> common::CallBuilder for FolderGetKajPolicyConfigCall<'a, C> {}
4011
4012impl<'a, C> FolderGetKajPolicyConfigCall<'a, C>
4013where
4014    C: common::Connector,
4015{
4016    /// Perform the operation you have build so far.
4017    pub async fn doit(
4018        mut self,
4019    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
4020        use std::borrow::Cow;
4021        use std::io::{Read, Seek};
4022
4023        use common::{url::Params, ToParts};
4024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4025
4026        let mut dd = common::DefaultDelegate;
4027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4028        dlg.begin(common::MethodInfo {
4029            id: "cloudkms.folders.getKajPolicyConfig",
4030            http_method: hyper::Method::GET,
4031        });
4032
4033        for &field in ["alt", "name"].iter() {
4034            if self._additional_params.contains_key(field) {
4035                dlg.finished(false);
4036                return Err(common::Error::FieldClash(field));
4037            }
4038        }
4039
4040        let mut params = Params::with_capacity(3 + self._additional_params.len());
4041        params.push("name", self._name);
4042
4043        params.extend(self._additional_params.iter());
4044
4045        params.push("alt", "json");
4046        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4047        if self._scopes.is_empty() {
4048            self._scopes
4049                .insert(Scope::CloudPlatform.as_ref().to_string());
4050        }
4051
4052        #[allow(clippy::single_element_loop)]
4053        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4054            url = params.uri_replacement(url, param_name, find_this, true);
4055        }
4056        {
4057            let to_remove = ["name"];
4058            params.remove_params(&to_remove);
4059        }
4060
4061        let url = params.parse_with_url(&url);
4062
4063        loop {
4064            let token = match self
4065                .hub
4066                .auth
4067                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4068                .await
4069            {
4070                Ok(token) => token,
4071                Err(e) => match dlg.token(e) {
4072                    Ok(token) => token,
4073                    Err(e) => {
4074                        dlg.finished(false);
4075                        return Err(common::Error::MissingToken(e));
4076                    }
4077                },
4078            };
4079            let mut req_result = {
4080                let client = &self.hub.client;
4081                dlg.pre_request();
4082                let mut req_builder = hyper::Request::builder()
4083                    .method(hyper::Method::GET)
4084                    .uri(url.as_str())
4085                    .header(USER_AGENT, self.hub._user_agent.clone());
4086
4087                if let Some(token) = token.as_ref() {
4088                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4089                }
4090
4091                let request = req_builder
4092                    .header(CONTENT_LENGTH, 0_u64)
4093                    .body(common::to_body::<String>(None));
4094
4095                client.request(request.unwrap()).await
4096            };
4097
4098            match req_result {
4099                Err(err) => {
4100                    if let common::Retry::After(d) = dlg.http_error(&err) {
4101                        sleep(d).await;
4102                        continue;
4103                    }
4104                    dlg.finished(false);
4105                    return Err(common::Error::HttpError(err));
4106                }
4107                Ok(res) => {
4108                    let (mut parts, body) = res.into_parts();
4109                    let mut body = common::Body::new(body);
4110                    if !parts.status.is_success() {
4111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4112                        let error = serde_json::from_str(&common::to_string(&bytes));
4113                        let response = common::to_response(parts, bytes.into());
4114
4115                        if let common::Retry::After(d) =
4116                            dlg.http_failure(&response, error.as_ref().ok())
4117                        {
4118                            sleep(d).await;
4119                            continue;
4120                        }
4121
4122                        dlg.finished(false);
4123
4124                        return Err(match error {
4125                            Ok(value) => common::Error::BadRequest(value),
4126                            _ => common::Error::Failure(response),
4127                        });
4128                    }
4129                    let response = {
4130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4131                        let encoded = common::to_string(&bytes);
4132                        match serde_json::from_str(&encoded) {
4133                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4134                            Err(error) => {
4135                                dlg.response_json_decode_error(&encoded, &error);
4136                                return Err(common::Error::JsonDecodeError(
4137                                    encoded.to_string(),
4138                                    error,
4139                                ));
4140                            }
4141                        }
4142                    };
4143
4144                    dlg.finished(true);
4145                    return Ok(response);
4146                }
4147            }
4148        }
4149    }
4150
4151    /// Required. The name of the KeyAccessJustificationsPolicyConfig to get.
4152    ///
4153    /// Sets the *name* path property to the given value.
4154    ///
4155    /// Even though the property as already been set when instantiating this call,
4156    /// we provide this method for API completeness.
4157    pub fn name(mut self, new_value: &str) -> FolderGetKajPolicyConfigCall<'a, C> {
4158        self._name = new_value.to_string();
4159        self
4160    }
4161    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4162    /// while executing the actual API request.
4163    ///
4164    /// ````text
4165    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4166    /// ````
4167    ///
4168    /// Sets the *delegate* property to the given value.
4169    pub fn delegate(
4170        mut self,
4171        new_value: &'a mut dyn common::Delegate,
4172    ) -> FolderGetKajPolicyConfigCall<'a, C> {
4173        self._delegate = Some(new_value);
4174        self
4175    }
4176
4177    /// Set any additional parameter of the query string used in the request.
4178    /// It should be used to set parameters which are not yet available through their own
4179    /// setters.
4180    ///
4181    /// Please note that this method must not be used to set any of the known parameters
4182    /// which have their own setter method. If done anyway, the request will fail.
4183    ///
4184    /// # Additional Parameters
4185    ///
4186    /// * *$.xgafv* (query-string) - V1 error format.
4187    /// * *access_token* (query-string) - OAuth access token.
4188    /// * *alt* (query-string) - Data format for response.
4189    /// * *callback* (query-string) - JSONP
4190    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4191    /// * *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.
4192    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4193    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4194    /// * *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.
4195    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4196    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4197    pub fn param<T>(mut self, name: T, value: T) -> FolderGetKajPolicyConfigCall<'a, C>
4198    where
4199        T: AsRef<str>,
4200    {
4201        self._additional_params
4202            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4203        self
4204    }
4205
4206    /// Identifies the authorization scope for the method you are building.
4207    ///
4208    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4209    /// [`Scope::CloudPlatform`].
4210    ///
4211    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4212    /// tokens for more than one scope.
4213    ///
4214    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4215    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4216    /// sufficient, a read-write scope will do as well.
4217    pub fn add_scope<St>(mut self, scope: St) -> FolderGetKajPolicyConfigCall<'a, C>
4218    where
4219        St: AsRef<str>,
4220    {
4221        self._scopes.insert(String::from(scope.as_ref()));
4222        self
4223    }
4224    /// Identifies the authorization scope(s) for the method you are building.
4225    ///
4226    /// See [`Self::add_scope()`] for details.
4227    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetKajPolicyConfigCall<'a, C>
4228    where
4229        I: IntoIterator<Item = St>,
4230        St: AsRef<str>,
4231    {
4232        self._scopes
4233            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4234        self
4235    }
4236
4237    /// Removes all scopes, and no default scope will be used either.
4238    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4239    /// for details).
4240    pub fn clear_scopes(mut self) -> FolderGetKajPolicyConfigCall<'a, C> {
4241        self._scopes.clear();
4242        self
4243    }
4244}
4245
4246/// Updates the AutokeyConfig for a folder. The caller must have both `cloudkms.autokeyConfigs.update` permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy` permission on the provided key project. A KeyHandle creation in the folder's descendant projects will use this configuration to determine where to create the resulting CryptoKey.
4247///
4248/// A builder for the *updateAutokeyConfig* method supported by a *folder* resource.
4249/// It is not used directly, but through a [`FolderMethods`] instance.
4250///
4251/// # Example
4252///
4253/// Instantiate a resource method builder
4254///
4255/// ```test_harness,no_run
4256/// # extern crate hyper;
4257/// # extern crate hyper_rustls;
4258/// # extern crate google_cloudkms1 as cloudkms1;
4259/// use cloudkms1::api::AutokeyConfig;
4260/// # async fn dox() {
4261/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4262///
4263/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4264/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4265/// #     .with_native_roots()
4266/// #     .unwrap()
4267/// #     .https_only()
4268/// #     .enable_http2()
4269/// #     .build();
4270///
4271/// # let executor = hyper_util::rt::TokioExecutor::new();
4272/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4273/// #     secret,
4274/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4275/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4276/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4277/// #     ),
4278/// # ).build().await.unwrap();
4279///
4280/// # let client = hyper_util::client::legacy::Client::builder(
4281/// #     hyper_util::rt::TokioExecutor::new()
4282/// # )
4283/// # .build(
4284/// #     hyper_rustls::HttpsConnectorBuilder::new()
4285/// #         .with_native_roots()
4286/// #         .unwrap()
4287/// #         .https_or_http()
4288/// #         .enable_http2()
4289/// #         .build()
4290/// # );
4291/// # let mut hub = CloudKMS::new(client, auth);
4292/// // As the method needs a request, you would usually fill it with the desired information
4293/// // into the respective structure. Some of the parts shown here might not be applicable !
4294/// // Values shown here are possibly random and not representative !
4295/// let mut req = AutokeyConfig::default();
4296///
4297/// // You can configure optional parameters by calling the respective setters at will, and
4298/// // execute the final call using `doit()`.
4299/// // Values shown here are possibly random and not representative !
4300/// let result = hub.folders().update_autokey_config(req, "name")
4301///              .update_mask(FieldMask::new::<&str>(&[]))
4302///              .doit().await;
4303/// # }
4304/// ```
4305pub struct FolderUpdateAutokeyConfigCall<'a, C>
4306where
4307    C: 'a,
4308{
4309    hub: &'a CloudKMS<C>,
4310    _request: AutokeyConfig,
4311    _name: String,
4312    _update_mask: Option<common::FieldMask>,
4313    _delegate: Option<&'a mut dyn common::Delegate>,
4314    _additional_params: HashMap<String, String>,
4315    _scopes: BTreeSet<String>,
4316}
4317
4318impl<'a, C> common::CallBuilder for FolderUpdateAutokeyConfigCall<'a, C> {}
4319
4320impl<'a, C> FolderUpdateAutokeyConfigCall<'a, C>
4321where
4322    C: common::Connector,
4323{
4324    /// Perform the operation you have build so far.
4325    pub async fn doit(mut self) -> common::Result<(common::Response, AutokeyConfig)> {
4326        use std::borrow::Cow;
4327        use std::io::{Read, Seek};
4328
4329        use common::{url::Params, ToParts};
4330        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4331
4332        let mut dd = common::DefaultDelegate;
4333        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4334        dlg.begin(common::MethodInfo {
4335            id: "cloudkms.folders.updateAutokeyConfig",
4336            http_method: hyper::Method::PATCH,
4337        });
4338
4339        for &field in ["alt", "name", "updateMask"].iter() {
4340            if self._additional_params.contains_key(field) {
4341                dlg.finished(false);
4342                return Err(common::Error::FieldClash(field));
4343            }
4344        }
4345
4346        let mut params = Params::with_capacity(5 + self._additional_params.len());
4347        params.push("name", self._name);
4348        if let Some(value) = self._update_mask.as_ref() {
4349            params.push("updateMask", value.to_string());
4350        }
4351
4352        params.extend(self._additional_params.iter());
4353
4354        params.push("alt", "json");
4355        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4356        if self._scopes.is_empty() {
4357            self._scopes
4358                .insert(Scope::CloudPlatform.as_ref().to_string());
4359        }
4360
4361        #[allow(clippy::single_element_loop)]
4362        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4363            url = params.uri_replacement(url, param_name, find_this, true);
4364        }
4365        {
4366            let to_remove = ["name"];
4367            params.remove_params(&to_remove);
4368        }
4369
4370        let url = params.parse_with_url(&url);
4371
4372        let mut json_mime_type = mime::APPLICATION_JSON;
4373        let mut request_value_reader = {
4374            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4375            common::remove_json_null_values(&mut value);
4376            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4377            serde_json::to_writer(&mut dst, &value).unwrap();
4378            dst
4379        };
4380        let request_size = request_value_reader
4381            .seek(std::io::SeekFrom::End(0))
4382            .unwrap();
4383        request_value_reader
4384            .seek(std::io::SeekFrom::Start(0))
4385            .unwrap();
4386
4387        loop {
4388            let token = match self
4389                .hub
4390                .auth
4391                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4392                .await
4393            {
4394                Ok(token) => token,
4395                Err(e) => match dlg.token(e) {
4396                    Ok(token) => token,
4397                    Err(e) => {
4398                        dlg.finished(false);
4399                        return Err(common::Error::MissingToken(e));
4400                    }
4401                },
4402            };
4403            request_value_reader
4404                .seek(std::io::SeekFrom::Start(0))
4405                .unwrap();
4406            let mut req_result = {
4407                let client = &self.hub.client;
4408                dlg.pre_request();
4409                let mut req_builder = hyper::Request::builder()
4410                    .method(hyper::Method::PATCH)
4411                    .uri(url.as_str())
4412                    .header(USER_AGENT, self.hub._user_agent.clone());
4413
4414                if let Some(token) = token.as_ref() {
4415                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4416                }
4417
4418                let request = req_builder
4419                    .header(CONTENT_TYPE, json_mime_type.to_string())
4420                    .header(CONTENT_LENGTH, request_size as u64)
4421                    .body(common::to_body(
4422                        request_value_reader.get_ref().clone().into(),
4423                    ));
4424
4425                client.request(request.unwrap()).await
4426            };
4427
4428            match req_result {
4429                Err(err) => {
4430                    if let common::Retry::After(d) = dlg.http_error(&err) {
4431                        sleep(d).await;
4432                        continue;
4433                    }
4434                    dlg.finished(false);
4435                    return Err(common::Error::HttpError(err));
4436                }
4437                Ok(res) => {
4438                    let (mut parts, body) = res.into_parts();
4439                    let mut body = common::Body::new(body);
4440                    if !parts.status.is_success() {
4441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4442                        let error = serde_json::from_str(&common::to_string(&bytes));
4443                        let response = common::to_response(parts, bytes.into());
4444
4445                        if let common::Retry::After(d) =
4446                            dlg.http_failure(&response, error.as_ref().ok())
4447                        {
4448                            sleep(d).await;
4449                            continue;
4450                        }
4451
4452                        dlg.finished(false);
4453
4454                        return Err(match error {
4455                            Ok(value) => common::Error::BadRequest(value),
4456                            _ => common::Error::Failure(response),
4457                        });
4458                    }
4459                    let response = {
4460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4461                        let encoded = common::to_string(&bytes);
4462                        match serde_json::from_str(&encoded) {
4463                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4464                            Err(error) => {
4465                                dlg.response_json_decode_error(&encoded, &error);
4466                                return Err(common::Error::JsonDecodeError(
4467                                    encoded.to_string(),
4468                                    error,
4469                                ));
4470                            }
4471                        }
4472                    };
4473
4474                    dlg.finished(true);
4475                    return Ok(response);
4476                }
4477            }
4478        }
4479    }
4480
4481    ///
4482    /// Sets the *request* property to the given value.
4483    ///
4484    /// Even though the property as already been set when instantiating this call,
4485    /// we provide this method for API completeness.
4486    pub fn request(mut self, new_value: AutokeyConfig) -> FolderUpdateAutokeyConfigCall<'a, C> {
4487        self._request = new_value;
4488        self
4489    }
4490    /// Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`
4491    ///
4492    /// Sets the *name* path property to the given value.
4493    ///
4494    /// Even though the property as already been set when instantiating this call,
4495    /// we provide this method for API completeness.
4496    pub fn name(mut self, new_value: &str) -> FolderUpdateAutokeyConfigCall<'a, C> {
4497        self._name = new_value.to_string();
4498        self
4499    }
4500    /// Required. Masks which fields of the AutokeyConfig to update, e.g. `keyProject`.
4501    ///
4502    /// Sets the *update mask* query property to the given value.
4503    pub fn update_mask(
4504        mut self,
4505        new_value: common::FieldMask,
4506    ) -> FolderUpdateAutokeyConfigCall<'a, C> {
4507        self._update_mask = Some(new_value);
4508        self
4509    }
4510    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4511    /// while executing the actual API request.
4512    ///
4513    /// ````text
4514    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4515    /// ````
4516    ///
4517    /// Sets the *delegate* property to the given value.
4518    pub fn delegate(
4519        mut self,
4520        new_value: &'a mut dyn common::Delegate,
4521    ) -> FolderUpdateAutokeyConfigCall<'a, C> {
4522        self._delegate = Some(new_value);
4523        self
4524    }
4525
4526    /// Set any additional parameter of the query string used in the request.
4527    /// It should be used to set parameters which are not yet available through their own
4528    /// setters.
4529    ///
4530    /// Please note that this method must not be used to set any of the known parameters
4531    /// which have their own setter method. If done anyway, the request will fail.
4532    ///
4533    /// # Additional Parameters
4534    ///
4535    /// * *$.xgafv* (query-string) - V1 error format.
4536    /// * *access_token* (query-string) - OAuth access token.
4537    /// * *alt* (query-string) - Data format for response.
4538    /// * *callback* (query-string) - JSONP
4539    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4540    /// * *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.
4541    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4542    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4543    /// * *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.
4544    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4545    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4546    pub fn param<T>(mut self, name: T, value: T) -> FolderUpdateAutokeyConfigCall<'a, C>
4547    where
4548        T: AsRef<str>,
4549    {
4550        self._additional_params
4551            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4552        self
4553    }
4554
4555    /// Identifies the authorization scope for the method you are building.
4556    ///
4557    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4558    /// [`Scope::CloudPlatform`].
4559    ///
4560    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4561    /// tokens for more than one scope.
4562    ///
4563    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4564    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4565    /// sufficient, a read-write scope will do as well.
4566    pub fn add_scope<St>(mut self, scope: St) -> FolderUpdateAutokeyConfigCall<'a, C>
4567    where
4568        St: AsRef<str>,
4569    {
4570        self._scopes.insert(String::from(scope.as_ref()));
4571        self
4572    }
4573    /// Identifies the authorization scope(s) for the method you are building.
4574    ///
4575    /// See [`Self::add_scope()`] for details.
4576    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUpdateAutokeyConfigCall<'a, C>
4577    where
4578        I: IntoIterator<Item = St>,
4579        St: AsRef<str>,
4580    {
4581        self._scopes
4582            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4583        self
4584    }
4585
4586    /// Removes all scopes, and no default scope will be used either.
4587    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4588    /// for details).
4589    pub fn clear_scopes(mut self) -> FolderUpdateAutokeyConfigCall<'a, C> {
4590        self._scopes.clear();
4591        self
4592    }
4593}
4594
4595/// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
4596///
4597/// A builder for the *updateKajPolicyConfig* method supported by a *folder* resource.
4598/// It is not used directly, but through a [`FolderMethods`] instance.
4599///
4600/// # Example
4601///
4602/// Instantiate a resource method builder
4603///
4604/// ```test_harness,no_run
4605/// # extern crate hyper;
4606/// # extern crate hyper_rustls;
4607/// # extern crate google_cloudkms1 as cloudkms1;
4608/// use cloudkms1::api::KeyAccessJustificationsPolicyConfig;
4609/// # async fn dox() {
4610/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4611///
4612/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4613/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4614/// #     .with_native_roots()
4615/// #     .unwrap()
4616/// #     .https_only()
4617/// #     .enable_http2()
4618/// #     .build();
4619///
4620/// # let executor = hyper_util::rt::TokioExecutor::new();
4621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4622/// #     secret,
4623/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4624/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4625/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4626/// #     ),
4627/// # ).build().await.unwrap();
4628///
4629/// # let client = hyper_util::client::legacy::Client::builder(
4630/// #     hyper_util::rt::TokioExecutor::new()
4631/// # )
4632/// # .build(
4633/// #     hyper_rustls::HttpsConnectorBuilder::new()
4634/// #         .with_native_roots()
4635/// #         .unwrap()
4636/// #         .https_or_http()
4637/// #         .enable_http2()
4638/// #         .build()
4639/// # );
4640/// # let mut hub = CloudKMS::new(client, auth);
4641/// // As the method needs a request, you would usually fill it with the desired information
4642/// // into the respective structure. Some of the parts shown here might not be applicable !
4643/// // Values shown here are possibly random and not representative !
4644/// let mut req = KeyAccessJustificationsPolicyConfig::default();
4645///
4646/// // You can configure optional parameters by calling the respective setters at will, and
4647/// // execute the final call using `doit()`.
4648/// // Values shown here are possibly random and not representative !
4649/// let result = hub.folders().update_kaj_policy_config(req, "name")
4650///              .update_mask(FieldMask::new::<&str>(&[]))
4651///              .doit().await;
4652/// # }
4653/// ```
4654pub struct FolderUpdateKajPolicyConfigCall<'a, C>
4655where
4656    C: 'a,
4657{
4658    hub: &'a CloudKMS<C>,
4659    _request: KeyAccessJustificationsPolicyConfig,
4660    _name: String,
4661    _update_mask: Option<common::FieldMask>,
4662    _delegate: Option<&'a mut dyn common::Delegate>,
4663    _additional_params: HashMap<String, String>,
4664    _scopes: BTreeSet<String>,
4665}
4666
4667impl<'a, C> common::CallBuilder for FolderUpdateKajPolicyConfigCall<'a, C> {}
4668
4669impl<'a, C> FolderUpdateKajPolicyConfigCall<'a, C>
4670where
4671    C: common::Connector,
4672{
4673    /// Perform the operation you have build so far.
4674    pub async fn doit(
4675        mut self,
4676    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
4677        use std::borrow::Cow;
4678        use std::io::{Read, Seek};
4679
4680        use common::{url::Params, ToParts};
4681        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4682
4683        let mut dd = common::DefaultDelegate;
4684        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4685        dlg.begin(common::MethodInfo {
4686            id: "cloudkms.folders.updateKajPolicyConfig",
4687            http_method: hyper::Method::PATCH,
4688        });
4689
4690        for &field in ["alt", "name", "updateMask"].iter() {
4691            if self._additional_params.contains_key(field) {
4692                dlg.finished(false);
4693                return Err(common::Error::FieldClash(field));
4694            }
4695        }
4696
4697        let mut params = Params::with_capacity(5 + self._additional_params.len());
4698        params.push("name", self._name);
4699        if let Some(value) = self._update_mask.as_ref() {
4700            params.push("updateMask", value.to_string());
4701        }
4702
4703        params.extend(self._additional_params.iter());
4704
4705        params.push("alt", "json");
4706        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4707        if self._scopes.is_empty() {
4708            self._scopes
4709                .insert(Scope::CloudPlatform.as_ref().to_string());
4710        }
4711
4712        #[allow(clippy::single_element_loop)]
4713        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4714            url = params.uri_replacement(url, param_name, find_this, true);
4715        }
4716        {
4717            let to_remove = ["name"];
4718            params.remove_params(&to_remove);
4719        }
4720
4721        let url = params.parse_with_url(&url);
4722
4723        let mut json_mime_type = mime::APPLICATION_JSON;
4724        let mut request_value_reader = {
4725            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4726            common::remove_json_null_values(&mut value);
4727            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4728            serde_json::to_writer(&mut dst, &value).unwrap();
4729            dst
4730        };
4731        let request_size = request_value_reader
4732            .seek(std::io::SeekFrom::End(0))
4733            .unwrap();
4734        request_value_reader
4735            .seek(std::io::SeekFrom::Start(0))
4736            .unwrap();
4737
4738        loop {
4739            let token = match self
4740                .hub
4741                .auth
4742                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4743                .await
4744            {
4745                Ok(token) => token,
4746                Err(e) => match dlg.token(e) {
4747                    Ok(token) => token,
4748                    Err(e) => {
4749                        dlg.finished(false);
4750                        return Err(common::Error::MissingToken(e));
4751                    }
4752                },
4753            };
4754            request_value_reader
4755                .seek(std::io::SeekFrom::Start(0))
4756                .unwrap();
4757            let mut req_result = {
4758                let client = &self.hub.client;
4759                dlg.pre_request();
4760                let mut req_builder = hyper::Request::builder()
4761                    .method(hyper::Method::PATCH)
4762                    .uri(url.as_str())
4763                    .header(USER_AGENT, self.hub._user_agent.clone());
4764
4765                if let Some(token) = token.as_ref() {
4766                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4767                }
4768
4769                let request = req_builder
4770                    .header(CONTENT_TYPE, json_mime_type.to_string())
4771                    .header(CONTENT_LENGTH, request_size as u64)
4772                    .body(common::to_body(
4773                        request_value_reader.get_ref().clone().into(),
4774                    ));
4775
4776                client.request(request.unwrap()).await
4777            };
4778
4779            match req_result {
4780                Err(err) => {
4781                    if let common::Retry::After(d) = dlg.http_error(&err) {
4782                        sleep(d).await;
4783                        continue;
4784                    }
4785                    dlg.finished(false);
4786                    return Err(common::Error::HttpError(err));
4787                }
4788                Ok(res) => {
4789                    let (mut parts, body) = res.into_parts();
4790                    let mut body = common::Body::new(body);
4791                    if !parts.status.is_success() {
4792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4793                        let error = serde_json::from_str(&common::to_string(&bytes));
4794                        let response = common::to_response(parts, bytes.into());
4795
4796                        if let common::Retry::After(d) =
4797                            dlg.http_failure(&response, error.as_ref().ok())
4798                        {
4799                            sleep(d).await;
4800                            continue;
4801                        }
4802
4803                        dlg.finished(false);
4804
4805                        return Err(match error {
4806                            Ok(value) => common::Error::BadRequest(value),
4807                            _ => common::Error::Failure(response),
4808                        });
4809                    }
4810                    let response = {
4811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4812                        let encoded = common::to_string(&bytes);
4813                        match serde_json::from_str(&encoded) {
4814                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4815                            Err(error) => {
4816                                dlg.response_json_decode_error(&encoded, &error);
4817                                return Err(common::Error::JsonDecodeError(
4818                                    encoded.to_string(),
4819                                    error,
4820                                ));
4821                            }
4822                        }
4823                    };
4824
4825                    dlg.finished(true);
4826                    return Ok(response);
4827                }
4828            }
4829        }
4830    }
4831
4832    ///
4833    /// Sets the *request* property to the given value.
4834    ///
4835    /// Even though the property as already been set when instantiating this call,
4836    /// we provide this method for API completeness.
4837    pub fn request(
4838        mut self,
4839        new_value: KeyAccessJustificationsPolicyConfig,
4840    ) -> FolderUpdateKajPolicyConfigCall<'a, C> {
4841        self._request = new_value;
4842        self
4843    }
4844    /// Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
4845    ///
4846    /// Sets the *name* path property to the given value.
4847    ///
4848    /// Even though the property as already been set when instantiating this call,
4849    /// we provide this method for API completeness.
4850    pub fn name(mut self, new_value: &str) -> FolderUpdateKajPolicyConfigCall<'a, C> {
4851        self._name = new_value.to_string();
4852        self
4853    }
4854    /// Optional. The list of fields to update.
4855    ///
4856    /// Sets the *update mask* query property to the given value.
4857    pub fn update_mask(
4858        mut self,
4859        new_value: common::FieldMask,
4860    ) -> FolderUpdateKajPolicyConfigCall<'a, C> {
4861        self._update_mask = Some(new_value);
4862        self
4863    }
4864    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4865    /// while executing the actual API request.
4866    ///
4867    /// ````text
4868    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4869    /// ````
4870    ///
4871    /// Sets the *delegate* property to the given value.
4872    pub fn delegate(
4873        mut self,
4874        new_value: &'a mut dyn common::Delegate,
4875    ) -> FolderUpdateKajPolicyConfigCall<'a, C> {
4876        self._delegate = Some(new_value);
4877        self
4878    }
4879
4880    /// Set any additional parameter of the query string used in the request.
4881    /// It should be used to set parameters which are not yet available through their own
4882    /// setters.
4883    ///
4884    /// Please note that this method must not be used to set any of the known parameters
4885    /// which have their own setter method. If done anyway, the request will fail.
4886    ///
4887    /// # Additional Parameters
4888    ///
4889    /// * *$.xgafv* (query-string) - V1 error format.
4890    /// * *access_token* (query-string) - OAuth access token.
4891    /// * *alt* (query-string) - Data format for response.
4892    /// * *callback* (query-string) - JSONP
4893    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4894    /// * *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.
4895    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4896    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4897    /// * *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.
4898    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4899    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4900    pub fn param<T>(mut self, name: T, value: T) -> FolderUpdateKajPolicyConfigCall<'a, C>
4901    where
4902        T: AsRef<str>,
4903    {
4904        self._additional_params
4905            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4906        self
4907    }
4908
4909    /// Identifies the authorization scope for the method you are building.
4910    ///
4911    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4912    /// [`Scope::CloudPlatform`].
4913    ///
4914    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4915    /// tokens for more than one scope.
4916    ///
4917    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4918    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4919    /// sufficient, a read-write scope will do as well.
4920    pub fn add_scope<St>(mut self, scope: St) -> FolderUpdateKajPolicyConfigCall<'a, C>
4921    where
4922        St: AsRef<str>,
4923    {
4924        self._scopes.insert(String::from(scope.as_ref()));
4925        self
4926    }
4927    /// Identifies the authorization scope(s) for the method you are building.
4928    ///
4929    /// See [`Self::add_scope()`] for details.
4930    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUpdateKajPolicyConfigCall<'a, C>
4931    where
4932        I: IntoIterator<Item = St>,
4933        St: AsRef<str>,
4934    {
4935        self._scopes
4936            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4937        self
4938    }
4939
4940    /// Removes all scopes, and no default scope will be used either.
4941    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4942    /// for details).
4943    pub fn clear_scopes(mut self) -> FolderUpdateKajPolicyConfigCall<'a, C> {
4944        self._scopes.clear();
4945        self
4946    }
4947}
4948
4949/// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
4950///
4951/// A builder for the *getKajPolicyConfig* method supported by a *organization* resource.
4952/// It is not used directly, but through a [`OrganizationMethods`] instance.
4953///
4954/// # Example
4955///
4956/// Instantiate a resource method builder
4957///
4958/// ```test_harness,no_run
4959/// # extern crate hyper;
4960/// # extern crate hyper_rustls;
4961/// # extern crate google_cloudkms1 as cloudkms1;
4962/// # async fn dox() {
4963/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4964///
4965/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4966/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4967/// #     .with_native_roots()
4968/// #     .unwrap()
4969/// #     .https_only()
4970/// #     .enable_http2()
4971/// #     .build();
4972///
4973/// # let executor = hyper_util::rt::TokioExecutor::new();
4974/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4975/// #     secret,
4976/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4977/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4978/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4979/// #     ),
4980/// # ).build().await.unwrap();
4981///
4982/// # let client = hyper_util::client::legacy::Client::builder(
4983/// #     hyper_util::rt::TokioExecutor::new()
4984/// # )
4985/// # .build(
4986/// #     hyper_rustls::HttpsConnectorBuilder::new()
4987/// #         .with_native_roots()
4988/// #         .unwrap()
4989/// #         .https_or_http()
4990/// #         .enable_http2()
4991/// #         .build()
4992/// # );
4993/// # let mut hub = CloudKMS::new(client, auth);
4994/// // You can configure optional parameters by calling the respective setters at will, and
4995/// // execute the final call using `doit()`.
4996/// // Values shown here are possibly random and not representative !
4997/// let result = hub.organizations().get_kaj_policy_config("name")
4998///              .doit().await;
4999/// # }
5000/// ```
5001pub struct OrganizationGetKajPolicyConfigCall<'a, C>
5002where
5003    C: 'a,
5004{
5005    hub: &'a CloudKMS<C>,
5006    _name: String,
5007    _delegate: Option<&'a mut dyn common::Delegate>,
5008    _additional_params: HashMap<String, String>,
5009    _scopes: BTreeSet<String>,
5010}
5011
5012impl<'a, C> common::CallBuilder for OrganizationGetKajPolicyConfigCall<'a, C> {}
5013
5014impl<'a, C> OrganizationGetKajPolicyConfigCall<'a, C>
5015where
5016    C: common::Connector,
5017{
5018    /// Perform the operation you have build so far.
5019    pub async fn doit(
5020        mut self,
5021    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
5022        use std::borrow::Cow;
5023        use std::io::{Read, Seek};
5024
5025        use common::{url::Params, ToParts};
5026        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5027
5028        let mut dd = common::DefaultDelegate;
5029        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5030        dlg.begin(common::MethodInfo {
5031            id: "cloudkms.organizations.getKajPolicyConfig",
5032            http_method: hyper::Method::GET,
5033        });
5034
5035        for &field in ["alt", "name"].iter() {
5036            if self._additional_params.contains_key(field) {
5037                dlg.finished(false);
5038                return Err(common::Error::FieldClash(field));
5039            }
5040        }
5041
5042        let mut params = Params::with_capacity(3 + self._additional_params.len());
5043        params.push("name", self._name);
5044
5045        params.extend(self._additional_params.iter());
5046
5047        params.push("alt", "json");
5048        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5049        if self._scopes.is_empty() {
5050            self._scopes
5051                .insert(Scope::CloudPlatform.as_ref().to_string());
5052        }
5053
5054        #[allow(clippy::single_element_loop)]
5055        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5056            url = params.uri_replacement(url, param_name, find_this, true);
5057        }
5058        {
5059            let to_remove = ["name"];
5060            params.remove_params(&to_remove);
5061        }
5062
5063        let url = params.parse_with_url(&url);
5064
5065        loop {
5066            let token = match self
5067                .hub
5068                .auth
5069                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5070                .await
5071            {
5072                Ok(token) => token,
5073                Err(e) => match dlg.token(e) {
5074                    Ok(token) => token,
5075                    Err(e) => {
5076                        dlg.finished(false);
5077                        return Err(common::Error::MissingToken(e));
5078                    }
5079                },
5080            };
5081            let mut req_result = {
5082                let client = &self.hub.client;
5083                dlg.pre_request();
5084                let mut req_builder = hyper::Request::builder()
5085                    .method(hyper::Method::GET)
5086                    .uri(url.as_str())
5087                    .header(USER_AGENT, self.hub._user_agent.clone());
5088
5089                if let Some(token) = token.as_ref() {
5090                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5091                }
5092
5093                let request = req_builder
5094                    .header(CONTENT_LENGTH, 0_u64)
5095                    .body(common::to_body::<String>(None));
5096
5097                client.request(request.unwrap()).await
5098            };
5099
5100            match req_result {
5101                Err(err) => {
5102                    if let common::Retry::After(d) = dlg.http_error(&err) {
5103                        sleep(d).await;
5104                        continue;
5105                    }
5106                    dlg.finished(false);
5107                    return Err(common::Error::HttpError(err));
5108                }
5109                Ok(res) => {
5110                    let (mut parts, body) = res.into_parts();
5111                    let mut body = common::Body::new(body);
5112                    if !parts.status.is_success() {
5113                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5114                        let error = serde_json::from_str(&common::to_string(&bytes));
5115                        let response = common::to_response(parts, bytes.into());
5116
5117                        if let common::Retry::After(d) =
5118                            dlg.http_failure(&response, error.as_ref().ok())
5119                        {
5120                            sleep(d).await;
5121                            continue;
5122                        }
5123
5124                        dlg.finished(false);
5125
5126                        return Err(match error {
5127                            Ok(value) => common::Error::BadRequest(value),
5128                            _ => common::Error::Failure(response),
5129                        });
5130                    }
5131                    let response = {
5132                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5133                        let encoded = common::to_string(&bytes);
5134                        match serde_json::from_str(&encoded) {
5135                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5136                            Err(error) => {
5137                                dlg.response_json_decode_error(&encoded, &error);
5138                                return Err(common::Error::JsonDecodeError(
5139                                    encoded.to_string(),
5140                                    error,
5141                                ));
5142                            }
5143                        }
5144                    };
5145
5146                    dlg.finished(true);
5147                    return Ok(response);
5148                }
5149            }
5150        }
5151    }
5152
5153    /// Required. The name of the KeyAccessJustificationsPolicyConfig to get.
5154    ///
5155    /// Sets the *name* path property to the given value.
5156    ///
5157    /// Even though the property as already been set when instantiating this call,
5158    /// we provide this method for API completeness.
5159    pub fn name(mut self, new_value: &str) -> OrganizationGetKajPolicyConfigCall<'a, C> {
5160        self._name = new_value.to_string();
5161        self
5162    }
5163    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5164    /// while executing the actual API request.
5165    ///
5166    /// ````text
5167    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5168    /// ````
5169    ///
5170    /// Sets the *delegate* property to the given value.
5171    pub fn delegate(
5172        mut self,
5173        new_value: &'a mut dyn common::Delegate,
5174    ) -> OrganizationGetKajPolicyConfigCall<'a, C> {
5175        self._delegate = Some(new_value);
5176        self
5177    }
5178
5179    /// Set any additional parameter of the query string used in the request.
5180    /// It should be used to set parameters which are not yet available through their own
5181    /// setters.
5182    ///
5183    /// Please note that this method must not be used to set any of the known parameters
5184    /// which have their own setter method. If done anyway, the request will fail.
5185    ///
5186    /// # Additional Parameters
5187    ///
5188    /// * *$.xgafv* (query-string) - V1 error format.
5189    /// * *access_token* (query-string) - OAuth access token.
5190    /// * *alt* (query-string) - Data format for response.
5191    /// * *callback* (query-string) - JSONP
5192    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5193    /// * *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.
5194    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5195    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5196    /// * *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.
5197    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5198    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5199    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetKajPolicyConfigCall<'a, C>
5200    where
5201        T: AsRef<str>,
5202    {
5203        self._additional_params
5204            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5205        self
5206    }
5207
5208    /// Identifies the authorization scope for the method you are building.
5209    ///
5210    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5211    /// [`Scope::CloudPlatform`].
5212    ///
5213    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5214    /// tokens for more than one scope.
5215    ///
5216    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5217    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5218    /// sufficient, a read-write scope will do as well.
5219    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetKajPolicyConfigCall<'a, C>
5220    where
5221        St: AsRef<str>,
5222    {
5223        self._scopes.insert(String::from(scope.as_ref()));
5224        self
5225    }
5226    /// Identifies the authorization scope(s) for the method you are building.
5227    ///
5228    /// See [`Self::add_scope()`] for details.
5229    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetKajPolicyConfigCall<'a, C>
5230    where
5231        I: IntoIterator<Item = St>,
5232        St: AsRef<str>,
5233    {
5234        self._scopes
5235            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5236        self
5237    }
5238
5239    /// Removes all scopes, and no default scope will be used either.
5240    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5241    /// for details).
5242    pub fn clear_scopes(mut self) -> OrganizationGetKajPolicyConfigCall<'a, C> {
5243        self._scopes.clear();
5244        self
5245    }
5246}
5247
5248/// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
5249///
5250/// A builder for the *updateKajPolicyConfig* method supported by a *organization* resource.
5251/// It is not used directly, but through a [`OrganizationMethods`] instance.
5252///
5253/// # Example
5254///
5255/// Instantiate a resource method builder
5256///
5257/// ```test_harness,no_run
5258/// # extern crate hyper;
5259/// # extern crate hyper_rustls;
5260/// # extern crate google_cloudkms1 as cloudkms1;
5261/// use cloudkms1::api::KeyAccessJustificationsPolicyConfig;
5262/// # async fn dox() {
5263/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5264///
5265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5267/// #     .with_native_roots()
5268/// #     .unwrap()
5269/// #     .https_only()
5270/// #     .enable_http2()
5271/// #     .build();
5272///
5273/// # let executor = hyper_util::rt::TokioExecutor::new();
5274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5275/// #     secret,
5276/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5277/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5278/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5279/// #     ),
5280/// # ).build().await.unwrap();
5281///
5282/// # let client = hyper_util::client::legacy::Client::builder(
5283/// #     hyper_util::rt::TokioExecutor::new()
5284/// # )
5285/// # .build(
5286/// #     hyper_rustls::HttpsConnectorBuilder::new()
5287/// #         .with_native_roots()
5288/// #         .unwrap()
5289/// #         .https_or_http()
5290/// #         .enable_http2()
5291/// #         .build()
5292/// # );
5293/// # let mut hub = CloudKMS::new(client, auth);
5294/// // As the method needs a request, you would usually fill it with the desired information
5295/// // into the respective structure. Some of the parts shown here might not be applicable !
5296/// // Values shown here are possibly random and not representative !
5297/// let mut req = KeyAccessJustificationsPolicyConfig::default();
5298///
5299/// // You can configure optional parameters by calling the respective setters at will, and
5300/// // execute the final call using `doit()`.
5301/// // Values shown here are possibly random and not representative !
5302/// let result = hub.organizations().update_kaj_policy_config(req, "name")
5303///              .update_mask(FieldMask::new::<&str>(&[]))
5304///              .doit().await;
5305/// # }
5306/// ```
5307pub struct OrganizationUpdateKajPolicyConfigCall<'a, C>
5308where
5309    C: 'a,
5310{
5311    hub: &'a CloudKMS<C>,
5312    _request: KeyAccessJustificationsPolicyConfig,
5313    _name: String,
5314    _update_mask: Option<common::FieldMask>,
5315    _delegate: Option<&'a mut dyn common::Delegate>,
5316    _additional_params: HashMap<String, String>,
5317    _scopes: BTreeSet<String>,
5318}
5319
5320impl<'a, C> common::CallBuilder for OrganizationUpdateKajPolicyConfigCall<'a, C> {}
5321
5322impl<'a, C> OrganizationUpdateKajPolicyConfigCall<'a, C>
5323where
5324    C: common::Connector,
5325{
5326    /// Perform the operation you have build so far.
5327    pub async fn doit(
5328        mut self,
5329    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
5330        use std::borrow::Cow;
5331        use std::io::{Read, Seek};
5332
5333        use common::{url::Params, ToParts};
5334        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5335
5336        let mut dd = common::DefaultDelegate;
5337        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5338        dlg.begin(common::MethodInfo {
5339            id: "cloudkms.organizations.updateKajPolicyConfig",
5340            http_method: hyper::Method::PATCH,
5341        });
5342
5343        for &field in ["alt", "name", "updateMask"].iter() {
5344            if self._additional_params.contains_key(field) {
5345                dlg.finished(false);
5346                return Err(common::Error::FieldClash(field));
5347            }
5348        }
5349
5350        let mut params = Params::with_capacity(5 + self._additional_params.len());
5351        params.push("name", self._name);
5352        if let Some(value) = self._update_mask.as_ref() {
5353            params.push("updateMask", value.to_string());
5354        }
5355
5356        params.extend(self._additional_params.iter());
5357
5358        params.push("alt", "json");
5359        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5360        if self._scopes.is_empty() {
5361            self._scopes
5362                .insert(Scope::CloudPlatform.as_ref().to_string());
5363        }
5364
5365        #[allow(clippy::single_element_loop)]
5366        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5367            url = params.uri_replacement(url, param_name, find_this, true);
5368        }
5369        {
5370            let to_remove = ["name"];
5371            params.remove_params(&to_remove);
5372        }
5373
5374        let url = params.parse_with_url(&url);
5375
5376        let mut json_mime_type = mime::APPLICATION_JSON;
5377        let mut request_value_reader = {
5378            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5379            common::remove_json_null_values(&mut value);
5380            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5381            serde_json::to_writer(&mut dst, &value).unwrap();
5382            dst
5383        };
5384        let request_size = request_value_reader
5385            .seek(std::io::SeekFrom::End(0))
5386            .unwrap();
5387        request_value_reader
5388            .seek(std::io::SeekFrom::Start(0))
5389            .unwrap();
5390
5391        loop {
5392            let token = match self
5393                .hub
5394                .auth
5395                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5396                .await
5397            {
5398                Ok(token) => token,
5399                Err(e) => match dlg.token(e) {
5400                    Ok(token) => token,
5401                    Err(e) => {
5402                        dlg.finished(false);
5403                        return Err(common::Error::MissingToken(e));
5404                    }
5405                },
5406            };
5407            request_value_reader
5408                .seek(std::io::SeekFrom::Start(0))
5409                .unwrap();
5410            let mut req_result = {
5411                let client = &self.hub.client;
5412                dlg.pre_request();
5413                let mut req_builder = hyper::Request::builder()
5414                    .method(hyper::Method::PATCH)
5415                    .uri(url.as_str())
5416                    .header(USER_AGENT, self.hub._user_agent.clone());
5417
5418                if let Some(token) = token.as_ref() {
5419                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5420                }
5421
5422                let request = req_builder
5423                    .header(CONTENT_TYPE, json_mime_type.to_string())
5424                    .header(CONTENT_LENGTH, request_size as u64)
5425                    .body(common::to_body(
5426                        request_value_reader.get_ref().clone().into(),
5427                    ));
5428
5429                client.request(request.unwrap()).await
5430            };
5431
5432            match req_result {
5433                Err(err) => {
5434                    if let common::Retry::After(d) = dlg.http_error(&err) {
5435                        sleep(d).await;
5436                        continue;
5437                    }
5438                    dlg.finished(false);
5439                    return Err(common::Error::HttpError(err));
5440                }
5441                Ok(res) => {
5442                    let (mut parts, body) = res.into_parts();
5443                    let mut body = common::Body::new(body);
5444                    if !parts.status.is_success() {
5445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5446                        let error = serde_json::from_str(&common::to_string(&bytes));
5447                        let response = common::to_response(parts, bytes.into());
5448
5449                        if let common::Retry::After(d) =
5450                            dlg.http_failure(&response, error.as_ref().ok())
5451                        {
5452                            sleep(d).await;
5453                            continue;
5454                        }
5455
5456                        dlg.finished(false);
5457
5458                        return Err(match error {
5459                            Ok(value) => common::Error::BadRequest(value),
5460                            _ => common::Error::Failure(response),
5461                        });
5462                    }
5463                    let response = {
5464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5465                        let encoded = common::to_string(&bytes);
5466                        match serde_json::from_str(&encoded) {
5467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5468                            Err(error) => {
5469                                dlg.response_json_decode_error(&encoded, &error);
5470                                return Err(common::Error::JsonDecodeError(
5471                                    encoded.to_string(),
5472                                    error,
5473                                ));
5474                            }
5475                        }
5476                    };
5477
5478                    dlg.finished(true);
5479                    return Ok(response);
5480                }
5481            }
5482        }
5483    }
5484
5485    ///
5486    /// Sets the *request* property to the given value.
5487    ///
5488    /// Even though the property as already been set when instantiating this call,
5489    /// we provide this method for API completeness.
5490    pub fn request(
5491        mut self,
5492        new_value: KeyAccessJustificationsPolicyConfig,
5493    ) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
5494        self._request = new_value;
5495        self
5496    }
5497    /// Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
5498    ///
5499    /// Sets the *name* path property to the given value.
5500    ///
5501    /// Even though the property as already been set when instantiating this call,
5502    /// we provide this method for API completeness.
5503    pub fn name(mut self, new_value: &str) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
5504        self._name = new_value.to_string();
5505        self
5506    }
5507    /// Optional. The list of fields to update.
5508    ///
5509    /// Sets the *update mask* query property to the given value.
5510    pub fn update_mask(
5511        mut self,
5512        new_value: common::FieldMask,
5513    ) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
5514        self._update_mask = Some(new_value);
5515        self
5516    }
5517    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5518    /// while executing the actual API request.
5519    ///
5520    /// ````text
5521    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5522    /// ````
5523    ///
5524    /// Sets the *delegate* property to the given value.
5525    pub fn delegate(
5526        mut self,
5527        new_value: &'a mut dyn common::Delegate,
5528    ) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
5529        self._delegate = Some(new_value);
5530        self
5531    }
5532
5533    /// Set any additional parameter of the query string used in the request.
5534    /// It should be used to set parameters which are not yet available through their own
5535    /// setters.
5536    ///
5537    /// Please note that this method must not be used to set any of the known parameters
5538    /// which have their own setter method. If done anyway, the request will fail.
5539    ///
5540    /// # Additional Parameters
5541    ///
5542    /// * *$.xgafv* (query-string) - V1 error format.
5543    /// * *access_token* (query-string) - OAuth access token.
5544    /// * *alt* (query-string) - Data format for response.
5545    /// * *callback* (query-string) - JSONP
5546    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5547    /// * *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.
5548    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5549    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5550    /// * *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.
5551    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5552    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5553    pub fn param<T>(mut self, name: T, value: T) -> OrganizationUpdateKajPolicyConfigCall<'a, C>
5554    where
5555        T: AsRef<str>,
5556    {
5557        self._additional_params
5558            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5559        self
5560    }
5561
5562    /// Identifies the authorization scope for the method you are building.
5563    ///
5564    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5565    /// [`Scope::CloudPlatform`].
5566    ///
5567    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5568    /// tokens for more than one scope.
5569    ///
5570    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5571    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5572    /// sufficient, a read-write scope will do as well.
5573    pub fn add_scope<St>(mut self, scope: St) -> OrganizationUpdateKajPolicyConfigCall<'a, C>
5574    where
5575        St: AsRef<str>,
5576    {
5577        self._scopes.insert(String::from(scope.as_ref()));
5578        self
5579    }
5580    /// Identifies the authorization scope(s) for the method you are building.
5581    ///
5582    /// See [`Self::add_scope()`] for details.
5583    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationUpdateKajPolicyConfigCall<'a, C>
5584    where
5585        I: IntoIterator<Item = St>,
5586        St: AsRef<str>,
5587    {
5588        self._scopes
5589            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5590        self
5591    }
5592
5593    /// Removes all scopes, and no default scope will be used either.
5594    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5595    /// for details).
5596    pub fn clear_scopes(mut self) -> OrganizationUpdateKajPolicyConfigCall<'a, C> {
5597        self._scopes.clear();
5598        self
5599    }
5600}
5601
5602/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
5603///
5604/// A builder for the *locations.ekmConfig.getIamPolicy* method supported by a *project* resource.
5605/// It is not used directly, but through a [`ProjectMethods`] instance.
5606///
5607/// # Example
5608///
5609/// Instantiate a resource method builder
5610///
5611/// ```test_harness,no_run
5612/// # extern crate hyper;
5613/// # extern crate hyper_rustls;
5614/// # extern crate google_cloudkms1 as cloudkms1;
5615/// # async fn dox() {
5616/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5617///
5618/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5619/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5620/// #     .with_native_roots()
5621/// #     .unwrap()
5622/// #     .https_only()
5623/// #     .enable_http2()
5624/// #     .build();
5625///
5626/// # let executor = hyper_util::rt::TokioExecutor::new();
5627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5628/// #     secret,
5629/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5630/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5631/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5632/// #     ),
5633/// # ).build().await.unwrap();
5634///
5635/// # let client = hyper_util::client::legacy::Client::builder(
5636/// #     hyper_util::rt::TokioExecutor::new()
5637/// # )
5638/// # .build(
5639/// #     hyper_rustls::HttpsConnectorBuilder::new()
5640/// #         .with_native_roots()
5641/// #         .unwrap()
5642/// #         .https_or_http()
5643/// #         .enable_http2()
5644/// #         .build()
5645/// # );
5646/// # let mut hub = CloudKMS::new(client, auth);
5647/// // You can configure optional parameters by calling the respective setters at will, and
5648/// // execute the final call using `doit()`.
5649/// // Values shown here are possibly random and not representative !
5650/// let result = hub.projects().locations_ekm_config_get_iam_policy("resource")
5651///              .options_requested_policy_version(-62)
5652///              .doit().await;
5653/// # }
5654/// ```
5655pub struct ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
5656where
5657    C: 'a,
5658{
5659    hub: &'a CloudKMS<C>,
5660    _resource: String,
5661    _options_requested_policy_version: Option<i32>,
5662    _delegate: Option<&'a mut dyn common::Delegate>,
5663    _additional_params: HashMap<String, String>,
5664    _scopes: BTreeSet<String>,
5665}
5666
5667impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {}
5668
5669impl<'a, C> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
5670where
5671    C: common::Connector,
5672{
5673    /// Perform the operation you have build so far.
5674    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5675        use std::borrow::Cow;
5676        use std::io::{Read, Seek};
5677
5678        use common::{url::Params, ToParts};
5679        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5680
5681        let mut dd = common::DefaultDelegate;
5682        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5683        dlg.begin(common::MethodInfo {
5684            id: "cloudkms.projects.locations.ekmConfig.getIamPolicy",
5685            http_method: hyper::Method::GET,
5686        });
5687
5688        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
5689            if self._additional_params.contains_key(field) {
5690                dlg.finished(false);
5691                return Err(common::Error::FieldClash(field));
5692            }
5693        }
5694
5695        let mut params = Params::with_capacity(4 + self._additional_params.len());
5696        params.push("resource", self._resource);
5697        if let Some(value) = self._options_requested_policy_version.as_ref() {
5698            params.push("options.requestedPolicyVersion", value.to_string());
5699        }
5700
5701        params.extend(self._additional_params.iter());
5702
5703        params.push("alt", "json");
5704        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
5705        if self._scopes.is_empty() {
5706            self._scopes
5707                .insert(Scope::CloudPlatform.as_ref().to_string());
5708        }
5709
5710        #[allow(clippy::single_element_loop)]
5711        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5712            url = params.uri_replacement(url, param_name, find_this, true);
5713        }
5714        {
5715            let to_remove = ["resource"];
5716            params.remove_params(&to_remove);
5717        }
5718
5719        let url = params.parse_with_url(&url);
5720
5721        loop {
5722            let token = match self
5723                .hub
5724                .auth
5725                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5726                .await
5727            {
5728                Ok(token) => token,
5729                Err(e) => match dlg.token(e) {
5730                    Ok(token) => token,
5731                    Err(e) => {
5732                        dlg.finished(false);
5733                        return Err(common::Error::MissingToken(e));
5734                    }
5735                },
5736            };
5737            let mut req_result = {
5738                let client = &self.hub.client;
5739                dlg.pre_request();
5740                let mut req_builder = hyper::Request::builder()
5741                    .method(hyper::Method::GET)
5742                    .uri(url.as_str())
5743                    .header(USER_AGENT, self.hub._user_agent.clone());
5744
5745                if let Some(token) = token.as_ref() {
5746                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5747                }
5748
5749                let request = req_builder
5750                    .header(CONTENT_LENGTH, 0_u64)
5751                    .body(common::to_body::<String>(None));
5752
5753                client.request(request.unwrap()).await
5754            };
5755
5756            match req_result {
5757                Err(err) => {
5758                    if let common::Retry::After(d) = dlg.http_error(&err) {
5759                        sleep(d).await;
5760                        continue;
5761                    }
5762                    dlg.finished(false);
5763                    return Err(common::Error::HttpError(err));
5764                }
5765                Ok(res) => {
5766                    let (mut parts, body) = res.into_parts();
5767                    let mut body = common::Body::new(body);
5768                    if !parts.status.is_success() {
5769                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5770                        let error = serde_json::from_str(&common::to_string(&bytes));
5771                        let response = common::to_response(parts, bytes.into());
5772
5773                        if let common::Retry::After(d) =
5774                            dlg.http_failure(&response, error.as_ref().ok())
5775                        {
5776                            sleep(d).await;
5777                            continue;
5778                        }
5779
5780                        dlg.finished(false);
5781
5782                        return Err(match error {
5783                            Ok(value) => common::Error::BadRequest(value),
5784                            _ => common::Error::Failure(response),
5785                        });
5786                    }
5787                    let response = {
5788                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5789                        let encoded = common::to_string(&bytes);
5790                        match serde_json::from_str(&encoded) {
5791                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5792                            Err(error) => {
5793                                dlg.response_json_decode_error(&encoded, &error);
5794                                return Err(common::Error::JsonDecodeError(
5795                                    encoded.to_string(),
5796                                    error,
5797                                ));
5798                            }
5799                        }
5800                    };
5801
5802                    dlg.finished(true);
5803                    return Ok(response);
5804                }
5805            }
5806        }
5807    }
5808
5809    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5810    ///
5811    /// Sets the *resource* path property to the given value.
5812    ///
5813    /// Even though the property as already been set when instantiating this call,
5814    /// we provide this method for API completeness.
5815    pub fn resource(mut self, new_value: &str) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
5816        self._resource = new_value.to_string();
5817        self
5818    }
5819    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
5820    ///
5821    /// Sets the *options.requested policy version* query property to the given value.
5822    pub fn options_requested_policy_version(
5823        mut self,
5824        new_value: i32,
5825    ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
5826        self._options_requested_policy_version = Some(new_value);
5827        self
5828    }
5829    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5830    /// while executing the actual API request.
5831    ///
5832    /// ````text
5833    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5834    /// ````
5835    ///
5836    /// Sets the *delegate* property to the given value.
5837    pub fn delegate(
5838        mut self,
5839        new_value: &'a mut dyn common::Delegate,
5840    ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
5841        self._delegate = Some(new_value);
5842        self
5843    }
5844
5845    /// Set any additional parameter of the query string used in the request.
5846    /// It should be used to set parameters which are not yet available through their own
5847    /// setters.
5848    ///
5849    /// Please note that this method must not be used to set any of the known parameters
5850    /// which have their own setter method. If done anyway, the request will fail.
5851    ///
5852    /// # Additional Parameters
5853    ///
5854    /// * *$.xgafv* (query-string) - V1 error format.
5855    /// * *access_token* (query-string) - OAuth access token.
5856    /// * *alt* (query-string) - Data format for response.
5857    /// * *callback* (query-string) - JSONP
5858    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5859    /// * *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.
5860    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5861    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5862    /// * *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.
5863    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5864    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5865    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
5866    where
5867        T: AsRef<str>,
5868    {
5869        self._additional_params
5870            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5871        self
5872    }
5873
5874    /// Identifies the authorization scope for the method you are building.
5875    ///
5876    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5877    /// [`Scope::CloudPlatform`].
5878    ///
5879    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5880    /// tokens for more than one scope.
5881    ///
5882    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5883    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5884    /// sufficient, a read-write scope will do as well.
5885    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
5886    where
5887        St: AsRef<str>,
5888    {
5889        self._scopes.insert(String::from(scope.as_ref()));
5890        self
5891    }
5892    /// Identifies the authorization scope(s) for the method you are building.
5893    ///
5894    /// See [`Self::add_scope()`] for details.
5895    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
5896    where
5897        I: IntoIterator<Item = St>,
5898        St: AsRef<str>,
5899    {
5900        self._scopes
5901            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5902        self
5903    }
5904
5905    /// Removes all scopes, and no default scope will be used either.
5906    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5907    /// for details).
5908    pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
5909        self._scopes.clear();
5910        self
5911    }
5912}
5913
5914/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
5915///
5916/// A builder for the *locations.ekmConfig.setIamPolicy* method supported by a *project* resource.
5917/// It is not used directly, but through a [`ProjectMethods`] instance.
5918///
5919/// # Example
5920///
5921/// Instantiate a resource method builder
5922///
5923/// ```test_harness,no_run
5924/// # extern crate hyper;
5925/// # extern crate hyper_rustls;
5926/// # extern crate google_cloudkms1 as cloudkms1;
5927/// use cloudkms1::api::SetIamPolicyRequest;
5928/// # async fn dox() {
5929/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5930///
5931/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5932/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5933/// #     .with_native_roots()
5934/// #     .unwrap()
5935/// #     .https_only()
5936/// #     .enable_http2()
5937/// #     .build();
5938///
5939/// # let executor = hyper_util::rt::TokioExecutor::new();
5940/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5941/// #     secret,
5942/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5943/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5944/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5945/// #     ),
5946/// # ).build().await.unwrap();
5947///
5948/// # let client = hyper_util::client::legacy::Client::builder(
5949/// #     hyper_util::rt::TokioExecutor::new()
5950/// # )
5951/// # .build(
5952/// #     hyper_rustls::HttpsConnectorBuilder::new()
5953/// #         .with_native_roots()
5954/// #         .unwrap()
5955/// #         .https_or_http()
5956/// #         .enable_http2()
5957/// #         .build()
5958/// # );
5959/// # let mut hub = CloudKMS::new(client, auth);
5960/// // As the method needs a request, you would usually fill it with the desired information
5961/// // into the respective structure. Some of the parts shown here might not be applicable !
5962/// // Values shown here are possibly random and not representative !
5963/// let mut req = SetIamPolicyRequest::default();
5964///
5965/// // You can configure optional parameters by calling the respective setters at will, and
5966/// // execute the final call using `doit()`.
5967/// // Values shown here are possibly random and not representative !
5968/// let result = hub.projects().locations_ekm_config_set_iam_policy(req, "resource")
5969///              .doit().await;
5970/// # }
5971/// ```
5972pub struct ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
5973where
5974    C: 'a,
5975{
5976    hub: &'a CloudKMS<C>,
5977    _request: SetIamPolicyRequest,
5978    _resource: String,
5979    _delegate: Option<&'a mut dyn common::Delegate>,
5980    _additional_params: HashMap<String, String>,
5981    _scopes: BTreeSet<String>,
5982}
5983
5984impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {}
5985
5986impl<'a, C> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
5987where
5988    C: common::Connector,
5989{
5990    /// Perform the operation you have build so far.
5991    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5992        use std::borrow::Cow;
5993        use std::io::{Read, Seek};
5994
5995        use common::{url::Params, ToParts};
5996        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5997
5998        let mut dd = common::DefaultDelegate;
5999        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6000        dlg.begin(common::MethodInfo {
6001            id: "cloudkms.projects.locations.ekmConfig.setIamPolicy",
6002            http_method: hyper::Method::POST,
6003        });
6004
6005        for &field in ["alt", "resource"].iter() {
6006            if self._additional_params.contains_key(field) {
6007                dlg.finished(false);
6008                return Err(common::Error::FieldClash(field));
6009            }
6010        }
6011
6012        let mut params = Params::with_capacity(4 + self._additional_params.len());
6013        params.push("resource", self._resource);
6014
6015        params.extend(self._additional_params.iter());
6016
6017        params.push("alt", "json");
6018        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
6019        if self._scopes.is_empty() {
6020            self._scopes
6021                .insert(Scope::CloudPlatform.as_ref().to_string());
6022        }
6023
6024        #[allow(clippy::single_element_loop)]
6025        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6026            url = params.uri_replacement(url, param_name, find_this, true);
6027        }
6028        {
6029            let to_remove = ["resource"];
6030            params.remove_params(&to_remove);
6031        }
6032
6033        let url = params.parse_with_url(&url);
6034
6035        let mut json_mime_type = mime::APPLICATION_JSON;
6036        let mut request_value_reader = {
6037            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6038            common::remove_json_null_values(&mut value);
6039            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6040            serde_json::to_writer(&mut dst, &value).unwrap();
6041            dst
6042        };
6043        let request_size = request_value_reader
6044            .seek(std::io::SeekFrom::End(0))
6045            .unwrap();
6046        request_value_reader
6047            .seek(std::io::SeekFrom::Start(0))
6048            .unwrap();
6049
6050        loop {
6051            let token = match self
6052                .hub
6053                .auth
6054                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6055                .await
6056            {
6057                Ok(token) => token,
6058                Err(e) => match dlg.token(e) {
6059                    Ok(token) => token,
6060                    Err(e) => {
6061                        dlg.finished(false);
6062                        return Err(common::Error::MissingToken(e));
6063                    }
6064                },
6065            };
6066            request_value_reader
6067                .seek(std::io::SeekFrom::Start(0))
6068                .unwrap();
6069            let mut req_result = {
6070                let client = &self.hub.client;
6071                dlg.pre_request();
6072                let mut req_builder = hyper::Request::builder()
6073                    .method(hyper::Method::POST)
6074                    .uri(url.as_str())
6075                    .header(USER_AGENT, self.hub._user_agent.clone());
6076
6077                if let Some(token) = token.as_ref() {
6078                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6079                }
6080
6081                let request = req_builder
6082                    .header(CONTENT_TYPE, json_mime_type.to_string())
6083                    .header(CONTENT_LENGTH, request_size as u64)
6084                    .body(common::to_body(
6085                        request_value_reader.get_ref().clone().into(),
6086                    ));
6087
6088                client.request(request.unwrap()).await
6089            };
6090
6091            match req_result {
6092                Err(err) => {
6093                    if let common::Retry::After(d) = dlg.http_error(&err) {
6094                        sleep(d).await;
6095                        continue;
6096                    }
6097                    dlg.finished(false);
6098                    return Err(common::Error::HttpError(err));
6099                }
6100                Ok(res) => {
6101                    let (mut parts, body) = res.into_parts();
6102                    let mut body = common::Body::new(body);
6103                    if !parts.status.is_success() {
6104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6105                        let error = serde_json::from_str(&common::to_string(&bytes));
6106                        let response = common::to_response(parts, bytes.into());
6107
6108                        if let common::Retry::After(d) =
6109                            dlg.http_failure(&response, error.as_ref().ok())
6110                        {
6111                            sleep(d).await;
6112                            continue;
6113                        }
6114
6115                        dlg.finished(false);
6116
6117                        return Err(match error {
6118                            Ok(value) => common::Error::BadRequest(value),
6119                            _ => common::Error::Failure(response),
6120                        });
6121                    }
6122                    let response = {
6123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6124                        let encoded = common::to_string(&bytes);
6125                        match serde_json::from_str(&encoded) {
6126                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6127                            Err(error) => {
6128                                dlg.response_json_decode_error(&encoded, &error);
6129                                return Err(common::Error::JsonDecodeError(
6130                                    encoded.to_string(),
6131                                    error,
6132                                ));
6133                            }
6134                        }
6135                    };
6136
6137                    dlg.finished(true);
6138                    return Ok(response);
6139                }
6140            }
6141        }
6142    }
6143
6144    ///
6145    /// Sets the *request* property to the given value.
6146    ///
6147    /// Even though the property as already been set when instantiating this call,
6148    /// we provide this method for API completeness.
6149    pub fn request(
6150        mut self,
6151        new_value: SetIamPolicyRequest,
6152    ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
6153        self._request = new_value;
6154        self
6155    }
6156    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6157    ///
6158    /// Sets the *resource* path property to the given value.
6159    ///
6160    /// Even though the property as already been set when instantiating this call,
6161    /// we provide this method for API completeness.
6162    pub fn resource(mut self, new_value: &str) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
6163        self._resource = new_value.to_string();
6164        self
6165    }
6166    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6167    /// while executing the actual API request.
6168    ///
6169    /// ````text
6170    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6171    /// ````
6172    ///
6173    /// Sets the *delegate* property to the given value.
6174    pub fn delegate(
6175        mut self,
6176        new_value: &'a mut dyn common::Delegate,
6177    ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
6178        self._delegate = Some(new_value);
6179        self
6180    }
6181
6182    /// Set any additional parameter of the query string used in the request.
6183    /// It should be used to set parameters which are not yet available through their own
6184    /// setters.
6185    ///
6186    /// Please note that this method must not be used to set any of the known parameters
6187    /// which have their own setter method. If done anyway, the request will fail.
6188    ///
6189    /// # Additional Parameters
6190    ///
6191    /// * *$.xgafv* (query-string) - V1 error format.
6192    /// * *access_token* (query-string) - OAuth access token.
6193    /// * *alt* (query-string) - Data format for response.
6194    /// * *callback* (query-string) - JSONP
6195    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6196    /// * *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.
6197    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6198    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6199    /// * *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.
6200    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6201    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6202    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
6203    where
6204        T: AsRef<str>,
6205    {
6206        self._additional_params
6207            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6208        self
6209    }
6210
6211    /// Identifies the authorization scope for the method you are building.
6212    ///
6213    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6214    /// [`Scope::CloudPlatform`].
6215    ///
6216    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6217    /// tokens for more than one scope.
6218    ///
6219    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6220    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6221    /// sufficient, a read-write scope will do as well.
6222    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
6223    where
6224        St: AsRef<str>,
6225    {
6226        self._scopes.insert(String::from(scope.as_ref()));
6227        self
6228    }
6229    /// Identifies the authorization scope(s) for the method you are building.
6230    ///
6231    /// See [`Self::add_scope()`] for details.
6232    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
6233    where
6234        I: IntoIterator<Item = St>,
6235        St: AsRef<str>,
6236    {
6237        self._scopes
6238            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6239        self
6240    }
6241
6242    /// Removes all scopes, and no default scope will be used either.
6243    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6244    /// for details).
6245    pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
6246        self._scopes.clear();
6247        self
6248    }
6249}
6250
6251/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
6252///
6253/// A builder for the *locations.ekmConfig.testIamPermissions* method supported by a *project* resource.
6254/// It is not used directly, but through a [`ProjectMethods`] instance.
6255///
6256/// # Example
6257///
6258/// Instantiate a resource method builder
6259///
6260/// ```test_harness,no_run
6261/// # extern crate hyper;
6262/// # extern crate hyper_rustls;
6263/// # extern crate google_cloudkms1 as cloudkms1;
6264/// use cloudkms1::api::TestIamPermissionsRequest;
6265/// # async fn dox() {
6266/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6267///
6268/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6269/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6270/// #     .with_native_roots()
6271/// #     .unwrap()
6272/// #     .https_only()
6273/// #     .enable_http2()
6274/// #     .build();
6275///
6276/// # let executor = hyper_util::rt::TokioExecutor::new();
6277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6278/// #     secret,
6279/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6280/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6281/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6282/// #     ),
6283/// # ).build().await.unwrap();
6284///
6285/// # let client = hyper_util::client::legacy::Client::builder(
6286/// #     hyper_util::rt::TokioExecutor::new()
6287/// # )
6288/// # .build(
6289/// #     hyper_rustls::HttpsConnectorBuilder::new()
6290/// #         .with_native_roots()
6291/// #         .unwrap()
6292/// #         .https_or_http()
6293/// #         .enable_http2()
6294/// #         .build()
6295/// # );
6296/// # let mut hub = CloudKMS::new(client, auth);
6297/// // As the method needs a request, you would usually fill it with the desired information
6298/// // into the respective structure. Some of the parts shown here might not be applicable !
6299/// // Values shown here are possibly random and not representative !
6300/// let mut req = TestIamPermissionsRequest::default();
6301///
6302/// // You can configure optional parameters by calling the respective setters at will, and
6303/// // execute the final call using `doit()`.
6304/// // Values shown here are possibly random and not representative !
6305/// let result = hub.projects().locations_ekm_config_test_iam_permissions(req, "resource")
6306///              .doit().await;
6307/// # }
6308/// ```
6309pub struct ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
6310where
6311    C: 'a,
6312{
6313    hub: &'a CloudKMS<C>,
6314    _request: TestIamPermissionsRequest,
6315    _resource: String,
6316    _delegate: Option<&'a mut dyn common::Delegate>,
6317    _additional_params: HashMap<String, String>,
6318    _scopes: BTreeSet<String>,
6319}
6320
6321impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {}
6322
6323impl<'a, C> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
6324where
6325    C: common::Connector,
6326{
6327    /// Perform the operation you have build so far.
6328    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
6329        use std::borrow::Cow;
6330        use std::io::{Read, Seek};
6331
6332        use common::{url::Params, ToParts};
6333        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6334
6335        let mut dd = common::DefaultDelegate;
6336        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6337        dlg.begin(common::MethodInfo {
6338            id: "cloudkms.projects.locations.ekmConfig.testIamPermissions",
6339            http_method: hyper::Method::POST,
6340        });
6341
6342        for &field in ["alt", "resource"].iter() {
6343            if self._additional_params.contains_key(field) {
6344                dlg.finished(false);
6345                return Err(common::Error::FieldClash(field));
6346            }
6347        }
6348
6349        let mut params = Params::with_capacity(4 + self._additional_params.len());
6350        params.push("resource", self._resource);
6351
6352        params.extend(self._additional_params.iter());
6353
6354        params.push("alt", "json");
6355        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
6356        if self._scopes.is_empty() {
6357            self._scopes
6358                .insert(Scope::CloudPlatform.as_ref().to_string());
6359        }
6360
6361        #[allow(clippy::single_element_loop)]
6362        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6363            url = params.uri_replacement(url, param_name, find_this, true);
6364        }
6365        {
6366            let to_remove = ["resource"];
6367            params.remove_params(&to_remove);
6368        }
6369
6370        let url = params.parse_with_url(&url);
6371
6372        let mut json_mime_type = mime::APPLICATION_JSON;
6373        let mut request_value_reader = {
6374            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6375            common::remove_json_null_values(&mut value);
6376            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6377            serde_json::to_writer(&mut dst, &value).unwrap();
6378            dst
6379        };
6380        let request_size = request_value_reader
6381            .seek(std::io::SeekFrom::End(0))
6382            .unwrap();
6383        request_value_reader
6384            .seek(std::io::SeekFrom::Start(0))
6385            .unwrap();
6386
6387        loop {
6388            let token = match self
6389                .hub
6390                .auth
6391                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6392                .await
6393            {
6394                Ok(token) => token,
6395                Err(e) => match dlg.token(e) {
6396                    Ok(token) => token,
6397                    Err(e) => {
6398                        dlg.finished(false);
6399                        return Err(common::Error::MissingToken(e));
6400                    }
6401                },
6402            };
6403            request_value_reader
6404                .seek(std::io::SeekFrom::Start(0))
6405                .unwrap();
6406            let mut req_result = {
6407                let client = &self.hub.client;
6408                dlg.pre_request();
6409                let mut req_builder = hyper::Request::builder()
6410                    .method(hyper::Method::POST)
6411                    .uri(url.as_str())
6412                    .header(USER_AGENT, self.hub._user_agent.clone());
6413
6414                if let Some(token) = token.as_ref() {
6415                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6416                }
6417
6418                let request = req_builder
6419                    .header(CONTENT_TYPE, json_mime_type.to_string())
6420                    .header(CONTENT_LENGTH, request_size as u64)
6421                    .body(common::to_body(
6422                        request_value_reader.get_ref().clone().into(),
6423                    ));
6424
6425                client.request(request.unwrap()).await
6426            };
6427
6428            match req_result {
6429                Err(err) => {
6430                    if let common::Retry::After(d) = dlg.http_error(&err) {
6431                        sleep(d).await;
6432                        continue;
6433                    }
6434                    dlg.finished(false);
6435                    return Err(common::Error::HttpError(err));
6436                }
6437                Ok(res) => {
6438                    let (mut parts, body) = res.into_parts();
6439                    let mut body = common::Body::new(body);
6440                    if !parts.status.is_success() {
6441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6442                        let error = serde_json::from_str(&common::to_string(&bytes));
6443                        let response = common::to_response(parts, bytes.into());
6444
6445                        if let common::Retry::After(d) =
6446                            dlg.http_failure(&response, error.as_ref().ok())
6447                        {
6448                            sleep(d).await;
6449                            continue;
6450                        }
6451
6452                        dlg.finished(false);
6453
6454                        return Err(match error {
6455                            Ok(value) => common::Error::BadRequest(value),
6456                            _ => common::Error::Failure(response),
6457                        });
6458                    }
6459                    let response = {
6460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6461                        let encoded = common::to_string(&bytes);
6462                        match serde_json::from_str(&encoded) {
6463                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6464                            Err(error) => {
6465                                dlg.response_json_decode_error(&encoded, &error);
6466                                return Err(common::Error::JsonDecodeError(
6467                                    encoded.to_string(),
6468                                    error,
6469                                ));
6470                            }
6471                        }
6472                    };
6473
6474                    dlg.finished(true);
6475                    return Ok(response);
6476                }
6477            }
6478        }
6479    }
6480
6481    ///
6482    /// Sets the *request* property to the given value.
6483    ///
6484    /// Even though the property as already been set when instantiating this call,
6485    /// we provide this method for API completeness.
6486    pub fn request(
6487        mut self,
6488        new_value: TestIamPermissionsRequest,
6489    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
6490        self._request = new_value;
6491        self
6492    }
6493    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6494    ///
6495    /// Sets the *resource* path property to the given value.
6496    ///
6497    /// Even though the property as already been set when instantiating this call,
6498    /// we provide this method for API completeness.
6499    pub fn resource(
6500        mut self,
6501        new_value: &str,
6502    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
6503        self._resource = new_value.to_string();
6504        self
6505    }
6506    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6507    /// while executing the actual API request.
6508    ///
6509    /// ````text
6510    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6511    /// ````
6512    ///
6513    /// Sets the *delegate* property to the given value.
6514    pub fn delegate(
6515        mut self,
6516        new_value: &'a mut dyn common::Delegate,
6517    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
6518        self._delegate = Some(new_value);
6519        self
6520    }
6521
6522    /// Set any additional parameter of the query string used in the request.
6523    /// It should be used to set parameters which are not yet available through their own
6524    /// setters.
6525    ///
6526    /// Please note that this method must not be used to set any of the known parameters
6527    /// which have their own setter method. If done anyway, the request will fail.
6528    ///
6529    /// # Additional Parameters
6530    ///
6531    /// * *$.xgafv* (query-string) - V1 error format.
6532    /// * *access_token* (query-string) - OAuth access token.
6533    /// * *alt* (query-string) - Data format for response.
6534    /// * *callback* (query-string) - JSONP
6535    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6536    /// * *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.
6537    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6538    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6539    /// * *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.
6540    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6541    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6542    pub fn param<T>(
6543        mut self,
6544        name: T,
6545        value: T,
6546    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
6547    where
6548        T: AsRef<str>,
6549    {
6550        self._additional_params
6551            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6552        self
6553    }
6554
6555    /// Identifies the authorization scope for the method you are building.
6556    ///
6557    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6558    /// [`Scope::CloudPlatform`].
6559    ///
6560    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6561    /// tokens for more than one scope.
6562    ///
6563    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6564    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6565    /// sufficient, a read-write scope will do as well.
6566    pub fn add_scope<St>(
6567        mut self,
6568        scope: St,
6569    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
6570    where
6571        St: AsRef<str>,
6572    {
6573        self._scopes.insert(String::from(scope.as_ref()));
6574        self
6575    }
6576    /// Identifies the authorization scope(s) for the method you are building.
6577    ///
6578    /// See [`Self::add_scope()`] for details.
6579    pub fn add_scopes<I, St>(
6580        mut self,
6581        scopes: I,
6582    ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
6583    where
6584        I: IntoIterator<Item = St>,
6585        St: AsRef<str>,
6586    {
6587        self._scopes
6588            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6589        self
6590    }
6591
6592    /// Removes all scopes, and no default scope will be used either.
6593    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6594    /// for details).
6595    pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
6596        self._scopes.clear();
6597        self
6598    }
6599}
6600
6601/// Creates a new EkmConnection in a given Project and Location.
6602///
6603/// A builder for the *locations.ekmConnections.create* method supported by a *project* resource.
6604/// It is not used directly, but through a [`ProjectMethods`] instance.
6605///
6606/// # Example
6607///
6608/// Instantiate a resource method builder
6609///
6610/// ```test_harness,no_run
6611/// # extern crate hyper;
6612/// # extern crate hyper_rustls;
6613/// # extern crate google_cloudkms1 as cloudkms1;
6614/// use cloudkms1::api::EkmConnection;
6615/// # async fn dox() {
6616/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6617///
6618/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6619/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6620/// #     .with_native_roots()
6621/// #     .unwrap()
6622/// #     .https_only()
6623/// #     .enable_http2()
6624/// #     .build();
6625///
6626/// # let executor = hyper_util::rt::TokioExecutor::new();
6627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6628/// #     secret,
6629/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6630/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6631/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6632/// #     ),
6633/// # ).build().await.unwrap();
6634///
6635/// # let client = hyper_util::client::legacy::Client::builder(
6636/// #     hyper_util::rt::TokioExecutor::new()
6637/// # )
6638/// # .build(
6639/// #     hyper_rustls::HttpsConnectorBuilder::new()
6640/// #         .with_native_roots()
6641/// #         .unwrap()
6642/// #         .https_or_http()
6643/// #         .enable_http2()
6644/// #         .build()
6645/// # );
6646/// # let mut hub = CloudKMS::new(client, auth);
6647/// // As the method needs a request, you would usually fill it with the desired information
6648/// // into the respective structure. Some of the parts shown here might not be applicable !
6649/// // Values shown here are possibly random and not representative !
6650/// let mut req = EkmConnection::default();
6651///
6652/// // You can configure optional parameters by calling the respective setters at will, and
6653/// // execute the final call using `doit()`.
6654/// // Values shown here are possibly random and not representative !
6655/// let result = hub.projects().locations_ekm_connections_create(req, "parent")
6656///              .ekm_connection_id("dolor")
6657///              .doit().await;
6658/// # }
6659/// ```
6660pub struct ProjectLocationEkmConnectionCreateCall<'a, C>
6661where
6662    C: 'a,
6663{
6664    hub: &'a CloudKMS<C>,
6665    _request: EkmConnection,
6666    _parent: String,
6667    _ekm_connection_id: Option<String>,
6668    _delegate: Option<&'a mut dyn common::Delegate>,
6669    _additional_params: HashMap<String, String>,
6670    _scopes: BTreeSet<String>,
6671}
6672
6673impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionCreateCall<'a, C> {}
6674
6675impl<'a, C> ProjectLocationEkmConnectionCreateCall<'a, C>
6676where
6677    C: common::Connector,
6678{
6679    /// Perform the operation you have build so far.
6680    pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
6681        use std::borrow::Cow;
6682        use std::io::{Read, Seek};
6683
6684        use common::{url::Params, ToParts};
6685        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6686
6687        let mut dd = common::DefaultDelegate;
6688        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6689        dlg.begin(common::MethodInfo {
6690            id: "cloudkms.projects.locations.ekmConnections.create",
6691            http_method: hyper::Method::POST,
6692        });
6693
6694        for &field in ["alt", "parent", "ekmConnectionId"].iter() {
6695            if self._additional_params.contains_key(field) {
6696                dlg.finished(false);
6697                return Err(common::Error::FieldClash(field));
6698            }
6699        }
6700
6701        let mut params = Params::with_capacity(5 + self._additional_params.len());
6702        params.push("parent", self._parent);
6703        if let Some(value) = self._ekm_connection_id.as_ref() {
6704            params.push("ekmConnectionId", value);
6705        }
6706
6707        params.extend(self._additional_params.iter());
6708
6709        params.push("alt", "json");
6710        let mut url = self.hub._base_url.clone() + "v1/{+parent}/ekmConnections";
6711        if self._scopes.is_empty() {
6712            self._scopes
6713                .insert(Scope::CloudPlatform.as_ref().to_string());
6714        }
6715
6716        #[allow(clippy::single_element_loop)]
6717        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6718            url = params.uri_replacement(url, param_name, find_this, true);
6719        }
6720        {
6721            let to_remove = ["parent"];
6722            params.remove_params(&to_remove);
6723        }
6724
6725        let url = params.parse_with_url(&url);
6726
6727        let mut json_mime_type = mime::APPLICATION_JSON;
6728        let mut request_value_reader = {
6729            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6730            common::remove_json_null_values(&mut value);
6731            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6732            serde_json::to_writer(&mut dst, &value).unwrap();
6733            dst
6734        };
6735        let request_size = request_value_reader
6736            .seek(std::io::SeekFrom::End(0))
6737            .unwrap();
6738        request_value_reader
6739            .seek(std::io::SeekFrom::Start(0))
6740            .unwrap();
6741
6742        loop {
6743            let token = match self
6744                .hub
6745                .auth
6746                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6747                .await
6748            {
6749                Ok(token) => token,
6750                Err(e) => match dlg.token(e) {
6751                    Ok(token) => token,
6752                    Err(e) => {
6753                        dlg.finished(false);
6754                        return Err(common::Error::MissingToken(e));
6755                    }
6756                },
6757            };
6758            request_value_reader
6759                .seek(std::io::SeekFrom::Start(0))
6760                .unwrap();
6761            let mut req_result = {
6762                let client = &self.hub.client;
6763                dlg.pre_request();
6764                let mut req_builder = hyper::Request::builder()
6765                    .method(hyper::Method::POST)
6766                    .uri(url.as_str())
6767                    .header(USER_AGENT, self.hub._user_agent.clone());
6768
6769                if let Some(token) = token.as_ref() {
6770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6771                }
6772
6773                let request = req_builder
6774                    .header(CONTENT_TYPE, json_mime_type.to_string())
6775                    .header(CONTENT_LENGTH, request_size as u64)
6776                    .body(common::to_body(
6777                        request_value_reader.get_ref().clone().into(),
6778                    ));
6779
6780                client.request(request.unwrap()).await
6781            };
6782
6783            match req_result {
6784                Err(err) => {
6785                    if let common::Retry::After(d) = dlg.http_error(&err) {
6786                        sleep(d).await;
6787                        continue;
6788                    }
6789                    dlg.finished(false);
6790                    return Err(common::Error::HttpError(err));
6791                }
6792                Ok(res) => {
6793                    let (mut parts, body) = res.into_parts();
6794                    let mut body = common::Body::new(body);
6795                    if !parts.status.is_success() {
6796                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6797                        let error = serde_json::from_str(&common::to_string(&bytes));
6798                        let response = common::to_response(parts, bytes.into());
6799
6800                        if let common::Retry::After(d) =
6801                            dlg.http_failure(&response, error.as_ref().ok())
6802                        {
6803                            sleep(d).await;
6804                            continue;
6805                        }
6806
6807                        dlg.finished(false);
6808
6809                        return Err(match error {
6810                            Ok(value) => common::Error::BadRequest(value),
6811                            _ => common::Error::Failure(response),
6812                        });
6813                    }
6814                    let response = {
6815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6816                        let encoded = common::to_string(&bytes);
6817                        match serde_json::from_str(&encoded) {
6818                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6819                            Err(error) => {
6820                                dlg.response_json_decode_error(&encoded, &error);
6821                                return Err(common::Error::JsonDecodeError(
6822                                    encoded.to_string(),
6823                                    error,
6824                                ));
6825                            }
6826                        }
6827                    };
6828
6829                    dlg.finished(true);
6830                    return Ok(response);
6831                }
6832            }
6833        }
6834    }
6835
6836    ///
6837    /// Sets the *request* property to the given value.
6838    ///
6839    /// Even though the property as already been set when instantiating this call,
6840    /// we provide this method for API completeness.
6841    pub fn request(
6842        mut self,
6843        new_value: EkmConnection,
6844    ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
6845        self._request = new_value;
6846        self
6847    }
6848    /// Required. The resource name of the location associated with the EkmConnection, in the format `projects/*/locations/*`.
6849    ///
6850    /// Sets the *parent* path property to the given value.
6851    ///
6852    /// Even though the property as already been set when instantiating this call,
6853    /// we provide this method for API completeness.
6854    pub fn parent(mut self, new_value: &str) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
6855        self._parent = new_value.to_string();
6856        self
6857    }
6858    /// Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`.
6859    ///
6860    /// Sets the *ekm connection id* query property to the given value.
6861    pub fn ekm_connection_id(
6862        mut self,
6863        new_value: &str,
6864    ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
6865        self._ekm_connection_id = Some(new_value.to_string());
6866        self
6867    }
6868    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6869    /// while executing the actual API request.
6870    ///
6871    /// ````text
6872    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6873    /// ````
6874    ///
6875    /// Sets the *delegate* property to the given value.
6876    pub fn delegate(
6877        mut self,
6878        new_value: &'a mut dyn common::Delegate,
6879    ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
6880        self._delegate = Some(new_value);
6881        self
6882    }
6883
6884    /// Set any additional parameter of the query string used in the request.
6885    /// It should be used to set parameters which are not yet available through their own
6886    /// setters.
6887    ///
6888    /// Please note that this method must not be used to set any of the known parameters
6889    /// which have their own setter method. If done anyway, the request will fail.
6890    ///
6891    /// # Additional Parameters
6892    ///
6893    /// * *$.xgafv* (query-string) - V1 error format.
6894    /// * *access_token* (query-string) - OAuth access token.
6895    /// * *alt* (query-string) - Data format for response.
6896    /// * *callback* (query-string) - JSONP
6897    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6898    /// * *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.
6899    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6900    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6901    /// * *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.
6902    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6903    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6904    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionCreateCall<'a, C>
6905    where
6906        T: AsRef<str>,
6907    {
6908        self._additional_params
6909            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6910        self
6911    }
6912
6913    /// Identifies the authorization scope for the method you are building.
6914    ///
6915    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6916    /// [`Scope::CloudPlatform`].
6917    ///
6918    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6919    /// tokens for more than one scope.
6920    ///
6921    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6922    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6923    /// sufficient, a read-write scope will do as well.
6924    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionCreateCall<'a, C>
6925    where
6926        St: AsRef<str>,
6927    {
6928        self._scopes.insert(String::from(scope.as_ref()));
6929        self
6930    }
6931    /// Identifies the authorization scope(s) for the method you are building.
6932    ///
6933    /// See [`Self::add_scope()`] for details.
6934    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionCreateCall<'a, C>
6935    where
6936        I: IntoIterator<Item = St>,
6937        St: AsRef<str>,
6938    {
6939        self._scopes
6940            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6941        self
6942    }
6943
6944    /// Removes all scopes, and no default scope will be used either.
6945    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6946    /// for details).
6947    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
6948        self._scopes.clear();
6949        self
6950    }
6951}
6952
6953/// Returns metadata for a given EkmConnection.
6954///
6955/// A builder for the *locations.ekmConnections.get* method supported by a *project* resource.
6956/// It is not used directly, but through a [`ProjectMethods`] instance.
6957///
6958/// # Example
6959///
6960/// Instantiate a resource method builder
6961///
6962/// ```test_harness,no_run
6963/// # extern crate hyper;
6964/// # extern crate hyper_rustls;
6965/// # extern crate google_cloudkms1 as cloudkms1;
6966/// # async fn dox() {
6967/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6968///
6969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6970/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6971/// #     .with_native_roots()
6972/// #     .unwrap()
6973/// #     .https_only()
6974/// #     .enable_http2()
6975/// #     .build();
6976///
6977/// # let executor = hyper_util::rt::TokioExecutor::new();
6978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6979/// #     secret,
6980/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6981/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6982/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6983/// #     ),
6984/// # ).build().await.unwrap();
6985///
6986/// # let client = hyper_util::client::legacy::Client::builder(
6987/// #     hyper_util::rt::TokioExecutor::new()
6988/// # )
6989/// # .build(
6990/// #     hyper_rustls::HttpsConnectorBuilder::new()
6991/// #         .with_native_roots()
6992/// #         .unwrap()
6993/// #         .https_or_http()
6994/// #         .enable_http2()
6995/// #         .build()
6996/// # );
6997/// # let mut hub = CloudKMS::new(client, auth);
6998/// // You can configure optional parameters by calling the respective setters at will, and
6999/// // execute the final call using `doit()`.
7000/// // Values shown here are possibly random and not representative !
7001/// let result = hub.projects().locations_ekm_connections_get("name")
7002///              .doit().await;
7003/// # }
7004/// ```
7005pub struct ProjectLocationEkmConnectionGetCall<'a, C>
7006where
7007    C: 'a,
7008{
7009    hub: &'a CloudKMS<C>,
7010    _name: String,
7011    _delegate: Option<&'a mut dyn common::Delegate>,
7012    _additional_params: HashMap<String, String>,
7013    _scopes: BTreeSet<String>,
7014}
7015
7016impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionGetCall<'a, C> {}
7017
7018impl<'a, C> ProjectLocationEkmConnectionGetCall<'a, C>
7019where
7020    C: common::Connector,
7021{
7022    /// Perform the operation you have build so far.
7023    pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
7024        use std::borrow::Cow;
7025        use std::io::{Read, Seek};
7026
7027        use common::{url::Params, ToParts};
7028        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7029
7030        let mut dd = common::DefaultDelegate;
7031        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7032        dlg.begin(common::MethodInfo {
7033            id: "cloudkms.projects.locations.ekmConnections.get",
7034            http_method: hyper::Method::GET,
7035        });
7036
7037        for &field in ["alt", "name"].iter() {
7038            if self._additional_params.contains_key(field) {
7039                dlg.finished(false);
7040                return Err(common::Error::FieldClash(field));
7041            }
7042        }
7043
7044        let mut params = Params::with_capacity(3 + self._additional_params.len());
7045        params.push("name", self._name);
7046
7047        params.extend(self._additional_params.iter());
7048
7049        params.push("alt", "json");
7050        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7051        if self._scopes.is_empty() {
7052            self._scopes
7053                .insert(Scope::CloudPlatform.as_ref().to_string());
7054        }
7055
7056        #[allow(clippy::single_element_loop)]
7057        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7058            url = params.uri_replacement(url, param_name, find_this, true);
7059        }
7060        {
7061            let to_remove = ["name"];
7062            params.remove_params(&to_remove);
7063        }
7064
7065        let url = params.parse_with_url(&url);
7066
7067        loop {
7068            let token = match self
7069                .hub
7070                .auth
7071                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7072                .await
7073            {
7074                Ok(token) => token,
7075                Err(e) => match dlg.token(e) {
7076                    Ok(token) => token,
7077                    Err(e) => {
7078                        dlg.finished(false);
7079                        return Err(common::Error::MissingToken(e));
7080                    }
7081                },
7082            };
7083            let mut req_result = {
7084                let client = &self.hub.client;
7085                dlg.pre_request();
7086                let mut req_builder = hyper::Request::builder()
7087                    .method(hyper::Method::GET)
7088                    .uri(url.as_str())
7089                    .header(USER_AGENT, self.hub._user_agent.clone());
7090
7091                if let Some(token) = token.as_ref() {
7092                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7093                }
7094
7095                let request = req_builder
7096                    .header(CONTENT_LENGTH, 0_u64)
7097                    .body(common::to_body::<String>(None));
7098
7099                client.request(request.unwrap()).await
7100            };
7101
7102            match req_result {
7103                Err(err) => {
7104                    if let common::Retry::After(d) = dlg.http_error(&err) {
7105                        sleep(d).await;
7106                        continue;
7107                    }
7108                    dlg.finished(false);
7109                    return Err(common::Error::HttpError(err));
7110                }
7111                Ok(res) => {
7112                    let (mut parts, body) = res.into_parts();
7113                    let mut body = common::Body::new(body);
7114                    if !parts.status.is_success() {
7115                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7116                        let error = serde_json::from_str(&common::to_string(&bytes));
7117                        let response = common::to_response(parts, bytes.into());
7118
7119                        if let common::Retry::After(d) =
7120                            dlg.http_failure(&response, error.as_ref().ok())
7121                        {
7122                            sleep(d).await;
7123                            continue;
7124                        }
7125
7126                        dlg.finished(false);
7127
7128                        return Err(match error {
7129                            Ok(value) => common::Error::BadRequest(value),
7130                            _ => common::Error::Failure(response),
7131                        });
7132                    }
7133                    let response = {
7134                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7135                        let encoded = common::to_string(&bytes);
7136                        match serde_json::from_str(&encoded) {
7137                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7138                            Err(error) => {
7139                                dlg.response_json_decode_error(&encoded, &error);
7140                                return Err(common::Error::JsonDecodeError(
7141                                    encoded.to_string(),
7142                                    error,
7143                                ));
7144                            }
7145                        }
7146                    };
7147
7148                    dlg.finished(true);
7149                    return Ok(response);
7150                }
7151            }
7152        }
7153    }
7154
7155    /// Required. The name of the EkmConnection to get.
7156    ///
7157    /// Sets the *name* path property to the given value.
7158    ///
7159    /// Even though the property as already been set when instantiating this call,
7160    /// we provide this method for API completeness.
7161    pub fn name(mut self, new_value: &str) -> ProjectLocationEkmConnectionGetCall<'a, C> {
7162        self._name = new_value.to_string();
7163        self
7164    }
7165    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7166    /// while executing the actual API request.
7167    ///
7168    /// ````text
7169    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7170    /// ````
7171    ///
7172    /// Sets the *delegate* property to the given value.
7173    pub fn delegate(
7174        mut self,
7175        new_value: &'a mut dyn common::Delegate,
7176    ) -> ProjectLocationEkmConnectionGetCall<'a, C> {
7177        self._delegate = Some(new_value);
7178        self
7179    }
7180
7181    /// Set any additional parameter of the query string used in the request.
7182    /// It should be used to set parameters which are not yet available through their own
7183    /// setters.
7184    ///
7185    /// Please note that this method must not be used to set any of the known parameters
7186    /// which have their own setter method. If done anyway, the request will fail.
7187    ///
7188    /// # Additional Parameters
7189    ///
7190    /// * *$.xgafv* (query-string) - V1 error format.
7191    /// * *access_token* (query-string) - OAuth access token.
7192    /// * *alt* (query-string) - Data format for response.
7193    /// * *callback* (query-string) - JSONP
7194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7195    /// * *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.
7196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7198    /// * *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.
7199    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7200    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7201    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionGetCall<'a, C>
7202    where
7203        T: AsRef<str>,
7204    {
7205        self._additional_params
7206            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7207        self
7208    }
7209
7210    /// Identifies the authorization scope for the method you are building.
7211    ///
7212    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7213    /// [`Scope::CloudPlatform`].
7214    ///
7215    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7216    /// tokens for more than one scope.
7217    ///
7218    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7219    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7220    /// sufficient, a read-write scope will do as well.
7221    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionGetCall<'a, C>
7222    where
7223        St: AsRef<str>,
7224    {
7225        self._scopes.insert(String::from(scope.as_ref()));
7226        self
7227    }
7228    /// Identifies the authorization scope(s) for the method you are building.
7229    ///
7230    /// See [`Self::add_scope()`] for details.
7231    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionGetCall<'a, C>
7232    where
7233        I: IntoIterator<Item = St>,
7234        St: AsRef<str>,
7235    {
7236        self._scopes
7237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7238        self
7239    }
7240
7241    /// Removes all scopes, and no default scope will be used either.
7242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7243    /// for details).
7244    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionGetCall<'a, C> {
7245        self._scopes.clear();
7246        self
7247    }
7248}
7249
7250/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7251///
7252/// A builder for the *locations.ekmConnections.getIamPolicy* method supported by a *project* resource.
7253/// It is not used directly, but through a [`ProjectMethods`] instance.
7254///
7255/// # Example
7256///
7257/// Instantiate a resource method builder
7258///
7259/// ```test_harness,no_run
7260/// # extern crate hyper;
7261/// # extern crate hyper_rustls;
7262/// # extern crate google_cloudkms1 as cloudkms1;
7263/// # async fn dox() {
7264/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7265///
7266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7268/// #     .with_native_roots()
7269/// #     .unwrap()
7270/// #     .https_only()
7271/// #     .enable_http2()
7272/// #     .build();
7273///
7274/// # let executor = hyper_util::rt::TokioExecutor::new();
7275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7276/// #     secret,
7277/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7278/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7279/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7280/// #     ),
7281/// # ).build().await.unwrap();
7282///
7283/// # let client = hyper_util::client::legacy::Client::builder(
7284/// #     hyper_util::rt::TokioExecutor::new()
7285/// # )
7286/// # .build(
7287/// #     hyper_rustls::HttpsConnectorBuilder::new()
7288/// #         .with_native_roots()
7289/// #         .unwrap()
7290/// #         .https_or_http()
7291/// #         .enable_http2()
7292/// #         .build()
7293/// # );
7294/// # let mut hub = CloudKMS::new(client, auth);
7295/// // You can configure optional parameters by calling the respective setters at will, and
7296/// // execute the final call using `doit()`.
7297/// // Values shown here are possibly random and not representative !
7298/// let result = hub.projects().locations_ekm_connections_get_iam_policy("resource")
7299///              .options_requested_policy_version(-88)
7300///              .doit().await;
7301/// # }
7302/// ```
7303pub struct ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
7304where
7305    C: 'a,
7306{
7307    hub: &'a CloudKMS<C>,
7308    _resource: String,
7309    _options_requested_policy_version: Option<i32>,
7310    _delegate: Option<&'a mut dyn common::Delegate>,
7311    _additional_params: HashMap<String, String>,
7312    _scopes: BTreeSet<String>,
7313}
7314
7315impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {}
7316
7317impl<'a, C> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
7318where
7319    C: common::Connector,
7320{
7321    /// Perform the operation you have build so far.
7322    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7323        use std::borrow::Cow;
7324        use std::io::{Read, Seek};
7325
7326        use common::{url::Params, ToParts};
7327        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7328
7329        let mut dd = common::DefaultDelegate;
7330        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7331        dlg.begin(common::MethodInfo {
7332            id: "cloudkms.projects.locations.ekmConnections.getIamPolicy",
7333            http_method: hyper::Method::GET,
7334        });
7335
7336        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7337            if self._additional_params.contains_key(field) {
7338                dlg.finished(false);
7339                return Err(common::Error::FieldClash(field));
7340            }
7341        }
7342
7343        let mut params = Params::with_capacity(4 + self._additional_params.len());
7344        params.push("resource", self._resource);
7345        if let Some(value) = self._options_requested_policy_version.as_ref() {
7346            params.push("options.requestedPolicyVersion", value.to_string());
7347        }
7348
7349        params.extend(self._additional_params.iter());
7350
7351        params.push("alt", "json");
7352        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7353        if self._scopes.is_empty() {
7354            self._scopes
7355                .insert(Scope::CloudPlatform.as_ref().to_string());
7356        }
7357
7358        #[allow(clippy::single_element_loop)]
7359        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7360            url = params.uri_replacement(url, param_name, find_this, true);
7361        }
7362        {
7363            let to_remove = ["resource"];
7364            params.remove_params(&to_remove);
7365        }
7366
7367        let url = params.parse_with_url(&url);
7368
7369        loop {
7370            let token = match self
7371                .hub
7372                .auth
7373                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7374                .await
7375            {
7376                Ok(token) => token,
7377                Err(e) => match dlg.token(e) {
7378                    Ok(token) => token,
7379                    Err(e) => {
7380                        dlg.finished(false);
7381                        return Err(common::Error::MissingToken(e));
7382                    }
7383                },
7384            };
7385            let mut req_result = {
7386                let client = &self.hub.client;
7387                dlg.pre_request();
7388                let mut req_builder = hyper::Request::builder()
7389                    .method(hyper::Method::GET)
7390                    .uri(url.as_str())
7391                    .header(USER_AGENT, self.hub._user_agent.clone());
7392
7393                if let Some(token) = token.as_ref() {
7394                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7395                }
7396
7397                let request = req_builder
7398                    .header(CONTENT_LENGTH, 0_u64)
7399                    .body(common::to_body::<String>(None));
7400
7401                client.request(request.unwrap()).await
7402            };
7403
7404            match req_result {
7405                Err(err) => {
7406                    if let common::Retry::After(d) = dlg.http_error(&err) {
7407                        sleep(d).await;
7408                        continue;
7409                    }
7410                    dlg.finished(false);
7411                    return Err(common::Error::HttpError(err));
7412                }
7413                Ok(res) => {
7414                    let (mut parts, body) = res.into_parts();
7415                    let mut body = common::Body::new(body);
7416                    if !parts.status.is_success() {
7417                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7418                        let error = serde_json::from_str(&common::to_string(&bytes));
7419                        let response = common::to_response(parts, bytes.into());
7420
7421                        if let common::Retry::After(d) =
7422                            dlg.http_failure(&response, error.as_ref().ok())
7423                        {
7424                            sleep(d).await;
7425                            continue;
7426                        }
7427
7428                        dlg.finished(false);
7429
7430                        return Err(match error {
7431                            Ok(value) => common::Error::BadRequest(value),
7432                            _ => common::Error::Failure(response),
7433                        });
7434                    }
7435                    let response = {
7436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7437                        let encoded = common::to_string(&bytes);
7438                        match serde_json::from_str(&encoded) {
7439                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7440                            Err(error) => {
7441                                dlg.response_json_decode_error(&encoded, &error);
7442                                return Err(common::Error::JsonDecodeError(
7443                                    encoded.to_string(),
7444                                    error,
7445                                ));
7446                            }
7447                        }
7448                    };
7449
7450                    dlg.finished(true);
7451                    return Ok(response);
7452                }
7453            }
7454        }
7455    }
7456
7457    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
7458    ///
7459    /// Sets the *resource* path property to the given value.
7460    ///
7461    /// Even though the property as already been set when instantiating this call,
7462    /// we provide this method for API completeness.
7463    pub fn resource(
7464        mut self,
7465        new_value: &str,
7466    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
7467        self._resource = new_value.to_string();
7468        self
7469    }
7470    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
7471    ///
7472    /// Sets the *options.requested policy version* query property to the given value.
7473    pub fn options_requested_policy_version(
7474        mut self,
7475        new_value: i32,
7476    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
7477        self._options_requested_policy_version = Some(new_value);
7478        self
7479    }
7480    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7481    /// while executing the actual API request.
7482    ///
7483    /// ````text
7484    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7485    /// ````
7486    ///
7487    /// Sets the *delegate* property to the given value.
7488    pub fn delegate(
7489        mut self,
7490        new_value: &'a mut dyn common::Delegate,
7491    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
7492        self._delegate = Some(new_value);
7493        self
7494    }
7495
7496    /// Set any additional parameter of the query string used in the request.
7497    /// It should be used to set parameters which are not yet available through their own
7498    /// setters.
7499    ///
7500    /// Please note that this method must not be used to set any of the known parameters
7501    /// which have their own setter method. If done anyway, the request will fail.
7502    ///
7503    /// # Additional Parameters
7504    ///
7505    /// * *$.xgafv* (query-string) - V1 error format.
7506    /// * *access_token* (query-string) - OAuth access token.
7507    /// * *alt* (query-string) - Data format for response.
7508    /// * *callback* (query-string) - JSONP
7509    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7510    /// * *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.
7511    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7512    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7513    /// * *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.
7514    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7515    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7516    pub fn param<T>(
7517        mut self,
7518        name: T,
7519        value: T,
7520    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
7521    where
7522        T: AsRef<str>,
7523    {
7524        self._additional_params
7525            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7526        self
7527    }
7528
7529    /// Identifies the authorization scope for the method you are building.
7530    ///
7531    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7532    /// [`Scope::CloudPlatform`].
7533    ///
7534    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7535    /// tokens for more than one scope.
7536    ///
7537    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7538    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7539    /// sufficient, a read-write scope will do as well.
7540    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
7541    where
7542        St: AsRef<str>,
7543    {
7544        self._scopes.insert(String::from(scope.as_ref()));
7545        self
7546    }
7547    /// Identifies the authorization scope(s) for the method you are building.
7548    ///
7549    /// See [`Self::add_scope()`] for details.
7550    pub fn add_scopes<I, St>(
7551        mut self,
7552        scopes: I,
7553    ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
7554    where
7555        I: IntoIterator<Item = St>,
7556        St: AsRef<str>,
7557    {
7558        self._scopes
7559            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7560        self
7561    }
7562
7563    /// Removes all scopes, and no default scope will be used either.
7564    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7565    /// for details).
7566    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
7567        self._scopes.clear();
7568        self
7569    }
7570}
7571
7572/// Lists EkmConnections.
7573///
7574/// A builder for the *locations.ekmConnections.list* method supported by a *project* resource.
7575/// It is not used directly, but through a [`ProjectMethods`] instance.
7576///
7577/// # Example
7578///
7579/// Instantiate a resource method builder
7580///
7581/// ```test_harness,no_run
7582/// # extern crate hyper;
7583/// # extern crate hyper_rustls;
7584/// # extern crate google_cloudkms1 as cloudkms1;
7585/// # async fn dox() {
7586/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7587///
7588/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7589/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7590/// #     .with_native_roots()
7591/// #     .unwrap()
7592/// #     .https_only()
7593/// #     .enable_http2()
7594/// #     .build();
7595///
7596/// # let executor = hyper_util::rt::TokioExecutor::new();
7597/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7598/// #     secret,
7599/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7600/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7601/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7602/// #     ),
7603/// # ).build().await.unwrap();
7604///
7605/// # let client = hyper_util::client::legacy::Client::builder(
7606/// #     hyper_util::rt::TokioExecutor::new()
7607/// # )
7608/// # .build(
7609/// #     hyper_rustls::HttpsConnectorBuilder::new()
7610/// #         .with_native_roots()
7611/// #         .unwrap()
7612/// #         .https_or_http()
7613/// #         .enable_http2()
7614/// #         .build()
7615/// # );
7616/// # let mut hub = CloudKMS::new(client, auth);
7617/// // You can configure optional parameters by calling the respective setters at will, and
7618/// // execute the final call using `doit()`.
7619/// // Values shown here are possibly random and not representative !
7620/// let result = hub.projects().locations_ekm_connections_list("parent")
7621///              .page_token("duo")
7622///              .page_size(-50)
7623///              .order_by("sed")
7624///              .filter("ut")
7625///              .doit().await;
7626/// # }
7627/// ```
7628pub struct ProjectLocationEkmConnectionListCall<'a, C>
7629where
7630    C: 'a,
7631{
7632    hub: &'a CloudKMS<C>,
7633    _parent: String,
7634    _page_token: Option<String>,
7635    _page_size: Option<i32>,
7636    _order_by: Option<String>,
7637    _filter: Option<String>,
7638    _delegate: Option<&'a mut dyn common::Delegate>,
7639    _additional_params: HashMap<String, String>,
7640    _scopes: BTreeSet<String>,
7641}
7642
7643impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionListCall<'a, C> {}
7644
7645impl<'a, C> ProjectLocationEkmConnectionListCall<'a, C>
7646where
7647    C: common::Connector,
7648{
7649    /// Perform the operation you have build so far.
7650    pub async fn doit(mut self) -> common::Result<(common::Response, ListEkmConnectionsResponse)> {
7651        use std::borrow::Cow;
7652        use std::io::{Read, Seek};
7653
7654        use common::{url::Params, ToParts};
7655        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7656
7657        let mut dd = common::DefaultDelegate;
7658        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7659        dlg.begin(common::MethodInfo {
7660            id: "cloudkms.projects.locations.ekmConnections.list",
7661            http_method: hyper::Method::GET,
7662        });
7663
7664        for &field in [
7665            "alt",
7666            "parent",
7667            "pageToken",
7668            "pageSize",
7669            "orderBy",
7670            "filter",
7671        ]
7672        .iter()
7673        {
7674            if self._additional_params.contains_key(field) {
7675                dlg.finished(false);
7676                return Err(common::Error::FieldClash(field));
7677            }
7678        }
7679
7680        let mut params = Params::with_capacity(7 + self._additional_params.len());
7681        params.push("parent", self._parent);
7682        if let Some(value) = self._page_token.as_ref() {
7683            params.push("pageToken", value);
7684        }
7685        if let Some(value) = self._page_size.as_ref() {
7686            params.push("pageSize", value.to_string());
7687        }
7688        if let Some(value) = self._order_by.as_ref() {
7689            params.push("orderBy", value);
7690        }
7691        if let Some(value) = self._filter.as_ref() {
7692            params.push("filter", value);
7693        }
7694
7695        params.extend(self._additional_params.iter());
7696
7697        params.push("alt", "json");
7698        let mut url = self.hub._base_url.clone() + "v1/{+parent}/ekmConnections";
7699        if self._scopes.is_empty() {
7700            self._scopes
7701                .insert(Scope::CloudPlatform.as_ref().to_string());
7702        }
7703
7704        #[allow(clippy::single_element_loop)]
7705        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7706            url = params.uri_replacement(url, param_name, find_this, true);
7707        }
7708        {
7709            let to_remove = ["parent"];
7710            params.remove_params(&to_remove);
7711        }
7712
7713        let url = params.parse_with_url(&url);
7714
7715        loop {
7716            let token = match self
7717                .hub
7718                .auth
7719                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7720                .await
7721            {
7722                Ok(token) => token,
7723                Err(e) => match dlg.token(e) {
7724                    Ok(token) => token,
7725                    Err(e) => {
7726                        dlg.finished(false);
7727                        return Err(common::Error::MissingToken(e));
7728                    }
7729                },
7730            };
7731            let mut req_result = {
7732                let client = &self.hub.client;
7733                dlg.pre_request();
7734                let mut req_builder = hyper::Request::builder()
7735                    .method(hyper::Method::GET)
7736                    .uri(url.as_str())
7737                    .header(USER_AGENT, self.hub._user_agent.clone());
7738
7739                if let Some(token) = token.as_ref() {
7740                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7741                }
7742
7743                let request = req_builder
7744                    .header(CONTENT_LENGTH, 0_u64)
7745                    .body(common::to_body::<String>(None));
7746
7747                client.request(request.unwrap()).await
7748            };
7749
7750            match req_result {
7751                Err(err) => {
7752                    if let common::Retry::After(d) = dlg.http_error(&err) {
7753                        sleep(d).await;
7754                        continue;
7755                    }
7756                    dlg.finished(false);
7757                    return Err(common::Error::HttpError(err));
7758                }
7759                Ok(res) => {
7760                    let (mut parts, body) = res.into_parts();
7761                    let mut body = common::Body::new(body);
7762                    if !parts.status.is_success() {
7763                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7764                        let error = serde_json::from_str(&common::to_string(&bytes));
7765                        let response = common::to_response(parts, bytes.into());
7766
7767                        if let common::Retry::After(d) =
7768                            dlg.http_failure(&response, error.as_ref().ok())
7769                        {
7770                            sleep(d).await;
7771                            continue;
7772                        }
7773
7774                        dlg.finished(false);
7775
7776                        return Err(match error {
7777                            Ok(value) => common::Error::BadRequest(value),
7778                            _ => common::Error::Failure(response),
7779                        });
7780                    }
7781                    let response = {
7782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7783                        let encoded = common::to_string(&bytes);
7784                        match serde_json::from_str(&encoded) {
7785                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7786                            Err(error) => {
7787                                dlg.response_json_decode_error(&encoded, &error);
7788                                return Err(common::Error::JsonDecodeError(
7789                                    encoded.to_string(),
7790                                    error,
7791                                ));
7792                            }
7793                        }
7794                    };
7795
7796                    dlg.finished(true);
7797                    return Ok(response);
7798                }
7799            }
7800        }
7801    }
7802
7803    /// Required. The resource name of the location associated with the EkmConnections to list, in the format `projects/*/locations/*`.
7804    ///
7805    /// Sets the *parent* path property to the given value.
7806    ///
7807    /// Even though the property as already been set when instantiating this call,
7808    /// we provide this method for API completeness.
7809    pub fn parent(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
7810        self._parent = new_value.to_string();
7811        self
7812    }
7813    /// Optional. Optional pagination token, returned earlier via ListEkmConnectionsResponse.next_page_token.
7814    ///
7815    /// Sets the *page token* query property to the given value.
7816    pub fn page_token(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
7817        self._page_token = Some(new_value.to_string());
7818        self
7819    }
7820    /// Optional. Optional limit on the number of EkmConnections to include in the response. Further EkmConnections can subsequently be obtained by including the ListEkmConnectionsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.
7821    ///
7822    /// Sets the *page size* query property to the given value.
7823    pub fn page_size(mut self, new_value: i32) -> ProjectLocationEkmConnectionListCall<'a, C> {
7824        self._page_size = Some(new_value);
7825        self
7826    }
7827    /// Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
7828    ///
7829    /// Sets the *order by* query property to the given value.
7830    pub fn order_by(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
7831        self._order_by = Some(new_value.to_string());
7832        self
7833    }
7834    /// Optional. Only include resources that match the filter in the response. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
7835    ///
7836    /// Sets the *filter* query property to the given value.
7837    pub fn filter(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
7838        self._filter = Some(new_value.to_string());
7839        self
7840    }
7841    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7842    /// while executing the actual API request.
7843    ///
7844    /// ````text
7845    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7846    /// ````
7847    ///
7848    /// Sets the *delegate* property to the given value.
7849    pub fn delegate(
7850        mut self,
7851        new_value: &'a mut dyn common::Delegate,
7852    ) -> ProjectLocationEkmConnectionListCall<'a, C> {
7853        self._delegate = Some(new_value);
7854        self
7855    }
7856
7857    /// Set any additional parameter of the query string used in the request.
7858    /// It should be used to set parameters which are not yet available through their own
7859    /// setters.
7860    ///
7861    /// Please note that this method must not be used to set any of the known parameters
7862    /// which have their own setter method. If done anyway, the request will fail.
7863    ///
7864    /// # Additional Parameters
7865    ///
7866    /// * *$.xgafv* (query-string) - V1 error format.
7867    /// * *access_token* (query-string) - OAuth access token.
7868    /// * *alt* (query-string) - Data format for response.
7869    /// * *callback* (query-string) - JSONP
7870    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7871    /// * *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.
7872    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7873    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7874    /// * *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.
7875    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7876    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7877    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionListCall<'a, C>
7878    where
7879        T: AsRef<str>,
7880    {
7881        self._additional_params
7882            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7883        self
7884    }
7885
7886    /// Identifies the authorization scope for the method you are building.
7887    ///
7888    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7889    /// [`Scope::CloudPlatform`].
7890    ///
7891    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7892    /// tokens for more than one scope.
7893    ///
7894    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7895    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7896    /// sufficient, a read-write scope will do as well.
7897    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionListCall<'a, C>
7898    where
7899        St: AsRef<str>,
7900    {
7901        self._scopes.insert(String::from(scope.as_ref()));
7902        self
7903    }
7904    /// Identifies the authorization scope(s) for the method you are building.
7905    ///
7906    /// See [`Self::add_scope()`] for details.
7907    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionListCall<'a, C>
7908    where
7909        I: IntoIterator<Item = St>,
7910        St: AsRef<str>,
7911    {
7912        self._scopes
7913            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7914        self
7915    }
7916
7917    /// Removes all scopes, and no default scope will be used either.
7918    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7919    /// for details).
7920    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionListCall<'a, C> {
7921        self._scopes.clear();
7922        self
7923    }
7924}
7925
7926/// Updates an EkmConnection's metadata.
7927///
7928/// A builder for the *locations.ekmConnections.patch* method supported by a *project* resource.
7929/// It is not used directly, but through a [`ProjectMethods`] instance.
7930///
7931/// # Example
7932///
7933/// Instantiate a resource method builder
7934///
7935/// ```test_harness,no_run
7936/// # extern crate hyper;
7937/// # extern crate hyper_rustls;
7938/// # extern crate google_cloudkms1 as cloudkms1;
7939/// use cloudkms1::api::EkmConnection;
7940/// # async fn dox() {
7941/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7942///
7943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7944/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7945/// #     .with_native_roots()
7946/// #     .unwrap()
7947/// #     .https_only()
7948/// #     .enable_http2()
7949/// #     .build();
7950///
7951/// # let executor = hyper_util::rt::TokioExecutor::new();
7952/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7953/// #     secret,
7954/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7955/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7956/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7957/// #     ),
7958/// # ).build().await.unwrap();
7959///
7960/// # let client = hyper_util::client::legacy::Client::builder(
7961/// #     hyper_util::rt::TokioExecutor::new()
7962/// # )
7963/// # .build(
7964/// #     hyper_rustls::HttpsConnectorBuilder::new()
7965/// #         .with_native_roots()
7966/// #         .unwrap()
7967/// #         .https_or_http()
7968/// #         .enable_http2()
7969/// #         .build()
7970/// # );
7971/// # let mut hub = CloudKMS::new(client, auth);
7972/// // As the method needs a request, you would usually fill it with the desired information
7973/// // into the respective structure. Some of the parts shown here might not be applicable !
7974/// // Values shown here are possibly random and not representative !
7975/// let mut req = EkmConnection::default();
7976///
7977/// // You can configure optional parameters by calling the respective setters at will, and
7978/// // execute the final call using `doit()`.
7979/// // Values shown here are possibly random and not representative !
7980/// let result = hub.projects().locations_ekm_connections_patch(req, "name")
7981///              .update_mask(FieldMask::new::<&str>(&[]))
7982///              .doit().await;
7983/// # }
7984/// ```
7985pub struct ProjectLocationEkmConnectionPatchCall<'a, C>
7986where
7987    C: 'a,
7988{
7989    hub: &'a CloudKMS<C>,
7990    _request: EkmConnection,
7991    _name: String,
7992    _update_mask: Option<common::FieldMask>,
7993    _delegate: Option<&'a mut dyn common::Delegate>,
7994    _additional_params: HashMap<String, String>,
7995    _scopes: BTreeSet<String>,
7996}
7997
7998impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionPatchCall<'a, C> {}
7999
8000impl<'a, C> ProjectLocationEkmConnectionPatchCall<'a, C>
8001where
8002    C: common::Connector,
8003{
8004    /// Perform the operation you have build so far.
8005    pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
8006        use std::borrow::Cow;
8007        use std::io::{Read, Seek};
8008
8009        use common::{url::Params, ToParts};
8010        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8011
8012        let mut dd = common::DefaultDelegate;
8013        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8014        dlg.begin(common::MethodInfo {
8015            id: "cloudkms.projects.locations.ekmConnections.patch",
8016            http_method: hyper::Method::PATCH,
8017        });
8018
8019        for &field in ["alt", "name", "updateMask"].iter() {
8020            if self._additional_params.contains_key(field) {
8021                dlg.finished(false);
8022                return Err(common::Error::FieldClash(field));
8023            }
8024        }
8025
8026        let mut params = Params::with_capacity(5 + self._additional_params.len());
8027        params.push("name", self._name);
8028        if let Some(value) = self._update_mask.as_ref() {
8029            params.push("updateMask", value.to_string());
8030        }
8031
8032        params.extend(self._additional_params.iter());
8033
8034        params.push("alt", "json");
8035        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8036        if self._scopes.is_empty() {
8037            self._scopes
8038                .insert(Scope::CloudPlatform.as_ref().to_string());
8039        }
8040
8041        #[allow(clippy::single_element_loop)]
8042        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8043            url = params.uri_replacement(url, param_name, find_this, true);
8044        }
8045        {
8046            let to_remove = ["name"];
8047            params.remove_params(&to_remove);
8048        }
8049
8050        let url = params.parse_with_url(&url);
8051
8052        let mut json_mime_type = mime::APPLICATION_JSON;
8053        let mut request_value_reader = {
8054            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8055            common::remove_json_null_values(&mut value);
8056            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8057            serde_json::to_writer(&mut dst, &value).unwrap();
8058            dst
8059        };
8060        let request_size = request_value_reader
8061            .seek(std::io::SeekFrom::End(0))
8062            .unwrap();
8063        request_value_reader
8064            .seek(std::io::SeekFrom::Start(0))
8065            .unwrap();
8066
8067        loop {
8068            let token = match self
8069                .hub
8070                .auth
8071                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8072                .await
8073            {
8074                Ok(token) => token,
8075                Err(e) => match dlg.token(e) {
8076                    Ok(token) => token,
8077                    Err(e) => {
8078                        dlg.finished(false);
8079                        return Err(common::Error::MissingToken(e));
8080                    }
8081                },
8082            };
8083            request_value_reader
8084                .seek(std::io::SeekFrom::Start(0))
8085                .unwrap();
8086            let mut req_result = {
8087                let client = &self.hub.client;
8088                dlg.pre_request();
8089                let mut req_builder = hyper::Request::builder()
8090                    .method(hyper::Method::PATCH)
8091                    .uri(url.as_str())
8092                    .header(USER_AGENT, self.hub._user_agent.clone());
8093
8094                if let Some(token) = token.as_ref() {
8095                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8096                }
8097
8098                let request = req_builder
8099                    .header(CONTENT_TYPE, json_mime_type.to_string())
8100                    .header(CONTENT_LENGTH, request_size as u64)
8101                    .body(common::to_body(
8102                        request_value_reader.get_ref().clone().into(),
8103                    ));
8104
8105                client.request(request.unwrap()).await
8106            };
8107
8108            match req_result {
8109                Err(err) => {
8110                    if let common::Retry::After(d) = dlg.http_error(&err) {
8111                        sleep(d).await;
8112                        continue;
8113                    }
8114                    dlg.finished(false);
8115                    return Err(common::Error::HttpError(err));
8116                }
8117                Ok(res) => {
8118                    let (mut parts, body) = res.into_parts();
8119                    let mut body = common::Body::new(body);
8120                    if !parts.status.is_success() {
8121                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8122                        let error = serde_json::from_str(&common::to_string(&bytes));
8123                        let response = common::to_response(parts, bytes.into());
8124
8125                        if let common::Retry::After(d) =
8126                            dlg.http_failure(&response, error.as_ref().ok())
8127                        {
8128                            sleep(d).await;
8129                            continue;
8130                        }
8131
8132                        dlg.finished(false);
8133
8134                        return Err(match error {
8135                            Ok(value) => common::Error::BadRequest(value),
8136                            _ => common::Error::Failure(response),
8137                        });
8138                    }
8139                    let response = {
8140                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8141                        let encoded = common::to_string(&bytes);
8142                        match serde_json::from_str(&encoded) {
8143                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8144                            Err(error) => {
8145                                dlg.response_json_decode_error(&encoded, &error);
8146                                return Err(common::Error::JsonDecodeError(
8147                                    encoded.to_string(),
8148                                    error,
8149                                ));
8150                            }
8151                        }
8152                    };
8153
8154                    dlg.finished(true);
8155                    return Ok(response);
8156                }
8157            }
8158        }
8159    }
8160
8161    ///
8162    /// Sets the *request* property to the given value.
8163    ///
8164    /// Even though the property as already been set when instantiating this call,
8165    /// we provide this method for API completeness.
8166    pub fn request(
8167        mut self,
8168        new_value: EkmConnection,
8169    ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
8170        self._request = new_value;
8171        self
8172    }
8173    /// Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
8174    ///
8175    /// Sets the *name* path property to the given value.
8176    ///
8177    /// Even though the property as already been set when instantiating this call,
8178    /// we provide this method for API completeness.
8179    pub fn name(mut self, new_value: &str) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
8180        self._name = new_value.to_string();
8181        self
8182    }
8183    /// Required. List of fields to be updated in this request.
8184    ///
8185    /// Sets the *update mask* query property to the given value.
8186    pub fn update_mask(
8187        mut self,
8188        new_value: common::FieldMask,
8189    ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
8190        self._update_mask = Some(new_value);
8191        self
8192    }
8193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8194    /// while executing the actual API request.
8195    ///
8196    /// ````text
8197    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8198    /// ````
8199    ///
8200    /// Sets the *delegate* property to the given value.
8201    pub fn delegate(
8202        mut self,
8203        new_value: &'a mut dyn common::Delegate,
8204    ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
8205        self._delegate = Some(new_value);
8206        self
8207    }
8208
8209    /// Set any additional parameter of the query string used in the request.
8210    /// It should be used to set parameters which are not yet available through their own
8211    /// setters.
8212    ///
8213    /// Please note that this method must not be used to set any of the known parameters
8214    /// which have their own setter method. If done anyway, the request will fail.
8215    ///
8216    /// # Additional Parameters
8217    ///
8218    /// * *$.xgafv* (query-string) - V1 error format.
8219    /// * *access_token* (query-string) - OAuth access token.
8220    /// * *alt* (query-string) - Data format for response.
8221    /// * *callback* (query-string) - JSONP
8222    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8223    /// * *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.
8224    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8225    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8226    /// * *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.
8227    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8228    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8229    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionPatchCall<'a, C>
8230    where
8231        T: AsRef<str>,
8232    {
8233        self._additional_params
8234            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8235        self
8236    }
8237
8238    /// Identifies the authorization scope for the method you are building.
8239    ///
8240    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8241    /// [`Scope::CloudPlatform`].
8242    ///
8243    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8244    /// tokens for more than one scope.
8245    ///
8246    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8247    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8248    /// sufficient, a read-write scope will do as well.
8249    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionPatchCall<'a, C>
8250    where
8251        St: AsRef<str>,
8252    {
8253        self._scopes.insert(String::from(scope.as_ref()));
8254        self
8255    }
8256    /// Identifies the authorization scope(s) for the method you are building.
8257    ///
8258    /// See [`Self::add_scope()`] for details.
8259    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionPatchCall<'a, C>
8260    where
8261        I: IntoIterator<Item = St>,
8262        St: AsRef<str>,
8263    {
8264        self._scopes
8265            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8266        self
8267    }
8268
8269    /// Removes all scopes, and no default scope will be used either.
8270    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8271    /// for details).
8272    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
8273        self._scopes.clear();
8274        self
8275    }
8276}
8277
8278/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
8279///
8280/// A builder for the *locations.ekmConnections.setIamPolicy* method supported by a *project* resource.
8281/// It is not used directly, but through a [`ProjectMethods`] instance.
8282///
8283/// # Example
8284///
8285/// Instantiate a resource method builder
8286///
8287/// ```test_harness,no_run
8288/// # extern crate hyper;
8289/// # extern crate hyper_rustls;
8290/// # extern crate google_cloudkms1 as cloudkms1;
8291/// use cloudkms1::api::SetIamPolicyRequest;
8292/// # async fn dox() {
8293/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8294///
8295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8297/// #     .with_native_roots()
8298/// #     .unwrap()
8299/// #     .https_only()
8300/// #     .enable_http2()
8301/// #     .build();
8302///
8303/// # let executor = hyper_util::rt::TokioExecutor::new();
8304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8305/// #     secret,
8306/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8307/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8308/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8309/// #     ),
8310/// # ).build().await.unwrap();
8311///
8312/// # let client = hyper_util::client::legacy::Client::builder(
8313/// #     hyper_util::rt::TokioExecutor::new()
8314/// # )
8315/// # .build(
8316/// #     hyper_rustls::HttpsConnectorBuilder::new()
8317/// #         .with_native_roots()
8318/// #         .unwrap()
8319/// #         .https_or_http()
8320/// #         .enable_http2()
8321/// #         .build()
8322/// # );
8323/// # let mut hub = CloudKMS::new(client, auth);
8324/// // As the method needs a request, you would usually fill it with the desired information
8325/// // into the respective structure. Some of the parts shown here might not be applicable !
8326/// // Values shown here are possibly random and not representative !
8327/// let mut req = SetIamPolicyRequest::default();
8328///
8329/// // You can configure optional parameters by calling the respective setters at will, and
8330/// // execute the final call using `doit()`.
8331/// // Values shown here are possibly random and not representative !
8332/// let result = hub.projects().locations_ekm_connections_set_iam_policy(req, "resource")
8333///              .doit().await;
8334/// # }
8335/// ```
8336pub struct ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
8337where
8338    C: 'a,
8339{
8340    hub: &'a CloudKMS<C>,
8341    _request: SetIamPolicyRequest,
8342    _resource: String,
8343    _delegate: Option<&'a mut dyn common::Delegate>,
8344    _additional_params: HashMap<String, String>,
8345    _scopes: BTreeSet<String>,
8346}
8347
8348impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {}
8349
8350impl<'a, C> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
8351where
8352    C: common::Connector,
8353{
8354    /// Perform the operation you have build so far.
8355    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8356        use std::borrow::Cow;
8357        use std::io::{Read, Seek};
8358
8359        use common::{url::Params, ToParts};
8360        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8361
8362        let mut dd = common::DefaultDelegate;
8363        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8364        dlg.begin(common::MethodInfo {
8365            id: "cloudkms.projects.locations.ekmConnections.setIamPolicy",
8366            http_method: hyper::Method::POST,
8367        });
8368
8369        for &field in ["alt", "resource"].iter() {
8370            if self._additional_params.contains_key(field) {
8371                dlg.finished(false);
8372                return Err(common::Error::FieldClash(field));
8373            }
8374        }
8375
8376        let mut params = Params::with_capacity(4 + self._additional_params.len());
8377        params.push("resource", self._resource);
8378
8379        params.extend(self._additional_params.iter());
8380
8381        params.push("alt", "json");
8382        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8383        if self._scopes.is_empty() {
8384            self._scopes
8385                .insert(Scope::CloudPlatform.as_ref().to_string());
8386        }
8387
8388        #[allow(clippy::single_element_loop)]
8389        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8390            url = params.uri_replacement(url, param_name, find_this, true);
8391        }
8392        {
8393            let to_remove = ["resource"];
8394            params.remove_params(&to_remove);
8395        }
8396
8397        let url = params.parse_with_url(&url);
8398
8399        let mut json_mime_type = mime::APPLICATION_JSON;
8400        let mut request_value_reader = {
8401            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8402            common::remove_json_null_values(&mut value);
8403            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8404            serde_json::to_writer(&mut dst, &value).unwrap();
8405            dst
8406        };
8407        let request_size = request_value_reader
8408            .seek(std::io::SeekFrom::End(0))
8409            .unwrap();
8410        request_value_reader
8411            .seek(std::io::SeekFrom::Start(0))
8412            .unwrap();
8413
8414        loop {
8415            let token = match self
8416                .hub
8417                .auth
8418                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8419                .await
8420            {
8421                Ok(token) => token,
8422                Err(e) => match dlg.token(e) {
8423                    Ok(token) => token,
8424                    Err(e) => {
8425                        dlg.finished(false);
8426                        return Err(common::Error::MissingToken(e));
8427                    }
8428                },
8429            };
8430            request_value_reader
8431                .seek(std::io::SeekFrom::Start(0))
8432                .unwrap();
8433            let mut req_result = {
8434                let client = &self.hub.client;
8435                dlg.pre_request();
8436                let mut req_builder = hyper::Request::builder()
8437                    .method(hyper::Method::POST)
8438                    .uri(url.as_str())
8439                    .header(USER_AGENT, self.hub._user_agent.clone());
8440
8441                if let Some(token) = token.as_ref() {
8442                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8443                }
8444
8445                let request = req_builder
8446                    .header(CONTENT_TYPE, json_mime_type.to_string())
8447                    .header(CONTENT_LENGTH, request_size as u64)
8448                    .body(common::to_body(
8449                        request_value_reader.get_ref().clone().into(),
8450                    ));
8451
8452                client.request(request.unwrap()).await
8453            };
8454
8455            match req_result {
8456                Err(err) => {
8457                    if let common::Retry::After(d) = dlg.http_error(&err) {
8458                        sleep(d).await;
8459                        continue;
8460                    }
8461                    dlg.finished(false);
8462                    return Err(common::Error::HttpError(err));
8463                }
8464                Ok(res) => {
8465                    let (mut parts, body) = res.into_parts();
8466                    let mut body = common::Body::new(body);
8467                    if !parts.status.is_success() {
8468                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8469                        let error = serde_json::from_str(&common::to_string(&bytes));
8470                        let response = common::to_response(parts, bytes.into());
8471
8472                        if let common::Retry::After(d) =
8473                            dlg.http_failure(&response, error.as_ref().ok())
8474                        {
8475                            sleep(d).await;
8476                            continue;
8477                        }
8478
8479                        dlg.finished(false);
8480
8481                        return Err(match error {
8482                            Ok(value) => common::Error::BadRequest(value),
8483                            _ => common::Error::Failure(response),
8484                        });
8485                    }
8486                    let response = {
8487                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8488                        let encoded = common::to_string(&bytes);
8489                        match serde_json::from_str(&encoded) {
8490                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8491                            Err(error) => {
8492                                dlg.response_json_decode_error(&encoded, &error);
8493                                return Err(common::Error::JsonDecodeError(
8494                                    encoded.to_string(),
8495                                    error,
8496                                ));
8497                            }
8498                        }
8499                    };
8500
8501                    dlg.finished(true);
8502                    return Ok(response);
8503                }
8504            }
8505        }
8506    }
8507
8508    ///
8509    /// Sets the *request* property to the given value.
8510    ///
8511    /// Even though the property as already been set when instantiating this call,
8512    /// we provide this method for API completeness.
8513    pub fn request(
8514        mut self,
8515        new_value: SetIamPolicyRequest,
8516    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
8517        self._request = new_value;
8518        self
8519    }
8520    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8521    ///
8522    /// Sets the *resource* path property to the given value.
8523    ///
8524    /// Even though the property as already been set when instantiating this call,
8525    /// we provide this method for API completeness.
8526    pub fn resource(
8527        mut self,
8528        new_value: &str,
8529    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
8530        self._resource = new_value.to_string();
8531        self
8532    }
8533    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8534    /// while executing the actual API request.
8535    ///
8536    /// ````text
8537    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8538    /// ````
8539    ///
8540    /// Sets the *delegate* property to the given value.
8541    pub fn delegate(
8542        mut self,
8543        new_value: &'a mut dyn common::Delegate,
8544    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
8545        self._delegate = Some(new_value);
8546        self
8547    }
8548
8549    /// Set any additional parameter of the query string used in the request.
8550    /// It should be used to set parameters which are not yet available through their own
8551    /// setters.
8552    ///
8553    /// Please note that this method must not be used to set any of the known parameters
8554    /// which have their own setter method. If done anyway, the request will fail.
8555    ///
8556    /// # Additional Parameters
8557    ///
8558    /// * *$.xgafv* (query-string) - V1 error format.
8559    /// * *access_token* (query-string) - OAuth access token.
8560    /// * *alt* (query-string) - Data format for response.
8561    /// * *callback* (query-string) - JSONP
8562    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8563    /// * *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.
8564    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8565    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8566    /// * *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.
8567    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8568    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8569    pub fn param<T>(
8570        mut self,
8571        name: T,
8572        value: T,
8573    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
8574    where
8575        T: AsRef<str>,
8576    {
8577        self._additional_params
8578            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8579        self
8580    }
8581
8582    /// Identifies the authorization scope for the method you are building.
8583    ///
8584    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8585    /// [`Scope::CloudPlatform`].
8586    ///
8587    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8588    /// tokens for more than one scope.
8589    ///
8590    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8591    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8592    /// sufficient, a read-write scope will do as well.
8593    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
8594    where
8595        St: AsRef<str>,
8596    {
8597        self._scopes.insert(String::from(scope.as_ref()));
8598        self
8599    }
8600    /// Identifies the authorization scope(s) for the method you are building.
8601    ///
8602    /// See [`Self::add_scope()`] for details.
8603    pub fn add_scopes<I, St>(
8604        mut self,
8605        scopes: I,
8606    ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
8607    where
8608        I: IntoIterator<Item = St>,
8609        St: AsRef<str>,
8610    {
8611        self._scopes
8612            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8613        self
8614    }
8615
8616    /// Removes all scopes, and no default scope will be used either.
8617    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8618    /// for details).
8619    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
8620        self._scopes.clear();
8621        self
8622    }
8623}
8624
8625/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
8626///
8627/// A builder for the *locations.ekmConnections.testIamPermissions* method supported by a *project* resource.
8628/// It is not used directly, but through a [`ProjectMethods`] instance.
8629///
8630/// # Example
8631///
8632/// Instantiate a resource method builder
8633///
8634/// ```test_harness,no_run
8635/// # extern crate hyper;
8636/// # extern crate hyper_rustls;
8637/// # extern crate google_cloudkms1 as cloudkms1;
8638/// use cloudkms1::api::TestIamPermissionsRequest;
8639/// # async fn dox() {
8640/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8641///
8642/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8643/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8644/// #     .with_native_roots()
8645/// #     .unwrap()
8646/// #     .https_only()
8647/// #     .enable_http2()
8648/// #     .build();
8649///
8650/// # let executor = hyper_util::rt::TokioExecutor::new();
8651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8652/// #     secret,
8653/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8654/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8655/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8656/// #     ),
8657/// # ).build().await.unwrap();
8658///
8659/// # let client = hyper_util::client::legacy::Client::builder(
8660/// #     hyper_util::rt::TokioExecutor::new()
8661/// # )
8662/// # .build(
8663/// #     hyper_rustls::HttpsConnectorBuilder::new()
8664/// #         .with_native_roots()
8665/// #         .unwrap()
8666/// #         .https_or_http()
8667/// #         .enable_http2()
8668/// #         .build()
8669/// # );
8670/// # let mut hub = CloudKMS::new(client, auth);
8671/// // As the method needs a request, you would usually fill it with the desired information
8672/// // into the respective structure. Some of the parts shown here might not be applicable !
8673/// // Values shown here are possibly random and not representative !
8674/// let mut req = TestIamPermissionsRequest::default();
8675///
8676/// // You can configure optional parameters by calling the respective setters at will, and
8677/// // execute the final call using `doit()`.
8678/// // Values shown here are possibly random and not representative !
8679/// let result = hub.projects().locations_ekm_connections_test_iam_permissions(req, "resource")
8680///              .doit().await;
8681/// # }
8682/// ```
8683pub struct ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
8684where
8685    C: 'a,
8686{
8687    hub: &'a CloudKMS<C>,
8688    _request: TestIamPermissionsRequest,
8689    _resource: String,
8690    _delegate: Option<&'a mut dyn common::Delegate>,
8691    _additional_params: HashMap<String, String>,
8692    _scopes: BTreeSet<String>,
8693}
8694
8695impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {}
8696
8697impl<'a, C> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
8698where
8699    C: common::Connector,
8700{
8701    /// Perform the operation you have build so far.
8702    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8703        use std::borrow::Cow;
8704        use std::io::{Read, Seek};
8705
8706        use common::{url::Params, ToParts};
8707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8708
8709        let mut dd = common::DefaultDelegate;
8710        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8711        dlg.begin(common::MethodInfo {
8712            id: "cloudkms.projects.locations.ekmConnections.testIamPermissions",
8713            http_method: hyper::Method::POST,
8714        });
8715
8716        for &field in ["alt", "resource"].iter() {
8717            if self._additional_params.contains_key(field) {
8718                dlg.finished(false);
8719                return Err(common::Error::FieldClash(field));
8720            }
8721        }
8722
8723        let mut params = Params::with_capacity(4 + self._additional_params.len());
8724        params.push("resource", self._resource);
8725
8726        params.extend(self._additional_params.iter());
8727
8728        params.push("alt", "json");
8729        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8730        if self._scopes.is_empty() {
8731            self._scopes
8732                .insert(Scope::CloudPlatform.as_ref().to_string());
8733        }
8734
8735        #[allow(clippy::single_element_loop)]
8736        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8737            url = params.uri_replacement(url, param_name, find_this, true);
8738        }
8739        {
8740            let to_remove = ["resource"];
8741            params.remove_params(&to_remove);
8742        }
8743
8744        let url = params.parse_with_url(&url);
8745
8746        let mut json_mime_type = mime::APPLICATION_JSON;
8747        let mut request_value_reader = {
8748            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8749            common::remove_json_null_values(&mut value);
8750            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8751            serde_json::to_writer(&mut dst, &value).unwrap();
8752            dst
8753        };
8754        let request_size = request_value_reader
8755            .seek(std::io::SeekFrom::End(0))
8756            .unwrap();
8757        request_value_reader
8758            .seek(std::io::SeekFrom::Start(0))
8759            .unwrap();
8760
8761        loop {
8762            let token = match self
8763                .hub
8764                .auth
8765                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8766                .await
8767            {
8768                Ok(token) => token,
8769                Err(e) => match dlg.token(e) {
8770                    Ok(token) => token,
8771                    Err(e) => {
8772                        dlg.finished(false);
8773                        return Err(common::Error::MissingToken(e));
8774                    }
8775                },
8776            };
8777            request_value_reader
8778                .seek(std::io::SeekFrom::Start(0))
8779                .unwrap();
8780            let mut req_result = {
8781                let client = &self.hub.client;
8782                dlg.pre_request();
8783                let mut req_builder = hyper::Request::builder()
8784                    .method(hyper::Method::POST)
8785                    .uri(url.as_str())
8786                    .header(USER_AGENT, self.hub._user_agent.clone());
8787
8788                if let Some(token) = token.as_ref() {
8789                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8790                }
8791
8792                let request = req_builder
8793                    .header(CONTENT_TYPE, json_mime_type.to_string())
8794                    .header(CONTENT_LENGTH, request_size as u64)
8795                    .body(common::to_body(
8796                        request_value_reader.get_ref().clone().into(),
8797                    ));
8798
8799                client.request(request.unwrap()).await
8800            };
8801
8802            match req_result {
8803                Err(err) => {
8804                    if let common::Retry::After(d) = dlg.http_error(&err) {
8805                        sleep(d).await;
8806                        continue;
8807                    }
8808                    dlg.finished(false);
8809                    return Err(common::Error::HttpError(err));
8810                }
8811                Ok(res) => {
8812                    let (mut parts, body) = res.into_parts();
8813                    let mut body = common::Body::new(body);
8814                    if !parts.status.is_success() {
8815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8816                        let error = serde_json::from_str(&common::to_string(&bytes));
8817                        let response = common::to_response(parts, bytes.into());
8818
8819                        if let common::Retry::After(d) =
8820                            dlg.http_failure(&response, error.as_ref().ok())
8821                        {
8822                            sleep(d).await;
8823                            continue;
8824                        }
8825
8826                        dlg.finished(false);
8827
8828                        return Err(match error {
8829                            Ok(value) => common::Error::BadRequest(value),
8830                            _ => common::Error::Failure(response),
8831                        });
8832                    }
8833                    let response = {
8834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8835                        let encoded = common::to_string(&bytes);
8836                        match serde_json::from_str(&encoded) {
8837                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8838                            Err(error) => {
8839                                dlg.response_json_decode_error(&encoded, &error);
8840                                return Err(common::Error::JsonDecodeError(
8841                                    encoded.to_string(),
8842                                    error,
8843                                ));
8844                            }
8845                        }
8846                    };
8847
8848                    dlg.finished(true);
8849                    return Ok(response);
8850                }
8851            }
8852        }
8853    }
8854
8855    ///
8856    /// Sets the *request* property to the given value.
8857    ///
8858    /// Even though the property as already been set when instantiating this call,
8859    /// we provide this method for API completeness.
8860    pub fn request(
8861        mut self,
8862        new_value: TestIamPermissionsRequest,
8863    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
8864        self._request = new_value;
8865        self
8866    }
8867    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8868    ///
8869    /// Sets the *resource* path property to the given value.
8870    ///
8871    /// Even though the property as already been set when instantiating this call,
8872    /// we provide this method for API completeness.
8873    pub fn resource(
8874        mut self,
8875        new_value: &str,
8876    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
8877        self._resource = new_value.to_string();
8878        self
8879    }
8880    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8881    /// while executing the actual API request.
8882    ///
8883    /// ````text
8884    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8885    /// ````
8886    ///
8887    /// Sets the *delegate* property to the given value.
8888    pub fn delegate(
8889        mut self,
8890        new_value: &'a mut dyn common::Delegate,
8891    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
8892        self._delegate = Some(new_value);
8893        self
8894    }
8895
8896    /// Set any additional parameter of the query string used in the request.
8897    /// It should be used to set parameters which are not yet available through their own
8898    /// setters.
8899    ///
8900    /// Please note that this method must not be used to set any of the known parameters
8901    /// which have their own setter method. If done anyway, the request will fail.
8902    ///
8903    /// # Additional Parameters
8904    ///
8905    /// * *$.xgafv* (query-string) - V1 error format.
8906    /// * *access_token* (query-string) - OAuth access token.
8907    /// * *alt* (query-string) - Data format for response.
8908    /// * *callback* (query-string) - JSONP
8909    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8910    /// * *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.
8911    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8912    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8913    /// * *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.
8914    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8915    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8916    pub fn param<T>(
8917        mut self,
8918        name: T,
8919        value: T,
8920    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
8921    where
8922        T: AsRef<str>,
8923    {
8924        self._additional_params
8925            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8926        self
8927    }
8928
8929    /// Identifies the authorization scope for the method you are building.
8930    ///
8931    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8932    /// [`Scope::CloudPlatform`].
8933    ///
8934    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8935    /// tokens for more than one scope.
8936    ///
8937    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8938    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8939    /// sufficient, a read-write scope will do as well.
8940    pub fn add_scope<St>(
8941        mut self,
8942        scope: St,
8943    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
8944    where
8945        St: AsRef<str>,
8946    {
8947        self._scopes.insert(String::from(scope.as_ref()));
8948        self
8949    }
8950    /// Identifies the authorization scope(s) for the method you are building.
8951    ///
8952    /// See [`Self::add_scope()`] for details.
8953    pub fn add_scopes<I, St>(
8954        mut self,
8955        scopes: I,
8956    ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
8957    where
8958        I: IntoIterator<Item = St>,
8959        St: AsRef<str>,
8960    {
8961        self._scopes
8962            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8963        self
8964    }
8965
8966    /// Removes all scopes, and no default scope will be used either.
8967    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8968    /// for details).
8969    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
8970        self._scopes.clear();
8971        self
8972    }
8973}
8974
8975/// Verifies that Cloud KMS can successfully connect to the external key manager specified by an EkmConnection. If there is an error connecting to the EKM, this method returns a FAILED_PRECONDITION status containing structured information as described at https://cloud.google.com/kms/docs/reference/ekm_errors.
8976///
8977/// A builder for the *locations.ekmConnections.verifyConnectivity* method supported by a *project* resource.
8978/// It is not used directly, but through a [`ProjectMethods`] instance.
8979///
8980/// # Example
8981///
8982/// Instantiate a resource method builder
8983///
8984/// ```test_harness,no_run
8985/// # extern crate hyper;
8986/// # extern crate hyper_rustls;
8987/// # extern crate google_cloudkms1 as cloudkms1;
8988/// # async fn dox() {
8989/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8990///
8991/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8992/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8993/// #     .with_native_roots()
8994/// #     .unwrap()
8995/// #     .https_only()
8996/// #     .enable_http2()
8997/// #     .build();
8998///
8999/// # let executor = hyper_util::rt::TokioExecutor::new();
9000/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9001/// #     secret,
9002/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9003/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9004/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9005/// #     ),
9006/// # ).build().await.unwrap();
9007///
9008/// # let client = hyper_util::client::legacy::Client::builder(
9009/// #     hyper_util::rt::TokioExecutor::new()
9010/// # )
9011/// # .build(
9012/// #     hyper_rustls::HttpsConnectorBuilder::new()
9013/// #         .with_native_roots()
9014/// #         .unwrap()
9015/// #         .https_or_http()
9016/// #         .enable_http2()
9017/// #         .build()
9018/// # );
9019/// # let mut hub = CloudKMS::new(client, auth);
9020/// // You can configure optional parameters by calling the respective setters at will, and
9021/// // execute the final call using `doit()`.
9022/// // Values shown here are possibly random and not representative !
9023/// let result = hub.projects().locations_ekm_connections_verify_connectivity("name")
9024///              .doit().await;
9025/// # }
9026/// ```
9027pub struct ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
9028where
9029    C: 'a,
9030{
9031    hub: &'a CloudKMS<C>,
9032    _name: String,
9033    _delegate: Option<&'a mut dyn common::Delegate>,
9034    _additional_params: HashMap<String, String>,
9035    _scopes: BTreeSet<String>,
9036}
9037
9038impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {}
9039
9040impl<'a, C> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
9041where
9042    C: common::Connector,
9043{
9044    /// Perform the operation you have build so far.
9045    pub async fn doit(mut self) -> common::Result<(common::Response, VerifyConnectivityResponse)> {
9046        use std::borrow::Cow;
9047        use std::io::{Read, Seek};
9048
9049        use common::{url::Params, ToParts};
9050        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9051
9052        let mut dd = common::DefaultDelegate;
9053        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9054        dlg.begin(common::MethodInfo {
9055            id: "cloudkms.projects.locations.ekmConnections.verifyConnectivity",
9056            http_method: hyper::Method::GET,
9057        });
9058
9059        for &field in ["alt", "name"].iter() {
9060            if self._additional_params.contains_key(field) {
9061                dlg.finished(false);
9062                return Err(common::Error::FieldClash(field));
9063            }
9064        }
9065
9066        let mut params = Params::with_capacity(3 + self._additional_params.len());
9067        params.push("name", self._name);
9068
9069        params.extend(self._additional_params.iter());
9070
9071        params.push("alt", "json");
9072        let mut url = self.hub._base_url.clone() + "v1/{+name}:verifyConnectivity";
9073        if self._scopes.is_empty() {
9074            self._scopes
9075                .insert(Scope::CloudPlatform.as_ref().to_string());
9076        }
9077
9078        #[allow(clippy::single_element_loop)]
9079        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9080            url = params.uri_replacement(url, param_name, find_this, true);
9081        }
9082        {
9083            let to_remove = ["name"];
9084            params.remove_params(&to_remove);
9085        }
9086
9087        let url = params.parse_with_url(&url);
9088
9089        loop {
9090            let token = match self
9091                .hub
9092                .auth
9093                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9094                .await
9095            {
9096                Ok(token) => token,
9097                Err(e) => match dlg.token(e) {
9098                    Ok(token) => token,
9099                    Err(e) => {
9100                        dlg.finished(false);
9101                        return Err(common::Error::MissingToken(e));
9102                    }
9103                },
9104            };
9105            let mut req_result = {
9106                let client = &self.hub.client;
9107                dlg.pre_request();
9108                let mut req_builder = hyper::Request::builder()
9109                    .method(hyper::Method::GET)
9110                    .uri(url.as_str())
9111                    .header(USER_AGENT, self.hub._user_agent.clone());
9112
9113                if let Some(token) = token.as_ref() {
9114                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9115                }
9116
9117                let request = req_builder
9118                    .header(CONTENT_LENGTH, 0_u64)
9119                    .body(common::to_body::<String>(None));
9120
9121                client.request(request.unwrap()).await
9122            };
9123
9124            match req_result {
9125                Err(err) => {
9126                    if let common::Retry::After(d) = dlg.http_error(&err) {
9127                        sleep(d).await;
9128                        continue;
9129                    }
9130                    dlg.finished(false);
9131                    return Err(common::Error::HttpError(err));
9132                }
9133                Ok(res) => {
9134                    let (mut parts, body) = res.into_parts();
9135                    let mut body = common::Body::new(body);
9136                    if !parts.status.is_success() {
9137                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9138                        let error = serde_json::from_str(&common::to_string(&bytes));
9139                        let response = common::to_response(parts, bytes.into());
9140
9141                        if let common::Retry::After(d) =
9142                            dlg.http_failure(&response, error.as_ref().ok())
9143                        {
9144                            sleep(d).await;
9145                            continue;
9146                        }
9147
9148                        dlg.finished(false);
9149
9150                        return Err(match error {
9151                            Ok(value) => common::Error::BadRequest(value),
9152                            _ => common::Error::Failure(response),
9153                        });
9154                    }
9155                    let response = {
9156                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9157                        let encoded = common::to_string(&bytes);
9158                        match serde_json::from_str(&encoded) {
9159                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9160                            Err(error) => {
9161                                dlg.response_json_decode_error(&encoded, &error);
9162                                return Err(common::Error::JsonDecodeError(
9163                                    encoded.to_string(),
9164                                    error,
9165                                ));
9166                            }
9167                        }
9168                    };
9169
9170                    dlg.finished(true);
9171                    return Ok(response);
9172                }
9173            }
9174        }
9175    }
9176
9177    /// Required. The name of the EkmConnection to verify.
9178    ///
9179    /// Sets the *name* path property to the given value.
9180    ///
9181    /// Even though the property as already been set when instantiating this call,
9182    /// we provide this method for API completeness.
9183    pub fn name(
9184        mut self,
9185        new_value: &str,
9186    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
9187        self._name = new_value.to_string();
9188        self
9189    }
9190    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9191    /// while executing the actual API request.
9192    ///
9193    /// ````text
9194    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9195    /// ````
9196    ///
9197    /// Sets the *delegate* property to the given value.
9198    pub fn delegate(
9199        mut self,
9200        new_value: &'a mut dyn common::Delegate,
9201    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
9202        self._delegate = Some(new_value);
9203        self
9204    }
9205
9206    /// Set any additional parameter of the query string used in the request.
9207    /// It should be used to set parameters which are not yet available through their own
9208    /// setters.
9209    ///
9210    /// Please note that this method must not be used to set any of the known parameters
9211    /// which have their own setter method. If done anyway, the request will fail.
9212    ///
9213    /// # Additional Parameters
9214    ///
9215    /// * *$.xgafv* (query-string) - V1 error format.
9216    /// * *access_token* (query-string) - OAuth access token.
9217    /// * *alt* (query-string) - Data format for response.
9218    /// * *callback* (query-string) - JSONP
9219    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9220    /// * *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.
9221    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9222    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9223    /// * *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.
9224    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9225    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9226    pub fn param<T>(
9227        mut self,
9228        name: T,
9229        value: T,
9230    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
9231    where
9232        T: AsRef<str>,
9233    {
9234        self._additional_params
9235            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9236        self
9237    }
9238
9239    /// Identifies the authorization scope for the method you are building.
9240    ///
9241    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9242    /// [`Scope::CloudPlatform`].
9243    ///
9244    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9245    /// tokens for more than one scope.
9246    ///
9247    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9248    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9249    /// sufficient, a read-write scope will do as well.
9250    pub fn add_scope<St>(
9251        mut self,
9252        scope: St,
9253    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
9254    where
9255        St: AsRef<str>,
9256    {
9257        self._scopes.insert(String::from(scope.as_ref()));
9258        self
9259    }
9260    /// Identifies the authorization scope(s) for the method you are building.
9261    ///
9262    /// See [`Self::add_scope()`] for details.
9263    pub fn add_scopes<I, St>(
9264        mut self,
9265        scopes: I,
9266    ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
9267    where
9268        I: IntoIterator<Item = St>,
9269        St: AsRef<str>,
9270    {
9271        self._scopes
9272            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9273        self
9274    }
9275
9276    /// Removes all scopes, and no default scope will be used either.
9277    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9278    /// for details).
9279    pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
9280        self._scopes.clear();
9281        self
9282    }
9283}
9284
9285/// Creates a new KeyHandle, triggering the provisioning of a new CryptoKey for CMEK use with the given resource type in the configured key project and the same location. GetOperation should be used to resolve the resulting long-running operation and get the resulting KeyHandle and CryptoKey.
9286///
9287/// A builder for the *locations.keyHandles.create* method supported by a *project* resource.
9288/// It is not used directly, but through a [`ProjectMethods`] instance.
9289///
9290/// # Example
9291///
9292/// Instantiate a resource method builder
9293///
9294/// ```test_harness,no_run
9295/// # extern crate hyper;
9296/// # extern crate hyper_rustls;
9297/// # extern crate google_cloudkms1 as cloudkms1;
9298/// use cloudkms1::api::KeyHandle;
9299/// # async fn dox() {
9300/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9301///
9302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9303/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9304/// #     .with_native_roots()
9305/// #     .unwrap()
9306/// #     .https_only()
9307/// #     .enable_http2()
9308/// #     .build();
9309///
9310/// # let executor = hyper_util::rt::TokioExecutor::new();
9311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9312/// #     secret,
9313/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9314/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9315/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9316/// #     ),
9317/// # ).build().await.unwrap();
9318///
9319/// # let client = hyper_util::client::legacy::Client::builder(
9320/// #     hyper_util::rt::TokioExecutor::new()
9321/// # )
9322/// # .build(
9323/// #     hyper_rustls::HttpsConnectorBuilder::new()
9324/// #         .with_native_roots()
9325/// #         .unwrap()
9326/// #         .https_or_http()
9327/// #         .enable_http2()
9328/// #         .build()
9329/// # );
9330/// # let mut hub = CloudKMS::new(client, auth);
9331/// // As the method needs a request, you would usually fill it with the desired information
9332/// // into the respective structure. Some of the parts shown here might not be applicable !
9333/// // Values shown here are possibly random and not representative !
9334/// let mut req = KeyHandle::default();
9335///
9336/// // You can configure optional parameters by calling the respective setters at will, and
9337/// // execute the final call using `doit()`.
9338/// // Values shown here are possibly random and not representative !
9339/// let result = hub.projects().locations_key_handles_create(req, "parent")
9340///              .key_handle_id("est")
9341///              .doit().await;
9342/// # }
9343/// ```
9344pub struct ProjectLocationKeyHandleCreateCall<'a, C>
9345where
9346    C: 'a,
9347{
9348    hub: &'a CloudKMS<C>,
9349    _request: KeyHandle,
9350    _parent: String,
9351    _key_handle_id: Option<String>,
9352    _delegate: Option<&'a mut dyn common::Delegate>,
9353    _additional_params: HashMap<String, String>,
9354    _scopes: BTreeSet<String>,
9355}
9356
9357impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleCreateCall<'a, C> {}
9358
9359impl<'a, C> ProjectLocationKeyHandleCreateCall<'a, C>
9360where
9361    C: common::Connector,
9362{
9363    /// Perform the operation you have build so far.
9364    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9365        use std::borrow::Cow;
9366        use std::io::{Read, Seek};
9367
9368        use common::{url::Params, ToParts};
9369        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9370
9371        let mut dd = common::DefaultDelegate;
9372        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9373        dlg.begin(common::MethodInfo {
9374            id: "cloudkms.projects.locations.keyHandles.create",
9375            http_method: hyper::Method::POST,
9376        });
9377
9378        for &field in ["alt", "parent", "keyHandleId"].iter() {
9379            if self._additional_params.contains_key(field) {
9380                dlg.finished(false);
9381                return Err(common::Error::FieldClash(field));
9382            }
9383        }
9384
9385        let mut params = Params::with_capacity(5 + self._additional_params.len());
9386        params.push("parent", self._parent);
9387        if let Some(value) = self._key_handle_id.as_ref() {
9388            params.push("keyHandleId", value);
9389        }
9390
9391        params.extend(self._additional_params.iter());
9392
9393        params.push("alt", "json");
9394        let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyHandles";
9395        if self._scopes.is_empty() {
9396            self._scopes
9397                .insert(Scope::CloudPlatform.as_ref().to_string());
9398        }
9399
9400        #[allow(clippy::single_element_loop)]
9401        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9402            url = params.uri_replacement(url, param_name, find_this, true);
9403        }
9404        {
9405            let to_remove = ["parent"];
9406            params.remove_params(&to_remove);
9407        }
9408
9409        let url = params.parse_with_url(&url);
9410
9411        let mut json_mime_type = mime::APPLICATION_JSON;
9412        let mut request_value_reader = {
9413            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9414            common::remove_json_null_values(&mut value);
9415            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9416            serde_json::to_writer(&mut dst, &value).unwrap();
9417            dst
9418        };
9419        let request_size = request_value_reader
9420            .seek(std::io::SeekFrom::End(0))
9421            .unwrap();
9422        request_value_reader
9423            .seek(std::io::SeekFrom::Start(0))
9424            .unwrap();
9425
9426        loop {
9427            let token = match self
9428                .hub
9429                .auth
9430                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9431                .await
9432            {
9433                Ok(token) => token,
9434                Err(e) => match dlg.token(e) {
9435                    Ok(token) => token,
9436                    Err(e) => {
9437                        dlg.finished(false);
9438                        return Err(common::Error::MissingToken(e));
9439                    }
9440                },
9441            };
9442            request_value_reader
9443                .seek(std::io::SeekFrom::Start(0))
9444                .unwrap();
9445            let mut req_result = {
9446                let client = &self.hub.client;
9447                dlg.pre_request();
9448                let mut req_builder = hyper::Request::builder()
9449                    .method(hyper::Method::POST)
9450                    .uri(url.as_str())
9451                    .header(USER_AGENT, self.hub._user_agent.clone());
9452
9453                if let Some(token) = token.as_ref() {
9454                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9455                }
9456
9457                let request = req_builder
9458                    .header(CONTENT_TYPE, json_mime_type.to_string())
9459                    .header(CONTENT_LENGTH, request_size as u64)
9460                    .body(common::to_body(
9461                        request_value_reader.get_ref().clone().into(),
9462                    ));
9463
9464                client.request(request.unwrap()).await
9465            };
9466
9467            match req_result {
9468                Err(err) => {
9469                    if let common::Retry::After(d) = dlg.http_error(&err) {
9470                        sleep(d).await;
9471                        continue;
9472                    }
9473                    dlg.finished(false);
9474                    return Err(common::Error::HttpError(err));
9475                }
9476                Ok(res) => {
9477                    let (mut parts, body) = res.into_parts();
9478                    let mut body = common::Body::new(body);
9479                    if !parts.status.is_success() {
9480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9481                        let error = serde_json::from_str(&common::to_string(&bytes));
9482                        let response = common::to_response(parts, bytes.into());
9483
9484                        if let common::Retry::After(d) =
9485                            dlg.http_failure(&response, error.as_ref().ok())
9486                        {
9487                            sleep(d).await;
9488                            continue;
9489                        }
9490
9491                        dlg.finished(false);
9492
9493                        return Err(match error {
9494                            Ok(value) => common::Error::BadRequest(value),
9495                            _ => common::Error::Failure(response),
9496                        });
9497                    }
9498                    let response = {
9499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9500                        let encoded = common::to_string(&bytes);
9501                        match serde_json::from_str(&encoded) {
9502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9503                            Err(error) => {
9504                                dlg.response_json_decode_error(&encoded, &error);
9505                                return Err(common::Error::JsonDecodeError(
9506                                    encoded.to_string(),
9507                                    error,
9508                                ));
9509                            }
9510                        }
9511                    };
9512
9513                    dlg.finished(true);
9514                    return Ok(response);
9515                }
9516            }
9517        }
9518    }
9519
9520    ///
9521    /// Sets the *request* property to the given value.
9522    ///
9523    /// Even though the property as already been set when instantiating this call,
9524    /// we provide this method for API completeness.
9525    pub fn request(mut self, new_value: KeyHandle) -> ProjectLocationKeyHandleCreateCall<'a, C> {
9526        self._request = new_value;
9527        self
9528    }
9529    /// Required. Name of the resource project and location to create the KeyHandle in, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
9530    ///
9531    /// Sets the *parent* path property to the given value.
9532    ///
9533    /// Even though the property as already been set when instantiating this call,
9534    /// we provide this method for API completeness.
9535    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyHandleCreateCall<'a, C> {
9536        self._parent = new_value.to_string();
9537        self
9538    }
9539    /// Optional. Id of the KeyHandle. Must be unique to the resource project and location. If not provided by the caller, a new UUID is used.
9540    ///
9541    /// Sets the *key handle id* query property to the given value.
9542    pub fn key_handle_id(mut self, new_value: &str) -> ProjectLocationKeyHandleCreateCall<'a, C> {
9543        self._key_handle_id = Some(new_value.to_string());
9544        self
9545    }
9546    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9547    /// while executing the actual API request.
9548    ///
9549    /// ````text
9550    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9551    /// ````
9552    ///
9553    /// Sets the *delegate* property to the given value.
9554    pub fn delegate(
9555        mut self,
9556        new_value: &'a mut dyn common::Delegate,
9557    ) -> ProjectLocationKeyHandleCreateCall<'a, C> {
9558        self._delegate = Some(new_value);
9559        self
9560    }
9561
9562    /// Set any additional parameter of the query string used in the request.
9563    /// It should be used to set parameters which are not yet available through their own
9564    /// setters.
9565    ///
9566    /// Please note that this method must not be used to set any of the known parameters
9567    /// which have their own setter method. If done anyway, the request will fail.
9568    ///
9569    /// # Additional Parameters
9570    ///
9571    /// * *$.xgafv* (query-string) - V1 error format.
9572    /// * *access_token* (query-string) - OAuth access token.
9573    /// * *alt* (query-string) - Data format for response.
9574    /// * *callback* (query-string) - JSONP
9575    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9576    /// * *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.
9577    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9578    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9579    /// * *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.
9580    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9581    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9582    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleCreateCall<'a, C>
9583    where
9584        T: AsRef<str>,
9585    {
9586        self._additional_params
9587            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9588        self
9589    }
9590
9591    /// Identifies the authorization scope for the method you are building.
9592    ///
9593    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9594    /// [`Scope::CloudPlatform`].
9595    ///
9596    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9597    /// tokens for more than one scope.
9598    ///
9599    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9600    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9601    /// sufficient, a read-write scope will do as well.
9602    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleCreateCall<'a, C>
9603    where
9604        St: AsRef<str>,
9605    {
9606        self._scopes.insert(String::from(scope.as_ref()));
9607        self
9608    }
9609    /// Identifies the authorization scope(s) for the method you are building.
9610    ///
9611    /// See [`Self::add_scope()`] for details.
9612    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleCreateCall<'a, C>
9613    where
9614        I: IntoIterator<Item = St>,
9615        St: AsRef<str>,
9616    {
9617        self._scopes
9618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9619        self
9620    }
9621
9622    /// Removes all scopes, and no default scope will be used either.
9623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9624    /// for details).
9625    pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleCreateCall<'a, C> {
9626        self._scopes.clear();
9627        self
9628    }
9629}
9630
9631/// Returns the KeyHandle.
9632///
9633/// A builder for the *locations.keyHandles.get* method supported by a *project* resource.
9634/// It is not used directly, but through a [`ProjectMethods`] instance.
9635///
9636/// # Example
9637///
9638/// Instantiate a resource method builder
9639///
9640/// ```test_harness,no_run
9641/// # extern crate hyper;
9642/// # extern crate hyper_rustls;
9643/// # extern crate google_cloudkms1 as cloudkms1;
9644/// # async fn dox() {
9645/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9646///
9647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9648/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9649/// #     .with_native_roots()
9650/// #     .unwrap()
9651/// #     .https_only()
9652/// #     .enable_http2()
9653/// #     .build();
9654///
9655/// # let executor = hyper_util::rt::TokioExecutor::new();
9656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9657/// #     secret,
9658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9659/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9660/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9661/// #     ),
9662/// # ).build().await.unwrap();
9663///
9664/// # let client = hyper_util::client::legacy::Client::builder(
9665/// #     hyper_util::rt::TokioExecutor::new()
9666/// # )
9667/// # .build(
9668/// #     hyper_rustls::HttpsConnectorBuilder::new()
9669/// #         .with_native_roots()
9670/// #         .unwrap()
9671/// #         .https_or_http()
9672/// #         .enable_http2()
9673/// #         .build()
9674/// # );
9675/// # let mut hub = CloudKMS::new(client, auth);
9676/// // You can configure optional parameters by calling the respective setters at will, and
9677/// // execute the final call using `doit()`.
9678/// // Values shown here are possibly random and not representative !
9679/// let result = hub.projects().locations_key_handles_get("name")
9680///              .doit().await;
9681/// # }
9682/// ```
9683pub struct ProjectLocationKeyHandleGetCall<'a, C>
9684where
9685    C: 'a,
9686{
9687    hub: &'a CloudKMS<C>,
9688    _name: String,
9689    _delegate: Option<&'a mut dyn common::Delegate>,
9690    _additional_params: HashMap<String, String>,
9691    _scopes: BTreeSet<String>,
9692}
9693
9694impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleGetCall<'a, C> {}
9695
9696impl<'a, C> ProjectLocationKeyHandleGetCall<'a, C>
9697where
9698    C: common::Connector,
9699{
9700    /// Perform the operation you have build so far.
9701    pub async fn doit(mut self) -> common::Result<(common::Response, KeyHandle)> {
9702        use std::borrow::Cow;
9703        use std::io::{Read, Seek};
9704
9705        use common::{url::Params, ToParts};
9706        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9707
9708        let mut dd = common::DefaultDelegate;
9709        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9710        dlg.begin(common::MethodInfo {
9711            id: "cloudkms.projects.locations.keyHandles.get",
9712            http_method: hyper::Method::GET,
9713        });
9714
9715        for &field in ["alt", "name"].iter() {
9716            if self._additional_params.contains_key(field) {
9717                dlg.finished(false);
9718                return Err(common::Error::FieldClash(field));
9719            }
9720        }
9721
9722        let mut params = Params::with_capacity(3 + self._additional_params.len());
9723        params.push("name", self._name);
9724
9725        params.extend(self._additional_params.iter());
9726
9727        params.push("alt", "json");
9728        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9729        if self._scopes.is_empty() {
9730            self._scopes
9731                .insert(Scope::CloudPlatform.as_ref().to_string());
9732        }
9733
9734        #[allow(clippy::single_element_loop)]
9735        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9736            url = params.uri_replacement(url, param_name, find_this, true);
9737        }
9738        {
9739            let to_remove = ["name"];
9740            params.remove_params(&to_remove);
9741        }
9742
9743        let url = params.parse_with_url(&url);
9744
9745        loop {
9746            let token = match self
9747                .hub
9748                .auth
9749                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9750                .await
9751            {
9752                Ok(token) => token,
9753                Err(e) => match dlg.token(e) {
9754                    Ok(token) => token,
9755                    Err(e) => {
9756                        dlg.finished(false);
9757                        return Err(common::Error::MissingToken(e));
9758                    }
9759                },
9760            };
9761            let mut req_result = {
9762                let client = &self.hub.client;
9763                dlg.pre_request();
9764                let mut req_builder = hyper::Request::builder()
9765                    .method(hyper::Method::GET)
9766                    .uri(url.as_str())
9767                    .header(USER_AGENT, self.hub._user_agent.clone());
9768
9769                if let Some(token) = token.as_ref() {
9770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9771                }
9772
9773                let request = req_builder
9774                    .header(CONTENT_LENGTH, 0_u64)
9775                    .body(common::to_body::<String>(None));
9776
9777                client.request(request.unwrap()).await
9778            };
9779
9780            match req_result {
9781                Err(err) => {
9782                    if let common::Retry::After(d) = dlg.http_error(&err) {
9783                        sleep(d).await;
9784                        continue;
9785                    }
9786                    dlg.finished(false);
9787                    return Err(common::Error::HttpError(err));
9788                }
9789                Ok(res) => {
9790                    let (mut parts, body) = res.into_parts();
9791                    let mut body = common::Body::new(body);
9792                    if !parts.status.is_success() {
9793                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9794                        let error = serde_json::from_str(&common::to_string(&bytes));
9795                        let response = common::to_response(parts, bytes.into());
9796
9797                        if let common::Retry::After(d) =
9798                            dlg.http_failure(&response, error.as_ref().ok())
9799                        {
9800                            sleep(d).await;
9801                            continue;
9802                        }
9803
9804                        dlg.finished(false);
9805
9806                        return Err(match error {
9807                            Ok(value) => common::Error::BadRequest(value),
9808                            _ => common::Error::Failure(response),
9809                        });
9810                    }
9811                    let response = {
9812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9813                        let encoded = common::to_string(&bytes);
9814                        match serde_json::from_str(&encoded) {
9815                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9816                            Err(error) => {
9817                                dlg.response_json_decode_error(&encoded, &error);
9818                                return Err(common::Error::JsonDecodeError(
9819                                    encoded.to_string(),
9820                                    error,
9821                                ));
9822                            }
9823                        }
9824                    };
9825
9826                    dlg.finished(true);
9827                    return Ok(response);
9828                }
9829            }
9830        }
9831    }
9832
9833    /// Required. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
9834    ///
9835    /// Sets the *name* path property to the given value.
9836    ///
9837    /// Even though the property as already been set when instantiating this call,
9838    /// we provide this method for API completeness.
9839    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyHandleGetCall<'a, C> {
9840        self._name = new_value.to_string();
9841        self
9842    }
9843    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9844    /// while executing the actual API request.
9845    ///
9846    /// ````text
9847    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9848    /// ````
9849    ///
9850    /// Sets the *delegate* property to the given value.
9851    pub fn delegate(
9852        mut self,
9853        new_value: &'a mut dyn common::Delegate,
9854    ) -> ProjectLocationKeyHandleGetCall<'a, C> {
9855        self._delegate = Some(new_value);
9856        self
9857    }
9858
9859    /// Set any additional parameter of the query string used in the request.
9860    /// It should be used to set parameters which are not yet available through their own
9861    /// setters.
9862    ///
9863    /// Please note that this method must not be used to set any of the known parameters
9864    /// which have their own setter method. If done anyway, the request will fail.
9865    ///
9866    /// # Additional Parameters
9867    ///
9868    /// * *$.xgafv* (query-string) - V1 error format.
9869    /// * *access_token* (query-string) - OAuth access token.
9870    /// * *alt* (query-string) - Data format for response.
9871    /// * *callback* (query-string) - JSONP
9872    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9873    /// * *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.
9874    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9875    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9876    /// * *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.
9877    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9878    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9879    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleGetCall<'a, C>
9880    where
9881        T: AsRef<str>,
9882    {
9883        self._additional_params
9884            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9885        self
9886    }
9887
9888    /// Identifies the authorization scope for the method you are building.
9889    ///
9890    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9891    /// [`Scope::CloudPlatform`].
9892    ///
9893    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9894    /// tokens for more than one scope.
9895    ///
9896    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9897    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9898    /// sufficient, a read-write scope will do as well.
9899    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleGetCall<'a, C>
9900    where
9901        St: AsRef<str>,
9902    {
9903        self._scopes.insert(String::from(scope.as_ref()));
9904        self
9905    }
9906    /// Identifies the authorization scope(s) for the method you are building.
9907    ///
9908    /// See [`Self::add_scope()`] for details.
9909    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleGetCall<'a, C>
9910    where
9911        I: IntoIterator<Item = St>,
9912        St: AsRef<str>,
9913    {
9914        self._scopes
9915            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9916        self
9917    }
9918
9919    /// Removes all scopes, and no default scope will be used either.
9920    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9921    /// for details).
9922    pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleGetCall<'a, C> {
9923        self._scopes.clear();
9924        self
9925    }
9926}
9927
9928/// Lists KeyHandles.
9929///
9930/// A builder for the *locations.keyHandles.list* method supported by a *project* resource.
9931/// It is not used directly, but through a [`ProjectMethods`] instance.
9932///
9933/// # Example
9934///
9935/// Instantiate a resource method builder
9936///
9937/// ```test_harness,no_run
9938/// # extern crate hyper;
9939/// # extern crate hyper_rustls;
9940/// # extern crate google_cloudkms1 as cloudkms1;
9941/// # async fn dox() {
9942/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9943///
9944/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9945/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9946/// #     .with_native_roots()
9947/// #     .unwrap()
9948/// #     .https_only()
9949/// #     .enable_http2()
9950/// #     .build();
9951///
9952/// # let executor = hyper_util::rt::TokioExecutor::new();
9953/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9954/// #     secret,
9955/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9956/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9957/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9958/// #     ),
9959/// # ).build().await.unwrap();
9960///
9961/// # let client = hyper_util::client::legacy::Client::builder(
9962/// #     hyper_util::rt::TokioExecutor::new()
9963/// # )
9964/// # .build(
9965/// #     hyper_rustls::HttpsConnectorBuilder::new()
9966/// #         .with_native_roots()
9967/// #         .unwrap()
9968/// #         .https_or_http()
9969/// #         .enable_http2()
9970/// #         .build()
9971/// # );
9972/// # let mut hub = CloudKMS::new(client, auth);
9973/// // You can configure optional parameters by calling the respective setters at will, and
9974/// // execute the final call using `doit()`.
9975/// // Values shown here are possibly random and not representative !
9976/// let result = hub.projects().locations_key_handles_list("parent")
9977///              .page_token("dolor")
9978///              .page_size(-56)
9979///              .filter("eos")
9980///              .doit().await;
9981/// # }
9982/// ```
9983pub struct ProjectLocationKeyHandleListCall<'a, C>
9984where
9985    C: 'a,
9986{
9987    hub: &'a CloudKMS<C>,
9988    _parent: String,
9989    _page_token: Option<String>,
9990    _page_size: Option<i32>,
9991    _filter: Option<String>,
9992    _delegate: Option<&'a mut dyn common::Delegate>,
9993    _additional_params: HashMap<String, String>,
9994    _scopes: BTreeSet<String>,
9995}
9996
9997impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleListCall<'a, C> {}
9998
9999impl<'a, C> ProjectLocationKeyHandleListCall<'a, C>
10000where
10001    C: common::Connector,
10002{
10003    /// Perform the operation you have build so far.
10004    pub async fn doit(mut self) -> common::Result<(common::Response, ListKeyHandlesResponse)> {
10005        use std::borrow::Cow;
10006        use std::io::{Read, Seek};
10007
10008        use common::{url::Params, ToParts};
10009        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10010
10011        let mut dd = common::DefaultDelegate;
10012        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10013        dlg.begin(common::MethodInfo {
10014            id: "cloudkms.projects.locations.keyHandles.list",
10015            http_method: hyper::Method::GET,
10016        });
10017
10018        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10019            if self._additional_params.contains_key(field) {
10020                dlg.finished(false);
10021                return Err(common::Error::FieldClash(field));
10022            }
10023        }
10024
10025        let mut params = Params::with_capacity(6 + self._additional_params.len());
10026        params.push("parent", self._parent);
10027        if let Some(value) = self._page_token.as_ref() {
10028            params.push("pageToken", value);
10029        }
10030        if let Some(value) = self._page_size.as_ref() {
10031            params.push("pageSize", value.to_string());
10032        }
10033        if let Some(value) = self._filter.as_ref() {
10034            params.push("filter", value);
10035        }
10036
10037        params.extend(self._additional_params.iter());
10038
10039        params.push("alt", "json");
10040        let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyHandles";
10041        if self._scopes.is_empty() {
10042            self._scopes
10043                .insert(Scope::CloudPlatform.as_ref().to_string());
10044        }
10045
10046        #[allow(clippy::single_element_loop)]
10047        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10048            url = params.uri_replacement(url, param_name, find_this, true);
10049        }
10050        {
10051            let to_remove = ["parent"];
10052            params.remove_params(&to_remove);
10053        }
10054
10055        let url = params.parse_with_url(&url);
10056
10057        loop {
10058            let token = match self
10059                .hub
10060                .auth
10061                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10062                .await
10063            {
10064                Ok(token) => token,
10065                Err(e) => match dlg.token(e) {
10066                    Ok(token) => token,
10067                    Err(e) => {
10068                        dlg.finished(false);
10069                        return Err(common::Error::MissingToken(e));
10070                    }
10071                },
10072            };
10073            let mut req_result = {
10074                let client = &self.hub.client;
10075                dlg.pre_request();
10076                let mut req_builder = hyper::Request::builder()
10077                    .method(hyper::Method::GET)
10078                    .uri(url.as_str())
10079                    .header(USER_AGENT, self.hub._user_agent.clone());
10080
10081                if let Some(token) = token.as_ref() {
10082                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10083                }
10084
10085                let request = req_builder
10086                    .header(CONTENT_LENGTH, 0_u64)
10087                    .body(common::to_body::<String>(None));
10088
10089                client.request(request.unwrap()).await
10090            };
10091
10092            match req_result {
10093                Err(err) => {
10094                    if let common::Retry::After(d) = dlg.http_error(&err) {
10095                        sleep(d).await;
10096                        continue;
10097                    }
10098                    dlg.finished(false);
10099                    return Err(common::Error::HttpError(err));
10100                }
10101                Ok(res) => {
10102                    let (mut parts, body) = res.into_parts();
10103                    let mut body = common::Body::new(body);
10104                    if !parts.status.is_success() {
10105                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10106                        let error = serde_json::from_str(&common::to_string(&bytes));
10107                        let response = common::to_response(parts, bytes.into());
10108
10109                        if let common::Retry::After(d) =
10110                            dlg.http_failure(&response, error.as_ref().ok())
10111                        {
10112                            sleep(d).await;
10113                            continue;
10114                        }
10115
10116                        dlg.finished(false);
10117
10118                        return Err(match error {
10119                            Ok(value) => common::Error::BadRequest(value),
10120                            _ => common::Error::Failure(response),
10121                        });
10122                    }
10123                    let response = {
10124                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10125                        let encoded = common::to_string(&bytes);
10126                        match serde_json::from_str(&encoded) {
10127                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10128                            Err(error) => {
10129                                dlg.response_json_decode_error(&encoded, &error);
10130                                return Err(common::Error::JsonDecodeError(
10131                                    encoded.to_string(),
10132                                    error,
10133                                ));
10134                            }
10135                        }
10136                    };
10137
10138                    dlg.finished(true);
10139                    return Ok(response);
10140                }
10141            }
10142        }
10143    }
10144
10145    /// Required. Name of the resource project and location from which to list KeyHandles, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
10146    ///
10147    /// Sets the *parent* path property to the given value.
10148    ///
10149    /// Even though the property as already been set when instantiating this call,
10150    /// we provide this method for API completeness.
10151    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyHandleListCall<'a, C> {
10152        self._parent = new_value.to_string();
10153        self
10154    }
10155    /// Optional. Optional pagination token, returned earlier via ListKeyHandlesResponse.next_page_token.
10156    ///
10157    /// Sets the *page token* query property to the given value.
10158    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyHandleListCall<'a, C> {
10159        self._page_token = Some(new_value.to_string());
10160        self
10161    }
10162    /// Optional. Optional limit on the number of KeyHandles to include in the response. The service may return fewer than this value. Further KeyHandles can subsequently be obtained by including the ListKeyHandlesResponse.next_page_token in a subsequent request. If unspecified, at most 100 KeyHandles will be returned.
10163    ///
10164    /// Sets the *page size* query property to the given value.
10165    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyHandleListCall<'a, C> {
10166        self._page_size = Some(new_value);
10167        self
10168    }
10169    /// Optional. Filter to apply when listing KeyHandles, e.g. `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`.
10170    ///
10171    /// Sets the *filter* query property to the given value.
10172    pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyHandleListCall<'a, C> {
10173        self._filter = Some(new_value.to_string());
10174        self
10175    }
10176    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10177    /// while executing the actual API request.
10178    ///
10179    /// ````text
10180    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10181    /// ````
10182    ///
10183    /// Sets the *delegate* property to the given value.
10184    pub fn delegate(
10185        mut self,
10186        new_value: &'a mut dyn common::Delegate,
10187    ) -> ProjectLocationKeyHandleListCall<'a, C> {
10188        self._delegate = Some(new_value);
10189        self
10190    }
10191
10192    /// Set any additional parameter of the query string used in the request.
10193    /// It should be used to set parameters which are not yet available through their own
10194    /// setters.
10195    ///
10196    /// Please note that this method must not be used to set any of the known parameters
10197    /// which have their own setter method. If done anyway, the request will fail.
10198    ///
10199    /// # Additional Parameters
10200    ///
10201    /// * *$.xgafv* (query-string) - V1 error format.
10202    /// * *access_token* (query-string) - OAuth access token.
10203    /// * *alt* (query-string) - Data format for response.
10204    /// * *callback* (query-string) - JSONP
10205    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10206    /// * *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.
10207    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10208    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10209    /// * *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.
10210    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10211    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10212    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleListCall<'a, C>
10213    where
10214        T: AsRef<str>,
10215    {
10216        self._additional_params
10217            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10218        self
10219    }
10220
10221    /// Identifies the authorization scope for the method you are building.
10222    ///
10223    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10224    /// [`Scope::CloudPlatform`].
10225    ///
10226    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10227    /// tokens for more than one scope.
10228    ///
10229    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10230    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10231    /// sufficient, a read-write scope will do as well.
10232    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleListCall<'a, C>
10233    where
10234        St: AsRef<str>,
10235    {
10236        self._scopes.insert(String::from(scope.as_ref()));
10237        self
10238    }
10239    /// Identifies the authorization scope(s) for the method you are building.
10240    ///
10241    /// See [`Self::add_scope()`] for details.
10242    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleListCall<'a, C>
10243    where
10244        I: IntoIterator<Item = St>,
10245        St: AsRef<str>,
10246    {
10247        self._scopes
10248            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10249        self
10250    }
10251
10252    /// Removes all scopes, and no default scope will be used either.
10253    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10254    /// for details).
10255    pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleListCall<'a, C> {
10256        self._scopes.clear();
10257        self
10258    }
10259}
10260
10261/// Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.
10262///
10263/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricDecrypt* method supported by a *project* resource.
10264/// It is not used directly, but through a [`ProjectMethods`] instance.
10265///
10266/// # Example
10267///
10268/// Instantiate a resource method builder
10269///
10270/// ```test_harness,no_run
10271/// # extern crate hyper;
10272/// # extern crate hyper_rustls;
10273/// # extern crate google_cloudkms1 as cloudkms1;
10274/// use cloudkms1::api::AsymmetricDecryptRequest;
10275/// # async fn dox() {
10276/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10277///
10278/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10279/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10280/// #     .with_native_roots()
10281/// #     .unwrap()
10282/// #     .https_only()
10283/// #     .enable_http2()
10284/// #     .build();
10285///
10286/// # let executor = hyper_util::rt::TokioExecutor::new();
10287/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10288/// #     secret,
10289/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10290/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10291/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10292/// #     ),
10293/// # ).build().await.unwrap();
10294///
10295/// # let client = hyper_util::client::legacy::Client::builder(
10296/// #     hyper_util::rt::TokioExecutor::new()
10297/// # )
10298/// # .build(
10299/// #     hyper_rustls::HttpsConnectorBuilder::new()
10300/// #         .with_native_roots()
10301/// #         .unwrap()
10302/// #         .https_or_http()
10303/// #         .enable_http2()
10304/// #         .build()
10305/// # );
10306/// # let mut hub = CloudKMS::new(client, auth);
10307/// // As the method needs a request, you would usually fill it with the desired information
10308/// // into the respective structure. Some of the parts shown here might not be applicable !
10309/// // Values shown here are possibly random and not representative !
10310/// let mut req = AsymmetricDecryptRequest::default();
10311///
10312/// // You can configure optional parameters by calling the respective setters at will, and
10313/// // execute the final call using `doit()`.
10314/// // Values shown here are possibly random and not representative !
10315/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_decrypt(req, "name")
10316///              .doit().await;
10317/// # }
10318/// ```
10319pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10320where
10321    C: 'a,
10322{
10323    hub: &'a CloudKMS<C>,
10324    _request: AsymmetricDecryptRequest,
10325    _name: String,
10326    _delegate: Option<&'a mut dyn common::Delegate>,
10327    _additional_params: HashMap<String, String>,
10328    _scopes: BTreeSet<String>,
10329}
10330
10331impl<'a, C> common::CallBuilder
10332    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10333{
10334}
10335
10336impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10337where
10338    C: common::Connector,
10339{
10340    /// Perform the operation you have build so far.
10341    pub async fn doit(mut self) -> common::Result<(common::Response, AsymmetricDecryptResponse)> {
10342        use std::borrow::Cow;
10343        use std::io::{Read, Seek};
10344
10345        use common::{url::Params, ToParts};
10346        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10347
10348        let mut dd = common::DefaultDelegate;
10349        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10350        dlg.begin(common::MethodInfo { id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricDecrypt",
10351                               http_method: hyper::Method::POST });
10352
10353        for &field in ["alt", "name"].iter() {
10354            if self._additional_params.contains_key(field) {
10355                dlg.finished(false);
10356                return Err(common::Error::FieldClash(field));
10357            }
10358        }
10359
10360        let mut params = Params::with_capacity(4 + self._additional_params.len());
10361        params.push("name", self._name);
10362
10363        params.extend(self._additional_params.iter());
10364
10365        params.push("alt", "json");
10366        let mut url = self.hub._base_url.clone() + "v1/{+name}:asymmetricDecrypt";
10367        if self._scopes.is_empty() {
10368            self._scopes
10369                .insert(Scope::CloudPlatform.as_ref().to_string());
10370        }
10371
10372        #[allow(clippy::single_element_loop)]
10373        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10374            url = params.uri_replacement(url, param_name, find_this, true);
10375        }
10376        {
10377            let to_remove = ["name"];
10378            params.remove_params(&to_remove);
10379        }
10380
10381        let url = params.parse_with_url(&url);
10382
10383        let mut json_mime_type = mime::APPLICATION_JSON;
10384        let mut request_value_reader = {
10385            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10386            common::remove_json_null_values(&mut value);
10387            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10388            serde_json::to_writer(&mut dst, &value).unwrap();
10389            dst
10390        };
10391        let request_size = request_value_reader
10392            .seek(std::io::SeekFrom::End(0))
10393            .unwrap();
10394        request_value_reader
10395            .seek(std::io::SeekFrom::Start(0))
10396            .unwrap();
10397
10398        loop {
10399            let token = match self
10400                .hub
10401                .auth
10402                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10403                .await
10404            {
10405                Ok(token) => token,
10406                Err(e) => match dlg.token(e) {
10407                    Ok(token) => token,
10408                    Err(e) => {
10409                        dlg.finished(false);
10410                        return Err(common::Error::MissingToken(e));
10411                    }
10412                },
10413            };
10414            request_value_reader
10415                .seek(std::io::SeekFrom::Start(0))
10416                .unwrap();
10417            let mut req_result = {
10418                let client = &self.hub.client;
10419                dlg.pre_request();
10420                let mut req_builder = hyper::Request::builder()
10421                    .method(hyper::Method::POST)
10422                    .uri(url.as_str())
10423                    .header(USER_AGENT, self.hub._user_agent.clone());
10424
10425                if let Some(token) = token.as_ref() {
10426                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10427                }
10428
10429                let request = req_builder
10430                    .header(CONTENT_TYPE, json_mime_type.to_string())
10431                    .header(CONTENT_LENGTH, request_size as u64)
10432                    .body(common::to_body(
10433                        request_value_reader.get_ref().clone().into(),
10434                    ));
10435
10436                client.request(request.unwrap()).await
10437            };
10438
10439            match req_result {
10440                Err(err) => {
10441                    if let common::Retry::After(d) = dlg.http_error(&err) {
10442                        sleep(d).await;
10443                        continue;
10444                    }
10445                    dlg.finished(false);
10446                    return Err(common::Error::HttpError(err));
10447                }
10448                Ok(res) => {
10449                    let (mut parts, body) = res.into_parts();
10450                    let mut body = common::Body::new(body);
10451                    if !parts.status.is_success() {
10452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10453                        let error = serde_json::from_str(&common::to_string(&bytes));
10454                        let response = common::to_response(parts, bytes.into());
10455
10456                        if let common::Retry::After(d) =
10457                            dlg.http_failure(&response, error.as_ref().ok())
10458                        {
10459                            sleep(d).await;
10460                            continue;
10461                        }
10462
10463                        dlg.finished(false);
10464
10465                        return Err(match error {
10466                            Ok(value) => common::Error::BadRequest(value),
10467                            _ => common::Error::Failure(response),
10468                        });
10469                    }
10470                    let response = {
10471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10472                        let encoded = common::to_string(&bytes);
10473                        match serde_json::from_str(&encoded) {
10474                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10475                            Err(error) => {
10476                                dlg.response_json_decode_error(&encoded, &error);
10477                                return Err(common::Error::JsonDecodeError(
10478                                    encoded.to_string(),
10479                                    error,
10480                                ));
10481                            }
10482                        }
10483                    };
10484
10485                    dlg.finished(true);
10486                    return Ok(response);
10487                }
10488            }
10489        }
10490    }
10491
10492    ///
10493    /// Sets the *request* property to the given value.
10494    ///
10495    /// Even though the property as already been set when instantiating this call,
10496    /// we provide this method for API completeness.
10497    pub fn request(
10498        mut self,
10499        new_value: AsymmetricDecryptRequest,
10500    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
10501        self._request = new_value;
10502        self
10503    }
10504    /// Required. The resource name of the CryptoKeyVersion to use for decryption.
10505    ///
10506    /// Sets the *name* path property to the given value.
10507    ///
10508    /// Even though the property as already been set when instantiating this call,
10509    /// we provide this method for API completeness.
10510    pub fn name(
10511        mut self,
10512        new_value: &str,
10513    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
10514        self._name = new_value.to_string();
10515        self
10516    }
10517    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10518    /// while executing the actual API request.
10519    ///
10520    /// ````text
10521    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10522    /// ````
10523    ///
10524    /// Sets the *delegate* property to the given value.
10525    pub fn delegate(
10526        mut self,
10527        new_value: &'a mut dyn common::Delegate,
10528    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
10529        self._delegate = Some(new_value);
10530        self
10531    }
10532
10533    /// Set any additional parameter of the query string used in the request.
10534    /// It should be used to set parameters which are not yet available through their own
10535    /// setters.
10536    ///
10537    /// Please note that this method must not be used to set any of the known parameters
10538    /// which have their own setter method. If done anyway, the request will fail.
10539    ///
10540    /// # Additional Parameters
10541    ///
10542    /// * *$.xgafv* (query-string) - V1 error format.
10543    /// * *access_token* (query-string) - OAuth access token.
10544    /// * *alt* (query-string) - Data format for response.
10545    /// * *callback* (query-string) - JSONP
10546    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10547    /// * *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.
10548    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10549    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10550    /// * *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.
10551    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10552    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10553    pub fn param<T>(
10554        mut self,
10555        name: T,
10556        value: T,
10557    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10558    where
10559        T: AsRef<str>,
10560    {
10561        self._additional_params
10562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10563        self
10564    }
10565
10566    /// Identifies the authorization scope for the method you are building.
10567    ///
10568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10569    /// [`Scope::CloudPlatform`].
10570    ///
10571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10572    /// tokens for more than one scope.
10573    ///
10574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10576    /// sufficient, a read-write scope will do as well.
10577    pub fn add_scope<St>(
10578        mut self,
10579        scope: St,
10580    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10581    where
10582        St: AsRef<str>,
10583    {
10584        self._scopes.insert(String::from(scope.as_ref()));
10585        self
10586    }
10587    /// Identifies the authorization scope(s) for the method you are building.
10588    ///
10589    /// See [`Self::add_scope()`] for details.
10590    pub fn add_scopes<I, St>(
10591        mut self,
10592        scopes: I,
10593    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
10594    where
10595        I: IntoIterator<Item = St>,
10596        St: AsRef<str>,
10597    {
10598        self._scopes
10599            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10600        self
10601    }
10602
10603    /// Removes all scopes, and no default scope will be used either.
10604    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10605    /// for details).
10606    pub fn clear_scopes(
10607        mut self,
10608    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
10609        self._scopes.clear();
10610        self
10611    }
10612}
10613
10614/// Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.
10615///
10616/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricSign* method supported by a *project* resource.
10617/// It is not used directly, but through a [`ProjectMethods`] instance.
10618///
10619/// # Example
10620///
10621/// Instantiate a resource method builder
10622///
10623/// ```test_harness,no_run
10624/// # extern crate hyper;
10625/// # extern crate hyper_rustls;
10626/// # extern crate google_cloudkms1 as cloudkms1;
10627/// use cloudkms1::api::AsymmetricSignRequest;
10628/// # async fn dox() {
10629/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10630///
10631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10633/// #     .with_native_roots()
10634/// #     .unwrap()
10635/// #     .https_only()
10636/// #     .enable_http2()
10637/// #     .build();
10638///
10639/// # let executor = hyper_util::rt::TokioExecutor::new();
10640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10641/// #     secret,
10642/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10643/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10644/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10645/// #     ),
10646/// # ).build().await.unwrap();
10647///
10648/// # let client = hyper_util::client::legacy::Client::builder(
10649/// #     hyper_util::rt::TokioExecutor::new()
10650/// # )
10651/// # .build(
10652/// #     hyper_rustls::HttpsConnectorBuilder::new()
10653/// #         .with_native_roots()
10654/// #         .unwrap()
10655/// #         .https_or_http()
10656/// #         .enable_http2()
10657/// #         .build()
10658/// # );
10659/// # let mut hub = CloudKMS::new(client, auth);
10660/// // As the method needs a request, you would usually fill it with the desired information
10661/// // into the respective structure. Some of the parts shown here might not be applicable !
10662/// // Values shown here are possibly random and not representative !
10663/// let mut req = AsymmetricSignRequest::default();
10664///
10665/// // You can configure optional parameters by calling the respective setters at will, and
10666/// // execute the final call using `doit()`.
10667/// // Values shown here are possibly random and not representative !
10668/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_sign(req, "name")
10669///              .doit().await;
10670/// # }
10671/// ```
10672pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10673where
10674    C: 'a,
10675{
10676    hub: &'a CloudKMS<C>,
10677    _request: AsymmetricSignRequest,
10678    _name: String,
10679    _delegate: Option<&'a mut dyn common::Delegate>,
10680    _additional_params: HashMap<String, String>,
10681    _scopes: BTreeSet<String>,
10682}
10683
10684impl<'a, C> common::CallBuilder
10685    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10686{
10687}
10688
10689impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10690where
10691    C: common::Connector,
10692{
10693    /// Perform the operation you have build so far.
10694    pub async fn doit(mut self) -> common::Result<(common::Response, AsymmetricSignResponse)> {
10695        use std::borrow::Cow;
10696        use std::io::{Read, Seek};
10697
10698        use common::{url::Params, ToParts};
10699        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10700
10701        let mut dd = common::DefaultDelegate;
10702        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10703        dlg.begin(common::MethodInfo {
10704            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricSign",
10705            http_method: hyper::Method::POST,
10706        });
10707
10708        for &field in ["alt", "name"].iter() {
10709            if self._additional_params.contains_key(field) {
10710                dlg.finished(false);
10711                return Err(common::Error::FieldClash(field));
10712            }
10713        }
10714
10715        let mut params = Params::with_capacity(4 + self._additional_params.len());
10716        params.push("name", self._name);
10717
10718        params.extend(self._additional_params.iter());
10719
10720        params.push("alt", "json");
10721        let mut url = self.hub._base_url.clone() + "v1/{+name}:asymmetricSign";
10722        if self._scopes.is_empty() {
10723            self._scopes
10724                .insert(Scope::CloudPlatform.as_ref().to_string());
10725        }
10726
10727        #[allow(clippy::single_element_loop)]
10728        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10729            url = params.uri_replacement(url, param_name, find_this, true);
10730        }
10731        {
10732            let to_remove = ["name"];
10733            params.remove_params(&to_remove);
10734        }
10735
10736        let url = params.parse_with_url(&url);
10737
10738        let mut json_mime_type = mime::APPLICATION_JSON;
10739        let mut request_value_reader = {
10740            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10741            common::remove_json_null_values(&mut value);
10742            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10743            serde_json::to_writer(&mut dst, &value).unwrap();
10744            dst
10745        };
10746        let request_size = request_value_reader
10747            .seek(std::io::SeekFrom::End(0))
10748            .unwrap();
10749        request_value_reader
10750            .seek(std::io::SeekFrom::Start(0))
10751            .unwrap();
10752
10753        loop {
10754            let token = match self
10755                .hub
10756                .auth
10757                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10758                .await
10759            {
10760                Ok(token) => token,
10761                Err(e) => match dlg.token(e) {
10762                    Ok(token) => token,
10763                    Err(e) => {
10764                        dlg.finished(false);
10765                        return Err(common::Error::MissingToken(e));
10766                    }
10767                },
10768            };
10769            request_value_reader
10770                .seek(std::io::SeekFrom::Start(0))
10771                .unwrap();
10772            let mut req_result = {
10773                let client = &self.hub.client;
10774                dlg.pre_request();
10775                let mut req_builder = hyper::Request::builder()
10776                    .method(hyper::Method::POST)
10777                    .uri(url.as_str())
10778                    .header(USER_AGENT, self.hub._user_agent.clone());
10779
10780                if let Some(token) = token.as_ref() {
10781                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10782                }
10783
10784                let request = req_builder
10785                    .header(CONTENT_TYPE, json_mime_type.to_string())
10786                    .header(CONTENT_LENGTH, request_size as u64)
10787                    .body(common::to_body(
10788                        request_value_reader.get_ref().clone().into(),
10789                    ));
10790
10791                client.request(request.unwrap()).await
10792            };
10793
10794            match req_result {
10795                Err(err) => {
10796                    if let common::Retry::After(d) = dlg.http_error(&err) {
10797                        sleep(d).await;
10798                        continue;
10799                    }
10800                    dlg.finished(false);
10801                    return Err(common::Error::HttpError(err));
10802                }
10803                Ok(res) => {
10804                    let (mut parts, body) = res.into_parts();
10805                    let mut body = common::Body::new(body);
10806                    if !parts.status.is_success() {
10807                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10808                        let error = serde_json::from_str(&common::to_string(&bytes));
10809                        let response = common::to_response(parts, bytes.into());
10810
10811                        if let common::Retry::After(d) =
10812                            dlg.http_failure(&response, error.as_ref().ok())
10813                        {
10814                            sleep(d).await;
10815                            continue;
10816                        }
10817
10818                        dlg.finished(false);
10819
10820                        return Err(match error {
10821                            Ok(value) => common::Error::BadRequest(value),
10822                            _ => common::Error::Failure(response),
10823                        });
10824                    }
10825                    let response = {
10826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10827                        let encoded = common::to_string(&bytes);
10828                        match serde_json::from_str(&encoded) {
10829                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10830                            Err(error) => {
10831                                dlg.response_json_decode_error(&encoded, &error);
10832                                return Err(common::Error::JsonDecodeError(
10833                                    encoded.to_string(),
10834                                    error,
10835                                ));
10836                            }
10837                        }
10838                    };
10839
10840                    dlg.finished(true);
10841                    return Ok(response);
10842                }
10843            }
10844        }
10845    }
10846
10847    ///
10848    /// Sets the *request* property to the given value.
10849    ///
10850    /// Even though the property as already been set when instantiating this call,
10851    /// we provide this method for API completeness.
10852    pub fn request(
10853        mut self,
10854        new_value: AsymmetricSignRequest,
10855    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
10856        self._request = new_value;
10857        self
10858    }
10859    /// Required. The resource name of the CryptoKeyVersion to use for signing.
10860    ///
10861    /// Sets the *name* path property to the given value.
10862    ///
10863    /// Even though the property as already been set when instantiating this call,
10864    /// we provide this method for API completeness.
10865    pub fn name(
10866        mut self,
10867        new_value: &str,
10868    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
10869        self._name = new_value.to_string();
10870        self
10871    }
10872    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10873    /// while executing the actual API request.
10874    ///
10875    /// ````text
10876    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10877    /// ````
10878    ///
10879    /// Sets the *delegate* property to the given value.
10880    pub fn delegate(
10881        mut self,
10882        new_value: &'a mut dyn common::Delegate,
10883    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
10884        self._delegate = Some(new_value);
10885        self
10886    }
10887
10888    /// Set any additional parameter of the query string used in the request.
10889    /// It should be used to set parameters which are not yet available through their own
10890    /// setters.
10891    ///
10892    /// Please note that this method must not be used to set any of the known parameters
10893    /// which have their own setter method. If done anyway, the request will fail.
10894    ///
10895    /// # Additional Parameters
10896    ///
10897    /// * *$.xgafv* (query-string) - V1 error format.
10898    /// * *access_token* (query-string) - OAuth access token.
10899    /// * *alt* (query-string) - Data format for response.
10900    /// * *callback* (query-string) - JSONP
10901    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10902    /// * *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.
10903    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10904    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10905    /// * *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.
10906    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10907    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10908    pub fn param<T>(
10909        mut self,
10910        name: T,
10911        value: T,
10912    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10913    where
10914        T: AsRef<str>,
10915    {
10916        self._additional_params
10917            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10918        self
10919    }
10920
10921    /// Identifies the authorization scope for the method you are building.
10922    ///
10923    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10924    /// [`Scope::CloudPlatform`].
10925    ///
10926    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10927    /// tokens for more than one scope.
10928    ///
10929    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10930    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10931    /// sufficient, a read-write scope will do as well.
10932    pub fn add_scope<St>(
10933        mut self,
10934        scope: St,
10935    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10936    where
10937        St: AsRef<str>,
10938    {
10939        self._scopes.insert(String::from(scope.as_ref()));
10940        self
10941    }
10942    /// Identifies the authorization scope(s) for the method you are building.
10943    ///
10944    /// See [`Self::add_scope()`] for details.
10945    pub fn add_scopes<I, St>(
10946        mut self,
10947        scopes: I,
10948    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
10949    where
10950        I: IntoIterator<Item = St>,
10951        St: AsRef<str>,
10952    {
10953        self._scopes
10954            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10955        self
10956    }
10957
10958    /// Removes all scopes, and no default scope will be used either.
10959    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10960    /// for details).
10961    pub fn clear_scopes(
10962        mut self,
10963    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
10964        self._scopes.clear();
10965        self
10966    }
10967}
10968
10969/// Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next sequential id. If unset, state will be set to ENABLED.
10970///
10971/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.create* method supported by a *project* resource.
10972/// It is not used directly, but through a [`ProjectMethods`] instance.
10973///
10974/// # Example
10975///
10976/// Instantiate a resource method builder
10977///
10978/// ```test_harness,no_run
10979/// # extern crate hyper;
10980/// # extern crate hyper_rustls;
10981/// # extern crate google_cloudkms1 as cloudkms1;
10982/// use cloudkms1::api::CryptoKeyVersion;
10983/// # async fn dox() {
10984/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10985///
10986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10987/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10988/// #     .with_native_roots()
10989/// #     .unwrap()
10990/// #     .https_only()
10991/// #     .enable_http2()
10992/// #     .build();
10993///
10994/// # let executor = hyper_util::rt::TokioExecutor::new();
10995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10996/// #     secret,
10997/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10998/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10999/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11000/// #     ),
11001/// # ).build().await.unwrap();
11002///
11003/// # let client = hyper_util::client::legacy::Client::builder(
11004/// #     hyper_util::rt::TokioExecutor::new()
11005/// # )
11006/// # .build(
11007/// #     hyper_rustls::HttpsConnectorBuilder::new()
11008/// #         .with_native_roots()
11009/// #         .unwrap()
11010/// #         .https_or_http()
11011/// #         .enable_http2()
11012/// #         .build()
11013/// # );
11014/// # let mut hub = CloudKMS::new(client, auth);
11015/// // As the method needs a request, you would usually fill it with the desired information
11016/// // into the respective structure. Some of the parts shown here might not be applicable !
11017/// // Values shown here are possibly random and not representative !
11018/// let mut req = CryptoKeyVersion::default();
11019///
11020/// // You can configure optional parameters by calling the respective setters at will, and
11021/// // execute the final call using `doit()`.
11022/// // Values shown here are possibly random and not representative !
11023/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_create(req, "parent")
11024///              .doit().await;
11025/// # }
11026/// ```
11027pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11028where
11029    C: 'a,
11030{
11031    hub: &'a CloudKMS<C>,
11032    _request: CryptoKeyVersion,
11033    _parent: String,
11034    _delegate: Option<&'a mut dyn common::Delegate>,
11035    _additional_params: HashMap<String, String>,
11036    _scopes: BTreeSet<String>,
11037}
11038
11039impl<'a, C> common::CallBuilder
11040    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11041{
11042}
11043
11044impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11045where
11046    C: common::Connector,
11047{
11048    /// Perform the operation you have build so far.
11049    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
11050        use std::borrow::Cow;
11051        use std::io::{Read, Seek};
11052
11053        use common::{url::Params, ToParts};
11054        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11055
11056        let mut dd = common::DefaultDelegate;
11057        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11058        dlg.begin(common::MethodInfo {
11059            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create",
11060            http_method: hyper::Method::POST,
11061        });
11062
11063        for &field in ["alt", "parent"].iter() {
11064            if self._additional_params.contains_key(field) {
11065                dlg.finished(false);
11066                return Err(common::Error::FieldClash(field));
11067            }
11068        }
11069
11070        let mut params = Params::with_capacity(4 + self._additional_params.len());
11071        params.push("parent", self._parent);
11072
11073        params.extend(self._additional_params.iter());
11074
11075        params.push("alt", "json");
11076        let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions";
11077        if self._scopes.is_empty() {
11078            self._scopes
11079                .insert(Scope::CloudPlatform.as_ref().to_string());
11080        }
11081
11082        #[allow(clippy::single_element_loop)]
11083        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11084            url = params.uri_replacement(url, param_name, find_this, true);
11085        }
11086        {
11087            let to_remove = ["parent"];
11088            params.remove_params(&to_remove);
11089        }
11090
11091        let url = params.parse_with_url(&url);
11092
11093        let mut json_mime_type = mime::APPLICATION_JSON;
11094        let mut request_value_reader = {
11095            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11096            common::remove_json_null_values(&mut value);
11097            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11098            serde_json::to_writer(&mut dst, &value).unwrap();
11099            dst
11100        };
11101        let request_size = request_value_reader
11102            .seek(std::io::SeekFrom::End(0))
11103            .unwrap();
11104        request_value_reader
11105            .seek(std::io::SeekFrom::Start(0))
11106            .unwrap();
11107
11108        loop {
11109            let token = match self
11110                .hub
11111                .auth
11112                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11113                .await
11114            {
11115                Ok(token) => token,
11116                Err(e) => match dlg.token(e) {
11117                    Ok(token) => token,
11118                    Err(e) => {
11119                        dlg.finished(false);
11120                        return Err(common::Error::MissingToken(e));
11121                    }
11122                },
11123            };
11124            request_value_reader
11125                .seek(std::io::SeekFrom::Start(0))
11126                .unwrap();
11127            let mut req_result = {
11128                let client = &self.hub.client;
11129                dlg.pre_request();
11130                let mut req_builder = hyper::Request::builder()
11131                    .method(hyper::Method::POST)
11132                    .uri(url.as_str())
11133                    .header(USER_AGENT, self.hub._user_agent.clone());
11134
11135                if let Some(token) = token.as_ref() {
11136                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11137                }
11138
11139                let request = req_builder
11140                    .header(CONTENT_TYPE, json_mime_type.to_string())
11141                    .header(CONTENT_LENGTH, request_size as u64)
11142                    .body(common::to_body(
11143                        request_value_reader.get_ref().clone().into(),
11144                    ));
11145
11146                client.request(request.unwrap()).await
11147            };
11148
11149            match req_result {
11150                Err(err) => {
11151                    if let common::Retry::After(d) = dlg.http_error(&err) {
11152                        sleep(d).await;
11153                        continue;
11154                    }
11155                    dlg.finished(false);
11156                    return Err(common::Error::HttpError(err));
11157                }
11158                Ok(res) => {
11159                    let (mut parts, body) = res.into_parts();
11160                    let mut body = common::Body::new(body);
11161                    if !parts.status.is_success() {
11162                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11163                        let error = serde_json::from_str(&common::to_string(&bytes));
11164                        let response = common::to_response(parts, bytes.into());
11165
11166                        if let common::Retry::After(d) =
11167                            dlg.http_failure(&response, error.as_ref().ok())
11168                        {
11169                            sleep(d).await;
11170                            continue;
11171                        }
11172
11173                        dlg.finished(false);
11174
11175                        return Err(match error {
11176                            Ok(value) => common::Error::BadRequest(value),
11177                            _ => common::Error::Failure(response),
11178                        });
11179                    }
11180                    let response = {
11181                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11182                        let encoded = common::to_string(&bytes);
11183                        match serde_json::from_str(&encoded) {
11184                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11185                            Err(error) => {
11186                                dlg.response_json_decode_error(&encoded, &error);
11187                                return Err(common::Error::JsonDecodeError(
11188                                    encoded.to_string(),
11189                                    error,
11190                                ));
11191                            }
11192                        }
11193                    };
11194
11195                    dlg.finished(true);
11196                    return Ok(response);
11197                }
11198            }
11199        }
11200    }
11201
11202    ///
11203    /// Sets the *request* property to the given value.
11204    ///
11205    /// Even though the property as already been set when instantiating this call,
11206    /// we provide this method for API completeness.
11207    pub fn request(
11208        mut self,
11209        new_value: CryptoKeyVersion,
11210    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
11211        self._request = new_value;
11212        self
11213    }
11214    /// Required. The name of the CryptoKey associated with the CryptoKeyVersions.
11215    ///
11216    /// Sets the *parent* path property to the given value.
11217    ///
11218    /// Even though the property as already been set when instantiating this call,
11219    /// we provide this method for API completeness.
11220    pub fn parent(
11221        mut self,
11222        new_value: &str,
11223    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
11224        self._parent = new_value.to_string();
11225        self
11226    }
11227    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11228    /// while executing the actual API request.
11229    ///
11230    /// ````text
11231    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11232    /// ````
11233    ///
11234    /// Sets the *delegate* property to the given value.
11235    pub fn delegate(
11236        mut self,
11237        new_value: &'a mut dyn common::Delegate,
11238    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
11239        self._delegate = Some(new_value);
11240        self
11241    }
11242
11243    /// Set any additional parameter of the query string used in the request.
11244    /// It should be used to set parameters which are not yet available through their own
11245    /// setters.
11246    ///
11247    /// Please note that this method must not be used to set any of the known parameters
11248    /// which have their own setter method. If done anyway, the request will fail.
11249    ///
11250    /// # Additional Parameters
11251    ///
11252    /// * *$.xgafv* (query-string) - V1 error format.
11253    /// * *access_token* (query-string) - OAuth access token.
11254    /// * *alt* (query-string) - Data format for response.
11255    /// * *callback* (query-string) - JSONP
11256    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11257    /// * *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.
11258    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11259    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11260    /// * *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.
11261    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11262    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11263    pub fn param<T>(
11264        mut self,
11265        name: T,
11266        value: T,
11267    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11268    where
11269        T: AsRef<str>,
11270    {
11271        self._additional_params
11272            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11273        self
11274    }
11275
11276    /// Identifies the authorization scope for the method you are building.
11277    ///
11278    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11279    /// [`Scope::CloudPlatform`].
11280    ///
11281    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11282    /// tokens for more than one scope.
11283    ///
11284    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11285    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11286    /// sufficient, a read-write scope will do as well.
11287    pub fn add_scope<St>(
11288        mut self,
11289        scope: St,
11290    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11291    where
11292        St: AsRef<str>,
11293    {
11294        self._scopes.insert(String::from(scope.as_ref()));
11295        self
11296    }
11297    /// Identifies the authorization scope(s) for the method you are building.
11298    ///
11299    /// See [`Self::add_scope()`] for details.
11300    pub fn add_scopes<I, St>(
11301        mut self,
11302        scopes: I,
11303    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
11304    where
11305        I: IntoIterator<Item = St>,
11306        St: AsRef<str>,
11307    {
11308        self._scopes
11309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11310        self
11311    }
11312
11313    /// Removes all scopes, and no default scope will be used either.
11314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11315    /// for details).
11316    pub fn clear_scopes(
11317        mut self,
11318    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
11319        self._scopes.clear();
11320        self
11321    }
11322}
11323
11324/// Decapsulates data that was encapsulated with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose KEY_ENCAPSULATION.
11325///
11326/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.decapsulate* method supported by a *project* resource.
11327/// It is not used directly, but through a [`ProjectMethods`] instance.
11328///
11329/// # Example
11330///
11331/// Instantiate a resource method builder
11332///
11333/// ```test_harness,no_run
11334/// # extern crate hyper;
11335/// # extern crate hyper_rustls;
11336/// # extern crate google_cloudkms1 as cloudkms1;
11337/// use cloudkms1::api::DecapsulateRequest;
11338/// # async fn dox() {
11339/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11340///
11341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11342/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11343/// #     .with_native_roots()
11344/// #     .unwrap()
11345/// #     .https_only()
11346/// #     .enable_http2()
11347/// #     .build();
11348///
11349/// # let executor = hyper_util::rt::TokioExecutor::new();
11350/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11351/// #     secret,
11352/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11353/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11354/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11355/// #     ),
11356/// # ).build().await.unwrap();
11357///
11358/// # let client = hyper_util::client::legacy::Client::builder(
11359/// #     hyper_util::rt::TokioExecutor::new()
11360/// # )
11361/// # .build(
11362/// #     hyper_rustls::HttpsConnectorBuilder::new()
11363/// #         .with_native_roots()
11364/// #         .unwrap()
11365/// #         .https_or_http()
11366/// #         .enable_http2()
11367/// #         .build()
11368/// # );
11369/// # let mut hub = CloudKMS::new(client, auth);
11370/// // As the method needs a request, you would usually fill it with the desired information
11371/// // into the respective structure. Some of the parts shown here might not be applicable !
11372/// // Values shown here are possibly random and not representative !
11373/// let mut req = DecapsulateRequest::default();
11374///
11375/// // You can configure optional parameters by calling the respective setters at will, and
11376/// // execute the final call using `doit()`.
11377/// // Values shown here are possibly random and not representative !
11378/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_decapsulate(req, "name")
11379///              .doit().await;
11380/// # }
11381/// ```
11382pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11383where
11384    C: 'a,
11385{
11386    hub: &'a CloudKMS<C>,
11387    _request: DecapsulateRequest,
11388    _name: String,
11389    _delegate: Option<&'a mut dyn common::Delegate>,
11390    _additional_params: HashMap<String, String>,
11391    _scopes: BTreeSet<String>,
11392}
11393
11394impl<'a, C> common::CallBuilder
11395    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11396{
11397}
11398
11399impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11400where
11401    C: common::Connector,
11402{
11403    /// Perform the operation you have build so far.
11404    pub async fn doit(mut self) -> common::Result<(common::Response, DecapsulateResponse)> {
11405        use std::borrow::Cow;
11406        use std::io::{Read, Seek};
11407
11408        use common::{url::Params, ToParts};
11409        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11410
11411        let mut dd = common::DefaultDelegate;
11412        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11413        dlg.begin(common::MethodInfo {
11414            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.decapsulate",
11415            http_method: hyper::Method::POST,
11416        });
11417
11418        for &field in ["alt", "name"].iter() {
11419            if self._additional_params.contains_key(field) {
11420                dlg.finished(false);
11421                return Err(common::Error::FieldClash(field));
11422            }
11423        }
11424
11425        let mut params = Params::with_capacity(4 + self._additional_params.len());
11426        params.push("name", self._name);
11427
11428        params.extend(self._additional_params.iter());
11429
11430        params.push("alt", "json");
11431        let mut url = self.hub._base_url.clone() + "v1/{+name}:decapsulate";
11432        if self._scopes.is_empty() {
11433            self._scopes
11434                .insert(Scope::CloudPlatform.as_ref().to_string());
11435        }
11436
11437        #[allow(clippy::single_element_loop)]
11438        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11439            url = params.uri_replacement(url, param_name, find_this, true);
11440        }
11441        {
11442            let to_remove = ["name"];
11443            params.remove_params(&to_remove);
11444        }
11445
11446        let url = params.parse_with_url(&url);
11447
11448        let mut json_mime_type = mime::APPLICATION_JSON;
11449        let mut request_value_reader = {
11450            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11451            common::remove_json_null_values(&mut value);
11452            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11453            serde_json::to_writer(&mut dst, &value).unwrap();
11454            dst
11455        };
11456        let request_size = request_value_reader
11457            .seek(std::io::SeekFrom::End(0))
11458            .unwrap();
11459        request_value_reader
11460            .seek(std::io::SeekFrom::Start(0))
11461            .unwrap();
11462
11463        loop {
11464            let token = match self
11465                .hub
11466                .auth
11467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11468                .await
11469            {
11470                Ok(token) => token,
11471                Err(e) => match dlg.token(e) {
11472                    Ok(token) => token,
11473                    Err(e) => {
11474                        dlg.finished(false);
11475                        return Err(common::Error::MissingToken(e));
11476                    }
11477                },
11478            };
11479            request_value_reader
11480                .seek(std::io::SeekFrom::Start(0))
11481                .unwrap();
11482            let mut req_result = {
11483                let client = &self.hub.client;
11484                dlg.pre_request();
11485                let mut req_builder = hyper::Request::builder()
11486                    .method(hyper::Method::POST)
11487                    .uri(url.as_str())
11488                    .header(USER_AGENT, self.hub._user_agent.clone());
11489
11490                if let Some(token) = token.as_ref() {
11491                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11492                }
11493
11494                let request = req_builder
11495                    .header(CONTENT_TYPE, json_mime_type.to_string())
11496                    .header(CONTENT_LENGTH, request_size as u64)
11497                    .body(common::to_body(
11498                        request_value_reader.get_ref().clone().into(),
11499                    ));
11500
11501                client.request(request.unwrap()).await
11502            };
11503
11504            match req_result {
11505                Err(err) => {
11506                    if let common::Retry::After(d) = dlg.http_error(&err) {
11507                        sleep(d).await;
11508                        continue;
11509                    }
11510                    dlg.finished(false);
11511                    return Err(common::Error::HttpError(err));
11512                }
11513                Ok(res) => {
11514                    let (mut parts, body) = res.into_parts();
11515                    let mut body = common::Body::new(body);
11516                    if !parts.status.is_success() {
11517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11518                        let error = serde_json::from_str(&common::to_string(&bytes));
11519                        let response = common::to_response(parts, bytes.into());
11520
11521                        if let common::Retry::After(d) =
11522                            dlg.http_failure(&response, error.as_ref().ok())
11523                        {
11524                            sleep(d).await;
11525                            continue;
11526                        }
11527
11528                        dlg.finished(false);
11529
11530                        return Err(match error {
11531                            Ok(value) => common::Error::BadRequest(value),
11532                            _ => common::Error::Failure(response),
11533                        });
11534                    }
11535                    let response = {
11536                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11537                        let encoded = common::to_string(&bytes);
11538                        match serde_json::from_str(&encoded) {
11539                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11540                            Err(error) => {
11541                                dlg.response_json_decode_error(&encoded, &error);
11542                                return Err(common::Error::JsonDecodeError(
11543                                    encoded.to_string(),
11544                                    error,
11545                                ));
11546                            }
11547                        }
11548                    };
11549
11550                    dlg.finished(true);
11551                    return Ok(response);
11552                }
11553            }
11554        }
11555    }
11556
11557    ///
11558    /// Sets the *request* property to the given value.
11559    ///
11560    /// Even though the property as already been set when instantiating this call,
11561    /// we provide this method for API completeness.
11562    pub fn request(
11563        mut self,
11564        new_value: DecapsulateRequest,
11565    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C> {
11566        self._request = new_value;
11567        self
11568    }
11569    /// Required. The resource name of the CryptoKeyVersion to use for decapsulation.
11570    ///
11571    /// Sets the *name* path property to the given value.
11572    ///
11573    /// Even though the property as already been set when instantiating this call,
11574    /// we provide this method for API completeness.
11575    pub fn name(
11576        mut self,
11577        new_value: &str,
11578    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C> {
11579        self._name = new_value.to_string();
11580        self
11581    }
11582    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11583    /// while executing the actual API request.
11584    ///
11585    /// ````text
11586    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11587    /// ````
11588    ///
11589    /// Sets the *delegate* property to the given value.
11590    pub fn delegate(
11591        mut self,
11592        new_value: &'a mut dyn common::Delegate,
11593    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C> {
11594        self._delegate = Some(new_value);
11595        self
11596    }
11597
11598    /// Set any additional parameter of the query string used in the request.
11599    /// It should be used to set parameters which are not yet available through their own
11600    /// setters.
11601    ///
11602    /// Please note that this method must not be used to set any of the known parameters
11603    /// which have their own setter method. If done anyway, the request will fail.
11604    ///
11605    /// # Additional Parameters
11606    ///
11607    /// * *$.xgafv* (query-string) - V1 error format.
11608    /// * *access_token* (query-string) - OAuth access token.
11609    /// * *alt* (query-string) - Data format for response.
11610    /// * *callback* (query-string) - JSONP
11611    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11612    /// * *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.
11613    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11614    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11615    /// * *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.
11616    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11617    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11618    pub fn param<T>(
11619        mut self,
11620        name: T,
11621        value: T,
11622    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11623    where
11624        T: AsRef<str>,
11625    {
11626        self._additional_params
11627            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11628        self
11629    }
11630
11631    /// Identifies the authorization scope for the method you are building.
11632    ///
11633    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11634    /// [`Scope::CloudPlatform`].
11635    ///
11636    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11637    /// tokens for more than one scope.
11638    ///
11639    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11640    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11641    /// sufficient, a read-write scope will do as well.
11642    pub fn add_scope<St>(
11643        mut self,
11644        scope: St,
11645    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11646    where
11647        St: AsRef<str>,
11648    {
11649        self._scopes.insert(String::from(scope.as_ref()));
11650        self
11651    }
11652    /// Identifies the authorization scope(s) for the method you are building.
11653    ///
11654    /// See [`Self::add_scope()`] for details.
11655    pub fn add_scopes<I, St>(
11656        mut self,
11657        scopes: I,
11658    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C>
11659    where
11660        I: IntoIterator<Item = St>,
11661        St: AsRef<str>,
11662    {
11663        self._scopes
11664            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11665        self
11666    }
11667
11668    /// Removes all scopes, and no default scope will be used either.
11669    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11670    /// for details).
11671    pub fn clear_scopes(
11672        mut self,
11673    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDecapsulateCall<'a, C> {
11674        self._scopes.clear();
11675        self
11676    }
11677}
11678
11679/// Schedule a CryptoKeyVersion for destruction. Upon calling this method, CryptoKeyVersion.state will be set to DESTROY_SCHEDULED, and destroy_time will be set to the time destroy_scheduled_duration in the future. At that time, the state will automatically change to DESTROYED, and the key material will be irrevocably destroyed. Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process.
11680///
11681/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy* method supported by a *project* resource.
11682/// It is not used directly, but through a [`ProjectMethods`] instance.
11683///
11684/// # Example
11685///
11686/// Instantiate a resource method builder
11687///
11688/// ```test_harness,no_run
11689/// # extern crate hyper;
11690/// # extern crate hyper_rustls;
11691/// # extern crate google_cloudkms1 as cloudkms1;
11692/// use cloudkms1::api::DestroyCryptoKeyVersionRequest;
11693/// # async fn dox() {
11694/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11695///
11696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11697/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11698/// #     .with_native_roots()
11699/// #     .unwrap()
11700/// #     .https_only()
11701/// #     .enable_http2()
11702/// #     .build();
11703///
11704/// # let executor = hyper_util::rt::TokioExecutor::new();
11705/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11706/// #     secret,
11707/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11708/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11709/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11710/// #     ),
11711/// # ).build().await.unwrap();
11712///
11713/// # let client = hyper_util::client::legacy::Client::builder(
11714/// #     hyper_util::rt::TokioExecutor::new()
11715/// # )
11716/// # .build(
11717/// #     hyper_rustls::HttpsConnectorBuilder::new()
11718/// #         .with_native_roots()
11719/// #         .unwrap()
11720/// #         .https_or_http()
11721/// #         .enable_http2()
11722/// #         .build()
11723/// # );
11724/// # let mut hub = CloudKMS::new(client, auth);
11725/// // As the method needs a request, you would usually fill it with the desired information
11726/// // into the respective structure. Some of the parts shown here might not be applicable !
11727/// // Values shown here are possibly random and not representative !
11728/// let mut req = DestroyCryptoKeyVersionRequest::default();
11729///
11730/// // You can configure optional parameters by calling the respective setters at will, and
11731/// // execute the final call using `doit()`.
11732/// // Values shown here are possibly random and not representative !
11733/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_destroy(req, "name")
11734///              .doit().await;
11735/// # }
11736/// ```
11737pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
11738where
11739    C: 'a,
11740{
11741    hub: &'a CloudKMS<C>,
11742    _request: DestroyCryptoKeyVersionRequest,
11743    _name: String,
11744    _delegate: Option<&'a mut dyn common::Delegate>,
11745    _additional_params: HashMap<String, String>,
11746    _scopes: BTreeSet<String>,
11747}
11748
11749impl<'a, C> common::CallBuilder
11750    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
11751{
11752}
11753
11754impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
11755where
11756    C: common::Connector,
11757{
11758    /// Perform the operation you have build so far.
11759    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
11760        use std::borrow::Cow;
11761        use std::io::{Read, Seek};
11762
11763        use common::{url::Params, ToParts};
11764        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11765
11766        let mut dd = common::DefaultDelegate;
11767        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11768        dlg.begin(common::MethodInfo {
11769            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy",
11770            http_method: hyper::Method::POST,
11771        });
11772
11773        for &field in ["alt", "name"].iter() {
11774            if self._additional_params.contains_key(field) {
11775                dlg.finished(false);
11776                return Err(common::Error::FieldClash(field));
11777            }
11778        }
11779
11780        let mut params = Params::with_capacity(4 + self._additional_params.len());
11781        params.push("name", self._name);
11782
11783        params.extend(self._additional_params.iter());
11784
11785        params.push("alt", "json");
11786        let mut url = self.hub._base_url.clone() + "v1/{+name}:destroy";
11787        if self._scopes.is_empty() {
11788            self._scopes
11789                .insert(Scope::CloudPlatform.as_ref().to_string());
11790        }
11791
11792        #[allow(clippy::single_element_loop)]
11793        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11794            url = params.uri_replacement(url, param_name, find_this, true);
11795        }
11796        {
11797            let to_remove = ["name"];
11798            params.remove_params(&to_remove);
11799        }
11800
11801        let url = params.parse_with_url(&url);
11802
11803        let mut json_mime_type = mime::APPLICATION_JSON;
11804        let mut request_value_reader = {
11805            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11806            common::remove_json_null_values(&mut value);
11807            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11808            serde_json::to_writer(&mut dst, &value).unwrap();
11809            dst
11810        };
11811        let request_size = request_value_reader
11812            .seek(std::io::SeekFrom::End(0))
11813            .unwrap();
11814        request_value_reader
11815            .seek(std::io::SeekFrom::Start(0))
11816            .unwrap();
11817
11818        loop {
11819            let token = match self
11820                .hub
11821                .auth
11822                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11823                .await
11824            {
11825                Ok(token) => token,
11826                Err(e) => match dlg.token(e) {
11827                    Ok(token) => token,
11828                    Err(e) => {
11829                        dlg.finished(false);
11830                        return Err(common::Error::MissingToken(e));
11831                    }
11832                },
11833            };
11834            request_value_reader
11835                .seek(std::io::SeekFrom::Start(0))
11836                .unwrap();
11837            let mut req_result = {
11838                let client = &self.hub.client;
11839                dlg.pre_request();
11840                let mut req_builder = hyper::Request::builder()
11841                    .method(hyper::Method::POST)
11842                    .uri(url.as_str())
11843                    .header(USER_AGENT, self.hub._user_agent.clone());
11844
11845                if let Some(token) = token.as_ref() {
11846                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11847                }
11848
11849                let request = req_builder
11850                    .header(CONTENT_TYPE, json_mime_type.to_string())
11851                    .header(CONTENT_LENGTH, request_size as u64)
11852                    .body(common::to_body(
11853                        request_value_reader.get_ref().clone().into(),
11854                    ));
11855
11856                client.request(request.unwrap()).await
11857            };
11858
11859            match req_result {
11860                Err(err) => {
11861                    if let common::Retry::After(d) = dlg.http_error(&err) {
11862                        sleep(d).await;
11863                        continue;
11864                    }
11865                    dlg.finished(false);
11866                    return Err(common::Error::HttpError(err));
11867                }
11868                Ok(res) => {
11869                    let (mut parts, body) = res.into_parts();
11870                    let mut body = common::Body::new(body);
11871                    if !parts.status.is_success() {
11872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11873                        let error = serde_json::from_str(&common::to_string(&bytes));
11874                        let response = common::to_response(parts, bytes.into());
11875
11876                        if let common::Retry::After(d) =
11877                            dlg.http_failure(&response, error.as_ref().ok())
11878                        {
11879                            sleep(d).await;
11880                            continue;
11881                        }
11882
11883                        dlg.finished(false);
11884
11885                        return Err(match error {
11886                            Ok(value) => common::Error::BadRequest(value),
11887                            _ => common::Error::Failure(response),
11888                        });
11889                    }
11890                    let response = {
11891                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11892                        let encoded = common::to_string(&bytes);
11893                        match serde_json::from_str(&encoded) {
11894                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11895                            Err(error) => {
11896                                dlg.response_json_decode_error(&encoded, &error);
11897                                return Err(common::Error::JsonDecodeError(
11898                                    encoded.to_string(),
11899                                    error,
11900                                ));
11901                            }
11902                        }
11903                    };
11904
11905                    dlg.finished(true);
11906                    return Ok(response);
11907                }
11908            }
11909        }
11910    }
11911
11912    ///
11913    /// Sets the *request* property to the given value.
11914    ///
11915    /// Even though the property as already been set when instantiating this call,
11916    /// we provide this method for API completeness.
11917    pub fn request(
11918        mut self,
11919        new_value: DestroyCryptoKeyVersionRequest,
11920    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
11921        self._request = new_value;
11922        self
11923    }
11924    /// Required. The resource name of the CryptoKeyVersion to destroy.
11925    ///
11926    /// Sets the *name* path property to the given value.
11927    ///
11928    /// Even though the property as already been set when instantiating this call,
11929    /// we provide this method for API completeness.
11930    pub fn name(
11931        mut self,
11932        new_value: &str,
11933    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
11934        self._name = new_value.to_string();
11935        self
11936    }
11937    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11938    /// while executing the actual API request.
11939    ///
11940    /// ````text
11941    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11942    /// ````
11943    ///
11944    /// Sets the *delegate* property to the given value.
11945    pub fn delegate(
11946        mut self,
11947        new_value: &'a mut dyn common::Delegate,
11948    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
11949        self._delegate = Some(new_value);
11950        self
11951    }
11952
11953    /// Set any additional parameter of the query string used in the request.
11954    /// It should be used to set parameters which are not yet available through their own
11955    /// setters.
11956    ///
11957    /// Please note that this method must not be used to set any of the known parameters
11958    /// which have their own setter method. If done anyway, the request will fail.
11959    ///
11960    /// # Additional Parameters
11961    ///
11962    /// * *$.xgafv* (query-string) - V1 error format.
11963    /// * *access_token* (query-string) - OAuth access token.
11964    /// * *alt* (query-string) - Data format for response.
11965    /// * *callback* (query-string) - JSONP
11966    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11967    /// * *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.
11968    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11969    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11970    /// * *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.
11971    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11972    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11973    pub fn param<T>(
11974        mut self,
11975        name: T,
11976        value: T,
11977    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
11978    where
11979        T: AsRef<str>,
11980    {
11981        self._additional_params
11982            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11983        self
11984    }
11985
11986    /// Identifies the authorization scope for the method you are building.
11987    ///
11988    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11989    /// [`Scope::CloudPlatform`].
11990    ///
11991    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11992    /// tokens for more than one scope.
11993    ///
11994    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11995    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11996    /// sufficient, a read-write scope will do as well.
11997    pub fn add_scope<St>(
11998        mut self,
11999        scope: St,
12000    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
12001    where
12002        St: AsRef<str>,
12003    {
12004        self._scopes.insert(String::from(scope.as_ref()));
12005        self
12006    }
12007    /// Identifies the authorization scope(s) for the method you are building.
12008    ///
12009    /// See [`Self::add_scope()`] for details.
12010    pub fn add_scopes<I, St>(
12011        mut self,
12012        scopes: I,
12013    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
12014    where
12015        I: IntoIterator<Item = St>,
12016        St: AsRef<str>,
12017    {
12018        self._scopes
12019            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12020        self
12021    }
12022
12023    /// Removes all scopes, and no default scope will be used either.
12024    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12025    /// for details).
12026    pub fn clear_scopes(
12027        mut self,
12028    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
12029        self._scopes.clear();
12030        self
12031    }
12032}
12033
12034/// Returns metadata for a given CryptoKeyVersion.
12035///
12036/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.get* method supported by a *project* resource.
12037/// It is not used directly, but through a [`ProjectMethods`] instance.
12038///
12039/// # Example
12040///
12041/// Instantiate a resource method builder
12042///
12043/// ```test_harness,no_run
12044/// # extern crate hyper;
12045/// # extern crate hyper_rustls;
12046/// # extern crate google_cloudkms1 as cloudkms1;
12047/// # async fn dox() {
12048/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12049///
12050/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12051/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12052/// #     .with_native_roots()
12053/// #     .unwrap()
12054/// #     .https_only()
12055/// #     .enable_http2()
12056/// #     .build();
12057///
12058/// # let executor = hyper_util::rt::TokioExecutor::new();
12059/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12060/// #     secret,
12061/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12062/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12063/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12064/// #     ),
12065/// # ).build().await.unwrap();
12066///
12067/// # let client = hyper_util::client::legacy::Client::builder(
12068/// #     hyper_util::rt::TokioExecutor::new()
12069/// # )
12070/// # .build(
12071/// #     hyper_rustls::HttpsConnectorBuilder::new()
12072/// #         .with_native_roots()
12073/// #         .unwrap()
12074/// #         .https_or_http()
12075/// #         .enable_http2()
12076/// #         .build()
12077/// # );
12078/// # let mut hub = CloudKMS::new(client, auth);
12079/// // You can configure optional parameters by calling the respective setters at will, and
12080/// // execute the final call using `doit()`.
12081/// // Values shown here are possibly random and not representative !
12082/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get("name")
12083///              .doit().await;
12084/// # }
12085/// ```
12086pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
12087where
12088    C: 'a,
12089{
12090    hub: &'a CloudKMS<C>,
12091    _name: String,
12092    _delegate: Option<&'a mut dyn common::Delegate>,
12093    _additional_params: HashMap<String, String>,
12094    _scopes: BTreeSet<String>,
12095}
12096
12097impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {}
12098
12099impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
12100where
12101    C: common::Connector,
12102{
12103    /// Perform the operation you have build so far.
12104    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
12105        use std::borrow::Cow;
12106        use std::io::{Read, Seek};
12107
12108        use common::{url::Params, ToParts};
12109        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12110
12111        let mut dd = common::DefaultDelegate;
12112        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12113        dlg.begin(common::MethodInfo {
12114            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get",
12115            http_method: hyper::Method::GET,
12116        });
12117
12118        for &field in ["alt", "name"].iter() {
12119            if self._additional_params.contains_key(field) {
12120                dlg.finished(false);
12121                return Err(common::Error::FieldClash(field));
12122            }
12123        }
12124
12125        let mut params = Params::with_capacity(3 + self._additional_params.len());
12126        params.push("name", self._name);
12127
12128        params.extend(self._additional_params.iter());
12129
12130        params.push("alt", "json");
12131        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12132        if self._scopes.is_empty() {
12133            self._scopes
12134                .insert(Scope::CloudPlatform.as_ref().to_string());
12135        }
12136
12137        #[allow(clippy::single_element_loop)]
12138        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12139            url = params.uri_replacement(url, param_name, find_this, true);
12140        }
12141        {
12142            let to_remove = ["name"];
12143            params.remove_params(&to_remove);
12144        }
12145
12146        let url = params.parse_with_url(&url);
12147
12148        loop {
12149            let token = match self
12150                .hub
12151                .auth
12152                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12153                .await
12154            {
12155                Ok(token) => token,
12156                Err(e) => match dlg.token(e) {
12157                    Ok(token) => token,
12158                    Err(e) => {
12159                        dlg.finished(false);
12160                        return Err(common::Error::MissingToken(e));
12161                    }
12162                },
12163            };
12164            let mut req_result = {
12165                let client = &self.hub.client;
12166                dlg.pre_request();
12167                let mut req_builder = hyper::Request::builder()
12168                    .method(hyper::Method::GET)
12169                    .uri(url.as_str())
12170                    .header(USER_AGENT, self.hub._user_agent.clone());
12171
12172                if let Some(token) = token.as_ref() {
12173                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12174                }
12175
12176                let request = req_builder
12177                    .header(CONTENT_LENGTH, 0_u64)
12178                    .body(common::to_body::<String>(None));
12179
12180                client.request(request.unwrap()).await
12181            };
12182
12183            match req_result {
12184                Err(err) => {
12185                    if let common::Retry::After(d) = dlg.http_error(&err) {
12186                        sleep(d).await;
12187                        continue;
12188                    }
12189                    dlg.finished(false);
12190                    return Err(common::Error::HttpError(err));
12191                }
12192                Ok(res) => {
12193                    let (mut parts, body) = res.into_parts();
12194                    let mut body = common::Body::new(body);
12195                    if !parts.status.is_success() {
12196                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12197                        let error = serde_json::from_str(&common::to_string(&bytes));
12198                        let response = common::to_response(parts, bytes.into());
12199
12200                        if let common::Retry::After(d) =
12201                            dlg.http_failure(&response, error.as_ref().ok())
12202                        {
12203                            sleep(d).await;
12204                            continue;
12205                        }
12206
12207                        dlg.finished(false);
12208
12209                        return Err(match error {
12210                            Ok(value) => common::Error::BadRequest(value),
12211                            _ => common::Error::Failure(response),
12212                        });
12213                    }
12214                    let response = {
12215                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12216                        let encoded = common::to_string(&bytes);
12217                        match serde_json::from_str(&encoded) {
12218                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12219                            Err(error) => {
12220                                dlg.response_json_decode_error(&encoded, &error);
12221                                return Err(common::Error::JsonDecodeError(
12222                                    encoded.to_string(),
12223                                    error,
12224                                ));
12225                            }
12226                        }
12227                    };
12228
12229                    dlg.finished(true);
12230                    return Ok(response);
12231                }
12232            }
12233        }
12234    }
12235
12236    /// Required. The name of the CryptoKeyVersion to get.
12237    ///
12238    /// Sets the *name* path property to the given value.
12239    ///
12240    /// Even though the property as already been set when instantiating this call,
12241    /// we provide this method for API completeness.
12242    pub fn name(
12243        mut self,
12244        new_value: &str,
12245    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
12246        self._name = new_value.to_string();
12247        self
12248    }
12249    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12250    /// while executing the actual API request.
12251    ///
12252    /// ````text
12253    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12254    /// ````
12255    ///
12256    /// Sets the *delegate* property to the given value.
12257    pub fn delegate(
12258        mut self,
12259        new_value: &'a mut dyn common::Delegate,
12260    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
12261        self._delegate = Some(new_value);
12262        self
12263    }
12264
12265    /// Set any additional parameter of the query string used in the request.
12266    /// It should be used to set parameters which are not yet available through their own
12267    /// setters.
12268    ///
12269    /// Please note that this method must not be used to set any of the known parameters
12270    /// which have their own setter method. If done anyway, the request will fail.
12271    ///
12272    /// # Additional Parameters
12273    ///
12274    /// * *$.xgafv* (query-string) - V1 error format.
12275    /// * *access_token* (query-string) - OAuth access token.
12276    /// * *alt* (query-string) - Data format for response.
12277    /// * *callback* (query-string) - JSONP
12278    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12279    /// * *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.
12280    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12281    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12282    /// * *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.
12283    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12284    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12285    pub fn param<T>(
12286        mut self,
12287        name: T,
12288        value: T,
12289    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
12290    where
12291        T: AsRef<str>,
12292    {
12293        self._additional_params
12294            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12295        self
12296    }
12297
12298    /// Identifies the authorization scope for the method you are building.
12299    ///
12300    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12301    /// [`Scope::CloudPlatform`].
12302    ///
12303    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12304    /// tokens for more than one scope.
12305    ///
12306    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12307    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12308    /// sufficient, a read-write scope will do as well.
12309    pub fn add_scope<St>(
12310        mut self,
12311        scope: St,
12312    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
12313    where
12314        St: AsRef<str>,
12315    {
12316        self._scopes.insert(String::from(scope.as_ref()));
12317        self
12318    }
12319    /// Identifies the authorization scope(s) for the method you are building.
12320    ///
12321    /// See [`Self::add_scope()`] for details.
12322    pub fn add_scopes<I, St>(
12323        mut self,
12324        scopes: I,
12325    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
12326    where
12327        I: IntoIterator<Item = St>,
12328        St: AsRef<str>,
12329    {
12330        self._scopes
12331            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12332        self
12333    }
12334
12335    /// Removes all scopes, and no default scope will be used either.
12336    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12337    /// for details).
12338    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
12339        self._scopes.clear();
12340        self
12341    }
12342}
12343
12344/// Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.
12345///
12346/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.getPublicKey* method supported by a *project* resource.
12347/// It is not used directly, but through a [`ProjectMethods`] instance.
12348///
12349/// # Example
12350///
12351/// Instantiate a resource method builder
12352///
12353/// ```test_harness,no_run
12354/// # extern crate hyper;
12355/// # extern crate hyper_rustls;
12356/// # extern crate google_cloudkms1 as cloudkms1;
12357/// # async fn dox() {
12358/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12359///
12360/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12361/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12362/// #     .with_native_roots()
12363/// #     .unwrap()
12364/// #     .https_only()
12365/// #     .enable_http2()
12366/// #     .build();
12367///
12368/// # let executor = hyper_util::rt::TokioExecutor::new();
12369/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12370/// #     secret,
12371/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12372/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12373/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12374/// #     ),
12375/// # ).build().await.unwrap();
12376///
12377/// # let client = hyper_util::client::legacy::Client::builder(
12378/// #     hyper_util::rt::TokioExecutor::new()
12379/// # )
12380/// # .build(
12381/// #     hyper_rustls::HttpsConnectorBuilder::new()
12382/// #         .with_native_roots()
12383/// #         .unwrap()
12384/// #         .https_or_http()
12385/// #         .enable_http2()
12386/// #         .build()
12387/// # );
12388/// # let mut hub = CloudKMS::new(client, auth);
12389/// // You can configure optional parameters by calling the respective setters at will, and
12390/// // execute the final call using `doit()`.
12391/// // Values shown here are possibly random and not representative !
12392/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get_public_key("name")
12393///              .public_key_format("et")
12394///              .doit().await;
12395/// # }
12396/// ```
12397pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12398where
12399    C: 'a,
12400{
12401    hub: &'a CloudKMS<C>,
12402    _name: String,
12403    _public_key_format: Option<String>,
12404    _delegate: Option<&'a mut dyn common::Delegate>,
12405    _additional_params: HashMap<String, String>,
12406    _scopes: BTreeSet<String>,
12407}
12408
12409impl<'a, C> common::CallBuilder
12410    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12411{
12412}
12413
12414impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12415where
12416    C: common::Connector,
12417{
12418    /// Perform the operation you have build so far.
12419    pub async fn doit(mut self) -> common::Result<(common::Response, PublicKey)> {
12420        use std::borrow::Cow;
12421        use std::io::{Read, Seek};
12422
12423        use common::{url::Params, ToParts};
12424        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12425
12426        let mut dd = common::DefaultDelegate;
12427        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12428        dlg.begin(common::MethodInfo {
12429            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.getPublicKey",
12430            http_method: hyper::Method::GET,
12431        });
12432
12433        for &field in ["alt", "name", "publicKeyFormat"].iter() {
12434            if self._additional_params.contains_key(field) {
12435                dlg.finished(false);
12436                return Err(common::Error::FieldClash(field));
12437            }
12438        }
12439
12440        let mut params = Params::with_capacity(4 + self._additional_params.len());
12441        params.push("name", self._name);
12442        if let Some(value) = self._public_key_format.as_ref() {
12443            params.push("publicKeyFormat", value);
12444        }
12445
12446        params.extend(self._additional_params.iter());
12447
12448        params.push("alt", "json");
12449        let mut url = self.hub._base_url.clone() + "v1/{+name}/publicKey";
12450        if self._scopes.is_empty() {
12451            self._scopes
12452                .insert(Scope::CloudPlatform.as_ref().to_string());
12453        }
12454
12455        #[allow(clippy::single_element_loop)]
12456        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12457            url = params.uri_replacement(url, param_name, find_this, true);
12458        }
12459        {
12460            let to_remove = ["name"];
12461            params.remove_params(&to_remove);
12462        }
12463
12464        let url = params.parse_with_url(&url);
12465
12466        loop {
12467            let token = match self
12468                .hub
12469                .auth
12470                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12471                .await
12472            {
12473                Ok(token) => token,
12474                Err(e) => match dlg.token(e) {
12475                    Ok(token) => token,
12476                    Err(e) => {
12477                        dlg.finished(false);
12478                        return Err(common::Error::MissingToken(e));
12479                    }
12480                },
12481            };
12482            let mut req_result = {
12483                let client = &self.hub.client;
12484                dlg.pre_request();
12485                let mut req_builder = hyper::Request::builder()
12486                    .method(hyper::Method::GET)
12487                    .uri(url.as_str())
12488                    .header(USER_AGENT, self.hub._user_agent.clone());
12489
12490                if let Some(token) = token.as_ref() {
12491                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12492                }
12493
12494                let request = req_builder
12495                    .header(CONTENT_LENGTH, 0_u64)
12496                    .body(common::to_body::<String>(None));
12497
12498                client.request(request.unwrap()).await
12499            };
12500
12501            match req_result {
12502                Err(err) => {
12503                    if let common::Retry::After(d) = dlg.http_error(&err) {
12504                        sleep(d).await;
12505                        continue;
12506                    }
12507                    dlg.finished(false);
12508                    return Err(common::Error::HttpError(err));
12509                }
12510                Ok(res) => {
12511                    let (mut parts, body) = res.into_parts();
12512                    let mut body = common::Body::new(body);
12513                    if !parts.status.is_success() {
12514                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12515                        let error = serde_json::from_str(&common::to_string(&bytes));
12516                        let response = common::to_response(parts, bytes.into());
12517
12518                        if let common::Retry::After(d) =
12519                            dlg.http_failure(&response, error.as_ref().ok())
12520                        {
12521                            sleep(d).await;
12522                            continue;
12523                        }
12524
12525                        dlg.finished(false);
12526
12527                        return Err(match error {
12528                            Ok(value) => common::Error::BadRequest(value),
12529                            _ => common::Error::Failure(response),
12530                        });
12531                    }
12532                    let response = {
12533                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12534                        let encoded = common::to_string(&bytes);
12535                        match serde_json::from_str(&encoded) {
12536                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12537                            Err(error) => {
12538                                dlg.response_json_decode_error(&encoded, &error);
12539                                return Err(common::Error::JsonDecodeError(
12540                                    encoded.to_string(),
12541                                    error,
12542                                ));
12543                            }
12544                        }
12545                    };
12546
12547                    dlg.finished(true);
12548                    return Ok(response);
12549                }
12550            }
12551        }
12552    }
12553
12554    /// Required. The name of the CryptoKeyVersion public key to get.
12555    ///
12556    /// Sets the *name* path property to the given value.
12557    ///
12558    /// Even though the property as already been set when instantiating this call,
12559    /// we provide this method for API completeness.
12560    pub fn name(
12561        mut self,
12562        new_value: &str,
12563    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
12564        self._name = new_value.to_string();
12565        self
12566    }
12567    /// Optional. The PublicKey format specified by the user. This field is required for PQC algorithms. If specified, the public key will be exported through the public_key field in the requested format. Otherwise, the pem field will be populated for non-PQC algorithms, and an error will be returned for PQC algorithms.
12568    ///
12569    /// Sets the *public key format* query property to the given value.
12570    pub fn public_key_format(
12571        mut self,
12572        new_value: &str,
12573    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
12574        self._public_key_format = Some(new_value.to_string());
12575        self
12576    }
12577    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12578    /// while executing the actual API request.
12579    ///
12580    /// ````text
12581    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12582    /// ````
12583    ///
12584    /// Sets the *delegate* property to the given value.
12585    pub fn delegate(
12586        mut self,
12587        new_value: &'a mut dyn common::Delegate,
12588    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
12589        self._delegate = Some(new_value);
12590        self
12591    }
12592
12593    /// Set any additional parameter of the query string used in the request.
12594    /// It should be used to set parameters which are not yet available through their own
12595    /// setters.
12596    ///
12597    /// Please note that this method must not be used to set any of the known parameters
12598    /// which have their own setter method. If done anyway, the request will fail.
12599    ///
12600    /// # Additional Parameters
12601    ///
12602    /// * *$.xgafv* (query-string) - V1 error format.
12603    /// * *access_token* (query-string) - OAuth access token.
12604    /// * *alt* (query-string) - Data format for response.
12605    /// * *callback* (query-string) - JSONP
12606    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12607    /// * *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.
12608    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12609    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12610    /// * *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.
12611    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12612    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12613    pub fn param<T>(
12614        mut self,
12615        name: T,
12616        value: T,
12617    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12618    where
12619        T: AsRef<str>,
12620    {
12621        self._additional_params
12622            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12623        self
12624    }
12625
12626    /// Identifies the authorization scope for the method you are building.
12627    ///
12628    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12629    /// [`Scope::CloudPlatform`].
12630    ///
12631    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12632    /// tokens for more than one scope.
12633    ///
12634    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12635    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12636    /// sufficient, a read-write scope will do as well.
12637    pub fn add_scope<St>(
12638        mut self,
12639        scope: St,
12640    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12641    where
12642        St: AsRef<str>,
12643    {
12644        self._scopes.insert(String::from(scope.as_ref()));
12645        self
12646    }
12647    /// Identifies the authorization scope(s) for the method you are building.
12648    ///
12649    /// See [`Self::add_scope()`] for details.
12650    pub fn add_scopes<I, St>(
12651        mut self,
12652        scopes: I,
12653    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
12654    where
12655        I: IntoIterator<Item = St>,
12656        St: AsRef<str>,
12657    {
12658        self._scopes
12659            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12660        self
12661    }
12662
12663    /// Removes all scopes, and no default scope will be used either.
12664    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12665    /// for details).
12666    pub fn clear_scopes(
12667        mut self,
12668    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
12669        self._scopes.clear();
12670        self
12671    }
12672}
12673
12674/// Import wrapped key material into a CryptoKeyVersion. All requests must specify a CryptoKey. If a CryptoKeyVersion is additionally specified in the request, key material will be reimported into that version. Otherwise, a new version will be created, and will be assigned the next sequential id within the CryptoKey.
12675///
12676/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.import* method supported by a *project* resource.
12677/// It is not used directly, but through a [`ProjectMethods`] instance.
12678///
12679/// # Example
12680///
12681/// Instantiate a resource method builder
12682///
12683/// ```test_harness,no_run
12684/// # extern crate hyper;
12685/// # extern crate hyper_rustls;
12686/// # extern crate google_cloudkms1 as cloudkms1;
12687/// use cloudkms1::api::ImportCryptoKeyVersionRequest;
12688/// # async fn dox() {
12689/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12690///
12691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12693/// #     .with_native_roots()
12694/// #     .unwrap()
12695/// #     .https_only()
12696/// #     .enable_http2()
12697/// #     .build();
12698///
12699/// # let executor = hyper_util::rt::TokioExecutor::new();
12700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12701/// #     secret,
12702/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12703/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12704/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12705/// #     ),
12706/// # ).build().await.unwrap();
12707///
12708/// # let client = hyper_util::client::legacy::Client::builder(
12709/// #     hyper_util::rt::TokioExecutor::new()
12710/// # )
12711/// # .build(
12712/// #     hyper_rustls::HttpsConnectorBuilder::new()
12713/// #         .with_native_roots()
12714/// #         .unwrap()
12715/// #         .https_or_http()
12716/// #         .enable_http2()
12717/// #         .build()
12718/// # );
12719/// # let mut hub = CloudKMS::new(client, auth);
12720/// // As the method needs a request, you would usually fill it with the desired information
12721/// // into the respective structure. Some of the parts shown here might not be applicable !
12722/// // Values shown here are possibly random and not representative !
12723/// let mut req = ImportCryptoKeyVersionRequest::default();
12724///
12725/// // You can configure optional parameters by calling the respective setters at will, and
12726/// // execute the final call using `doit()`.
12727/// // Values shown here are possibly random and not representative !
12728/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_import(req, "parent")
12729///              .doit().await;
12730/// # }
12731/// ```
12732pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
12733where
12734    C: 'a,
12735{
12736    hub: &'a CloudKMS<C>,
12737    _request: ImportCryptoKeyVersionRequest,
12738    _parent: String,
12739    _delegate: Option<&'a mut dyn common::Delegate>,
12740    _additional_params: HashMap<String, String>,
12741    _scopes: BTreeSet<String>,
12742}
12743
12744impl<'a, C> common::CallBuilder
12745    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
12746{
12747}
12748
12749impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
12750where
12751    C: common::Connector,
12752{
12753    /// Perform the operation you have build so far.
12754    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
12755        use std::borrow::Cow;
12756        use std::io::{Read, Seek};
12757
12758        use common::{url::Params, ToParts};
12759        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12760
12761        let mut dd = common::DefaultDelegate;
12762        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12763        dlg.begin(common::MethodInfo {
12764            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.import",
12765            http_method: hyper::Method::POST,
12766        });
12767
12768        for &field in ["alt", "parent"].iter() {
12769            if self._additional_params.contains_key(field) {
12770                dlg.finished(false);
12771                return Err(common::Error::FieldClash(field));
12772            }
12773        }
12774
12775        let mut params = Params::with_capacity(4 + self._additional_params.len());
12776        params.push("parent", self._parent);
12777
12778        params.extend(self._additional_params.iter());
12779
12780        params.push("alt", "json");
12781        let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions:import";
12782        if self._scopes.is_empty() {
12783            self._scopes
12784                .insert(Scope::CloudPlatform.as_ref().to_string());
12785        }
12786
12787        #[allow(clippy::single_element_loop)]
12788        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12789            url = params.uri_replacement(url, param_name, find_this, true);
12790        }
12791        {
12792            let to_remove = ["parent"];
12793            params.remove_params(&to_remove);
12794        }
12795
12796        let url = params.parse_with_url(&url);
12797
12798        let mut json_mime_type = mime::APPLICATION_JSON;
12799        let mut request_value_reader = {
12800            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12801            common::remove_json_null_values(&mut value);
12802            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12803            serde_json::to_writer(&mut dst, &value).unwrap();
12804            dst
12805        };
12806        let request_size = request_value_reader
12807            .seek(std::io::SeekFrom::End(0))
12808            .unwrap();
12809        request_value_reader
12810            .seek(std::io::SeekFrom::Start(0))
12811            .unwrap();
12812
12813        loop {
12814            let token = match self
12815                .hub
12816                .auth
12817                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12818                .await
12819            {
12820                Ok(token) => token,
12821                Err(e) => match dlg.token(e) {
12822                    Ok(token) => token,
12823                    Err(e) => {
12824                        dlg.finished(false);
12825                        return Err(common::Error::MissingToken(e));
12826                    }
12827                },
12828            };
12829            request_value_reader
12830                .seek(std::io::SeekFrom::Start(0))
12831                .unwrap();
12832            let mut req_result = {
12833                let client = &self.hub.client;
12834                dlg.pre_request();
12835                let mut req_builder = hyper::Request::builder()
12836                    .method(hyper::Method::POST)
12837                    .uri(url.as_str())
12838                    .header(USER_AGENT, self.hub._user_agent.clone());
12839
12840                if let Some(token) = token.as_ref() {
12841                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12842                }
12843
12844                let request = req_builder
12845                    .header(CONTENT_TYPE, json_mime_type.to_string())
12846                    .header(CONTENT_LENGTH, request_size as u64)
12847                    .body(common::to_body(
12848                        request_value_reader.get_ref().clone().into(),
12849                    ));
12850
12851                client.request(request.unwrap()).await
12852            };
12853
12854            match req_result {
12855                Err(err) => {
12856                    if let common::Retry::After(d) = dlg.http_error(&err) {
12857                        sleep(d).await;
12858                        continue;
12859                    }
12860                    dlg.finished(false);
12861                    return Err(common::Error::HttpError(err));
12862                }
12863                Ok(res) => {
12864                    let (mut parts, body) = res.into_parts();
12865                    let mut body = common::Body::new(body);
12866                    if !parts.status.is_success() {
12867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12868                        let error = serde_json::from_str(&common::to_string(&bytes));
12869                        let response = common::to_response(parts, bytes.into());
12870
12871                        if let common::Retry::After(d) =
12872                            dlg.http_failure(&response, error.as_ref().ok())
12873                        {
12874                            sleep(d).await;
12875                            continue;
12876                        }
12877
12878                        dlg.finished(false);
12879
12880                        return Err(match error {
12881                            Ok(value) => common::Error::BadRequest(value),
12882                            _ => common::Error::Failure(response),
12883                        });
12884                    }
12885                    let response = {
12886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12887                        let encoded = common::to_string(&bytes);
12888                        match serde_json::from_str(&encoded) {
12889                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12890                            Err(error) => {
12891                                dlg.response_json_decode_error(&encoded, &error);
12892                                return Err(common::Error::JsonDecodeError(
12893                                    encoded.to_string(),
12894                                    error,
12895                                ));
12896                            }
12897                        }
12898                    };
12899
12900                    dlg.finished(true);
12901                    return Ok(response);
12902                }
12903            }
12904        }
12905    }
12906
12907    ///
12908    /// Sets the *request* property to the given value.
12909    ///
12910    /// Even though the property as already been set when instantiating this call,
12911    /// we provide this method for API completeness.
12912    pub fn request(
12913        mut self,
12914        new_value: ImportCryptoKeyVersionRequest,
12915    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
12916        self._request = new_value;
12917        self
12918    }
12919    /// Required. The name of the CryptoKey to be imported into. The create permission is only required on this key when creating a new CryptoKeyVersion.
12920    ///
12921    /// Sets the *parent* path property to the given value.
12922    ///
12923    /// Even though the property as already been set when instantiating this call,
12924    /// we provide this method for API completeness.
12925    pub fn parent(
12926        mut self,
12927        new_value: &str,
12928    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
12929        self._parent = new_value.to_string();
12930        self
12931    }
12932    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12933    /// while executing the actual API request.
12934    ///
12935    /// ````text
12936    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12937    /// ````
12938    ///
12939    /// Sets the *delegate* property to the given value.
12940    pub fn delegate(
12941        mut self,
12942        new_value: &'a mut dyn common::Delegate,
12943    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
12944        self._delegate = Some(new_value);
12945        self
12946    }
12947
12948    /// Set any additional parameter of the query string used in the request.
12949    /// It should be used to set parameters which are not yet available through their own
12950    /// setters.
12951    ///
12952    /// Please note that this method must not be used to set any of the known parameters
12953    /// which have their own setter method. If done anyway, the request will fail.
12954    ///
12955    /// # Additional Parameters
12956    ///
12957    /// * *$.xgafv* (query-string) - V1 error format.
12958    /// * *access_token* (query-string) - OAuth access token.
12959    /// * *alt* (query-string) - Data format for response.
12960    /// * *callback* (query-string) - JSONP
12961    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12962    /// * *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.
12963    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12964    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12965    /// * *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.
12966    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12967    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12968    pub fn param<T>(
12969        mut self,
12970        name: T,
12971        value: T,
12972    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
12973    where
12974        T: AsRef<str>,
12975    {
12976        self._additional_params
12977            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12978        self
12979    }
12980
12981    /// Identifies the authorization scope for the method you are building.
12982    ///
12983    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12984    /// [`Scope::CloudPlatform`].
12985    ///
12986    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12987    /// tokens for more than one scope.
12988    ///
12989    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12990    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12991    /// sufficient, a read-write scope will do as well.
12992    pub fn add_scope<St>(
12993        mut self,
12994        scope: St,
12995    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
12996    where
12997        St: AsRef<str>,
12998    {
12999        self._scopes.insert(String::from(scope.as_ref()));
13000        self
13001    }
13002    /// Identifies the authorization scope(s) for the method you are building.
13003    ///
13004    /// See [`Self::add_scope()`] for details.
13005    pub fn add_scopes<I, St>(
13006        mut self,
13007        scopes: I,
13008    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
13009    where
13010        I: IntoIterator<Item = St>,
13011        St: AsRef<str>,
13012    {
13013        self._scopes
13014            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13015        self
13016    }
13017
13018    /// Removes all scopes, and no default scope will be used either.
13019    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13020    /// for details).
13021    pub fn clear_scopes(
13022        mut self,
13023    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
13024        self._scopes.clear();
13025        self
13026    }
13027}
13028
13029/// Lists CryptoKeyVersions.
13030///
13031/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.list* method supported by a *project* resource.
13032/// It is not used directly, but through a [`ProjectMethods`] instance.
13033///
13034/// # Example
13035///
13036/// Instantiate a resource method builder
13037///
13038/// ```test_harness,no_run
13039/// # extern crate hyper;
13040/// # extern crate hyper_rustls;
13041/// # extern crate google_cloudkms1 as cloudkms1;
13042/// # async fn dox() {
13043/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13044///
13045/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13046/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13047/// #     .with_native_roots()
13048/// #     .unwrap()
13049/// #     .https_only()
13050/// #     .enable_http2()
13051/// #     .build();
13052///
13053/// # let executor = hyper_util::rt::TokioExecutor::new();
13054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13055/// #     secret,
13056/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13057/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13058/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13059/// #     ),
13060/// # ).build().await.unwrap();
13061///
13062/// # let client = hyper_util::client::legacy::Client::builder(
13063/// #     hyper_util::rt::TokioExecutor::new()
13064/// # )
13065/// # .build(
13066/// #     hyper_rustls::HttpsConnectorBuilder::new()
13067/// #         .with_native_roots()
13068/// #         .unwrap()
13069/// #         .https_or_http()
13070/// #         .enable_http2()
13071/// #         .build()
13072/// # );
13073/// # let mut hub = CloudKMS::new(client, auth);
13074/// // You can configure optional parameters by calling the respective setters at will, and
13075/// // execute the final call using `doit()`.
13076/// // Values shown here are possibly random and not representative !
13077/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_list("parent")
13078///              .view("et")
13079///              .page_token("vero")
13080///              .page_size(-31)
13081///              .order_by("sed")
13082///              .filter("duo")
13083///              .doit().await;
13084/// # }
13085/// ```
13086pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
13087where
13088    C: 'a,
13089{
13090    hub: &'a CloudKMS<C>,
13091    _parent: String,
13092    _view: Option<String>,
13093    _page_token: Option<String>,
13094    _page_size: Option<i32>,
13095    _order_by: Option<String>,
13096    _filter: Option<String>,
13097    _delegate: Option<&'a mut dyn common::Delegate>,
13098    _additional_params: HashMap<String, String>,
13099    _scopes: BTreeSet<String>,
13100}
13101
13102impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {}
13103
13104impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
13105where
13106    C: common::Connector,
13107{
13108    /// Perform the operation you have build so far.
13109    pub async fn doit(
13110        mut self,
13111    ) -> common::Result<(common::Response, ListCryptoKeyVersionsResponse)> {
13112        use std::borrow::Cow;
13113        use std::io::{Read, Seek};
13114
13115        use common::{url::Params, ToParts};
13116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13117
13118        let mut dd = common::DefaultDelegate;
13119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13120        dlg.begin(common::MethodInfo {
13121            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list",
13122            http_method: hyper::Method::GET,
13123        });
13124
13125        for &field in [
13126            "alt",
13127            "parent",
13128            "view",
13129            "pageToken",
13130            "pageSize",
13131            "orderBy",
13132            "filter",
13133        ]
13134        .iter()
13135        {
13136            if self._additional_params.contains_key(field) {
13137                dlg.finished(false);
13138                return Err(common::Error::FieldClash(field));
13139            }
13140        }
13141
13142        let mut params = Params::with_capacity(8 + self._additional_params.len());
13143        params.push("parent", self._parent);
13144        if let Some(value) = self._view.as_ref() {
13145            params.push("view", value);
13146        }
13147        if let Some(value) = self._page_token.as_ref() {
13148            params.push("pageToken", value);
13149        }
13150        if let Some(value) = self._page_size.as_ref() {
13151            params.push("pageSize", value.to_string());
13152        }
13153        if let Some(value) = self._order_by.as_ref() {
13154            params.push("orderBy", value);
13155        }
13156        if let Some(value) = self._filter.as_ref() {
13157            params.push("filter", value);
13158        }
13159
13160        params.extend(self._additional_params.iter());
13161
13162        params.push("alt", "json");
13163        let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions";
13164        if self._scopes.is_empty() {
13165            self._scopes
13166                .insert(Scope::CloudPlatform.as_ref().to_string());
13167        }
13168
13169        #[allow(clippy::single_element_loop)]
13170        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13171            url = params.uri_replacement(url, param_name, find_this, true);
13172        }
13173        {
13174            let to_remove = ["parent"];
13175            params.remove_params(&to_remove);
13176        }
13177
13178        let url = params.parse_with_url(&url);
13179
13180        loop {
13181            let token = match self
13182                .hub
13183                .auth
13184                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13185                .await
13186            {
13187                Ok(token) => token,
13188                Err(e) => match dlg.token(e) {
13189                    Ok(token) => token,
13190                    Err(e) => {
13191                        dlg.finished(false);
13192                        return Err(common::Error::MissingToken(e));
13193                    }
13194                },
13195            };
13196            let mut req_result = {
13197                let client = &self.hub.client;
13198                dlg.pre_request();
13199                let mut req_builder = hyper::Request::builder()
13200                    .method(hyper::Method::GET)
13201                    .uri(url.as_str())
13202                    .header(USER_AGENT, self.hub._user_agent.clone());
13203
13204                if let Some(token) = token.as_ref() {
13205                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13206                }
13207
13208                let request = req_builder
13209                    .header(CONTENT_LENGTH, 0_u64)
13210                    .body(common::to_body::<String>(None));
13211
13212                client.request(request.unwrap()).await
13213            };
13214
13215            match req_result {
13216                Err(err) => {
13217                    if let common::Retry::After(d) = dlg.http_error(&err) {
13218                        sleep(d).await;
13219                        continue;
13220                    }
13221                    dlg.finished(false);
13222                    return Err(common::Error::HttpError(err));
13223                }
13224                Ok(res) => {
13225                    let (mut parts, body) = res.into_parts();
13226                    let mut body = common::Body::new(body);
13227                    if !parts.status.is_success() {
13228                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13229                        let error = serde_json::from_str(&common::to_string(&bytes));
13230                        let response = common::to_response(parts, bytes.into());
13231
13232                        if let common::Retry::After(d) =
13233                            dlg.http_failure(&response, error.as_ref().ok())
13234                        {
13235                            sleep(d).await;
13236                            continue;
13237                        }
13238
13239                        dlg.finished(false);
13240
13241                        return Err(match error {
13242                            Ok(value) => common::Error::BadRequest(value),
13243                            _ => common::Error::Failure(response),
13244                        });
13245                    }
13246                    let response = {
13247                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13248                        let encoded = common::to_string(&bytes);
13249                        match serde_json::from_str(&encoded) {
13250                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13251                            Err(error) => {
13252                                dlg.response_json_decode_error(&encoded, &error);
13253                                return Err(common::Error::JsonDecodeError(
13254                                    encoded.to_string(),
13255                                    error,
13256                                ));
13257                            }
13258                        }
13259                    };
13260
13261                    dlg.finished(true);
13262                    return Ok(response);
13263                }
13264            }
13265        }
13266    }
13267
13268    /// Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
13269    ///
13270    /// Sets the *parent* path property to the given value.
13271    ///
13272    /// Even though the property as already been set when instantiating this call,
13273    /// we provide this method for API completeness.
13274    pub fn parent(
13275        mut self,
13276        new_value: &str,
13277    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13278        self._parent = new_value.to_string();
13279        self
13280    }
13281    /// The fields to include in the response.
13282    ///
13283    /// Sets the *view* query property to the given value.
13284    pub fn view(
13285        mut self,
13286        new_value: &str,
13287    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13288        self._view = Some(new_value.to_string());
13289        self
13290    }
13291    /// Optional. Optional pagination token, returned earlier via ListCryptoKeyVersionsResponse.next_page_token.
13292    ///
13293    /// Sets the *page token* query property to the given value.
13294    pub fn page_token(
13295        mut self,
13296        new_value: &str,
13297    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13298        self._page_token = Some(new_value.to_string());
13299        self
13300    }
13301    /// Optional. Optional limit on the number of CryptoKeyVersions to include in the response. Further CryptoKeyVersions can subsequently be obtained by including the ListCryptoKeyVersionsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.
13302    ///
13303    /// Sets the *page size* query property to the given value.
13304    pub fn page_size(
13305        mut self,
13306        new_value: i32,
13307    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13308        self._page_size = Some(new_value);
13309        self
13310    }
13311    /// Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
13312    ///
13313    /// Sets the *order by* query property to the given value.
13314    pub fn order_by(
13315        mut self,
13316        new_value: &str,
13317    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13318        self._order_by = Some(new_value.to_string());
13319        self
13320    }
13321    /// Optional. Only include resources that match the filter in the response. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
13322    ///
13323    /// Sets the *filter* query property to the given value.
13324    pub fn filter(
13325        mut self,
13326        new_value: &str,
13327    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13328        self._filter = Some(new_value.to_string());
13329        self
13330    }
13331    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13332    /// while executing the actual API request.
13333    ///
13334    /// ````text
13335    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13336    /// ````
13337    ///
13338    /// Sets the *delegate* property to the given value.
13339    pub fn delegate(
13340        mut self,
13341        new_value: &'a mut dyn common::Delegate,
13342    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13343        self._delegate = Some(new_value);
13344        self
13345    }
13346
13347    /// Set any additional parameter of the query string used in the request.
13348    /// It should be used to set parameters which are not yet available through their own
13349    /// setters.
13350    ///
13351    /// Please note that this method must not be used to set any of the known parameters
13352    /// which have their own setter method. If done anyway, the request will fail.
13353    ///
13354    /// # Additional Parameters
13355    ///
13356    /// * *$.xgafv* (query-string) - V1 error format.
13357    /// * *access_token* (query-string) - OAuth access token.
13358    /// * *alt* (query-string) - Data format for response.
13359    /// * *callback* (query-string) - JSONP
13360    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13361    /// * *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.
13362    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13363    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13364    /// * *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.
13365    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13366    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13367    pub fn param<T>(
13368        mut self,
13369        name: T,
13370        value: T,
13371    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
13372    where
13373        T: AsRef<str>,
13374    {
13375        self._additional_params
13376            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13377        self
13378    }
13379
13380    /// Identifies the authorization scope for the method you are building.
13381    ///
13382    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13383    /// [`Scope::CloudPlatform`].
13384    ///
13385    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13386    /// tokens for more than one scope.
13387    ///
13388    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13389    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13390    /// sufficient, a read-write scope will do as well.
13391    pub fn add_scope<St>(
13392        mut self,
13393        scope: St,
13394    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
13395    where
13396        St: AsRef<str>,
13397    {
13398        self._scopes.insert(String::from(scope.as_ref()));
13399        self
13400    }
13401    /// Identifies the authorization scope(s) for the method you are building.
13402    ///
13403    /// See [`Self::add_scope()`] for details.
13404    pub fn add_scopes<I, St>(
13405        mut self,
13406        scopes: I,
13407    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
13408    where
13409        I: IntoIterator<Item = St>,
13410        St: AsRef<str>,
13411    {
13412        self._scopes
13413            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13414        self
13415    }
13416
13417    /// Removes all scopes, and no default scope will be used either.
13418    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13419    /// for details).
13420    pub fn clear_scopes(
13421        mut self,
13422    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
13423        self._scopes.clear();
13424        self
13425    }
13426}
13427
13428/// Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key.
13429///
13430/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.macSign* method supported by a *project* resource.
13431/// It is not used directly, but through a [`ProjectMethods`] instance.
13432///
13433/// # Example
13434///
13435/// Instantiate a resource method builder
13436///
13437/// ```test_harness,no_run
13438/// # extern crate hyper;
13439/// # extern crate hyper_rustls;
13440/// # extern crate google_cloudkms1 as cloudkms1;
13441/// use cloudkms1::api::MacSignRequest;
13442/// # async fn dox() {
13443/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13444///
13445/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13446/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13447/// #     .with_native_roots()
13448/// #     .unwrap()
13449/// #     .https_only()
13450/// #     .enable_http2()
13451/// #     .build();
13452///
13453/// # let executor = hyper_util::rt::TokioExecutor::new();
13454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13455/// #     secret,
13456/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13457/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13458/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13459/// #     ),
13460/// # ).build().await.unwrap();
13461///
13462/// # let client = hyper_util::client::legacy::Client::builder(
13463/// #     hyper_util::rt::TokioExecutor::new()
13464/// # )
13465/// # .build(
13466/// #     hyper_rustls::HttpsConnectorBuilder::new()
13467/// #         .with_native_roots()
13468/// #         .unwrap()
13469/// #         .https_or_http()
13470/// #         .enable_http2()
13471/// #         .build()
13472/// # );
13473/// # let mut hub = CloudKMS::new(client, auth);
13474/// // As the method needs a request, you would usually fill it with the desired information
13475/// // into the respective structure. Some of the parts shown here might not be applicable !
13476/// // Values shown here are possibly random and not representative !
13477/// let mut req = MacSignRequest::default();
13478///
13479/// // You can configure optional parameters by calling the respective setters at will, and
13480/// // execute the final call using `doit()`.
13481/// // Values shown here are possibly random and not representative !
13482/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_mac_sign(req, "name")
13483///              .doit().await;
13484/// # }
13485/// ```
13486pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13487where
13488    C: 'a,
13489{
13490    hub: &'a CloudKMS<C>,
13491    _request: MacSignRequest,
13492    _name: String,
13493    _delegate: Option<&'a mut dyn common::Delegate>,
13494    _additional_params: HashMap<String, String>,
13495    _scopes: BTreeSet<String>,
13496}
13497
13498impl<'a, C> common::CallBuilder
13499    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13500{
13501}
13502
13503impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13504where
13505    C: common::Connector,
13506{
13507    /// Perform the operation you have build so far.
13508    pub async fn doit(mut self) -> common::Result<(common::Response, MacSignResponse)> {
13509        use std::borrow::Cow;
13510        use std::io::{Read, Seek};
13511
13512        use common::{url::Params, ToParts};
13513        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13514
13515        let mut dd = common::DefaultDelegate;
13516        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13517        dlg.begin(common::MethodInfo {
13518            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.macSign",
13519            http_method: hyper::Method::POST,
13520        });
13521
13522        for &field in ["alt", "name"].iter() {
13523            if self._additional_params.contains_key(field) {
13524                dlg.finished(false);
13525                return Err(common::Error::FieldClash(field));
13526            }
13527        }
13528
13529        let mut params = Params::with_capacity(4 + self._additional_params.len());
13530        params.push("name", self._name);
13531
13532        params.extend(self._additional_params.iter());
13533
13534        params.push("alt", "json");
13535        let mut url = self.hub._base_url.clone() + "v1/{+name}:macSign";
13536        if self._scopes.is_empty() {
13537            self._scopes
13538                .insert(Scope::CloudPlatform.as_ref().to_string());
13539        }
13540
13541        #[allow(clippy::single_element_loop)]
13542        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13543            url = params.uri_replacement(url, param_name, find_this, true);
13544        }
13545        {
13546            let to_remove = ["name"];
13547            params.remove_params(&to_remove);
13548        }
13549
13550        let url = params.parse_with_url(&url);
13551
13552        let mut json_mime_type = mime::APPLICATION_JSON;
13553        let mut request_value_reader = {
13554            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13555            common::remove_json_null_values(&mut value);
13556            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13557            serde_json::to_writer(&mut dst, &value).unwrap();
13558            dst
13559        };
13560        let request_size = request_value_reader
13561            .seek(std::io::SeekFrom::End(0))
13562            .unwrap();
13563        request_value_reader
13564            .seek(std::io::SeekFrom::Start(0))
13565            .unwrap();
13566
13567        loop {
13568            let token = match self
13569                .hub
13570                .auth
13571                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13572                .await
13573            {
13574                Ok(token) => token,
13575                Err(e) => match dlg.token(e) {
13576                    Ok(token) => token,
13577                    Err(e) => {
13578                        dlg.finished(false);
13579                        return Err(common::Error::MissingToken(e));
13580                    }
13581                },
13582            };
13583            request_value_reader
13584                .seek(std::io::SeekFrom::Start(0))
13585                .unwrap();
13586            let mut req_result = {
13587                let client = &self.hub.client;
13588                dlg.pre_request();
13589                let mut req_builder = hyper::Request::builder()
13590                    .method(hyper::Method::POST)
13591                    .uri(url.as_str())
13592                    .header(USER_AGENT, self.hub._user_agent.clone());
13593
13594                if let Some(token) = token.as_ref() {
13595                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13596                }
13597
13598                let request = req_builder
13599                    .header(CONTENT_TYPE, json_mime_type.to_string())
13600                    .header(CONTENT_LENGTH, request_size as u64)
13601                    .body(common::to_body(
13602                        request_value_reader.get_ref().clone().into(),
13603                    ));
13604
13605                client.request(request.unwrap()).await
13606            };
13607
13608            match req_result {
13609                Err(err) => {
13610                    if let common::Retry::After(d) = dlg.http_error(&err) {
13611                        sleep(d).await;
13612                        continue;
13613                    }
13614                    dlg.finished(false);
13615                    return Err(common::Error::HttpError(err));
13616                }
13617                Ok(res) => {
13618                    let (mut parts, body) = res.into_parts();
13619                    let mut body = common::Body::new(body);
13620                    if !parts.status.is_success() {
13621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13622                        let error = serde_json::from_str(&common::to_string(&bytes));
13623                        let response = common::to_response(parts, bytes.into());
13624
13625                        if let common::Retry::After(d) =
13626                            dlg.http_failure(&response, error.as_ref().ok())
13627                        {
13628                            sleep(d).await;
13629                            continue;
13630                        }
13631
13632                        dlg.finished(false);
13633
13634                        return Err(match error {
13635                            Ok(value) => common::Error::BadRequest(value),
13636                            _ => common::Error::Failure(response),
13637                        });
13638                    }
13639                    let response = {
13640                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13641                        let encoded = common::to_string(&bytes);
13642                        match serde_json::from_str(&encoded) {
13643                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13644                            Err(error) => {
13645                                dlg.response_json_decode_error(&encoded, &error);
13646                                return Err(common::Error::JsonDecodeError(
13647                                    encoded.to_string(),
13648                                    error,
13649                                ));
13650                            }
13651                        }
13652                    };
13653
13654                    dlg.finished(true);
13655                    return Ok(response);
13656                }
13657            }
13658        }
13659    }
13660
13661    ///
13662    /// Sets the *request* property to the given value.
13663    ///
13664    /// Even though the property as already been set when instantiating this call,
13665    /// we provide this method for API completeness.
13666    pub fn request(
13667        mut self,
13668        new_value: MacSignRequest,
13669    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
13670        self._request = new_value;
13671        self
13672    }
13673    /// Required. The resource name of the CryptoKeyVersion to use for signing.
13674    ///
13675    /// Sets the *name* path property to the given value.
13676    ///
13677    /// Even though the property as already been set when instantiating this call,
13678    /// we provide this method for API completeness.
13679    pub fn name(
13680        mut self,
13681        new_value: &str,
13682    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
13683        self._name = new_value.to_string();
13684        self
13685    }
13686    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13687    /// while executing the actual API request.
13688    ///
13689    /// ````text
13690    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13691    /// ````
13692    ///
13693    /// Sets the *delegate* property to the given value.
13694    pub fn delegate(
13695        mut self,
13696        new_value: &'a mut dyn common::Delegate,
13697    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
13698        self._delegate = Some(new_value);
13699        self
13700    }
13701
13702    /// Set any additional parameter of the query string used in the request.
13703    /// It should be used to set parameters which are not yet available through their own
13704    /// setters.
13705    ///
13706    /// Please note that this method must not be used to set any of the known parameters
13707    /// which have their own setter method. If done anyway, the request will fail.
13708    ///
13709    /// # Additional Parameters
13710    ///
13711    /// * *$.xgafv* (query-string) - V1 error format.
13712    /// * *access_token* (query-string) - OAuth access token.
13713    /// * *alt* (query-string) - Data format for response.
13714    /// * *callback* (query-string) - JSONP
13715    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13716    /// * *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.
13717    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13718    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13719    /// * *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.
13720    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13721    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13722    pub fn param<T>(
13723        mut self,
13724        name: T,
13725        value: T,
13726    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13727    where
13728        T: AsRef<str>,
13729    {
13730        self._additional_params
13731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13732        self
13733    }
13734
13735    /// Identifies the authorization scope for the method you are building.
13736    ///
13737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13738    /// [`Scope::CloudPlatform`].
13739    ///
13740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13741    /// tokens for more than one scope.
13742    ///
13743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13745    /// sufficient, a read-write scope will do as well.
13746    pub fn add_scope<St>(
13747        mut self,
13748        scope: St,
13749    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13750    where
13751        St: AsRef<str>,
13752    {
13753        self._scopes.insert(String::from(scope.as_ref()));
13754        self
13755    }
13756    /// Identifies the authorization scope(s) for the method you are building.
13757    ///
13758    /// See [`Self::add_scope()`] for details.
13759    pub fn add_scopes<I, St>(
13760        mut self,
13761        scopes: I,
13762    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
13763    where
13764        I: IntoIterator<Item = St>,
13765        St: AsRef<str>,
13766    {
13767        self._scopes
13768            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13769        self
13770    }
13771
13772    /// Removes all scopes, and no default scope will be used either.
13773    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13774    /// for details).
13775    pub fn clear_scopes(
13776        mut self,
13777    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
13778        self._scopes.clear();
13779        self
13780    }
13781}
13782
13783/// Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful.
13784///
13785/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.macVerify* method supported by a *project* resource.
13786/// It is not used directly, but through a [`ProjectMethods`] instance.
13787///
13788/// # Example
13789///
13790/// Instantiate a resource method builder
13791///
13792/// ```test_harness,no_run
13793/// # extern crate hyper;
13794/// # extern crate hyper_rustls;
13795/// # extern crate google_cloudkms1 as cloudkms1;
13796/// use cloudkms1::api::MacVerifyRequest;
13797/// # async fn dox() {
13798/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13799///
13800/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13801/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13802/// #     .with_native_roots()
13803/// #     .unwrap()
13804/// #     .https_only()
13805/// #     .enable_http2()
13806/// #     .build();
13807///
13808/// # let executor = hyper_util::rt::TokioExecutor::new();
13809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13810/// #     secret,
13811/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13812/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13813/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13814/// #     ),
13815/// # ).build().await.unwrap();
13816///
13817/// # let client = hyper_util::client::legacy::Client::builder(
13818/// #     hyper_util::rt::TokioExecutor::new()
13819/// # )
13820/// # .build(
13821/// #     hyper_rustls::HttpsConnectorBuilder::new()
13822/// #         .with_native_roots()
13823/// #         .unwrap()
13824/// #         .https_or_http()
13825/// #         .enable_http2()
13826/// #         .build()
13827/// # );
13828/// # let mut hub = CloudKMS::new(client, auth);
13829/// // As the method needs a request, you would usually fill it with the desired information
13830/// // into the respective structure. Some of the parts shown here might not be applicable !
13831/// // Values shown here are possibly random and not representative !
13832/// let mut req = MacVerifyRequest::default();
13833///
13834/// // You can configure optional parameters by calling the respective setters at will, and
13835/// // execute the final call using `doit()`.
13836/// // Values shown here are possibly random and not representative !
13837/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_mac_verify(req, "name")
13838///              .doit().await;
13839/// # }
13840/// ```
13841pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
13842where
13843    C: 'a,
13844{
13845    hub: &'a CloudKMS<C>,
13846    _request: MacVerifyRequest,
13847    _name: String,
13848    _delegate: Option<&'a mut dyn common::Delegate>,
13849    _additional_params: HashMap<String, String>,
13850    _scopes: BTreeSet<String>,
13851}
13852
13853impl<'a, C> common::CallBuilder
13854    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
13855{
13856}
13857
13858impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
13859where
13860    C: common::Connector,
13861{
13862    /// Perform the operation you have build so far.
13863    pub async fn doit(mut self) -> common::Result<(common::Response, MacVerifyResponse)> {
13864        use std::borrow::Cow;
13865        use std::io::{Read, Seek};
13866
13867        use common::{url::Params, ToParts};
13868        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13869
13870        let mut dd = common::DefaultDelegate;
13871        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13872        dlg.begin(common::MethodInfo {
13873            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.macVerify",
13874            http_method: hyper::Method::POST,
13875        });
13876
13877        for &field in ["alt", "name"].iter() {
13878            if self._additional_params.contains_key(field) {
13879                dlg.finished(false);
13880                return Err(common::Error::FieldClash(field));
13881            }
13882        }
13883
13884        let mut params = Params::with_capacity(4 + self._additional_params.len());
13885        params.push("name", self._name);
13886
13887        params.extend(self._additional_params.iter());
13888
13889        params.push("alt", "json");
13890        let mut url = self.hub._base_url.clone() + "v1/{+name}:macVerify";
13891        if self._scopes.is_empty() {
13892            self._scopes
13893                .insert(Scope::CloudPlatform.as_ref().to_string());
13894        }
13895
13896        #[allow(clippy::single_element_loop)]
13897        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13898            url = params.uri_replacement(url, param_name, find_this, true);
13899        }
13900        {
13901            let to_remove = ["name"];
13902            params.remove_params(&to_remove);
13903        }
13904
13905        let url = params.parse_with_url(&url);
13906
13907        let mut json_mime_type = mime::APPLICATION_JSON;
13908        let mut request_value_reader = {
13909            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13910            common::remove_json_null_values(&mut value);
13911            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13912            serde_json::to_writer(&mut dst, &value).unwrap();
13913            dst
13914        };
13915        let request_size = request_value_reader
13916            .seek(std::io::SeekFrom::End(0))
13917            .unwrap();
13918        request_value_reader
13919            .seek(std::io::SeekFrom::Start(0))
13920            .unwrap();
13921
13922        loop {
13923            let token = match self
13924                .hub
13925                .auth
13926                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13927                .await
13928            {
13929                Ok(token) => token,
13930                Err(e) => match dlg.token(e) {
13931                    Ok(token) => token,
13932                    Err(e) => {
13933                        dlg.finished(false);
13934                        return Err(common::Error::MissingToken(e));
13935                    }
13936                },
13937            };
13938            request_value_reader
13939                .seek(std::io::SeekFrom::Start(0))
13940                .unwrap();
13941            let mut req_result = {
13942                let client = &self.hub.client;
13943                dlg.pre_request();
13944                let mut req_builder = hyper::Request::builder()
13945                    .method(hyper::Method::POST)
13946                    .uri(url.as_str())
13947                    .header(USER_AGENT, self.hub._user_agent.clone());
13948
13949                if let Some(token) = token.as_ref() {
13950                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13951                }
13952
13953                let request = req_builder
13954                    .header(CONTENT_TYPE, json_mime_type.to_string())
13955                    .header(CONTENT_LENGTH, request_size as u64)
13956                    .body(common::to_body(
13957                        request_value_reader.get_ref().clone().into(),
13958                    ));
13959
13960                client.request(request.unwrap()).await
13961            };
13962
13963            match req_result {
13964                Err(err) => {
13965                    if let common::Retry::After(d) = dlg.http_error(&err) {
13966                        sleep(d).await;
13967                        continue;
13968                    }
13969                    dlg.finished(false);
13970                    return Err(common::Error::HttpError(err));
13971                }
13972                Ok(res) => {
13973                    let (mut parts, body) = res.into_parts();
13974                    let mut body = common::Body::new(body);
13975                    if !parts.status.is_success() {
13976                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13977                        let error = serde_json::from_str(&common::to_string(&bytes));
13978                        let response = common::to_response(parts, bytes.into());
13979
13980                        if let common::Retry::After(d) =
13981                            dlg.http_failure(&response, error.as_ref().ok())
13982                        {
13983                            sleep(d).await;
13984                            continue;
13985                        }
13986
13987                        dlg.finished(false);
13988
13989                        return Err(match error {
13990                            Ok(value) => common::Error::BadRequest(value),
13991                            _ => common::Error::Failure(response),
13992                        });
13993                    }
13994                    let response = {
13995                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13996                        let encoded = common::to_string(&bytes);
13997                        match serde_json::from_str(&encoded) {
13998                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13999                            Err(error) => {
14000                                dlg.response_json_decode_error(&encoded, &error);
14001                                return Err(common::Error::JsonDecodeError(
14002                                    encoded.to_string(),
14003                                    error,
14004                                ));
14005                            }
14006                        }
14007                    };
14008
14009                    dlg.finished(true);
14010                    return Ok(response);
14011                }
14012            }
14013        }
14014    }
14015
14016    ///
14017    /// Sets the *request* property to the given value.
14018    ///
14019    /// Even though the property as already been set when instantiating this call,
14020    /// we provide this method for API completeness.
14021    pub fn request(
14022        mut self,
14023        new_value: MacVerifyRequest,
14024    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
14025        self._request = new_value;
14026        self
14027    }
14028    /// Required. The resource name of the CryptoKeyVersion to use for verification.
14029    ///
14030    /// Sets the *name* path property to the given value.
14031    ///
14032    /// Even though the property as already been set when instantiating this call,
14033    /// we provide this method for API completeness.
14034    pub fn name(
14035        mut self,
14036        new_value: &str,
14037    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
14038        self._name = new_value.to_string();
14039        self
14040    }
14041    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14042    /// while executing the actual API request.
14043    ///
14044    /// ````text
14045    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14046    /// ````
14047    ///
14048    /// Sets the *delegate* property to the given value.
14049    pub fn delegate(
14050        mut self,
14051        new_value: &'a mut dyn common::Delegate,
14052    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
14053        self._delegate = Some(new_value);
14054        self
14055    }
14056
14057    /// Set any additional parameter of the query string used in the request.
14058    /// It should be used to set parameters which are not yet available through their own
14059    /// setters.
14060    ///
14061    /// Please note that this method must not be used to set any of the known parameters
14062    /// which have their own setter method. If done anyway, the request will fail.
14063    ///
14064    /// # Additional Parameters
14065    ///
14066    /// * *$.xgafv* (query-string) - V1 error format.
14067    /// * *access_token* (query-string) - OAuth access token.
14068    /// * *alt* (query-string) - Data format for response.
14069    /// * *callback* (query-string) - JSONP
14070    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14071    /// * *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.
14072    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14073    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14074    /// * *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.
14075    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14076    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14077    pub fn param<T>(
14078        mut self,
14079        name: T,
14080        value: T,
14081    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
14082    where
14083        T: AsRef<str>,
14084    {
14085        self._additional_params
14086            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14087        self
14088    }
14089
14090    /// Identifies the authorization scope for the method you are building.
14091    ///
14092    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14093    /// [`Scope::CloudPlatform`].
14094    ///
14095    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14096    /// tokens for more than one scope.
14097    ///
14098    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14099    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14100    /// sufficient, a read-write scope will do as well.
14101    pub fn add_scope<St>(
14102        mut self,
14103        scope: St,
14104    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
14105    where
14106        St: AsRef<str>,
14107    {
14108        self._scopes.insert(String::from(scope.as_ref()));
14109        self
14110    }
14111    /// Identifies the authorization scope(s) for the method you are building.
14112    ///
14113    /// See [`Self::add_scope()`] for details.
14114    pub fn add_scopes<I, St>(
14115        mut self,
14116        scopes: I,
14117    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
14118    where
14119        I: IntoIterator<Item = St>,
14120        St: AsRef<str>,
14121    {
14122        self._scopes
14123            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14124        self
14125    }
14126
14127    /// Removes all scopes, and no default scope will be used either.
14128    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14129    /// for details).
14130    pub fn clear_scopes(
14131        mut self,
14132    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
14133        self._scopes.clear();
14134        self
14135    }
14136}
14137
14138/// Update a CryptoKeyVersion's metadata. state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states.
14139///
14140/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.patch* method supported by a *project* resource.
14141/// It is not used directly, but through a [`ProjectMethods`] instance.
14142///
14143/// # Example
14144///
14145/// Instantiate a resource method builder
14146///
14147/// ```test_harness,no_run
14148/// # extern crate hyper;
14149/// # extern crate hyper_rustls;
14150/// # extern crate google_cloudkms1 as cloudkms1;
14151/// use cloudkms1::api::CryptoKeyVersion;
14152/// # async fn dox() {
14153/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14154///
14155/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14156/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14157/// #     .with_native_roots()
14158/// #     .unwrap()
14159/// #     .https_only()
14160/// #     .enable_http2()
14161/// #     .build();
14162///
14163/// # let executor = hyper_util::rt::TokioExecutor::new();
14164/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14165/// #     secret,
14166/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14167/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14168/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14169/// #     ),
14170/// # ).build().await.unwrap();
14171///
14172/// # let client = hyper_util::client::legacy::Client::builder(
14173/// #     hyper_util::rt::TokioExecutor::new()
14174/// # )
14175/// # .build(
14176/// #     hyper_rustls::HttpsConnectorBuilder::new()
14177/// #         .with_native_roots()
14178/// #         .unwrap()
14179/// #         .https_or_http()
14180/// #         .enable_http2()
14181/// #         .build()
14182/// # );
14183/// # let mut hub = CloudKMS::new(client, auth);
14184/// // As the method needs a request, you would usually fill it with the desired information
14185/// // into the respective structure. Some of the parts shown here might not be applicable !
14186/// // Values shown here are possibly random and not representative !
14187/// let mut req = CryptoKeyVersion::default();
14188///
14189/// // You can configure optional parameters by calling the respective setters at will, and
14190/// // execute the final call using `doit()`.
14191/// // Values shown here are possibly random and not representative !
14192/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
14193///              .update_mask(FieldMask::new::<&str>(&[]))
14194///              .doit().await;
14195/// # }
14196/// ```
14197pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14198where
14199    C: 'a,
14200{
14201    hub: &'a CloudKMS<C>,
14202    _request: CryptoKeyVersion,
14203    _name: String,
14204    _update_mask: Option<common::FieldMask>,
14205    _delegate: Option<&'a mut dyn common::Delegate>,
14206    _additional_params: HashMap<String, String>,
14207    _scopes: BTreeSet<String>,
14208}
14209
14210impl<'a, C> common::CallBuilder
14211    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14212{
14213}
14214
14215impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14216where
14217    C: common::Connector,
14218{
14219    /// Perform the operation you have build so far.
14220    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
14221        use std::borrow::Cow;
14222        use std::io::{Read, Seek};
14223
14224        use common::{url::Params, ToParts};
14225        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14226
14227        let mut dd = common::DefaultDelegate;
14228        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14229        dlg.begin(common::MethodInfo {
14230            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch",
14231            http_method: hyper::Method::PATCH,
14232        });
14233
14234        for &field in ["alt", "name", "updateMask"].iter() {
14235            if self._additional_params.contains_key(field) {
14236                dlg.finished(false);
14237                return Err(common::Error::FieldClash(field));
14238            }
14239        }
14240
14241        let mut params = Params::with_capacity(5 + self._additional_params.len());
14242        params.push("name", self._name);
14243        if let Some(value) = self._update_mask.as_ref() {
14244            params.push("updateMask", value.to_string());
14245        }
14246
14247        params.extend(self._additional_params.iter());
14248
14249        params.push("alt", "json");
14250        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14251        if self._scopes.is_empty() {
14252            self._scopes
14253                .insert(Scope::CloudPlatform.as_ref().to_string());
14254        }
14255
14256        #[allow(clippy::single_element_loop)]
14257        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14258            url = params.uri_replacement(url, param_name, find_this, true);
14259        }
14260        {
14261            let to_remove = ["name"];
14262            params.remove_params(&to_remove);
14263        }
14264
14265        let url = params.parse_with_url(&url);
14266
14267        let mut json_mime_type = mime::APPLICATION_JSON;
14268        let mut request_value_reader = {
14269            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14270            common::remove_json_null_values(&mut value);
14271            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14272            serde_json::to_writer(&mut dst, &value).unwrap();
14273            dst
14274        };
14275        let request_size = request_value_reader
14276            .seek(std::io::SeekFrom::End(0))
14277            .unwrap();
14278        request_value_reader
14279            .seek(std::io::SeekFrom::Start(0))
14280            .unwrap();
14281
14282        loop {
14283            let token = match self
14284                .hub
14285                .auth
14286                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14287                .await
14288            {
14289                Ok(token) => token,
14290                Err(e) => match dlg.token(e) {
14291                    Ok(token) => token,
14292                    Err(e) => {
14293                        dlg.finished(false);
14294                        return Err(common::Error::MissingToken(e));
14295                    }
14296                },
14297            };
14298            request_value_reader
14299                .seek(std::io::SeekFrom::Start(0))
14300                .unwrap();
14301            let mut req_result = {
14302                let client = &self.hub.client;
14303                dlg.pre_request();
14304                let mut req_builder = hyper::Request::builder()
14305                    .method(hyper::Method::PATCH)
14306                    .uri(url.as_str())
14307                    .header(USER_AGENT, self.hub._user_agent.clone());
14308
14309                if let Some(token) = token.as_ref() {
14310                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14311                }
14312
14313                let request = req_builder
14314                    .header(CONTENT_TYPE, json_mime_type.to_string())
14315                    .header(CONTENT_LENGTH, request_size as u64)
14316                    .body(common::to_body(
14317                        request_value_reader.get_ref().clone().into(),
14318                    ));
14319
14320                client.request(request.unwrap()).await
14321            };
14322
14323            match req_result {
14324                Err(err) => {
14325                    if let common::Retry::After(d) = dlg.http_error(&err) {
14326                        sleep(d).await;
14327                        continue;
14328                    }
14329                    dlg.finished(false);
14330                    return Err(common::Error::HttpError(err));
14331                }
14332                Ok(res) => {
14333                    let (mut parts, body) = res.into_parts();
14334                    let mut body = common::Body::new(body);
14335                    if !parts.status.is_success() {
14336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14337                        let error = serde_json::from_str(&common::to_string(&bytes));
14338                        let response = common::to_response(parts, bytes.into());
14339
14340                        if let common::Retry::After(d) =
14341                            dlg.http_failure(&response, error.as_ref().ok())
14342                        {
14343                            sleep(d).await;
14344                            continue;
14345                        }
14346
14347                        dlg.finished(false);
14348
14349                        return Err(match error {
14350                            Ok(value) => common::Error::BadRequest(value),
14351                            _ => common::Error::Failure(response),
14352                        });
14353                    }
14354                    let response = {
14355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14356                        let encoded = common::to_string(&bytes);
14357                        match serde_json::from_str(&encoded) {
14358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14359                            Err(error) => {
14360                                dlg.response_json_decode_error(&encoded, &error);
14361                                return Err(common::Error::JsonDecodeError(
14362                                    encoded.to_string(),
14363                                    error,
14364                                ));
14365                            }
14366                        }
14367                    };
14368
14369                    dlg.finished(true);
14370                    return Ok(response);
14371                }
14372            }
14373        }
14374    }
14375
14376    ///
14377    /// Sets the *request* property to the given value.
14378    ///
14379    /// Even though the property as already been set when instantiating this call,
14380    /// we provide this method for API completeness.
14381    pub fn request(
14382        mut self,
14383        new_value: CryptoKeyVersion,
14384    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
14385        self._request = new_value;
14386        self
14387    }
14388    /// Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
14389    ///
14390    /// Sets the *name* path property to the given value.
14391    ///
14392    /// Even though the property as already been set when instantiating this call,
14393    /// we provide this method for API completeness.
14394    pub fn name(
14395        mut self,
14396        new_value: &str,
14397    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
14398        self._name = new_value.to_string();
14399        self
14400    }
14401    /// Required. List of fields to be updated in this request.
14402    ///
14403    /// Sets the *update mask* query property to the given value.
14404    pub fn update_mask(
14405        mut self,
14406        new_value: common::FieldMask,
14407    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
14408        self._update_mask = Some(new_value);
14409        self
14410    }
14411    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14412    /// while executing the actual API request.
14413    ///
14414    /// ````text
14415    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14416    /// ````
14417    ///
14418    /// Sets the *delegate* property to the given value.
14419    pub fn delegate(
14420        mut self,
14421        new_value: &'a mut dyn common::Delegate,
14422    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
14423        self._delegate = Some(new_value);
14424        self
14425    }
14426
14427    /// Set any additional parameter of the query string used in the request.
14428    /// It should be used to set parameters which are not yet available through their own
14429    /// setters.
14430    ///
14431    /// Please note that this method must not be used to set any of the known parameters
14432    /// which have their own setter method. If done anyway, the request will fail.
14433    ///
14434    /// # Additional Parameters
14435    ///
14436    /// * *$.xgafv* (query-string) - V1 error format.
14437    /// * *access_token* (query-string) - OAuth access token.
14438    /// * *alt* (query-string) - Data format for response.
14439    /// * *callback* (query-string) - JSONP
14440    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14441    /// * *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.
14442    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14443    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14444    /// * *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.
14445    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14446    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14447    pub fn param<T>(
14448        mut self,
14449        name: T,
14450        value: T,
14451    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14452    where
14453        T: AsRef<str>,
14454    {
14455        self._additional_params
14456            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14457        self
14458    }
14459
14460    /// Identifies the authorization scope for the method you are building.
14461    ///
14462    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14463    /// [`Scope::CloudPlatform`].
14464    ///
14465    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14466    /// tokens for more than one scope.
14467    ///
14468    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14469    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14470    /// sufficient, a read-write scope will do as well.
14471    pub fn add_scope<St>(
14472        mut self,
14473        scope: St,
14474    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14475    where
14476        St: AsRef<str>,
14477    {
14478        self._scopes.insert(String::from(scope.as_ref()));
14479        self
14480    }
14481    /// Identifies the authorization scope(s) for the method you are building.
14482    ///
14483    /// See [`Self::add_scope()`] for details.
14484    pub fn add_scopes<I, St>(
14485        mut self,
14486        scopes: I,
14487    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
14488    where
14489        I: IntoIterator<Item = St>,
14490        St: AsRef<str>,
14491    {
14492        self._scopes
14493            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14494        self
14495    }
14496
14497    /// Removes all scopes, and no default scope will be used either.
14498    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14499    /// for details).
14500    pub fn clear_scopes(
14501        mut self,
14502    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
14503        self._scopes.clear();
14504        self
14505    }
14506}
14507
14508/// Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
14509///
14510/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.rawDecrypt* method supported by a *project* resource.
14511/// It is not used directly, but through a [`ProjectMethods`] instance.
14512///
14513/// # Example
14514///
14515/// Instantiate a resource method builder
14516///
14517/// ```test_harness,no_run
14518/// # extern crate hyper;
14519/// # extern crate hyper_rustls;
14520/// # extern crate google_cloudkms1 as cloudkms1;
14521/// use cloudkms1::api::RawDecryptRequest;
14522/// # async fn dox() {
14523/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14524///
14525/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14526/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14527/// #     .with_native_roots()
14528/// #     .unwrap()
14529/// #     .https_only()
14530/// #     .enable_http2()
14531/// #     .build();
14532///
14533/// # let executor = hyper_util::rt::TokioExecutor::new();
14534/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14535/// #     secret,
14536/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14537/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14538/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14539/// #     ),
14540/// # ).build().await.unwrap();
14541///
14542/// # let client = hyper_util::client::legacy::Client::builder(
14543/// #     hyper_util::rt::TokioExecutor::new()
14544/// # )
14545/// # .build(
14546/// #     hyper_rustls::HttpsConnectorBuilder::new()
14547/// #         .with_native_roots()
14548/// #         .unwrap()
14549/// #         .https_or_http()
14550/// #         .enable_http2()
14551/// #         .build()
14552/// # );
14553/// # let mut hub = CloudKMS::new(client, auth);
14554/// // As the method needs a request, you would usually fill it with the desired information
14555/// // into the respective structure. Some of the parts shown here might not be applicable !
14556/// // Values shown here are possibly random and not representative !
14557/// let mut req = RawDecryptRequest::default();
14558///
14559/// // You can configure optional parameters by calling the respective setters at will, and
14560/// // execute the final call using `doit()`.
14561/// // Values shown here are possibly random and not representative !
14562/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_raw_decrypt(req, "name")
14563///              .doit().await;
14564/// # }
14565/// ```
14566pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14567where
14568    C: 'a,
14569{
14570    hub: &'a CloudKMS<C>,
14571    _request: RawDecryptRequest,
14572    _name: String,
14573    _delegate: Option<&'a mut dyn common::Delegate>,
14574    _additional_params: HashMap<String, String>,
14575    _scopes: BTreeSet<String>,
14576}
14577
14578impl<'a, C> common::CallBuilder
14579    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14580{
14581}
14582
14583impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14584where
14585    C: common::Connector,
14586{
14587    /// Perform the operation you have build so far.
14588    pub async fn doit(mut self) -> common::Result<(common::Response, RawDecryptResponse)> {
14589        use std::borrow::Cow;
14590        use std::io::{Read, Seek};
14591
14592        use common::{url::Params, ToParts};
14593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14594
14595        let mut dd = common::DefaultDelegate;
14596        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14597        dlg.begin(common::MethodInfo {
14598            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.rawDecrypt",
14599            http_method: hyper::Method::POST,
14600        });
14601
14602        for &field in ["alt", "name"].iter() {
14603            if self._additional_params.contains_key(field) {
14604                dlg.finished(false);
14605                return Err(common::Error::FieldClash(field));
14606            }
14607        }
14608
14609        let mut params = Params::with_capacity(4 + self._additional_params.len());
14610        params.push("name", self._name);
14611
14612        params.extend(self._additional_params.iter());
14613
14614        params.push("alt", "json");
14615        let mut url = self.hub._base_url.clone() + "v1/{+name}:rawDecrypt";
14616        if self._scopes.is_empty() {
14617            self._scopes
14618                .insert(Scope::CloudPlatform.as_ref().to_string());
14619        }
14620
14621        #[allow(clippy::single_element_loop)]
14622        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14623            url = params.uri_replacement(url, param_name, find_this, true);
14624        }
14625        {
14626            let to_remove = ["name"];
14627            params.remove_params(&to_remove);
14628        }
14629
14630        let url = params.parse_with_url(&url);
14631
14632        let mut json_mime_type = mime::APPLICATION_JSON;
14633        let mut request_value_reader = {
14634            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14635            common::remove_json_null_values(&mut value);
14636            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14637            serde_json::to_writer(&mut dst, &value).unwrap();
14638            dst
14639        };
14640        let request_size = request_value_reader
14641            .seek(std::io::SeekFrom::End(0))
14642            .unwrap();
14643        request_value_reader
14644            .seek(std::io::SeekFrom::Start(0))
14645            .unwrap();
14646
14647        loop {
14648            let token = match self
14649                .hub
14650                .auth
14651                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14652                .await
14653            {
14654                Ok(token) => token,
14655                Err(e) => match dlg.token(e) {
14656                    Ok(token) => token,
14657                    Err(e) => {
14658                        dlg.finished(false);
14659                        return Err(common::Error::MissingToken(e));
14660                    }
14661                },
14662            };
14663            request_value_reader
14664                .seek(std::io::SeekFrom::Start(0))
14665                .unwrap();
14666            let mut req_result = {
14667                let client = &self.hub.client;
14668                dlg.pre_request();
14669                let mut req_builder = hyper::Request::builder()
14670                    .method(hyper::Method::POST)
14671                    .uri(url.as_str())
14672                    .header(USER_AGENT, self.hub._user_agent.clone());
14673
14674                if let Some(token) = token.as_ref() {
14675                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14676                }
14677
14678                let request = req_builder
14679                    .header(CONTENT_TYPE, json_mime_type.to_string())
14680                    .header(CONTENT_LENGTH, request_size as u64)
14681                    .body(common::to_body(
14682                        request_value_reader.get_ref().clone().into(),
14683                    ));
14684
14685                client.request(request.unwrap()).await
14686            };
14687
14688            match req_result {
14689                Err(err) => {
14690                    if let common::Retry::After(d) = dlg.http_error(&err) {
14691                        sleep(d).await;
14692                        continue;
14693                    }
14694                    dlg.finished(false);
14695                    return Err(common::Error::HttpError(err));
14696                }
14697                Ok(res) => {
14698                    let (mut parts, body) = res.into_parts();
14699                    let mut body = common::Body::new(body);
14700                    if !parts.status.is_success() {
14701                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14702                        let error = serde_json::from_str(&common::to_string(&bytes));
14703                        let response = common::to_response(parts, bytes.into());
14704
14705                        if let common::Retry::After(d) =
14706                            dlg.http_failure(&response, error.as_ref().ok())
14707                        {
14708                            sleep(d).await;
14709                            continue;
14710                        }
14711
14712                        dlg.finished(false);
14713
14714                        return Err(match error {
14715                            Ok(value) => common::Error::BadRequest(value),
14716                            _ => common::Error::Failure(response),
14717                        });
14718                    }
14719                    let response = {
14720                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14721                        let encoded = common::to_string(&bytes);
14722                        match serde_json::from_str(&encoded) {
14723                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14724                            Err(error) => {
14725                                dlg.response_json_decode_error(&encoded, &error);
14726                                return Err(common::Error::JsonDecodeError(
14727                                    encoded.to_string(),
14728                                    error,
14729                                ));
14730                            }
14731                        }
14732                    };
14733
14734                    dlg.finished(true);
14735                    return Ok(response);
14736                }
14737            }
14738        }
14739    }
14740
14741    ///
14742    /// Sets the *request* property to the given value.
14743    ///
14744    /// Even though the property as already been set when instantiating this call,
14745    /// we provide this method for API completeness.
14746    pub fn request(
14747        mut self,
14748        new_value: RawDecryptRequest,
14749    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
14750        self._request = new_value;
14751        self
14752    }
14753    /// Required. The resource name of the CryptoKeyVersion to use for decryption.
14754    ///
14755    /// Sets the *name* path property to the given value.
14756    ///
14757    /// Even though the property as already been set when instantiating this call,
14758    /// we provide this method for API completeness.
14759    pub fn name(
14760        mut self,
14761        new_value: &str,
14762    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
14763        self._name = new_value.to_string();
14764        self
14765    }
14766    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14767    /// while executing the actual API request.
14768    ///
14769    /// ````text
14770    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14771    /// ````
14772    ///
14773    /// Sets the *delegate* property to the given value.
14774    pub fn delegate(
14775        mut self,
14776        new_value: &'a mut dyn common::Delegate,
14777    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
14778        self._delegate = Some(new_value);
14779        self
14780    }
14781
14782    /// Set any additional parameter of the query string used in the request.
14783    /// It should be used to set parameters which are not yet available through their own
14784    /// setters.
14785    ///
14786    /// Please note that this method must not be used to set any of the known parameters
14787    /// which have their own setter method. If done anyway, the request will fail.
14788    ///
14789    /// # Additional Parameters
14790    ///
14791    /// * *$.xgafv* (query-string) - V1 error format.
14792    /// * *access_token* (query-string) - OAuth access token.
14793    /// * *alt* (query-string) - Data format for response.
14794    /// * *callback* (query-string) - JSONP
14795    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14796    /// * *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.
14797    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14798    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14799    /// * *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.
14800    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14801    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14802    pub fn param<T>(
14803        mut self,
14804        name: T,
14805        value: T,
14806    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14807    where
14808        T: AsRef<str>,
14809    {
14810        self._additional_params
14811            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14812        self
14813    }
14814
14815    /// Identifies the authorization scope for the method you are building.
14816    ///
14817    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14818    /// [`Scope::CloudPlatform`].
14819    ///
14820    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14821    /// tokens for more than one scope.
14822    ///
14823    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14824    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14825    /// sufficient, a read-write scope will do as well.
14826    pub fn add_scope<St>(
14827        mut self,
14828        scope: St,
14829    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14830    where
14831        St: AsRef<str>,
14832    {
14833        self._scopes.insert(String::from(scope.as_ref()));
14834        self
14835    }
14836    /// Identifies the authorization scope(s) for the method you are building.
14837    ///
14838    /// See [`Self::add_scope()`] for details.
14839    pub fn add_scopes<I, St>(
14840        mut self,
14841        scopes: I,
14842    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
14843    where
14844        I: IntoIterator<Item = St>,
14845        St: AsRef<str>,
14846    {
14847        self._scopes
14848            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14849        self
14850    }
14851
14852    /// Removes all scopes, and no default scope will be used either.
14853    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14854    /// for details).
14855    pub fn clear_scopes(
14856        mut self,
14857    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
14858        self._scopes.clear();
14859        self
14860    }
14861}
14862
14863/// Encrypts data using portable cryptographic primitives. Most users should choose Encrypt and Decrypt rather than their raw counterparts. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
14864///
14865/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.rawEncrypt* method supported by a *project* resource.
14866/// It is not used directly, but through a [`ProjectMethods`] instance.
14867///
14868/// # Example
14869///
14870/// Instantiate a resource method builder
14871///
14872/// ```test_harness,no_run
14873/// # extern crate hyper;
14874/// # extern crate hyper_rustls;
14875/// # extern crate google_cloudkms1 as cloudkms1;
14876/// use cloudkms1::api::RawEncryptRequest;
14877/// # async fn dox() {
14878/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14879///
14880/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14881/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14882/// #     .with_native_roots()
14883/// #     .unwrap()
14884/// #     .https_only()
14885/// #     .enable_http2()
14886/// #     .build();
14887///
14888/// # let executor = hyper_util::rt::TokioExecutor::new();
14889/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14890/// #     secret,
14891/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14892/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14893/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14894/// #     ),
14895/// # ).build().await.unwrap();
14896///
14897/// # let client = hyper_util::client::legacy::Client::builder(
14898/// #     hyper_util::rt::TokioExecutor::new()
14899/// # )
14900/// # .build(
14901/// #     hyper_rustls::HttpsConnectorBuilder::new()
14902/// #         .with_native_roots()
14903/// #         .unwrap()
14904/// #         .https_or_http()
14905/// #         .enable_http2()
14906/// #         .build()
14907/// # );
14908/// # let mut hub = CloudKMS::new(client, auth);
14909/// // As the method needs a request, you would usually fill it with the desired information
14910/// // into the respective structure. Some of the parts shown here might not be applicable !
14911/// // Values shown here are possibly random and not representative !
14912/// let mut req = RawEncryptRequest::default();
14913///
14914/// // You can configure optional parameters by calling the respective setters at will, and
14915/// // execute the final call using `doit()`.
14916/// // Values shown here are possibly random and not representative !
14917/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_raw_encrypt(req, "name")
14918///              .doit().await;
14919/// # }
14920/// ```
14921pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
14922where
14923    C: 'a,
14924{
14925    hub: &'a CloudKMS<C>,
14926    _request: RawEncryptRequest,
14927    _name: String,
14928    _delegate: Option<&'a mut dyn common::Delegate>,
14929    _additional_params: HashMap<String, String>,
14930    _scopes: BTreeSet<String>,
14931}
14932
14933impl<'a, C> common::CallBuilder
14934    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
14935{
14936}
14937
14938impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
14939where
14940    C: common::Connector,
14941{
14942    /// Perform the operation you have build so far.
14943    pub async fn doit(mut self) -> common::Result<(common::Response, RawEncryptResponse)> {
14944        use std::borrow::Cow;
14945        use std::io::{Read, Seek};
14946
14947        use common::{url::Params, ToParts};
14948        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14949
14950        let mut dd = common::DefaultDelegate;
14951        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14952        dlg.begin(common::MethodInfo {
14953            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.rawEncrypt",
14954            http_method: hyper::Method::POST,
14955        });
14956
14957        for &field in ["alt", "name"].iter() {
14958            if self._additional_params.contains_key(field) {
14959                dlg.finished(false);
14960                return Err(common::Error::FieldClash(field));
14961            }
14962        }
14963
14964        let mut params = Params::with_capacity(4 + self._additional_params.len());
14965        params.push("name", self._name);
14966
14967        params.extend(self._additional_params.iter());
14968
14969        params.push("alt", "json");
14970        let mut url = self.hub._base_url.clone() + "v1/{+name}:rawEncrypt";
14971        if self._scopes.is_empty() {
14972            self._scopes
14973                .insert(Scope::CloudPlatform.as_ref().to_string());
14974        }
14975
14976        #[allow(clippy::single_element_loop)]
14977        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14978            url = params.uri_replacement(url, param_name, find_this, true);
14979        }
14980        {
14981            let to_remove = ["name"];
14982            params.remove_params(&to_remove);
14983        }
14984
14985        let url = params.parse_with_url(&url);
14986
14987        let mut json_mime_type = mime::APPLICATION_JSON;
14988        let mut request_value_reader = {
14989            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14990            common::remove_json_null_values(&mut value);
14991            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14992            serde_json::to_writer(&mut dst, &value).unwrap();
14993            dst
14994        };
14995        let request_size = request_value_reader
14996            .seek(std::io::SeekFrom::End(0))
14997            .unwrap();
14998        request_value_reader
14999            .seek(std::io::SeekFrom::Start(0))
15000            .unwrap();
15001
15002        loop {
15003            let token = match self
15004                .hub
15005                .auth
15006                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15007                .await
15008            {
15009                Ok(token) => token,
15010                Err(e) => match dlg.token(e) {
15011                    Ok(token) => token,
15012                    Err(e) => {
15013                        dlg.finished(false);
15014                        return Err(common::Error::MissingToken(e));
15015                    }
15016                },
15017            };
15018            request_value_reader
15019                .seek(std::io::SeekFrom::Start(0))
15020                .unwrap();
15021            let mut req_result = {
15022                let client = &self.hub.client;
15023                dlg.pre_request();
15024                let mut req_builder = hyper::Request::builder()
15025                    .method(hyper::Method::POST)
15026                    .uri(url.as_str())
15027                    .header(USER_AGENT, self.hub._user_agent.clone());
15028
15029                if let Some(token) = token.as_ref() {
15030                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15031                }
15032
15033                let request = req_builder
15034                    .header(CONTENT_TYPE, json_mime_type.to_string())
15035                    .header(CONTENT_LENGTH, request_size as u64)
15036                    .body(common::to_body(
15037                        request_value_reader.get_ref().clone().into(),
15038                    ));
15039
15040                client.request(request.unwrap()).await
15041            };
15042
15043            match req_result {
15044                Err(err) => {
15045                    if let common::Retry::After(d) = dlg.http_error(&err) {
15046                        sleep(d).await;
15047                        continue;
15048                    }
15049                    dlg.finished(false);
15050                    return Err(common::Error::HttpError(err));
15051                }
15052                Ok(res) => {
15053                    let (mut parts, body) = res.into_parts();
15054                    let mut body = common::Body::new(body);
15055                    if !parts.status.is_success() {
15056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15057                        let error = serde_json::from_str(&common::to_string(&bytes));
15058                        let response = common::to_response(parts, bytes.into());
15059
15060                        if let common::Retry::After(d) =
15061                            dlg.http_failure(&response, error.as_ref().ok())
15062                        {
15063                            sleep(d).await;
15064                            continue;
15065                        }
15066
15067                        dlg.finished(false);
15068
15069                        return Err(match error {
15070                            Ok(value) => common::Error::BadRequest(value),
15071                            _ => common::Error::Failure(response),
15072                        });
15073                    }
15074                    let response = {
15075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15076                        let encoded = common::to_string(&bytes);
15077                        match serde_json::from_str(&encoded) {
15078                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15079                            Err(error) => {
15080                                dlg.response_json_decode_error(&encoded, &error);
15081                                return Err(common::Error::JsonDecodeError(
15082                                    encoded.to_string(),
15083                                    error,
15084                                ));
15085                            }
15086                        }
15087                    };
15088
15089                    dlg.finished(true);
15090                    return Ok(response);
15091                }
15092            }
15093        }
15094    }
15095
15096    ///
15097    /// Sets the *request* property to the given value.
15098    ///
15099    /// Even though the property as already been set when instantiating this call,
15100    /// we provide this method for API completeness.
15101    pub fn request(
15102        mut self,
15103        new_value: RawEncryptRequest,
15104    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
15105        self._request = new_value;
15106        self
15107    }
15108    /// Required. The resource name of the CryptoKeyVersion to use for encryption.
15109    ///
15110    /// Sets the *name* path property to the given value.
15111    ///
15112    /// Even though the property as already been set when instantiating this call,
15113    /// we provide this method for API completeness.
15114    pub fn name(
15115        mut self,
15116        new_value: &str,
15117    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
15118        self._name = new_value.to_string();
15119        self
15120    }
15121    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15122    /// while executing the actual API request.
15123    ///
15124    /// ````text
15125    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15126    /// ````
15127    ///
15128    /// Sets the *delegate* property to the given value.
15129    pub fn delegate(
15130        mut self,
15131        new_value: &'a mut dyn common::Delegate,
15132    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
15133        self._delegate = Some(new_value);
15134        self
15135    }
15136
15137    /// Set any additional parameter of the query string used in the request.
15138    /// It should be used to set parameters which are not yet available through their own
15139    /// setters.
15140    ///
15141    /// Please note that this method must not be used to set any of the known parameters
15142    /// which have their own setter method. If done anyway, the request will fail.
15143    ///
15144    /// # Additional Parameters
15145    ///
15146    /// * *$.xgafv* (query-string) - V1 error format.
15147    /// * *access_token* (query-string) - OAuth access token.
15148    /// * *alt* (query-string) - Data format for response.
15149    /// * *callback* (query-string) - JSONP
15150    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15151    /// * *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.
15152    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15153    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15154    /// * *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.
15155    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15156    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15157    pub fn param<T>(
15158        mut self,
15159        name: T,
15160        value: T,
15161    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
15162    where
15163        T: AsRef<str>,
15164    {
15165        self._additional_params
15166            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15167        self
15168    }
15169
15170    /// Identifies the authorization scope for the method you are building.
15171    ///
15172    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15173    /// [`Scope::CloudPlatform`].
15174    ///
15175    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15176    /// tokens for more than one scope.
15177    ///
15178    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15179    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15180    /// sufficient, a read-write scope will do as well.
15181    pub fn add_scope<St>(
15182        mut self,
15183        scope: St,
15184    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
15185    where
15186        St: AsRef<str>,
15187    {
15188        self._scopes.insert(String::from(scope.as_ref()));
15189        self
15190    }
15191    /// Identifies the authorization scope(s) for the method you are building.
15192    ///
15193    /// See [`Self::add_scope()`] for details.
15194    pub fn add_scopes<I, St>(
15195        mut self,
15196        scopes: I,
15197    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
15198    where
15199        I: IntoIterator<Item = St>,
15200        St: AsRef<str>,
15201    {
15202        self._scopes
15203            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15204        self
15205    }
15206
15207    /// Removes all scopes, and no default scope will be used either.
15208    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15209    /// for details).
15210    pub fn clear_scopes(
15211        mut self,
15212    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
15213        self._scopes.clear();
15214        self
15215    }
15216}
15217
15218/// Restore a CryptoKeyVersion in the DESTROY_SCHEDULED state. Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared.
15219///
15220/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.restore* method supported by a *project* resource.
15221/// It is not used directly, but through a [`ProjectMethods`] instance.
15222///
15223/// # Example
15224///
15225/// Instantiate a resource method builder
15226///
15227/// ```test_harness,no_run
15228/// # extern crate hyper;
15229/// # extern crate hyper_rustls;
15230/// # extern crate google_cloudkms1 as cloudkms1;
15231/// use cloudkms1::api::RestoreCryptoKeyVersionRequest;
15232/// # async fn dox() {
15233/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15234///
15235/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15236/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15237/// #     .with_native_roots()
15238/// #     .unwrap()
15239/// #     .https_only()
15240/// #     .enable_http2()
15241/// #     .build();
15242///
15243/// # let executor = hyper_util::rt::TokioExecutor::new();
15244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15245/// #     secret,
15246/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15247/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15248/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15249/// #     ),
15250/// # ).build().await.unwrap();
15251///
15252/// # let client = hyper_util::client::legacy::Client::builder(
15253/// #     hyper_util::rt::TokioExecutor::new()
15254/// # )
15255/// # .build(
15256/// #     hyper_rustls::HttpsConnectorBuilder::new()
15257/// #         .with_native_roots()
15258/// #         .unwrap()
15259/// #         .https_or_http()
15260/// #         .enable_http2()
15261/// #         .build()
15262/// # );
15263/// # let mut hub = CloudKMS::new(client, auth);
15264/// // As the method needs a request, you would usually fill it with the desired information
15265/// // into the respective structure. Some of the parts shown here might not be applicable !
15266/// // Values shown here are possibly random and not representative !
15267/// let mut req = RestoreCryptoKeyVersionRequest::default();
15268///
15269/// // You can configure optional parameters by calling the respective setters at will, and
15270/// // execute the final call using `doit()`.
15271/// // Values shown here are possibly random and not representative !
15272/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_restore(req, "name")
15273///              .doit().await;
15274/// # }
15275/// ```
15276pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15277where
15278    C: 'a,
15279{
15280    hub: &'a CloudKMS<C>,
15281    _request: RestoreCryptoKeyVersionRequest,
15282    _name: String,
15283    _delegate: Option<&'a mut dyn common::Delegate>,
15284    _additional_params: HashMap<String, String>,
15285    _scopes: BTreeSet<String>,
15286}
15287
15288impl<'a, C> common::CallBuilder
15289    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15290{
15291}
15292
15293impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15294where
15295    C: common::Connector,
15296{
15297    /// Perform the operation you have build so far.
15298    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
15299        use std::borrow::Cow;
15300        use std::io::{Read, Seek};
15301
15302        use common::{url::Params, ToParts};
15303        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15304
15305        let mut dd = common::DefaultDelegate;
15306        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15307        dlg.begin(common::MethodInfo {
15308            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore",
15309            http_method: hyper::Method::POST,
15310        });
15311
15312        for &field in ["alt", "name"].iter() {
15313            if self._additional_params.contains_key(field) {
15314                dlg.finished(false);
15315                return Err(common::Error::FieldClash(field));
15316            }
15317        }
15318
15319        let mut params = Params::with_capacity(4 + self._additional_params.len());
15320        params.push("name", self._name);
15321
15322        params.extend(self._additional_params.iter());
15323
15324        params.push("alt", "json");
15325        let mut url = self.hub._base_url.clone() + "v1/{+name}:restore";
15326        if self._scopes.is_empty() {
15327            self._scopes
15328                .insert(Scope::CloudPlatform.as_ref().to_string());
15329        }
15330
15331        #[allow(clippy::single_element_loop)]
15332        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15333            url = params.uri_replacement(url, param_name, find_this, true);
15334        }
15335        {
15336            let to_remove = ["name"];
15337            params.remove_params(&to_remove);
15338        }
15339
15340        let url = params.parse_with_url(&url);
15341
15342        let mut json_mime_type = mime::APPLICATION_JSON;
15343        let mut request_value_reader = {
15344            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15345            common::remove_json_null_values(&mut value);
15346            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15347            serde_json::to_writer(&mut dst, &value).unwrap();
15348            dst
15349        };
15350        let request_size = request_value_reader
15351            .seek(std::io::SeekFrom::End(0))
15352            .unwrap();
15353        request_value_reader
15354            .seek(std::io::SeekFrom::Start(0))
15355            .unwrap();
15356
15357        loop {
15358            let token = match self
15359                .hub
15360                .auth
15361                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15362                .await
15363            {
15364                Ok(token) => token,
15365                Err(e) => match dlg.token(e) {
15366                    Ok(token) => token,
15367                    Err(e) => {
15368                        dlg.finished(false);
15369                        return Err(common::Error::MissingToken(e));
15370                    }
15371                },
15372            };
15373            request_value_reader
15374                .seek(std::io::SeekFrom::Start(0))
15375                .unwrap();
15376            let mut req_result = {
15377                let client = &self.hub.client;
15378                dlg.pre_request();
15379                let mut req_builder = hyper::Request::builder()
15380                    .method(hyper::Method::POST)
15381                    .uri(url.as_str())
15382                    .header(USER_AGENT, self.hub._user_agent.clone());
15383
15384                if let Some(token) = token.as_ref() {
15385                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15386                }
15387
15388                let request = req_builder
15389                    .header(CONTENT_TYPE, json_mime_type.to_string())
15390                    .header(CONTENT_LENGTH, request_size as u64)
15391                    .body(common::to_body(
15392                        request_value_reader.get_ref().clone().into(),
15393                    ));
15394
15395                client.request(request.unwrap()).await
15396            };
15397
15398            match req_result {
15399                Err(err) => {
15400                    if let common::Retry::After(d) = dlg.http_error(&err) {
15401                        sleep(d).await;
15402                        continue;
15403                    }
15404                    dlg.finished(false);
15405                    return Err(common::Error::HttpError(err));
15406                }
15407                Ok(res) => {
15408                    let (mut parts, body) = res.into_parts();
15409                    let mut body = common::Body::new(body);
15410                    if !parts.status.is_success() {
15411                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15412                        let error = serde_json::from_str(&common::to_string(&bytes));
15413                        let response = common::to_response(parts, bytes.into());
15414
15415                        if let common::Retry::After(d) =
15416                            dlg.http_failure(&response, error.as_ref().ok())
15417                        {
15418                            sleep(d).await;
15419                            continue;
15420                        }
15421
15422                        dlg.finished(false);
15423
15424                        return Err(match error {
15425                            Ok(value) => common::Error::BadRequest(value),
15426                            _ => common::Error::Failure(response),
15427                        });
15428                    }
15429                    let response = {
15430                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15431                        let encoded = common::to_string(&bytes);
15432                        match serde_json::from_str(&encoded) {
15433                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15434                            Err(error) => {
15435                                dlg.response_json_decode_error(&encoded, &error);
15436                                return Err(common::Error::JsonDecodeError(
15437                                    encoded.to_string(),
15438                                    error,
15439                                ));
15440                            }
15441                        }
15442                    };
15443
15444                    dlg.finished(true);
15445                    return Ok(response);
15446                }
15447            }
15448        }
15449    }
15450
15451    ///
15452    /// Sets the *request* property to the given value.
15453    ///
15454    /// Even though the property as already been set when instantiating this call,
15455    /// we provide this method for API completeness.
15456    pub fn request(
15457        mut self,
15458        new_value: RestoreCryptoKeyVersionRequest,
15459    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
15460        self._request = new_value;
15461        self
15462    }
15463    /// Required. The resource name of the CryptoKeyVersion to restore.
15464    ///
15465    /// Sets the *name* path property to the given value.
15466    ///
15467    /// Even though the property as already been set when instantiating this call,
15468    /// we provide this method for API completeness.
15469    pub fn name(
15470        mut self,
15471        new_value: &str,
15472    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
15473        self._name = new_value.to_string();
15474        self
15475    }
15476    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15477    /// while executing the actual API request.
15478    ///
15479    /// ````text
15480    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15481    /// ````
15482    ///
15483    /// Sets the *delegate* property to the given value.
15484    pub fn delegate(
15485        mut self,
15486        new_value: &'a mut dyn common::Delegate,
15487    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
15488        self._delegate = Some(new_value);
15489        self
15490    }
15491
15492    /// Set any additional parameter of the query string used in the request.
15493    /// It should be used to set parameters which are not yet available through their own
15494    /// setters.
15495    ///
15496    /// Please note that this method must not be used to set any of the known parameters
15497    /// which have their own setter method. If done anyway, the request will fail.
15498    ///
15499    /// # Additional Parameters
15500    ///
15501    /// * *$.xgafv* (query-string) - V1 error format.
15502    /// * *access_token* (query-string) - OAuth access token.
15503    /// * *alt* (query-string) - Data format for response.
15504    /// * *callback* (query-string) - JSONP
15505    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15506    /// * *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.
15507    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15508    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15509    /// * *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.
15510    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15511    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15512    pub fn param<T>(
15513        mut self,
15514        name: T,
15515        value: T,
15516    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15517    where
15518        T: AsRef<str>,
15519    {
15520        self._additional_params
15521            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15522        self
15523    }
15524
15525    /// Identifies the authorization scope for the method you are building.
15526    ///
15527    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15528    /// [`Scope::CloudPlatform`].
15529    ///
15530    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15531    /// tokens for more than one scope.
15532    ///
15533    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15534    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15535    /// sufficient, a read-write scope will do as well.
15536    pub fn add_scope<St>(
15537        mut self,
15538        scope: St,
15539    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15540    where
15541        St: AsRef<str>,
15542    {
15543        self._scopes.insert(String::from(scope.as_ref()));
15544        self
15545    }
15546    /// Identifies the authorization scope(s) for the method you are building.
15547    ///
15548    /// See [`Self::add_scope()`] for details.
15549    pub fn add_scopes<I, St>(
15550        mut self,
15551        scopes: I,
15552    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
15553    where
15554        I: IntoIterator<Item = St>,
15555        St: AsRef<str>,
15556    {
15557        self._scopes
15558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15559        self
15560    }
15561
15562    /// Removes all scopes, and no default scope will be used either.
15563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15564    /// for details).
15565    pub fn clear_scopes(
15566        mut self,
15567    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
15568        self._scopes.clear();
15569        self
15570    }
15571}
15572
15573/// Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required.
15574///
15575/// A builder for the *locations.keyRings.cryptoKeys.create* method supported by a *project* resource.
15576/// It is not used directly, but through a [`ProjectMethods`] instance.
15577///
15578/// # Example
15579///
15580/// Instantiate a resource method builder
15581///
15582/// ```test_harness,no_run
15583/// # extern crate hyper;
15584/// # extern crate hyper_rustls;
15585/// # extern crate google_cloudkms1 as cloudkms1;
15586/// use cloudkms1::api::CryptoKey;
15587/// # async fn dox() {
15588/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15589///
15590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15591/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15592/// #     .with_native_roots()
15593/// #     .unwrap()
15594/// #     .https_only()
15595/// #     .enable_http2()
15596/// #     .build();
15597///
15598/// # let executor = hyper_util::rt::TokioExecutor::new();
15599/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15600/// #     secret,
15601/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15602/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15603/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15604/// #     ),
15605/// # ).build().await.unwrap();
15606///
15607/// # let client = hyper_util::client::legacy::Client::builder(
15608/// #     hyper_util::rt::TokioExecutor::new()
15609/// # )
15610/// # .build(
15611/// #     hyper_rustls::HttpsConnectorBuilder::new()
15612/// #         .with_native_roots()
15613/// #         .unwrap()
15614/// #         .https_or_http()
15615/// #         .enable_http2()
15616/// #         .build()
15617/// # );
15618/// # let mut hub = CloudKMS::new(client, auth);
15619/// // As the method needs a request, you would usually fill it with the desired information
15620/// // into the respective structure. Some of the parts shown here might not be applicable !
15621/// // Values shown here are possibly random and not representative !
15622/// let mut req = CryptoKey::default();
15623///
15624/// // You can configure optional parameters by calling the respective setters at will, and
15625/// // execute the final call using `doit()`.
15626/// // Values shown here are possibly random and not representative !
15627/// let result = hub.projects().locations_key_rings_crypto_keys_create(req, "parent")
15628///              .skip_initial_version_creation(false)
15629///              .crypto_key_id("Stet")
15630///              .doit().await;
15631/// # }
15632/// ```
15633pub struct ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
15634where
15635    C: 'a,
15636{
15637    hub: &'a CloudKMS<C>,
15638    _request: CryptoKey,
15639    _parent: String,
15640    _skip_initial_version_creation: Option<bool>,
15641    _crypto_key_id: Option<String>,
15642    _delegate: Option<&'a mut dyn common::Delegate>,
15643    _additional_params: HashMap<String, String>,
15644    _scopes: BTreeSet<String>,
15645}
15646
15647impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {}
15648
15649impl<'a, C> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
15650where
15651    C: common::Connector,
15652{
15653    /// Perform the operation you have build so far.
15654    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
15655        use std::borrow::Cow;
15656        use std::io::{Read, Seek};
15657
15658        use common::{url::Params, ToParts};
15659        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15660
15661        let mut dd = common::DefaultDelegate;
15662        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15663        dlg.begin(common::MethodInfo {
15664            id: "cloudkms.projects.locations.keyRings.cryptoKeys.create",
15665            http_method: hyper::Method::POST,
15666        });
15667
15668        for &field in ["alt", "parent", "skipInitialVersionCreation", "cryptoKeyId"].iter() {
15669            if self._additional_params.contains_key(field) {
15670                dlg.finished(false);
15671                return Err(common::Error::FieldClash(field));
15672            }
15673        }
15674
15675        let mut params = Params::with_capacity(6 + self._additional_params.len());
15676        params.push("parent", self._parent);
15677        if let Some(value) = self._skip_initial_version_creation.as_ref() {
15678            params.push("skipInitialVersionCreation", value.to_string());
15679        }
15680        if let Some(value) = self._crypto_key_id.as_ref() {
15681            params.push("cryptoKeyId", value);
15682        }
15683
15684        params.extend(self._additional_params.iter());
15685
15686        params.push("alt", "json");
15687        let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeys";
15688        if self._scopes.is_empty() {
15689            self._scopes
15690                .insert(Scope::CloudPlatform.as_ref().to_string());
15691        }
15692
15693        #[allow(clippy::single_element_loop)]
15694        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15695            url = params.uri_replacement(url, param_name, find_this, true);
15696        }
15697        {
15698            let to_remove = ["parent"];
15699            params.remove_params(&to_remove);
15700        }
15701
15702        let url = params.parse_with_url(&url);
15703
15704        let mut json_mime_type = mime::APPLICATION_JSON;
15705        let mut request_value_reader = {
15706            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15707            common::remove_json_null_values(&mut value);
15708            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15709            serde_json::to_writer(&mut dst, &value).unwrap();
15710            dst
15711        };
15712        let request_size = request_value_reader
15713            .seek(std::io::SeekFrom::End(0))
15714            .unwrap();
15715        request_value_reader
15716            .seek(std::io::SeekFrom::Start(0))
15717            .unwrap();
15718
15719        loop {
15720            let token = match self
15721                .hub
15722                .auth
15723                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15724                .await
15725            {
15726                Ok(token) => token,
15727                Err(e) => match dlg.token(e) {
15728                    Ok(token) => token,
15729                    Err(e) => {
15730                        dlg.finished(false);
15731                        return Err(common::Error::MissingToken(e));
15732                    }
15733                },
15734            };
15735            request_value_reader
15736                .seek(std::io::SeekFrom::Start(0))
15737                .unwrap();
15738            let mut req_result = {
15739                let client = &self.hub.client;
15740                dlg.pre_request();
15741                let mut req_builder = hyper::Request::builder()
15742                    .method(hyper::Method::POST)
15743                    .uri(url.as_str())
15744                    .header(USER_AGENT, self.hub._user_agent.clone());
15745
15746                if let Some(token) = token.as_ref() {
15747                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15748                }
15749
15750                let request = req_builder
15751                    .header(CONTENT_TYPE, json_mime_type.to_string())
15752                    .header(CONTENT_LENGTH, request_size as u64)
15753                    .body(common::to_body(
15754                        request_value_reader.get_ref().clone().into(),
15755                    ));
15756
15757                client.request(request.unwrap()).await
15758            };
15759
15760            match req_result {
15761                Err(err) => {
15762                    if let common::Retry::After(d) = dlg.http_error(&err) {
15763                        sleep(d).await;
15764                        continue;
15765                    }
15766                    dlg.finished(false);
15767                    return Err(common::Error::HttpError(err));
15768                }
15769                Ok(res) => {
15770                    let (mut parts, body) = res.into_parts();
15771                    let mut body = common::Body::new(body);
15772                    if !parts.status.is_success() {
15773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15774                        let error = serde_json::from_str(&common::to_string(&bytes));
15775                        let response = common::to_response(parts, bytes.into());
15776
15777                        if let common::Retry::After(d) =
15778                            dlg.http_failure(&response, error.as_ref().ok())
15779                        {
15780                            sleep(d).await;
15781                            continue;
15782                        }
15783
15784                        dlg.finished(false);
15785
15786                        return Err(match error {
15787                            Ok(value) => common::Error::BadRequest(value),
15788                            _ => common::Error::Failure(response),
15789                        });
15790                    }
15791                    let response = {
15792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15793                        let encoded = common::to_string(&bytes);
15794                        match serde_json::from_str(&encoded) {
15795                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15796                            Err(error) => {
15797                                dlg.response_json_decode_error(&encoded, &error);
15798                                return Err(common::Error::JsonDecodeError(
15799                                    encoded.to_string(),
15800                                    error,
15801                                ));
15802                            }
15803                        }
15804                    };
15805
15806                    dlg.finished(true);
15807                    return Ok(response);
15808                }
15809            }
15810        }
15811    }
15812
15813    ///
15814    /// Sets the *request* property to the given value.
15815    ///
15816    /// Even though the property as already been set when instantiating this call,
15817    /// we provide this method for API completeness.
15818    pub fn request(
15819        mut self,
15820        new_value: CryptoKey,
15821    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15822        self._request = new_value;
15823        self
15824    }
15825    /// Required. The name of the KeyRing associated with the CryptoKeys.
15826    ///
15827    /// Sets the *parent* path property to the given value.
15828    ///
15829    /// Even though the property as already been set when instantiating this call,
15830    /// we provide this method for API completeness.
15831    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15832        self._parent = new_value.to_string();
15833        self
15834    }
15835    /// If set to true, the request will create a CryptoKey without any CryptoKeyVersions. You must manually call CreateCryptoKeyVersion or ImportCryptoKeyVersion before you can use this CryptoKey.
15836    ///
15837    /// Sets the *skip initial version creation* query property to the given value.
15838    pub fn skip_initial_version_creation(
15839        mut self,
15840        new_value: bool,
15841    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15842        self._skip_initial_version_creation = Some(new_value);
15843        self
15844    }
15845    /// Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`
15846    ///
15847    /// Sets the *crypto key id* query property to the given value.
15848    pub fn crypto_key_id(
15849        mut self,
15850        new_value: &str,
15851    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15852        self._crypto_key_id = Some(new_value.to_string());
15853        self
15854    }
15855    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15856    /// while executing the actual API request.
15857    ///
15858    /// ````text
15859    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15860    /// ````
15861    ///
15862    /// Sets the *delegate* property to the given value.
15863    pub fn delegate(
15864        mut self,
15865        new_value: &'a mut dyn common::Delegate,
15866    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15867        self._delegate = Some(new_value);
15868        self
15869    }
15870
15871    /// Set any additional parameter of the query string used in the request.
15872    /// It should be used to set parameters which are not yet available through their own
15873    /// setters.
15874    ///
15875    /// Please note that this method must not be used to set any of the known parameters
15876    /// which have their own setter method. If done anyway, the request will fail.
15877    ///
15878    /// # Additional Parameters
15879    ///
15880    /// * *$.xgafv* (query-string) - V1 error format.
15881    /// * *access_token* (query-string) - OAuth access token.
15882    /// * *alt* (query-string) - Data format for response.
15883    /// * *callback* (query-string) - JSONP
15884    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15885    /// * *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.
15886    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15887    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15888    /// * *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.
15889    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15890    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15891    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
15892    where
15893        T: AsRef<str>,
15894    {
15895        self._additional_params
15896            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15897        self
15898    }
15899
15900    /// Identifies the authorization scope for the method you are building.
15901    ///
15902    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15903    /// [`Scope::CloudPlatform`].
15904    ///
15905    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15906    /// tokens for more than one scope.
15907    ///
15908    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15909    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15910    /// sufficient, a read-write scope will do as well.
15911    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
15912    where
15913        St: AsRef<str>,
15914    {
15915        self._scopes.insert(String::from(scope.as_ref()));
15916        self
15917    }
15918    /// Identifies the authorization scope(s) for the method you are building.
15919    ///
15920    /// See [`Self::add_scope()`] for details.
15921    pub fn add_scopes<I, St>(
15922        mut self,
15923        scopes: I,
15924    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
15925    where
15926        I: IntoIterator<Item = St>,
15927        St: AsRef<str>,
15928    {
15929        self._scopes
15930            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15931        self
15932    }
15933
15934    /// Removes all scopes, and no default scope will be used either.
15935    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15936    /// for details).
15937    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
15938        self._scopes.clear();
15939        self
15940    }
15941}
15942
15943/// Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
15944///
15945/// A builder for the *locations.keyRings.cryptoKeys.decrypt* method supported by a *project* resource.
15946/// It is not used directly, but through a [`ProjectMethods`] instance.
15947///
15948/// # Example
15949///
15950/// Instantiate a resource method builder
15951///
15952/// ```test_harness,no_run
15953/// # extern crate hyper;
15954/// # extern crate hyper_rustls;
15955/// # extern crate google_cloudkms1 as cloudkms1;
15956/// use cloudkms1::api::DecryptRequest;
15957/// # async fn dox() {
15958/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15959///
15960/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15961/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15962/// #     .with_native_roots()
15963/// #     .unwrap()
15964/// #     .https_only()
15965/// #     .enable_http2()
15966/// #     .build();
15967///
15968/// # let executor = hyper_util::rt::TokioExecutor::new();
15969/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15970/// #     secret,
15971/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15972/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15973/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15974/// #     ),
15975/// # ).build().await.unwrap();
15976///
15977/// # let client = hyper_util::client::legacy::Client::builder(
15978/// #     hyper_util::rt::TokioExecutor::new()
15979/// # )
15980/// # .build(
15981/// #     hyper_rustls::HttpsConnectorBuilder::new()
15982/// #         .with_native_roots()
15983/// #         .unwrap()
15984/// #         .https_or_http()
15985/// #         .enable_http2()
15986/// #         .build()
15987/// # );
15988/// # let mut hub = CloudKMS::new(client, auth);
15989/// // As the method needs a request, you would usually fill it with the desired information
15990/// // into the respective structure. Some of the parts shown here might not be applicable !
15991/// // Values shown here are possibly random and not representative !
15992/// let mut req = DecryptRequest::default();
15993///
15994/// // You can configure optional parameters by calling the respective setters at will, and
15995/// // execute the final call using `doit()`.
15996/// // Values shown here are possibly random and not representative !
15997/// let result = hub.projects().locations_key_rings_crypto_keys_decrypt(req, "name")
15998///              .doit().await;
15999/// # }
16000/// ```
16001pub struct ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
16002where
16003    C: 'a,
16004{
16005    hub: &'a CloudKMS<C>,
16006    _request: DecryptRequest,
16007    _name: String,
16008    _delegate: Option<&'a mut dyn common::Delegate>,
16009    _additional_params: HashMap<String, String>,
16010    _scopes: BTreeSet<String>,
16011}
16012
16013impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {}
16014
16015impl<'a, C> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
16016where
16017    C: common::Connector,
16018{
16019    /// Perform the operation you have build so far.
16020    pub async fn doit(mut self) -> common::Result<(common::Response, DecryptResponse)> {
16021        use std::borrow::Cow;
16022        use std::io::{Read, Seek};
16023
16024        use common::{url::Params, ToParts};
16025        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16026
16027        let mut dd = common::DefaultDelegate;
16028        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16029        dlg.begin(common::MethodInfo {
16030            id: "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt",
16031            http_method: hyper::Method::POST,
16032        });
16033
16034        for &field in ["alt", "name"].iter() {
16035            if self._additional_params.contains_key(field) {
16036                dlg.finished(false);
16037                return Err(common::Error::FieldClash(field));
16038            }
16039        }
16040
16041        let mut params = Params::with_capacity(4 + self._additional_params.len());
16042        params.push("name", self._name);
16043
16044        params.extend(self._additional_params.iter());
16045
16046        params.push("alt", "json");
16047        let mut url = self.hub._base_url.clone() + "v1/{+name}:decrypt";
16048        if self._scopes.is_empty() {
16049            self._scopes
16050                .insert(Scope::CloudPlatform.as_ref().to_string());
16051        }
16052
16053        #[allow(clippy::single_element_loop)]
16054        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16055            url = params.uri_replacement(url, param_name, find_this, true);
16056        }
16057        {
16058            let to_remove = ["name"];
16059            params.remove_params(&to_remove);
16060        }
16061
16062        let url = params.parse_with_url(&url);
16063
16064        let mut json_mime_type = mime::APPLICATION_JSON;
16065        let mut request_value_reader = {
16066            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16067            common::remove_json_null_values(&mut value);
16068            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16069            serde_json::to_writer(&mut dst, &value).unwrap();
16070            dst
16071        };
16072        let request_size = request_value_reader
16073            .seek(std::io::SeekFrom::End(0))
16074            .unwrap();
16075        request_value_reader
16076            .seek(std::io::SeekFrom::Start(0))
16077            .unwrap();
16078
16079        loop {
16080            let token = match self
16081                .hub
16082                .auth
16083                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16084                .await
16085            {
16086                Ok(token) => token,
16087                Err(e) => match dlg.token(e) {
16088                    Ok(token) => token,
16089                    Err(e) => {
16090                        dlg.finished(false);
16091                        return Err(common::Error::MissingToken(e));
16092                    }
16093                },
16094            };
16095            request_value_reader
16096                .seek(std::io::SeekFrom::Start(0))
16097                .unwrap();
16098            let mut req_result = {
16099                let client = &self.hub.client;
16100                dlg.pre_request();
16101                let mut req_builder = hyper::Request::builder()
16102                    .method(hyper::Method::POST)
16103                    .uri(url.as_str())
16104                    .header(USER_AGENT, self.hub._user_agent.clone());
16105
16106                if let Some(token) = token.as_ref() {
16107                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16108                }
16109
16110                let request = req_builder
16111                    .header(CONTENT_TYPE, json_mime_type.to_string())
16112                    .header(CONTENT_LENGTH, request_size as u64)
16113                    .body(common::to_body(
16114                        request_value_reader.get_ref().clone().into(),
16115                    ));
16116
16117                client.request(request.unwrap()).await
16118            };
16119
16120            match req_result {
16121                Err(err) => {
16122                    if let common::Retry::After(d) = dlg.http_error(&err) {
16123                        sleep(d).await;
16124                        continue;
16125                    }
16126                    dlg.finished(false);
16127                    return Err(common::Error::HttpError(err));
16128                }
16129                Ok(res) => {
16130                    let (mut parts, body) = res.into_parts();
16131                    let mut body = common::Body::new(body);
16132                    if !parts.status.is_success() {
16133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16134                        let error = serde_json::from_str(&common::to_string(&bytes));
16135                        let response = common::to_response(parts, bytes.into());
16136
16137                        if let common::Retry::After(d) =
16138                            dlg.http_failure(&response, error.as_ref().ok())
16139                        {
16140                            sleep(d).await;
16141                            continue;
16142                        }
16143
16144                        dlg.finished(false);
16145
16146                        return Err(match error {
16147                            Ok(value) => common::Error::BadRequest(value),
16148                            _ => common::Error::Failure(response),
16149                        });
16150                    }
16151                    let response = {
16152                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16153                        let encoded = common::to_string(&bytes);
16154                        match serde_json::from_str(&encoded) {
16155                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16156                            Err(error) => {
16157                                dlg.response_json_decode_error(&encoded, &error);
16158                                return Err(common::Error::JsonDecodeError(
16159                                    encoded.to_string(),
16160                                    error,
16161                                ));
16162                            }
16163                        }
16164                    };
16165
16166                    dlg.finished(true);
16167                    return Ok(response);
16168                }
16169            }
16170        }
16171    }
16172
16173    ///
16174    /// Sets the *request* property to the given value.
16175    ///
16176    /// Even though the property as already been set when instantiating this call,
16177    /// we provide this method for API completeness.
16178    pub fn request(
16179        mut self,
16180        new_value: DecryptRequest,
16181    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
16182        self._request = new_value;
16183        self
16184    }
16185    /// Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version.
16186    ///
16187    /// Sets the *name* path property to the given value.
16188    ///
16189    /// Even though the property as already been set when instantiating this call,
16190    /// we provide this method for API completeness.
16191    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
16192        self._name = new_value.to_string();
16193        self
16194    }
16195    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16196    /// while executing the actual API request.
16197    ///
16198    /// ````text
16199    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16200    /// ````
16201    ///
16202    /// Sets the *delegate* property to the given value.
16203    pub fn delegate(
16204        mut self,
16205        new_value: &'a mut dyn common::Delegate,
16206    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
16207        self._delegate = Some(new_value);
16208        self
16209    }
16210
16211    /// Set any additional parameter of the query string used in the request.
16212    /// It should be used to set parameters which are not yet available through their own
16213    /// setters.
16214    ///
16215    /// Please note that this method must not be used to set any of the known parameters
16216    /// which have their own setter method. If done anyway, the request will fail.
16217    ///
16218    /// # Additional Parameters
16219    ///
16220    /// * *$.xgafv* (query-string) - V1 error format.
16221    /// * *access_token* (query-string) - OAuth access token.
16222    /// * *alt* (query-string) - Data format for response.
16223    /// * *callback* (query-string) - JSONP
16224    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16225    /// * *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.
16226    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16227    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16228    /// * *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.
16229    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16230    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16231    pub fn param<T>(
16232        mut self,
16233        name: T,
16234        value: T,
16235    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
16236    where
16237        T: AsRef<str>,
16238    {
16239        self._additional_params
16240            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16241        self
16242    }
16243
16244    /// Identifies the authorization scope for the method you are building.
16245    ///
16246    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16247    /// [`Scope::CloudPlatform`].
16248    ///
16249    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16250    /// tokens for more than one scope.
16251    ///
16252    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16253    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16254    /// sufficient, a read-write scope will do as well.
16255    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
16256    where
16257        St: AsRef<str>,
16258    {
16259        self._scopes.insert(String::from(scope.as_ref()));
16260        self
16261    }
16262    /// Identifies the authorization scope(s) for the method you are building.
16263    ///
16264    /// See [`Self::add_scope()`] for details.
16265    pub fn add_scopes<I, St>(
16266        mut self,
16267        scopes: I,
16268    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
16269    where
16270        I: IntoIterator<Item = St>,
16271        St: AsRef<str>,
16272    {
16273        self._scopes
16274            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16275        self
16276    }
16277
16278    /// Removes all scopes, and no default scope will be used either.
16279    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16280    /// for details).
16281    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
16282        self._scopes.clear();
16283        self
16284    }
16285}
16286
16287/// Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
16288///
16289/// A builder for the *locations.keyRings.cryptoKeys.encrypt* method supported by a *project* resource.
16290/// It is not used directly, but through a [`ProjectMethods`] instance.
16291///
16292/// # Example
16293///
16294/// Instantiate a resource method builder
16295///
16296/// ```test_harness,no_run
16297/// # extern crate hyper;
16298/// # extern crate hyper_rustls;
16299/// # extern crate google_cloudkms1 as cloudkms1;
16300/// use cloudkms1::api::EncryptRequest;
16301/// # async fn dox() {
16302/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16303///
16304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16306/// #     .with_native_roots()
16307/// #     .unwrap()
16308/// #     .https_only()
16309/// #     .enable_http2()
16310/// #     .build();
16311///
16312/// # let executor = hyper_util::rt::TokioExecutor::new();
16313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16314/// #     secret,
16315/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16316/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16317/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16318/// #     ),
16319/// # ).build().await.unwrap();
16320///
16321/// # let client = hyper_util::client::legacy::Client::builder(
16322/// #     hyper_util::rt::TokioExecutor::new()
16323/// # )
16324/// # .build(
16325/// #     hyper_rustls::HttpsConnectorBuilder::new()
16326/// #         .with_native_roots()
16327/// #         .unwrap()
16328/// #         .https_or_http()
16329/// #         .enable_http2()
16330/// #         .build()
16331/// # );
16332/// # let mut hub = CloudKMS::new(client, auth);
16333/// // As the method needs a request, you would usually fill it with the desired information
16334/// // into the respective structure. Some of the parts shown here might not be applicable !
16335/// // Values shown here are possibly random and not representative !
16336/// let mut req = EncryptRequest::default();
16337///
16338/// // You can configure optional parameters by calling the respective setters at will, and
16339/// // execute the final call using `doit()`.
16340/// // Values shown here are possibly random and not representative !
16341/// let result = hub.projects().locations_key_rings_crypto_keys_encrypt(req, "name")
16342///              .doit().await;
16343/// # }
16344/// ```
16345pub struct ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
16346where
16347    C: 'a,
16348{
16349    hub: &'a CloudKMS<C>,
16350    _request: EncryptRequest,
16351    _name: String,
16352    _delegate: Option<&'a mut dyn common::Delegate>,
16353    _additional_params: HashMap<String, String>,
16354    _scopes: BTreeSet<String>,
16355}
16356
16357impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {}
16358
16359impl<'a, C> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
16360where
16361    C: common::Connector,
16362{
16363    /// Perform the operation you have build so far.
16364    pub async fn doit(mut self) -> common::Result<(common::Response, EncryptResponse)> {
16365        use std::borrow::Cow;
16366        use std::io::{Read, Seek};
16367
16368        use common::{url::Params, ToParts};
16369        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16370
16371        let mut dd = common::DefaultDelegate;
16372        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16373        dlg.begin(common::MethodInfo {
16374            id: "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt",
16375            http_method: hyper::Method::POST,
16376        });
16377
16378        for &field in ["alt", "name"].iter() {
16379            if self._additional_params.contains_key(field) {
16380                dlg.finished(false);
16381                return Err(common::Error::FieldClash(field));
16382            }
16383        }
16384
16385        let mut params = Params::with_capacity(4 + self._additional_params.len());
16386        params.push("name", self._name);
16387
16388        params.extend(self._additional_params.iter());
16389
16390        params.push("alt", "json");
16391        let mut url = self.hub._base_url.clone() + "v1/{+name}:encrypt";
16392        if self._scopes.is_empty() {
16393            self._scopes
16394                .insert(Scope::CloudPlatform.as_ref().to_string());
16395        }
16396
16397        #[allow(clippy::single_element_loop)]
16398        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16399            url = params.uri_replacement(url, param_name, find_this, true);
16400        }
16401        {
16402            let to_remove = ["name"];
16403            params.remove_params(&to_remove);
16404        }
16405
16406        let url = params.parse_with_url(&url);
16407
16408        let mut json_mime_type = mime::APPLICATION_JSON;
16409        let mut request_value_reader = {
16410            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16411            common::remove_json_null_values(&mut value);
16412            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16413            serde_json::to_writer(&mut dst, &value).unwrap();
16414            dst
16415        };
16416        let request_size = request_value_reader
16417            .seek(std::io::SeekFrom::End(0))
16418            .unwrap();
16419        request_value_reader
16420            .seek(std::io::SeekFrom::Start(0))
16421            .unwrap();
16422
16423        loop {
16424            let token = match self
16425                .hub
16426                .auth
16427                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16428                .await
16429            {
16430                Ok(token) => token,
16431                Err(e) => match dlg.token(e) {
16432                    Ok(token) => token,
16433                    Err(e) => {
16434                        dlg.finished(false);
16435                        return Err(common::Error::MissingToken(e));
16436                    }
16437                },
16438            };
16439            request_value_reader
16440                .seek(std::io::SeekFrom::Start(0))
16441                .unwrap();
16442            let mut req_result = {
16443                let client = &self.hub.client;
16444                dlg.pre_request();
16445                let mut req_builder = hyper::Request::builder()
16446                    .method(hyper::Method::POST)
16447                    .uri(url.as_str())
16448                    .header(USER_AGENT, self.hub._user_agent.clone());
16449
16450                if let Some(token) = token.as_ref() {
16451                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16452                }
16453
16454                let request = req_builder
16455                    .header(CONTENT_TYPE, json_mime_type.to_string())
16456                    .header(CONTENT_LENGTH, request_size as u64)
16457                    .body(common::to_body(
16458                        request_value_reader.get_ref().clone().into(),
16459                    ));
16460
16461                client.request(request.unwrap()).await
16462            };
16463
16464            match req_result {
16465                Err(err) => {
16466                    if let common::Retry::After(d) = dlg.http_error(&err) {
16467                        sleep(d).await;
16468                        continue;
16469                    }
16470                    dlg.finished(false);
16471                    return Err(common::Error::HttpError(err));
16472                }
16473                Ok(res) => {
16474                    let (mut parts, body) = res.into_parts();
16475                    let mut body = common::Body::new(body);
16476                    if !parts.status.is_success() {
16477                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16478                        let error = serde_json::from_str(&common::to_string(&bytes));
16479                        let response = common::to_response(parts, bytes.into());
16480
16481                        if let common::Retry::After(d) =
16482                            dlg.http_failure(&response, error.as_ref().ok())
16483                        {
16484                            sleep(d).await;
16485                            continue;
16486                        }
16487
16488                        dlg.finished(false);
16489
16490                        return Err(match error {
16491                            Ok(value) => common::Error::BadRequest(value),
16492                            _ => common::Error::Failure(response),
16493                        });
16494                    }
16495                    let response = {
16496                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16497                        let encoded = common::to_string(&bytes);
16498                        match serde_json::from_str(&encoded) {
16499                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16500                            Err(error) => {
16501                                dlg.response_json_decode_error(&encoded, &error);
16502                                return Err(common::Error::JsonDecodeError(
16503                                    encoded.to_string(),
16504                                    error,
16505                                ));
16506                            }
16507                        }
16508                    };
16509
16510                    dlg.finished(true);
16511                    return Ok(response);
16512                }
16513            }
16514        }
16515    }
16516
16517    ///
16518    /// Sets the *request* property to the given value.
16519    ///
16520    /// Even though the property as already been set when instantiating this call,
16521    /// we provide this method for API completeness.
16522    pub fn request(
16523        mut self,
16524        new_value: EncryptRequest,
16525    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
16526        self._request = new_value;
16527        self
16528    }
16529    /// Required. The resource name of the CryptoKey or CryptoKeyVersion to use for encryption. If a CryptoKey is specified, the server will use its primary version.
16530    ///
16531    /// Sets the *name* path property to the given value.
16532    ///
16533    /// Even though the property as already been set when instantiating this call,
16534    /// we provide this method for API completeness.
16535    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
16536        self._name = new_value.to_string();
16537        self
16538    }
16539    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16540    /// while executing the actual API request.
16541    ///
16542    /// ````text
16543    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16544    /// ````
16545    ///
16546    /// Sets the *delegate* property to the given value.
16547    pub fn delegate(
16548        mut self,
16549        new_value: &'a mut dyn common::Delegate,
16550    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
16551        self._delegate = Some(new_value);
16552        self
16553    }
16554
16555    /// Set any additional parameter of the query string used in the request.
16556    /// It should be used to set parameters which are not yet available through their own
16557    /// setters.
16558    ///
16559    /// Please note that this method must not be used to set any of the known parameters
16560    /// which have their own setter method. If done anyway, the request will fail.
16561    ///
16562    /// # Additional Parameters
16563    ///
16564    /// * *$.xgafv* (query-string) - V1 error format.
16565    /// * *access_token* (query-string) - OAuth access token.
16566    /// * *alt* (query-string) - Data format for response.
16567    /// * *callback* (query-string) - JSONP
16568    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16569    /// * *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.
16570    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16571    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16572    /// * *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.
16573    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16574    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16575    pub fn param<T>(
16576        mut self,
16577        name: T,
16578        value: T,
16579    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
16580    where
16581        T: AsRef<str>,
16582    {
16583        self._additional_params
16584            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16585        self
16586    }
16587
16588    /// Identifies the authorization scope for the method you are building.
16589    ///
16590    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16591    /// [`Scope::CloudPlatform`].
16592    ///
16593    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16594    /// tokens for more than one scope.
16595    ///
16596    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16597    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16598    /// sufficient, a read-write scope will do as well.
16599    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
16600    where
16601        St: AsRef<str>,
16602    {
16603        self._scopes.insert(String::from(scope.as_ref()));
16604        self
16605    }
16606    /// Identifies the authorization scope(s) for the method you are building.
16607    ///
16608    /// See [`Self::add_scope()`] for details.
16609    pub fn add_scopes<I, St>(
16610        mut self,
16611        scopes: I,
16612    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
16613    where
16614        I: IntoIterator<Item = St>,
16615        St: AsRef<str>,
16616    {
16617        self._scopes
16618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16619        self
16620    }
16621
16622    /// Removes all scopes, and no default scope will be used either.
16623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16624    /// for details).
16625    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
16626        self._scopes.clear();
16627        self
16628    }
16629}
16630
16631/// Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
16632///
16633/// A builder for the *locations.keyRings.cryptoKeys.get* method supported by a *project* resource.
16634/// It is not used directly, but through a [`ProjectMethods`] instance.
16635///
16636/// # Example
16637///
16638/// Instantiate a resource method builder
16639///
16640/// ```test_harness,no_run
16641/// # extern crate hyper;
16642/// # extern crate hyper_rustls;
16643/// # extern crate google_cloudkms1 as cloudkms1;
16644/// # async fn dox() {
16645/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16646///
16647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16648/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16649/// #     .with_native_roots()
16650/// #     .unwrap()
16651/// #     .https_only()
16652/// #     .enable_http2()
16653/// #     .build();
16654///
16655/// # let executor = hyper_util::rt::TokioExecutor::new();
16656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16657/// #     secret,
16658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16659/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16660/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16661/// #     ),
16662/// # ).build().await.unwrap();
16663///
16664/// # let client = hyper_util::client::legacy::Client::builder(
16665/// #     hyper_util::rt::TokioExecutor::new()
16666/// # )
16667/// # .build(
16668/// #     hyper_rustls::HttpsConnectorBuilder::new()
16669/// #         .with_native_roots()
16670/// #         .unwrap()
16671/// #         .https_or_http()
16672/// #         .enable_http2()
16673/// #         .build()
16674/// # );
16675/// # let mut hub = CloudKMS::new(client, auth);
16676/// // You can configure optional parameters by calling the respective setters at will, and
16677/// // execute the final call using `doit()`.
16678/// // Values shown here are possibly random and not representative !
16679/// let result = hub.projects().locations_key_rings_crypto_keys_get("name")
16680///              .doit().await;
16681/// # }
16682/// ```
16683pub struct ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
16684where
16685    C: 'a,
16686{
16687    hub: &'a CloudKMS<C>,
16688    _name: String,
16689    _delegate: Option<&'a mut dyn common::Delegate>,
16690    _additional_params: HashMap<String, String>,
16691    _scopes: BTreeSet<String>,
16692}
16693
16694impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {}
16695
16696impl<'a, C> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
16697where
16698    C: common::Connector,
16699{
16700    /// Perform the operation you have build so far.
16701    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
16702        use std::borrow::Cow;
16703        use std::io::{Read, Seek};
16704
16705        use common::{url::Params, ToParts};
16706        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16707
16708        let mut dd = common::DefaultDelegate;
16709        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16710        dlg.begin(common::MethodInfo {
16711            id: "cloudkms.projects.locations.keyRings.cryptoKeys.get",
16712            http_method: hyper::Method::GET,
16713        });
16714
16715        for &field in ["alt", "name"].iter() {
16716            if self._additional_params.contains_key(field) {
16717                dlg.finished(false);
16718                return Err(common::Error::FieldClash(field));
16719            }
16720        }
16721
16722        let mut params = Params::with_capacity(3 + self._additional_params.len());
16723        params.push("name", self._name);
16724
16725        params.extend(self._additional_params.iter());
16726
16727        params.push("alt", "json");
16728        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16729        if self._scopes.is_empty() {
16730            self._scopes
16731                .insert(Scope::CloudPlatform.as_ref().to_string());
16732        }
16733
16734        #[allow(clippy::single_element_loop)]
16735        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16736            url = params.uri_replacement(url, param_name, find_this, true);
16737        }
16738        {
16739            let to_remove = ["name"];
16740            params.remove_params(&to_remove);
16741        }
16742
16743        let url = params.parse_with_url(&url);
16744
16745        loop {
16746            let token = match self
16747                .hub
16748                .auth
16749                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16750                .await
16751            {
16752                Ok(token) => token,
16753                Err(e) => match dlg.token(e) {
16754                    Ok(token) => token,
16755                    Err(e) => {
16756                        dlg.finished(false);
16757                        return Err(common::Error::MissingToken(e));
16758                    }
16759                },
16760            };
16761            let mut req_result = {
16762                let client = &self.hub.client;
16763                dlg.pre_request();
16764                let mut req_builder = hyper::Request::builder()
16765                    .method(hyper::Method::GET)
16766                    .uri(url.as_str())
16767                    .header(USER_AGENT, self.hub._user_agent.clone());
16768
16769                if let Some(token) = token.as_ref() {
16770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16771                }
16772
16773                let request = req_builder
16774                    .header(CONTENT_LENGTH, 0_u64)
16775                    .body(common::to_body::<String>(None));
16776
16777                client.request(request.unwrap()).await
16778            };
16779
16780            match req_result {
16781                Err(err) => {
16782                    if let common::Retry::After(d) = dlg.http_error(&err) {
16783                        sleep(d).await;
16784                        continue;
16785                    }
16786                    dlg.finished(false);
16787                    return Err(common::Error::HttpError(err));
16788                }
16789                Ok(res) => {
16790                    let (mut parts, body) = res.into_parts();
16791                    let mut body = common::Body::new(body);
16792                    if !parts.status.is_success() {
16793                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16794                        let error = serde_json::from_str(&common::to_string(&bytes));
16795                        let response = common::to_response(parts, bytes.into());
16796
16797                        if let common::Retry::After(d) =
16798                            dlg.http_failure(&response, error.as_ref().ok())
16799                        {
16800                            sleep(d).await;
16801                            continue;
16802                        }
16803
16804                        dlg.finished(false);
16805
16806                        return Err(match error {
16807                            Ok(value) => common::Error::BadRequest(value),
16808                            _ => common::Error::Failure(response),
16809                        });
16810                    }
16811                    let response = {
16812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16813                        let encoded = common::to_string(&bytes);
16814                        match serde_json::from_str(&encoded) {
16815                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16816                            Err(error) => {
16817                                dlg.response_json_decode_error(&encoded, &error);
16818                                return Err(common::Error::JsonDecodeError(
16819                                    encoded.to_string(),
16820                                    error,
16821                                ));
16822                            }
16823                        }
16824                    };
16825
16826                    dlg.finished(true);
16827                    return Ok(response);
16828                }
16829            }
16830        }
16831    }
16832
16833    /// Required. The name of the CryptoKey to get.
16834    ///
16835    /// Sets the *name* path property to the given value.
16836    ///
16837    /// Even though the property as already been set when instantiating this call,
16838    /// we provide this method for API completeness.
16839    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
16840        self._name = new_value.to_string();
16841        self
16842    }
16843    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16844    /// while executing the actual API request.
16845    ///
16846    /// ````text
16847    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16848    /// ````
16849    ///
16850    /// Sets the *delegate* property to the given value.
16851    pub fn delegate(
16852        mut self,
16853        new_value: &'a mut dyn common::Delegate,
16854    ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
16855        self._delegate = Some(new_value);
16856        self
16857    }
16858
16859    /// Set any additional parameter of the query string used in the request.
16860    /// It should be used to set parameters which are not yet available through their own
16861    /// setters.
16862    ///
16863    /// Please note that this method must not be used to set any of the known parameters
16864    /// which have their own setter method. If done anyway, the request will fail.
16865    ///
16866    /// # Additional Parameters
16867    ///
16868    /// * *$.xgafv* (query-string) - V1 error format.
16869    /// * *access_token* (query-string) - OAuth access token.
16870    /// * *alt* (query-string) - Data format for response.
16871    /// * *callback* (query-string) - JSONP
16872    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16873    /// * *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.
16874    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16875    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16876    /// * *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.
16877    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16878    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16879    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
16880    where
16881        T: AsRef<str>,
16882    {
16883        self._additional_params
16884            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16885        self
16886    }
16887
16888    /// Identifies the authorization scope for the method you are building.
16889    ///
16890    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16891    /// [`Scope::CloudPlatform`].
16892    ///
16893    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16894    /// tokens for more than one scope.
16895    ///
16896    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16897    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16898    /// sufficient, a read-write scope will do as well.
16899    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
16900    where
16901        St: AsRef<str>,
16902    {
16903        self._scopes.insert(String::from(scope.as_ref()));
16904        self
16905    }
16906    /// Identifies the authorization scope(s) for the method you are building.
16907    ///
16908    /// See [`Self::add_scope()`] for details.
16909    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
16910    where
16911        I: IntoIterator<Item = St>,
16912        St: AsRef<str>,
16913    {
16914        self._scopes
16915            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16916        self
16917    }
16918
16919    /// Removes all scopes, and no default scope will be used either.
16920    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16921    /// for details).
16922    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
16923        self._scopes.clear();
16924        self
16925    }
16926}
16927
16928/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
16929///
16930/// A builder for the *locations.keyRings.cryptoKeys.getIamPolicy* method supported by a *project* resource.
16931/// It is not used directly, but through a [`ProjectMethods`] instance.
16932///
16933/// # Example
16934///
16935/// Instantiate a resource method builder
16936///
16937/// ```test_harness,no_run
16938/// # extern crate hyper;
16939/// # extern crate hyper_rustls;
16940/// # extern crate google_cloudkms1 as cloudkms1;
16941/// # async fn dox() {
16942/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16943///
16944/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16945/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16946/// #     .with_native_roots()
16947/// #     .unwrap()
16948/// #     .https_only()
16949/// #     .enable_http2()
16950/// #     .build();
16951///
16952/// # let executor = hyper_util::rt::TokioExecutor::new();
16953/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16954/// #     secret,
16955/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16956/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16957/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16958/// #     ),
16959/// # ).build().await.unwrap();
16960///
16961/// # let client = hyper_util::client::legacy::Client::builder(
16962/// #     hyper_util::rt::TokioExecutor::new()
16963/// # )
16964/// # .build(
16965/// #     hyper_rustls::HttpsConnectorBuilder::new()
16966/// #         .with_native_roots()
16967/// #         .unwrap()
16968/// #         .https_or_http()
16969/// #         .enable_http2()
16970/// #         .build()
16971/// # );
16972/// # let mut hub = CloudKMS::new(client, auth);
16973/// // You can configure optional parameters by calling the respective setters at will, and
16974/// // execute the final call using `doit()`.
16975/// // Values shown here are possibly random and not representative !
16976/// let result = hub.projects().locations_key_rings_crypto_keys_get_iam_policy("resource")
16977///              .options_requested_policy_version(-88)
16978///              .doit().await;
16979/// # }
16980/// ```
16981pub struct ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
16982where
16983    C: 'a,
16984{
16985    hub: &'a CloudKMS<C>,
16986    _resource: String,
16987    _options_requested_policy_version: Option<i32>,
16988    _delegate: Option<&'a mut dyn common::Delegate>,
16989    _additional_params: HashMap<String, String>,
16990    _scopes: BTreeSet<String>,
16991}
16992
16993impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {}
16994
16995impl<'a, C> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
16996where
16997    C: common::Connector,
16998{
16999    /// Perform the operation you have build so far.
17000    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17001        use std::borrow::Cow;
17002        use std::io::{Read, Seek};
17003
17004        use common::{url::Params, ToParts};
17005        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17006
17007        let mut dd = common::DefaultDelegate;
17008        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17009        dlg.begin(common::MethodInfo {
17010            id: "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy",
17011            http_method: hyper::Method::GET,
17012        });
17013
17014        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
17015            if self._additional_params.contains_key(field) {
17016                dlg.finished(false);
17017                return Err(common::Error::FieldClash(field));
17018            }
17019        }
17020
17021        let mut params = Params::with_capacity(4 + self._additional_params.len());
17022        params.push("resource", self._resource);
17023        if let Some(value) = self._options_requested_policy_version.as_ref() {
17024            params.push("options.requestedPolicyVersion", value.to_string());
17025        }
17026
17027        params.extend(self._additional_params.iter());
17028
17029        params.push("alt", "json");
17030        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
17031        if self._scopes.is_empty() {
17032            self._scopes
17033                .insert(Scope::CloudPlatform.as_ref().to_string());
17034        }
17035
17036        #[allow(clippy::single_element_loop)]
17037        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17038            url = params.uri_replacement(url, param_name, find_this, true);
17039        }
17040        {
17041            let to_remove = ["resource"];
17042            params.remove_params(&to_remove);
17043        }
17044
17045        let url = params.parse_with_url(&url);
17046
17047        loop {
17048            let token = match self
17049                .hub
17050                .auth
17051                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17052                .await
17053            {
17054                Ok(token) => token,
17055                Err(e) => match dlg.token(e) {
17056                    Ok(token) => token,
17057                    Err(e) => {
17058                        dlg.finished(false);
17059                        return Err(common::Error::MissingToken(e));
17060                    }
17061                },
17062            };
17063            let mut req_result = {
17064                let client = &self.hub.client;
17065                dlg.pre_request();
17066                let mut req_builder = hyper::Request::builder()
17067                    .method(hyper::Method::GET)
17068                    .uri(url.as_str())
17069                    .header(USER_AGENT, self.hub._user_agent.clone());
17070
17071                if let Some(token) = token.as_ref() {
17072                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17073                }
17074
17075                let request = req_builder
17076                    .header(CONTENT_LENGTH, 0_u64)
17077                    .body(common::to_body::<String>(None));
17078
17079                client.request(request.unwrap()).await
17080            };
17081
17082            match req_result {
17083                Err(err) => {
17084                    if let common::Retry::After(d) = dlg.http_error(&err) {
17085                        sleep(d).await;
17086                        continue;
17087                    }
17088                    dlg.finished(false);
17089                    return Err(common::Error::HttpError(err));
17090                }
17091                Ok(res) => {
17092                    let (mut parts, body) = res.into_parts();
17093                    let mut body = common::Body::new(body);
17094                    if !parts.status.is_success() {
17095                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17096                        let error = serde_json::from_str(&common::to_string(&bytes));
17097                        let response = common::to_response(parts, bytes.into());
17098
17099                        if let common::Retry::After(d) =
17100                            dlg.http_failure(&response, error.as_ref().ok())
17101                        {
17102                            sleep(d).await;
17103                            continue;
17104                        }
17105
17106                        dlg.finished(false);
17107
17108                        return Err(match error {
17109                            Ok(value) => common::Error::BadRequest(value),
17110                            _ => common::Error::Failure(response),
17111                        });
17112                    }
17113                    let response = {
17114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17115                        let encoded = common::to_string(&bytes);
17116                        match serde_json::from_str(&encoded) {
17117                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17118                            Err(error) => {
17119                                dlg.response_json_decode_error(&encoded, &error);
17120                                return Err(common::Error::JsonDecodeError(
17121                                    encoded.to_string(),
17122                                    error,
17123                                ));
17124                            }
17125                        }
17126                    };
17127
17128                    dlg.finished(true);
17129                    return Ok(response);
17130                }
17131            }
17132        }
17133    }
17134
17135    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
17136    ///
17137    /// Sets the *resource* path property to the given value.
17138    ///
17139    /// Even though the property as already been set when instantiating this call,
17140    /// we provide this method for API completeness.
17141    pub fn resource(
17142        mut self,
17143        new_value: &str,
17144    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
17145        self._resource = new_value.to_string();
17146        self
17147    }
17148    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
17149    ///
17150    /// Sets the *options.requested policy version* query property to the given value.
17151    pub fn options_requested_policy_version(
17152        mut self,
17153        new_value: i32,
17154    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
17155        self._options_requested_policy_version = Some(new_value);
17156        self
17157    }
17158    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17159    /// while executing the actual API request.
17160    ///
17161    /// ````text
17162    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17163    /// ````
17164    ///
17165    /// Sets the *delegate* property to the given value.
17166    pub fn delegate(
17167        mut self,
17168        new_value: &'a mut dyn common::Delegate,
17169    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
17170        self._delegate = Some(new_value);
17171        self
17172    }
17173
17174    /// Set any additional parameter of the query string used in the request.
17175    /// It should be used to set parameters which are not yet available through their own
17176    /// setters.
17177    ///
17178    /// Please note that this method must not be used to set any of the known parameters
17179    /// which have their own setter method. If done anyway, the request will fail.
17180    ///
17181    /// # Additional Parameters
17182    ///
17183    /// * *$.xgafv* (query-string) - V1 error format.
17184    /// * *access_token* (query-string) - OAuth access token.
17185    /// * *alt* (query-string) - Data format for response.
17186    /// * *callback* (query-string) - JSONP
17187    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17188    /// * *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.
17189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17190    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17191    /// * *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.
17192    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17193    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17194    pub fn param<T>(
17195        mut self,
17196        name: T,
17197        value: T,
17198    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
17199    where
17200        T: AsRef<str>,
17201    {
17202        self._additional_params
17203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17204        self
17205    }
17206
17207    /// Identifies the authorization scope for the method you are building.
17208    ///
17209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17210    /// [`Scope::CloudPlatform`].
17211    ///
17212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17213    /// tokens for more than one scope.
17214    ///
17215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17217    /// sufficient, a read-write scope will do as well.
17218    pub fn add_scope<St>(
17219        mut self,
17220        scope: St,
17221    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
17222    where
17223        St: AsRef<str>,
17224    {
17225        self._scopes.insert(String::from(scope.as_ref()));
17226        self
17227    }
17228    /// Identifies the authorization scope(s) for the method you are building.
17229    ///
17230    /// See [`Self::add_scope()`] for details.
17231    pub fn add_scopes<I, St>(
17232        mut self,
17233        scopes: I,
17234    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
17235    where
17236        I: IntoIterator<Item = St>,
17237        St: AsRef<str>,
17238    {
17239        self._scopes
17240            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17241        self
17242    }
17243
17244    /// Removes all scopes, and no default scope will be used either.
17245    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17246    /// for details).
17247    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
17248        self._scopes.clear();
17249        self
17250    }
17251}
17252
17253/// Lists CryptoKeys.
17254///
17255/// A builder for the *locations.keyRings.cryptoKeys.list* method supported by a *project* resource.
17256/// It is not used directly, but through a [`ProjectMethods`] instance.
17257///
17258/// # Example
17259///
17260/// Instantiate a resource method builder
17261///
17262/// ```test_harness,no_run
17263/// # extern crate hyper;
17264/// # extern crate hyper_rustls;
17265/// # extern crate google_cloudkms1 as cloudkms1;
17266/// # async fn dox() {
17267/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17268///
17269/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17270/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17271/// #     .with_native_roots()
17272/// #     .unwrap()
17273/// #     .https_only()
17274/// #     .enable_http2()
17275/// #     .build();
17276///
17277/// # let executor = hyper_util::rt::TokioExecutor::new();
17278/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17279/// #     secret,
17280/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17281/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17282/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17283/// #     ),
17284/// # ).build().await.unwrap();
17285///
17286/// # let client = hyper_util::client::legacy::Client::builder(
17287/// #     hyper_util::rt::TokioExecutor::new()
17288/// # )
17289/// # .build(
17290/// #     hyper_rustls::HttpsConnectorBuilder::new()
17291/// #         .with_native_roots()
17292/// #         .unwrap()
17293/// #         .https_or_http()
17294/// #         .enable_http2()
17295/// #         .build()
17296/// # );
17297/// # let mut hub = CloudKMS::new(client, auth);
17298/// // You can configure optional parameters by calling the respective setters at will, and
17299/// // execute the final call using `doit()`.
17300/// // Values shown here are possibly random and not representative !
17301/// let result = hub.projects().locations_key_rings_crypto_keys_list("parent")
17302///              .version_view("vero")
17303///              .page_token("elitr")
17304///              .page_size(-6)
17305///              .order_by("diam")
17306///              .filter("no")
17307///              .doit().await;
17308/// # }
17309/// ```
17310pub struct ProjectLocationKeyRingCryptoKeyListCall<'a, C>
17311where
17312    C: 'a,
17313{
17314    hub: &'a CloudKMS<C>,
17315    _parent: String,
17316    _version_view: Option<String>,
17317    _page_token: Option<String>,
17318    _page_size: Option<i32>,
17319    _order_by: Option<String>,
17320    _filter: Option<String>,
17321    _delegate: Option<&'a mut dyn common::Delegate>,
17322    _additional_params: HashMap<String, String>,
17323    _scopes: BTreeSet<String>,
17324}
17325
17326impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyListCall<'a, C> {}
17327
17328impl<'a, C> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
17329where
17330    C: common::Connector,
17331{
17332    /// Perform the operation you have build so far.
17333    pub async fn doit(mut self) -> common::Result<(common::Response, ListCryptoKeysResponse)> {
17334        use std::borrow::Cow;
17335        use std::io::{Read, Seek};
17336
17337        use common::{url::Params, ToParts};
17338        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17339
17340        let mut dd = common::DefaultDelegate;
17341        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17342        dlg.begin(common::MethodInfo {
17343            id: "cloudkms.projects.locations.keyRings.cryptoKeys.list",
17344            http_method: hyper::Method::GET,
17345        });
17346
17347        for &field in [
17348            "alt",
17349            "parent",
17350            "versionView",
17351            "pageToken",
17352            "pageSize",
17353            "orderBy",
17354            "filter",
17355        ]
17356        .iter()
17357        {
17358            if self._additional_params.contains_key(field) {
17359                dlg.finished(false);
17360                return Err(common::Error::FieldClash(field));
17361            }
17362        }
17363
17364        let mut params = Params::with_capacity(8 + self._additional_params.len());
17365        params.push("parent", self._parent);
17366        if let Some(value) = self._version_view.as_ref() {
17367            params.push("versionView", value);
17368        }
17369        if let Some(value) = self._page_token.as_ref() {
17370            params.push("pageToken", value);
17371        }
17372        if let Some(value) = self._page_size.as_ref() {
17373            params.push("pageSize", value.to_string());
17374        }
17375        if let Some(value) = self._order_by.as_ref() {
17376            params.push("orderBy", value);
17377        }
17378        if let Some(value) = self._filter.as_ref() {
17379            params.push("filter", value);
17380        }
17381
17382        params.extend(self._additional_params.iter());
17383
17384        params.push("alt", "json");
17385        let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeys";
17386        if self._scopes.is_empty() {
17387            self._scopes
17388                .insert(Scope::CloudPlatform.as_ref().to_string());
17389        }
17390
17391        #[allow(clippy::single_element_loop)]
17392        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17393            url = params.uri_replacement(url, param_name, find_this, true);
17394        }
17395        {
17396            let to_remove = ["parent"];
17397            params.remove_params(&to_remove);
17398        }
17399
17400        let url = params.parse_with_url(&url);
17401
17402        loop {
17403            let token = match self
17404                .hub
17405                .auth
17406                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17407                .await
17408            {
17409                Ok(token) => token,
17410                Err(e) => match dlg.token(e) {
17411                    Ok(token) => token,
17412                    Err(e) => {
17413                        dlg.finished(false);
17414                        return Err(common::Error::MissingToken(e));
17415                    }
17416                },
17417            };
17418            let mut req_result = {
17419                let client = &self.hub.client;
17420                dlg.pre_request();
17421                let mut req_builder = hyper::Request::builder()
17422                    .method(hyper::Method::GET)
17423                    .uri(url.as_str())
17424                    .header(USER_AGENT, self.hub._user_agent.clone());
17425
17426                if let Some(token) = token.as_ref() {
17427                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17428                }
17429
17430                let request = req_builder
17431                    .header(CONTENT_LENGTH, 0_u64)
17432                    .body(common::to_body::<String>(None));
17433
17434                client.request(request.unwrap()).await
17435            };
17436
17437            match req_result {
17438                Err(err) => {
17439                    if let common::Retry::After(d) = dlg.http_error(&err) {
17440                        sleep(d).await;
17441                        continue;
17442                    }
17443                    dlg.finished(false);
17444                    return Err(common::Error::HttpError(err));
17445                }
17446                Ok(res) => {
17447                    let (mut parts, body) = res.into_parts();
17448                    let mut body = common::Body::new(body);
17449                    if !parts.status.is_success() {
17450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17451                        let error = serde_json::from_str(&common::to_string(&bytes));
17452                        let response = common::to_response(parts, bytes.into());
17453
17454                        if let common::Retry::After(d) =
17455                            dlg.http_failure(&response, error.as_ref().ok())
17456                        {
17457                            sleep(d).await;
17458                            continue;
17459                        }
17460
17461                        dlg.finished(false);
17462
17463                        return Err(match error {
17464                            Ok(value) => common::Error::BadRequest(value),
17465                            _ => common::Error::Failure(response),
17466                        });
17467                    }
17468                    let response = {
17469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17470                        let encoded = common::to_string(&bytes);
17471                        match serde_json::from_str(&encoded) {
17472                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17473                            Err(error) => {
17474                                dlg.response_json_decode_error(&encoded, &error);
17475                                return Err(common::Error::JsonDecodeError(
17476                                    encoded.to_string(),
17477                                    error,
17478                                ));
17479                            }
17480                        }
17481                    };
17482
17483                    dlg.finished(true);
17484                    return Ok(response);
17485                }
17486            }
17487        }
17488    }
17489
17490    /// Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
17491    ///
17492    /// Sets the *parent* path property to the given value.
17493    ///
17494    /// Even though the property as already been set when instantiating this call,
17495    /// we provide this method for API completeness.
17496    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17497        self._parent = new_value.to_string();
17498        self
17499    }
17500    /// The fields of the primary version to include in the response.
17501    ///
17502    /// Sets the *version view* query property to the given value.
17503    pub fn version_view(
17504        mut self,
17505        new_value: &str,
17506    ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17507        self._version_view = Some(new_value.to_string());
17508        self
17509    }
17510    /// Optional. Optional pagination token, returned earlier via ListCryptoKeysResponse.next_page_token.
17511    ///
17512    /// Sets the *page token* query property to the given value.
17513    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17514        self._page_token = Some(new_value.to_string());
17515        self
17516    }
17517    /// Optional. Optional limit on the number of CryptoKeys to include in the response. Further CryptoKeys can subsequently be obtained by including the ListCryptoKeysResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.
17518    ///
17519    /// Sets the *page size* query property to the given value.
17520    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17521        self._page_size = Some(new_value);
17522        self
17523    }
17524    /// Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
17525    ///
17526    /// Sets the *order by* query property to the given value.
17527    pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17528        self._order_by = Some(new_value.to_string());
17529        self
17530    }
17531    /// Optional. Only include resources that match the filter in the response. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
17532    ///
17533    /// Sets the *filter* query property to the given value.
17534    pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17535        self._filter = Some(new_value.to_string());
17536        self
17537    }
17538    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17539    /// while executing the actual API request.
17540    ///
17541    /// ````text
17542    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17543    /// ````
17544    ///
17545    /// Sets the *delegate* property to the given value.
17546    pub fn delegate(
17547        mut self,
17548        new_value: &'a mut dyn common::Delegate,
17549    ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17550        self._delegate = Some(new_value);
17551        self
17552    }
17553
17554    /// Set any additional parameter of the query string used in the request.
17555    /// It should be used to set parameters which are not yet available through their own
17556    /// setters.
17557    ///
17558    /// Please note that this method must not be used to set any of the known parameters
17559    /// which have their own setter method. If done anyway, the request will fail.
17560    ///
17561    /// # Additional Parameters
17562    ///
17563    /// * *$.xgafv* (query-string) - V1 error format.
17564    /// * *access_token* (query-string) - OAuth access token.
17565    /// * *alt* (query-string) - Data format for response.
17566    /// * *callback* (query-string) - JSONP
17567    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17568    /// * *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.
17569    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17570    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17571    /// * *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.
17572    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17573    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17574    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
17575    where
17576        T: AsRef<str>,
17577    {
17578        self._additional_params
17579            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17580        self
17581    }
17582
17583    /// Identifies the authorization scope for the method you are building.
17584    ///
17585    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17586    /// [`Scope::CloudPlatform`].
17587    ///
17588    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17589    /// tokens for more than one scope.
17590    ///
17591    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17592    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17593    /// sufficient, a read-write scope will do as well.
17594    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
17595    where
17596        St: AsRef<str>,
17597    {
17598        self._scopes.insert(String::from(scope.as_ref()));
17599        self
17600    }
17601    /// Identifies the authorization scope(s) for the method you are building.
17602    ///
17603    /// See [`Self::add_scope()`] for details.
17604    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
17605    where
17606        I: IntoIterator<Item = St>,
17607        St: AsRef<str>,
17608    {
17609        self._scopes
17610            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17611        self
17612    }
17613
17614    /// Removes all scopes, and no default scope will be used either.
17615    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17616    /// for details).
17617    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
17618        self._scopes.clear();
17619        self
17620    }
17621}
17622
17623/// Update a CryptoKey.
17624///
17625/// A builder for the *locations.keyRings.cryptoKeys.patch* method supported by a *project* resource.
17626/// It is not used directly, but through a [`ProjectMethods`] instance.
17627///
17628/// # Example
17629///
17630/// Instantiate a resource method builder
17631///
17632/// ```test_harness,no_run
17633/// # extern crate hyper;
17634/// # extern crate hyper_rustls;
17635/// # extern crate google_cloudkms1 as cloudkms1;
17636/// use cloudkms1::api::CryptoKey;
17637/// # async fn dox() {
17638/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17639///
17640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17642/// #     .with_native_roots()
17643/// #     .unwrap()
17644/// #     .https_only()
17645/// #     .enable_http2()
17646/// #     .build();
17647///
17648/// # let executor = hyper_util::rt::TokioExecutor::new();
17649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17650/// #     secret,
17651/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17652/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17653/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17654/// #     ),
17655/// # ).build().await.unwrap();
17656///
17657/// # let client = hyper_util::client::legacy::Client::builder(
17658/// #     hyper_util::rt::TokioExecutor::new()
17659/// # )
17660/// # .build(
17661/// #     hyper_rustls::HttpsConnectorBuilder::new()
17662/// #         .with_native_roots()
17663/// #         .unwrap()
17664/// #         .https_or_http()
17665/// #         .enable_http2()
17666/// #         .build()
17667/// # );
17668/// # let mut hub = CloudKMS::new(client, auth);
17669/// // As the method needs a request, you would usually fill it with the desired information
17670/// // into the respective structure. Some of the parts shown here might not be applicable !
17671/// // Values shown here are possibly random and not representative !
17672/// let mut req = CryptoKey::default();
17673///
17674/// // You can configure optional parameters by calling the respective setters at will, and
17675/// // execute the final call using `doit()`.
17676/// // Values shown here are possibly random and not representative !
17677/// let result = hub.projects().locations_key_rings_crypto_keys_patch(req, "name")
17678///              .update_mask(FieldMask::new::<&str>(&[]))
17679///              .doit().await;
17680/// # }
17681/// ```
17682pub struct ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
17683where
17684    C: 'a,
17685{
17686    hub: &'a CloudKMS<C>,
17687    _request: CryptoKey,
17688    _name: String,
17689    _update_mask: Option<common::FieldMask>,
17690    _delegate: Option<&'a mut dyn common::Delegate>,
17691    _additional_params: HashMap<String, String>,
17692    _scopes: BTreeSet<String>,
17693}
17694
17695impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {}
17696
17697impl<'a, C> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
17698where
17699    C: common::Connector,
17700{
17701    /// Perform the operation you have build so far.
17702    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
17703        use std::borrow::Cow;
17704        use std::io::{Read, Seek};
17705
17706        use common::{url::Params, ToParts};
17707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17708
17709        let mut dd = common::DefaultDelegate;
17710        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17711        dlg.begin(common::MethodInfo {
17712            id: "cloudkms.projects.locations.keyRings.cryptoKeys.patch",
17713            http_method: hyper::Method::PATCH,
17714        });
17715
17716        for &field in ["alt", "name", "updateMask"].iter() {
17717            if self._additional_params.contains_key(field) {
17718                dlg.finished(false);
17719                return Err(common::Error::FieldClash(field));
17720            }
17721        }
17722
17723        let mut params = Params::with_capacity(5 + self._additional_params.len());
17724        params.push("name", self._name);
17725        if let Some(value) = self._update_mask.as_ref() {
17726            params.push("updateMask", value.to_string());
17727        }
17728
17729        params.extend(self._additional_params.iter());
17730
17731        params.push("alt", "json");
17732        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17733        if self._scopes.is_empty() {
17734            self._scopes
17735                .insert(Scope::CloudPlatform.as_ref().to_string());
17736        }
17737
17738        #[allow(clippy::single_element_loop)]
17739        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17740            url = params.uri_replacement(url, param_name, find_this, true);
17741        }
17742        {
17743            let to_remove = ["name"];
17744            params.remove_params(&to_remove);
17745        }
17746
17747        let url = params.parse_with_url(&url);
17748
17749        let mut json_mime_type = mime::APPLICATION_JSON;
17750        let mut request_value_reader = {
17751            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17752            common::remove_json_null_values(&mut value);
17753            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17754            serde_json::to_writer(&mut dst, &value).unwrap();
17755            dst
17756        };
17757        let request_size = request_value_reader
17758            .seek(std::io::SeekFrom::End(0))
17759            .unwrap();
17760        request_value_reader
17761            .seek(std::io::SeekFrom::Start(0))
17762            .unwrap();
17763
17764        loop {
17765            let token = match self
17766                .hub
17767                .auth
17768                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17769                .await
17770            {
17771                Ok(token) => token,
17772                Err(e) => match dlg.token(e) {
17773                    Ok(token) => token,
17774                    Err(e) => {
17775                        dlg.finished(false);
17776                        return Err(common::Error::MissingToken(e));
17777                    }
17778                },
17779            };
17780            request_value_reader
17781                .seek(std::io::SeekFrom::Start(0))
17782                .unwrap();
17783            let mut req_result = {
17784                let client = &self.hub.client;
17785                dlg.pre_request();
17786                let mut req_builder = hyper::Request::builder()
17787                    .method(hyper::Method::PATCH)
17788                    .uri(url.as_str())
17789                    .header(USER_AGENT, self.hub._user_agent.clone());
17790
17791                if let Some(token) = token.as_ref() {
17792                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17793                }
17794
17795                let request = req_builder
17796                    .header(CONTENT_TYPE, json_mime_type.to_string())
17797                    .header(CONTENT_LENGTH, request_size as u64)
17798                    .body(common::to_body(
17799                        request_value_reader.get_ref().clone().into(),
17800                    ));
17801
17802                client.request(request.unwrap()).await
17803            };
17804
17805            match req_result {
17806                Err(err) => {
17807                    if let common::Retry::After(d) = dlg.http_error(&err) {
17808                        sleep(d).await;
17809                        continue;
17810                    }
17811                    dlg.finished(false);
17812                    return Err(common::Error::HttpError(err));
17813                }
17814                Ok(res) => {
17815                    let (mut parts, body) = res.into_parts();
17816                    let mut body = common::Body::new(body);
17817                    if !parts.status.is_success() {
17818                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17819                        let error = serde_json::from_str(&common::to_string(&bytes));
17820                        let response = common::to_response(parts, bytes.into());
17821
17822                        if let common::Retry::After(d) =
17823                            dlg.http_failure(&response, error.as_ref().ok())
17824                        {
17825                            sleep(d).await;
17826                            continue;
17827                        }
17828
17829                        dlg.finished(false);
17830
17831                        return Err(match error {
17832                            Ok(value) => common::Error::BadRequest(value),
17833                            _ => common::Error::Failure(response),
17834                        });
17835                    }
17836                    let response = {
17837                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17838                        let encoded = common::to_string(&bytes);
17839                        match serde_json::from_str(&encoded) {
17840                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17841                            Err(error) => {
17842                                dlg.response_json_decode_error(&encoded, &error);
17843                                return Err(common::Error::JsonDecodeError(
17844                                    encoded.to_string(),
17845                                    error,
17846                                ));
17847                            }
17848                        }
17849                    };
17850
17851                    dlg.finished(true);
17852                    return Ok(response);
17853                }
17854            }
17855        }
17856    }
17857
17858    ///
17859    /// Sets the *request* property to the given value.
17860    ///
17861    /// Even though the property as already been set when instantiating this call,
17862    /// we provide this method for API completeness.
17863    pub fn request(
17864        mut self,
17865        new_value: CryptoKey,
17866    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
17867        self._request = new_value;
17868        self
17869    }
17870    /// Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
17871    ///
17872    /// Sets the *name* path property to the given value.
17873    ///
17874    /// Even though the property as already been set when instantiating this call,
17875    /// we provide this method for API completeness.
17876    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
17877        self._name = new_value.to_string();
17878        self
17879    }
17880    /// Required. List of fields to be updated in this request.
17881    ///
17882    /// Sets the *update mask* query property to the given value.
17883    pub fn update_mask(
17884        mut self,
17885        new_value: common::FieldMask,
17886    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
17887        self._update_mask = Some(new_value);
17888        self
17889    }
17890    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17891    /// while executing the actual API request.
17892    ///
17893    /// ````text
17894    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17895    /// ````
17896    ///
17897    /// Sets the *delegate* property to the given value.
17898    pub fn delegate(
17899        mut self,
17900        new_value: &'a mut dyn common::Delegate,
17901    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
17902        self._delegate = Some(new_value);
17903        self
17904    }
17905
17906    /// Set any additional parameter of the query string used in the request.
17907    /// It should be used to set parameters which are not yet available through their own
17908    /// setters.
17909    ///
17910    /// Please note that this method must not be used to set any of the known parameters
17911    /// which have their own setter method. If done anyway, the request will fail.
17912    ///
17913    /// # Additional Parameters
17914    ///
17915    /// * *$.xgafv* (query-string) - V1 error format.
17916    /// * *access_token* (query-string) - OAuth access token.
17917    /// * *alt* (query-string) - Data format for response.
17918    /// * *callback* (query-string) - JSONP
17919    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17920    /// * *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.
17921    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17922    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17923    /// * *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.
17924    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17925    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17926    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
17927    where
17928        T: AsRef<str>,
17929    {
17930        self._additional_params
17931            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17932        self
17933    }
17934
17935    /// Identifies the authorization scope for the method you are building.
17936    ///
17937    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17938    /// [`Scope::CloudPlatform`].
17939    ///
17940    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17941    /// tokens for more than one scope.
17942    ///
17943    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17944    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17945    /// sufficient, a read-write scope will do as well.
17946    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
17947    where
17948        St: AsRef<str>,
17949    {
17950        self._scopes.insert(String::from(scope.as_ref()));
17951        self
17952    }
17953    /// Identifies the authorization scope(s) for the method you are building.
17954    ///
17955    /// See [`Self::add_scope()`] for details.
17956    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
17957    where
17958        I: IntoIterator<Item = St>,
17959        St: AsRef<str>,
17960    {
17961        self._scopes
17962            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17963        self
17964    }
17965
17966    /// Removes all scopes, and no default scope will be used either.
17967    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17968    /// for details).
17969    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
17970        self._scopes.clear();
17971        self
17972    }
17973}
17974
17975/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
17976///
17977/// A builder for the *locations.keyRings.cryptoKeys.setIamPolicy* method supported by a *project* resource.
17978/// It is not used directly, but through a [`ProjectMethods`] instance.
17979///
17980/// # Example
17981///
17982/// Instantiate a resource method builder
17983///
17984/// ```test_harness,no_run
17985/// # extern crate hyper;
17986/// # extern crate hyper_rustls;
17987/// # extern crate google_cloudkms1 as cloudkms1;
17988/// use cloudkms1::api::SetIamPolicyRequest;
17989/// # async fn dox() {
17990/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17991///
17992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17993/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17994/// #     .with_native_roots()
17995/// #     .unwrap()
17996/// #     .https_only()
17997/// #     .enable_http2()
17998/// #     .build();
17999///
18000/// # let executor = hyper_util::rt::TokioExecutor::new();
18001/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18002/// #     secret,
18003/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18004/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18005/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18006/// #     ),
18007/// # ).build().await.unwrap();
18008///
18009/// # let client = hyper_util::client::legacy::Client::builder(
18010/// #     hyper_util::rt::TokioExecutor::new()
18011/// # )
18012/// # .build(
18013/// #     hyper_rustls::HttpsConnectorBuilder::new()
18014/// #         .with_native_roots()
18015/// #         .unwrap()
18016/// #         .https_or_http()
18017/// #         .enable_http2()
18018/// #         .build()
18019/// # );
18020/// # let mut hub = CloudKMS::new(client, auth);
18021/// // As the method needs a request, you would usually fill it with the desired information
18022/// // into the respective structure. Some of the parts shown here might not be applicable !
18023/// // Values shown here are possibly random and not representative !
18024/// let mut req = SetIamPolicyRequest::default();
18025///
18026/// // You can configure optional parameters by calling the respective setters at will, and
18027/// // execute the final call using `doit()`.
18028/// // Values shown here are possibly random and not representative !
18029/// let result = hub.projects().locations_key_rings_crypto_keys_set_iam_policy(req, "resource")
18030///              .doit().await;
18031/// # }
18032/// ```
18033pub struct ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
18034where
18035    C: 'a,
18036{
18037    hub: &'a CloudKMS<C>,
18038    _request: SetIamPolicyRequest,
18039    _resource: String,
18040    _delegate: Option<&'a mut dyn common::Delegate>,
18041    _additional_params: HashMap<String, String>,
18042    _scopes: BTreeSet<String>,
18043}
18044
18045impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {}
18046
18047impl<'a, C> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
18048where
18049    C: common::Connector,
18050{
18051    /// Perform the operation you have build so far.
18052    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
18053        use std::borrow::Cow;
18054        use std::io::{Read, Seek};
18055
18056        use common::{url::Params, ToParts};
18057        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18058
18059        let mut dd = common::DefaultDelegate;
18060        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18061        dlg.begin(common::MethodInfo {
18062            id: "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy",
18063            http_method: hyper::Method::POST,
18064        });
18065
18066        for &field in ["alt", "resource"].iter() {
18067            if self._additional_params.contains_key(field) {
18068                dlg.finished(false);
18069                return Err(common::Error::FieldClash(field));
18070            }
18071        }
18072
18073        let mut params = Params::with_capacity(4 + self._additional_params.len());
18074        params.push("resource", self._resource);
18075
18076        params.extend(self._additional_params.iter());
18077
18078        params.push("alt", "json");
18079        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
18080        if self._scopes.is_empty() {
18081            self._scopes
18082                .insert(Scope::CloudPlatform.as_ref().to_string());
18083        }
18084
18085        #[allow(clippy::single_element_loop)]
18086        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18087            url = params.uri_replacement(url, param_name, find_this, true);
18088        }
18089        {
18090            let to_remove = ["resource"];
18091            params.remove_params(&to_remove);
18092        }
18093
18094        let url = params.parse_with_url(&url);
18095
18096        let mut json_mime_type = mime::APPLICATION_JSON;
18097        let mut request_value_reader = {
18098            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18099            common::remove_json_null_values(&mut value);
18100            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18101            serde_json::to_writer(&mut dst, &value).unwrap();
18102            dst
18103        };
18104        let request_size = request_value_reader
18105            .seek(std::io::SeekFrom::End(0))
18106            .unwrap();
18107        request_value_reader
18108            .seek(std::io::SeekFrom::Start(0))
18109            .unwrap();
18110
18111        loop {
18112            let token = match self
18113                .hub
18114                .auth
18115                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18116                .await
18117            {
18118                Ok(token) => token,
18119                Err(e) => match dlg.token(e) {
18120                    Ok(token) => token,
18121                    Err(e) => {
18122                        dlg.finished(false);
18123                        return Err(common::Error::MissingToken(e));
18124                    }
18125                },
18126            };
18127            request_value_reader
18128                .seek(std::io::SeekFrom::Start(0))
18129                .unwrap();
18130            let mut req_result = {
18131                let client = &self.hub.client;
18132                dlg.pre_request();
18133                let mut req_builder = hyper::Request::builder()
18134                    .method(hyper::Method::POST)
18135                    .uri(url.as_str())
18136                    .header(USER_AGENT, self.hub._user_agent.clone());
18137
18138                if let Some(token) = token.as_ref() {
18139                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18140                }
18141
18142                let request = req_builder
18143                    .header(CONTENT_TYPE, json_mime_type.to_string())
18144                    .header(CONTENT_LENGTH, request_size as u64)
18145                    .body(common::to_body(
18146                        request_value_reader.get_ref().clone().into(),
18147                    ));
18148
18149                client.request(request.unwrap()).await
18150            };
18151
18152            match req_result {
18153                Err(err) => {
18154                    if let common::Retry::After(d) = dlg.http_error(&err) {
18155                        sleep(d).await;
18156                        continue;
18157                    }
18158                    dlg.finished(false);
18159                    return Err(common::Error::HttpError(err));
18160                }
18161                Ok(res) => {
18162                    let (mut parts, body) = res.into_parts();
18163                    let mut body = common::Body::new(body);
18164                    if !parts.status.is_success() {
18165                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18166                        let error = serde_json::from_str(&common::to_string(&bytes));
18167                        let response = common::to_response(parts, bytes.into());
18168
18169                        if let common::Retry::After(d) =
18170                            dlg.http_failure(&response, error.as_ref().ok())
18171                        {
18172                            sleep(d).await;
18173                            continue;
18174                        }
18175
18176                        dlg.finished(false);
18177
18178                        return Err(match error {
18179                            Ok(value) => common::Error::BadRequest(value),
18180                            _ => common::Error::Failure(response),
18181                        });
18182                    }
18183                    let response = {
18184                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18185                        let encoded = common::to_string(&bytes);
18186                        match serde_json::from_str(&encoded) {
18187                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18188                            Err(error) => {
18189                                dlg.response_json_decode_error(&encoded, &error);
18190                                return Err(common::Error::JsonDecodeError(
18191                                    encoded.to_string(),
18192                                    error,
18193                                ));
18194                            }
18195                        }
18196                    };
18197
18198                    dlg.finished(true);
18199                    return Ok(response);
18200                }
18201            }
18202        }
18203    }
18204
18205    ///
18206    /// Sets the *request* property to the given value.
18207    ///
18208    /// Even though the property as already been set when instantiating this call,
18209    /// we provide this method for API completeness.
18210    pub fn request(
18211        mut self,
18212        new_value: SetIamPolicyRequest,
18213    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
18214        self._request = new_value;
18215        self
18216    }
18217    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
18218    ///
18219    /// Sets the *resource* path property to the given value.
18220    ///
18221    /// Even though the property as already been set when instantiating this call,
18222    /// we provide this method for API completeness.
18223    pub fn resource(
18224        mut self,
18225        new_value: &str,
18226    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
18227        self._resource = new_value.to_string();
18228        self
18229    }
18230    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18231    /// while executing the actual API request.
18232    ///
18233    /// ````text
18234    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18235    /// ````
18236    ///
18237    /// Sets the *delegate* property to the given value.
18238    pub fn delegate(
18239        mut self,
18240        new_value: &'a mut dyn common::Delegate,
18241    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
18242        self._delegate = Some(new_value);
18243        self
18244    }
18245
18246    /// Set any additional parameter of the query string used in the request.
18247    /// It should be used to set parameters which are not yet available through their own
18248    /// setters.
18249    ///
18250    /// Please note that this method must not be used to set any of the known parameters
18251    /// which have their own setter method. If done anyway, the request will fail.
18252    ///
18253    /// # Additional Parameters
18254    ///
18255    /// * *$.xgafv* (query-string) - V1 error format.
18256    /// * *access_token* (query-string) - OAuth access token.
18257    /// * *alt* (query-string) - Data format for response.
18258    /// * *callback* (query-string) - JSONP
18259    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18260    /// * *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.
18261    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18262    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18263    /// * *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.
18264    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18265    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18266    pub fn param<T>(
18267        mut self,
18268        name: T,
18269        value: T,
18270    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
18271    where
18272        T: AsRef<str>,
18273    {
18274        self._additional_params
18275            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18276        self
18277    }
18278
18279    /// Identifies the authorization scope for the method you are building.
18280    ///
18281    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18282    /// [`Scope::CloudPlatform`].
18283    ///
18284    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18285    /// tokens for more than one scope.
18286    ///
18287    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18288    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18289    /// sufficient, a read-write scope will do as well.
18290    pub fn add_scope<St>(
18291        mut self,
18292        scope: St,
18293    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
18294    where
18295        St: AsRef<str>,
18296    {
18297        self._scopes.insert(String::from(scope.as_ref()));
18298        self
18299    }
18300    /// Identifies the authorization scope(s) for the method you are building.
18301    ///
18302    /// See [`Self::add_scope()`] for details.
18303    pub fn add_scopes<I, St>(
18304        mut self,
18305        scopes: I,
18306    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
18307    where
18308        I: IntoIterator<Item = St>,
18309        St: AsRef<str>,
18310    {
18311        self._scopes
18312            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18313        self
18314    }
18315
18316    /// Removes all scopes, and no default scope will be used either.
18317    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18318    /// for details).
18319    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
18320        self._scopes.clear();
18321        self
18322    }
18323}
18324
18325/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
18326///
18327/// A builder for the *locations.keyRings.cryptoKeys.testIamPermissions* method supported by a *project* resource.
18328/// It is not used directly, but through a [`ProjectMethods`] instance.
18329///
18330/// # Example
18331///
18332/// Instantiate a resource method builder
18333///
18334/// ```test_harness,no_run
18335/// # extern crate hyper;
18336/// # extern crate hyper_rustls;
18337/// # extern crate google_cloudkms1 as cloudkms1;
18338/// use cloudkms1::api::TestIamPermissionsRequest;
18339/// # async fn dox() {
18340/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18341///
18342/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18343/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18344/// #     .with_native_roots()
18345/// #     .unwrap()
18346/// #     .https_only()
18347/// #     .enable_http2()
18348/// #     .build();
18349///
18350/// # let executor = hyper_util::rt::TokioExecutor::new();
18351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18352/// #     secret,
18353/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18354/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18355/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18356/// #     ),
18357/// # ).build().await.unwrap();
18358///
18359/// # let client = hyper_util::client::legacy::Client::builder(
18360/// #     hyper_util::rt::TokioExecutor::new()
18361/// # )
18362/// # .build(
18363/// #     hyper_rustls::HttpsConnectorBuilder::new()
18364/// #         .with_native_roots()
18365/// #         .unwrap()
18366/// #         .https_or_http()
18367/// #         .enable_http2()
18368/// #         .build()
18369/// # );
18370/// # let mut hub = CloudKMS::new(client, auth);
18371/// // As the method needs a request, you would usually fill it with the desired information
18372/// // into the respective structure. Some of the parts shown here might not be applicable !
18373/// // Values shown here are possibly random and not representative !
18374/// let mut req = TestIamPermissionsRequest::default();
18375///
18376/// // You can configure optional parameters by calling the respective setters at will, and
18377/// // execute the final call using `doit()`.
18378/// // Values shown here are possibly random and not representative !
18379/// let result = hub.projects().locations_key_rings_crypto_keys_test_iam_permissions(req, "resource")
18380///              .doit().await;
18381/// # }
18382/// ```
18383pub struct ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
18384where
18385    C: 'a,
18386{
18387    hub: &'a CloudKMS<C>,
18388    _request: TestIamPermissionsRequest,
18389    _resource: String,
18390    _delegate: Option<&'a mut dyn common::Delegate>,
18391    _additional_params: HashMap<String, String>,
18392    _scopes: BTreeSet<String>,
18393}
18394
18395impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {}
18396
18397impl<'a, C> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
18398where
18399    C: common::Connector,
18400{
18401    /// Perform the operation you have build so far.
18402    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
18403        use std::borrow::Cow;
18404        use std::io::{Read, Seek};
18405
18406        use common::{url::Params, ToParts};
18407        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18408
18409        let mut dd = common::DefaultDelegate;
18410        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18411        dlg.begin(common::MethodInfo {
18412            id: "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions",
18413            http_method: hyper::Method::POST,
18414        });
18415
18416        for &field in ["alt", "resource"].iter() {
18417            if self._additional_params.contains_key(field) {
18418                dlg.finished(false);
18419                return Err(common::Error::FieldClash(field));
18420            }
18421        }
18422
18423        let mut params = Params::with_capacity(4 + self._additional_params.len());
18424        params.push("resource", self._resource);
18425
18426        params.extend(self._additional_params.iter());
18427
18428        params.push("alt", "json");
18429        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
18430        if self._scopes.is_empty() {
18431            self._scopes
18432                .insert(Scope::CloudPlatform.as_ref().to_string());
18433        }
18434
18435        #[allow(clippy::single_element_loop)]
18436        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18437            url = params.uri_replacement(url, param_name, find_this, true);
18438        }
18439        {
18440            let to_remove = ["resource"];
18441            params.remove_params(&to_remove);
18442        }
18443
18444        let url = params.parse_with_url(&url);
18445
18446        let mut json_mime_type = mime::APPLICATION_JSON;
18447        let mut request_value_reader = {
18448            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18449            common::remove_json_null_values(&mut value);
18450            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18451            serde_json::to_writer(&mut dst, &value).unwrap();
18452            dst
18453        };
18454        let request_size = request_value_reader
18455            .seek(std::io::SeekFrom::End(0))
18456            .unwrap();
18457        request_value_reader
18458            .seek(std::io::SeekFrom::Start(0))
18459            .unwrap();
18460
18461        loop {
18462            let token = match self
18463                .hub
18464                .auth
18465                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18466                .await
18467            {
18468                Ok(token) => token,
18469                Err(e) => match dlg.token(e) {
18470                    Ok(token) => token,
18471                    Err(e) => {
18472                        dlg.finished(false);
18473                        return Err(common::Error::MissingToken(e));
18474                    }
18475                },
18476            };
18477            request_value_reader
18478                .seek(std::io::SeekFrom::Start(0))
18479                .unwrap();
18480            let mut req_result = {
18481                let client = &self.hub.client;
18482                dlg.pre_request();
18483                let mut req_builder = hyper::Request::builder()
18484                    .method(hyper::Method::POST)
18485                    .uri(url.as_str())
18486                    .header(USER_AGENT, self.hub._user_agent.clone());
18487
18488                if let Some(token) = token.as_ref() {
18489                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18490                }
18491
18492                let request = req_builder
18493                    .header(CONTENT_TYPE, json_mime_type.to_string())
18494                    .header(CONTENT_LENGTH, request_size as u64)
18495                    .body(common::to_body(
18496                        request_value_reader.get_ref().clone().into(),
18497                    ));
18498
18499                client.request(request.unwrap()).await
18500            };
18501
18502            match req_result {
18503                Err(err) => {
18504                    if let common::Retry::After(d) = dlg.http_error(&err) {
18505                        sleep(d).await;
18506                        continue;
18507                    }
18508                    dlg.finished(false);
18509                    return Err(common::Error::HttpError(err));
18510                }
18511                Ok(res) => {
18512                    let (mut parts, body) = res.into_parts();
18513                    let mut body = common::Body::new(body);
18514                    if !parts.status.is_success() {
18515                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18516                        let error = serde_json::from_str(&common::to_string(&bytes));
18517                        let response = common::to_response(parts, bytes.into());
18518
18519                        if let common::Retry::After(d) =
18520                            dlg.http_failure(&response, error.as_ref().ok())
18521                        {
18522                            sleep(d).await;
18523                            continue;
18524                        }
18525
18526                        dlg.finished(false);
18527
18528                        return Err(match error {
18529                            Ok(value) => common::Error::BadRequest(value),
18530                            _ => common::Error::Failure(response),
18531                        });
18532                    }
18533                    let response = {
18534                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18535                        let encoded = common::to_string(&bytes);
18536                        match serde_json::from_str(&encoded) {
18537                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18538                            Err(error) => {
18539                                dlg.response_json_decode_error(&encoded, &error);
18540                                return Err(common::Error::JsonDecodeError(
18541                                    encoded.to_string(),
18542                                    error,
18543                                ));
18544                            }
18545                        }
18546                    };
18547
18548                    dlg.finished(true);
18549                    return Ok(response);
18550                }
18551            }
18552        }
18553    }
18554
18555    ///
18556    /// Sets the *request* property to the given value.
18557    ///
18558    /// Even though the property as already been set when instantiating this call,
18559    /// we provide this method for API completeness.
18560    pub fn request(
18561        mut self,
18562        new_value: TestIamPermissionsRequest,
18563    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
18564        self._request = new_value;
18565        self
18566    }
18567    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
18568    ///
18569    /// Sets the *resource* path property to the given value.
18570    ///
18571    /// Even though the property as already been set when instantiating this call,
18572    /// we provide this method for API completeness.
18573    pub fn resource(
18574        mut self,
18575        new_value: &str,
18576    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
18577        self._resource = new_value.to_string();
18578        self
18579    }
18580    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18581    /// while executing the actual API request.
18582    ///
18583    /// ````text
18584    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18585    /// ````
18586    ///
18587    /// Sets the *delegate* property to the given value.
18588    pub fn delegate(
18589        mut self,
18590        new_value: &'a mut dyn common::Delegate,
18591    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
18592        self._delegate = Some(new_value);
18593        self
18594    }
18595
18596    /// Set any additional parameter of the query string used in the request.
18597    /// It should be used to set parameters which are not yet available through their own
18598    /// setters.
18599    ///
18600    /// Please note that this method must not be used to set any of the known parameters
18601    /// which have their own setter method. If done anyway, the request will fail.
18602    ///
18603    /// # Additional Parameters
18604    ///
18605    /// * *$.xgafv* (query-string) - V1 error format.
18606    /// * *access_token* (query-string) - OAuth access token.
18607    /// * *alt* (query-string) - Data format for response.
18608    /// * *callback* (query-string) - JSONP
18609    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18610    /// * *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.
18611    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18612    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18613    /// * *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.
18614    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18615    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18616    pub fn param<T>(
18617        mut self,
18618        name: T,
18619        value: T,
18620    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
18621    where
18622        T: AsRef<str>,
18623    {
18624        self._additional_params
18625            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18626        self
18627    }
18628
18629    /// Identifies the authorization scope for the method you are building.
18630    ///
18631    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18632    /// [`Scope::CloudPlatform`].
18633    ///
18634    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18635    /// tokens for more than one scope.
18636    ///
18637    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18638    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18639    /// sufficient, a read-write scope will do as well.
18640    pub fn add_scope<St>(
18641        mut self,
18642        scope: St,
18643    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
18644    where
18645        St: AsRef<str>,
18646    {
18647        self._scopes.insert(String::from(scope.as_ref()));
18648        self
18649    }
18650    /// Identifies the authorization scope(s) for the method you are building.
18651    ///
18652    /// See [`Self::add_scope()`] for details.
18653    pub fn add_scopes<I, St>(
18654        mut self,
18655        scopes: I,
18656    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
18657    where
18658        I: IntoIterator<Item = St>,
18659        St: AsRef<str>,
18660    {
18661        self._scopes
18662            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18663        self
18664    }
18665
18666    /// Removes all scopes, and no default scope will be used either.
18667    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18668    /// for details).
18669    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
18670        self._scopes.clear();
18671        self
18672    }
18673}
18674
18675/// Update the version of a CryptoKey that will be used in Encrypt. Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT.
18676///
18677/// A builder for the *locations.keyRings.cryptoKeys.updatePrimaryVersion* method supported by a *project* resource.
18678/// It is not used directly, but through a [`ProjectMethods`] instance.
18679///
18680/// # Example
18681///
18682/// Instantiate a resource method builder
18683///
18684/// ```test_harness,no_run
18685/// # extern crate hyper;
18686/// # extern crate hyper_rustls;
18687/// # extern crate google_cloudkms1 as cloudkms1;
18688/// use cloudkms1::api::UpdateCryptoKeyPrimaryVersionRequest;
18689/// # async fn dox() {
18690/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18691///
18692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18693/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18694/// #     .with_native_roots()
18695/// #     .unwrap()
18696/// #     .https_only()
18697/// #     .enable_http2()
18698/// #     .build();
18699///
18700/// # let executor = hyper_util::rt::TokioExecutor::new();
18701/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18702/// #     secret,
18703/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18704/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18705/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18706/// #     ),
18707/// # ).build().await.unwrap();
18708///
18709/// # let client = hyper_util::client::legacy::Client::builder(
18710/// #     hyper_util::rt::TokioExecutor::new()
18711/// # )
18712/// # .build(
18713/// #     hyper_rustls::HttpsConnectorBuilder::new()
18714/// #         .with_native_roots()
18715/// #         .unwrap()
18716/// #         .https_or_http()
18717/// #         .enable_http2()
18718/// #         .build()
18719/// # );
18720/// # let mut hub = CloudKMS::new(client, auth);
18721/// // As the method needs a request, you would usually fill it with the desired information
18722/// // into the respective structure. Some of the parts shown here might not be applicable !
18723/// // Values shown here are possibly random and not representative !
18724/// let mut req = UpdateCryptoKeyPrimaryVersionRequest::default();
18725///
18726/// // You can configure optional parameters by calling the respective setters at will, and
18727/// // execute the final call using `doit()`.
18728/// // Values shown here are possibly random and not representative !
18729/// let result = hub.projects().locations_key_rings_crypto_keys_update_primary_version(req, "name")
18730///              .doit().await;
18731/// # }
18732/// ```
18733pub struct ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
18734where
18735    C: 'a,
18736{
18737    hub: &'a CloudKMS<C>,
18738    _request: UpdateCryptoKeyPrimaryVersionRequest,
18739    _name: String,
18740    _delegate: Option<&'a mut dyn common::Delegate>,
18741    _additional_params: HashMap<String, String>,
18742    _scopes: BTreeSet<String>,
18743}
18744
18745impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {}
18746
18747impl<'a, C> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
18748where
18749    C: common::Connector,
18750{
18751    /// Perform the operation you have build so far.
18752    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
18753        use std::borrow::Cow;
18754        use std::io::{Read, Seek};
18755
18756        use common::{url::Params, ToParts};
18757        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18758
18759        let mut dd = common::DefaultDelegate;
18760        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18761        dlg.begin(common::MethodInfo {
18762            id: "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion",
18763            http_method: hyper::Method::POST,
18764        });
18765
18766        for &field in ["alt", "name"].iter() {
18767            if self._additional_params.contains_key(field) {
18768                dlg.finished(false);
18769                return Err(common::Error::FieldClash(field));
18770            }
18771        }
18772
18773        let mut params = Params::with_capacity(4 + self._additional_params.len());
18774        params.push("name", self._name);
18775
18776        params.extend(self._additional_params.iter());
18777
18778        params.push("alt", "json");
18779        let mut url = self.hub._base_url.clone() + "v1/{+name}:updatePrimaryVersion";
18780        if self._scopes.is_empty() {
18781            self._scopes
18782                .insert(Scope::CloudPlatform.as_ref().to_string());
18783        }
18784
18785        #[allow(clippy::single_element_loop)]
18786        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18787            url = params.uri_replacement(url, param_name, find_this, true);
18788        }
18789        {
18790            let to_remove = ["name"];
18791            params.remove_params(&to_remove);
18792        }
18793
18794        let url = params.parse_with_url(&url);
18795
18796        let mut json_mime_type = mime::APPLICATION_JSON;
18797        let mut request_value_reader = {
18798            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18799            common::remove_json_null_values(&mut value);
18800            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18801            serde_json::to_writer(&mut dst, &value).unwrap();
18802            dst
18803        };
18804        let request_size = request_value_reader
18805            .seek(std::io::SeekFrom::End(0))
18806            .unwrap();
18807        request_value_reader
18808            .seek(std::io::SeekFrom::Start(0))
18809            .unwrap();
18810
18811        loop {
18812            let token = match self
18813                .hub
18814                .auth
18815                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18816                .await
18817            {
18818                Ok(token) => token,
18819                Err(e) => match dlg.token(e) {
18820                    Ok(token) => token,
18821                    Err(e) => {
18822                        dlg.finished(false);
18823                        return Err(common::Error::MissingToken(e));
18824                    }
18825                },
18826            };
18827            request_value_reader
18828                .seek(std::io::SeekFrom::Start(0))
18829                .unwrap();
18830            let mut req_result = {
18831                let client = &self.hub.client;
18832                dlg.pre_request();
18833                let mut req_builder = hyper::Request::builder()
18834                    .method(hyper::Method::POST)
18835                    .uri(url.as_str())
18836                    .header(USER_AGENT, self.hub._user_agent.clone());
18837
18838                if let Some(token) = token.as_ref() {
18839                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18840                }
18841
18842                let request = req_builder
18843                    .header(CONTENT_TYPE, json_mime_type.to_string())
18844                    .header(CONTENT_LENGTH, request_size as u64)
18845                    .body(common::to_body(
18846                        request_value_reader.get_ref().clone().into(),
18847                    ));
18848
18849                client.request(request.unwrap()).await
18850            };
18851
18852            match req_result {
18853                Err(err) => {
18854                    if let common::Retry::After(d) = dlg.http_error(&err) {
18855                        sleep(d).await;
18856                        continue;
18857                    }
18858                    dlg.finished(false);
18859                    return Err(common::Error::HttpError(err));
18860                }
18861                Ok(res) => {
18862                    let (mut parts, body) = res.into_parts();
18863                    let mut body = common::Body::new(body);
18864                    if !parts.status.is_success() {
18865                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18866                        let error = serde_json::from_str(&common::to_string(&bytes));
18867                        let response = common::to_response(parts, bytes.into());
18868
18869                        if let common::Retry::After(d) =
18870                            dlg.http_failure(&response, error.as_ref().ok())
18871                        {
18872                            sleep(d).await;
18873                            continue;
18874                        }
18875
18876                        dlg.finished(false);
18877
18878                        return Err(match error {
18879                            Ok(value) => common::Error::BadRequest(value),
18880                            _ => common::Error::Failure(response),
18881                        });
18882                    }
18883                    let response = {
18884                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18885                        let encoded = common::to_string(&bytes);
18886                        match serde_json::from_str(&encoded) {
18887                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18888                            Err(error) => {
18889                                dlg.response_json_decode_error(&encoded, &error);
18890                                return Err(common::Error::JsonDecodeError(
18891                                    encoded.to_string(),
18892                                    error,
18893                                ));
18894                            }
18895                        }
18896                    };
18897
18898                    dlg.finished(true);
18899                    return Ok(response);
18900                }
18901            }
18902        }
18903    }
18904
18905    ///
18906    /// Sets the *request* property to the given value.
18907    ///
18908    /// Even though the property as already been set when instantiating this call,
18909    /// we provide this method for API completeness.
18910    pub fn request(
18911        mut self,
18912        new_value: UpdateCryptoKeyPrimaryVersionRequest,
18913    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
18914        self._request = new_value;
18915        self
18916    }
18917    /// Required. The resource name of the CryptoKey to update.
18918    ///
18919    /// Sets the *name* path property to the given value.
18920    ///
18921    /// Even though the property as already been set when instantiating this call,
18922    /// we provide this method for API completeness.
18923    pub fn name(
18924        mut self,
18925        new_value: &str,
18926    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
18927        self._name = new_value.to_string();
18928        self
18929    }
18930    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18931    /// while executing the actual API request.
18932    ///
18933    /// ````text
18934    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18935    /// ````
18936    ///
18937    /// Sets the *delegate* property to the given value.
18938    pub fn delegate(
18939        mut self,
18940        new_value: &'a mut dyn common::Delegate,
18941    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
18942        self._delegate = Some(new_value);
18943        self
18944    }
18945
18946    /// Set any additional parameter of the query string used in the request.
18947    /// It should be used to set parameters which are not yet available through their own
18948    /// setters.
18949    ///
18950    /// Please note that this method must not be used to set any of the known parameters
18951    /// which have their own setter method. If done anyway, the request will fail.
18952    ///
18953    /// # Additional Parameters
18954    ///
18955    /// * *$.xgafv* (query-string) - V1 error format.
18956    /// * *access_token* (query-string) - OAuth access token.
18957    /// * *alt* (query-string) - Data format for response.
18958    /// * *callback* (query-string) - JSONP
18959    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18960    /// * *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.
18961    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18962    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18963    /// * *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.
18964    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18965    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18966    pub fn param<T>(
18967        mut self,
18968        name: T,
18969        value: T,
18970    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
18971    where
18972        T: AsRef<str>,
18973    {
18974        self._additional_params
18975            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18976        self
18977    }
18978
18979    /// Identifies the authorization scope for the method you are building.
18980    ///
18981    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18982    /// [`Scope::CloudPlatform`].
18983    ///
18984    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18985    /// tokens for more than one scope.
18986    ///
18987    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18988    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18989    /// sufficient, a read-write scope will do as well.
18990    pub fn add_scope<St>(
18991        mut self,
18992        scope: St,
18993    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
18994    where
18995        St: AsRef<str>,
18996    {
18997        self._scopes.insert(String::from(scope.as_ref()));
18998        self
18999    }
19000    /// Identifies the authorization scope(s) for the method you are building.
19001    ///
19002    /// See [`Self::add_scope()`] for details.
19003    pub fn add_scopes<I, St>(
19004        mut self,
19005        scopes: I,
19006    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
19007    where
19008        I: IntoIterator<Item = St>,
19009        St: AsRef<str>,
19010    {
19011        self._scopes
19012            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19013        self
19014    }
19015
19016    /// Removes all scopes, and no default scope will be used either.
19017    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19018    /// for details).
19019    pub fn clear_scopes(
19020        mut self,
19021    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
19022        self._scopes.clear();
19023        self
19024    }
19025}
19026
19027/// Create a new ImportJob within a KeyRing. ImportJob.import_method is required.
19028///
19029/// A builder for the *locations.keyRings.importJobs.create* method supported by a *project* resource.
19030/// It is not used directly, but through a [`ProjectMethods`] instance.
19031///
19032/// # Example
19033///
19034/// Instantiate a resource method builder
19035///
19036/// ```test_harness,no_run
19037/// # extern crate hyper;
19038/// # extern crate hyper_rustls;
19039/// # extern crate google_cloudkms1 as cloudkms1;
19040/// use cloudkms1::api::ImportJob;
19041/// # async fn dox() {
19042/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19043///
19044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19046/// #     .with_native_roots()
19047/// #     .unwrap()
19048/// #     .https_only()
19049/// #     .enable_http2()
19050/// #     .build();
19051///
19052/// # let executor = hyper_util::rt::TokioExecutor::new();
19053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19054/// #     secret,
19055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19056/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19057/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19058/// #     ),
19059/// # ).build().await.unwrap();
19060///
19061/// # let client = hyper_util::client::legacy::Client::builder(
19062/// #     hyper_util::rt::TokioExecutor::new()
19063/// # )
19064/// # .build(
19065/// #     hyper_rustls::HttpsConnectorBuilder::new()
19066/// #         .with_native_roots()
19067/// #         .unwrap()
19068/// #         .https_or_http()
19069/// #         .enable_http2()
19070/// #         .build()
19071/// # );
19072/// # let mut hub = CloudKMS::new(client, auth);
19073/// // As the method needs a request, you would usually fill it with the desired information
19074/// // into the respective structure. Some of the parts shown here might not be applicable !
19075/// // Values shown here are possibly random and not representative !
19076/// let mut req = ImportJob::default();
19077///
19078/// // You can configure optional parameters by calling the respective setters at will, and
19079/// // execute the final call using `doit()`.
19080/// // Values shown here are possibly random and not representative !
19081/// let result = hub.projects().locations_key_rings_import_jobs_create(req, "parent")
19082///              .import_job_id("et")
19083///              .doit().await;
19084/// # }
19085/// ```
19086pub struct ProjectLocationKeyRingImportJobCreateCall<'a, C>
19087where
19088    C: 'a,
19089{
19090    hub: &'a CloudKMS<C>,
19091    _request: ImportJob,
19092    _parent: String,
19093    _import_job_id: Option<String>,
19094    _delegate: Option<&'a mut dyn common::Delegate>,
19095    _additional_params: HashMap<String, String>,
19096    _scopes: BTreeSet<String>,
19097}
19098
19099impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobCreateCall<'a, C> {}
19100
19101impl<'a, C> ProjectLocationKeyRingImportJobCreateCall<'a, C>
19102where
19103    C: common::Connector,
19104{
19105    /// Perform the operation you have build so far.
19106    pub async fn doit(mut self) -> common::Result<(common::Response, ImportJob)> {
19107        use std::borrow::Cow;
19108        use std::io::{Read, Seek};
19109
19110        use common::{url::Params, ToParts};
19111        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19112
19113        let mut dd = common::DefaultDelegate;
19114        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19115        dlg.begin(common::MethodInfo {
19116            id: "cloudkms.projects.locations.keyRings.importJobs.create",
19117            http_method: hyper::Method::POST,
19118        });
19119
19120        for &field in ["alt", "parent", "importJobId"].iter() {
19121            if self._additional_params.contains_key(field) {
19122                dlg.finished(false);
19123                return Err(common::Error::FieldClash(field));
19124            }
19125        }
19126
19127        let mut params = Params::with_capacity(5 + self._additional_params.len());
19128        params.push("parent", self._parent);
19129        if let Some(value) = self._import_job_id.as_ref() {
19130            params.push("importJobId", value);
19131        }
19132
19133        params.extend(self._additional_params.iter());
19134
19135        params.push("alt", "json");
19136        let mut url = self.hub._base_url.clone() + "v1/{+parent}/importJobs";
19137        if self._scopes.is_empty() {
19138            self._scopes
19139                .insert(Scope::CloudPlatform.as_ref().to_string());
19140        }
19141
19142        #[allow(clippy::single_element_loop)]
19143        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19144            url = params.uri_replacement(url, param_name, find_this, true);
19145        }
19146        {
19147            let to_remove = ["parent"];
19148            params.remove_params(&to_remove);
19149        }
19150
19151        let url = params.parse_with_url(&url);
19152
19153        let mut json_mime_type = mime::APPLICATION_JSON;
19154        let mut request_value_reader = {
19155            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19156            common::remove_json_null_values(&mut value);
19157            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19158            serde_json::to_writer(&mut dst, &value).unwrap();
19159            dst
19160        };
19161        let request_size = request_value_reader
19162            .seek(std::io::SeekFrom::End(0))
19163            .unwrap();
19164        request_value_reader
19165            .seek(std::io::SeekFrom::Start(0))
19166            .unwrap();
19167
19168        loop {
19169            let token = match self
19170                .hub
19171                .auth
19172                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19173                .await
19174            {
19175                Ok(token) => token,
19176                Err(e) => match dlg.token(e) {
19177                    Ok(token) => token,
19178                    Err(e) => {
19179                        dlg.finished(false);
19180                        return Err(common::Error::MissingToken(e));
19181                    }
19182                },
19183            };
19184            request_value_reader
19185                .seek(std::io::SeekFrom::Start(0))
19186                .unwrap();
19187            let mut req_result = {
19188                let client = &self.hub.client;
19189                dlg.pre_request();
19190                let mut req_builder = hyper::Request::builder()
19191                    .method(hyper::Method::POST)
19192                    .uri(url.as_str())
19193                    .header(USER_AGENT, self.hub._user_agent.clone());
19194
19195                if let Some(token) = token.as_ref() {
19196                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19197                }
19198
19199                let request = req_builder
19200                    .header(CONTENT_TYPE, json_mime_type.to_string())
19201                    .header(CONTENT_LENGTH, request_size as u64)
19202                    .body(common::to_body(
19203                        request_value_reader.get_ref().clone().into(),
19204                    ));
19205
19206                client.request(request.unwrap()).await
19207            };
19208
19209            match req_result {
19210                Err(err) => {
19211                    if let common::Retry::After(d) = dlg.http_error(&err) {
19212                        sleep(d).await;
19213                        continue;
19214                    }
19215                    dlg.finished(false);
19216                    return Err(common::Error::HttpError(err));
19217                }
19218                Ok(res) => {
19219                    let (mut parts, body) = res.into_parts();
19220                    let mut body = common::Body::new(body);
19221                    if !parts.status.is_success() {
19222                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19223                        let error = serde_json::from_str(&common::to_string(&bytes));
19224                        let response = common::to_response(parts, bytes.into());
19225
19226                        if let common::Retry::After(d) =
19227                            dlg.http_failure(&response, error.as_ref().ok())
19228                        {
19229                            sleep(d).await;
19230                            continue;
19231                        }
19232
19233                        dlg.finished(false);
19234
19235                        return Err(match error {
19236                            Ok(value) => common::Error::BadRequest(value),
19237                            _ => common::Error::Failure(response),
19238                        });
19239                    }
19240                    let response = {
19241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19242                        let encoded = common::to_string(&bytes);
19243                        match serde_json::from_str(&encoded) {
19244                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19245                            Err(error) => {
19246                                dlg.response_json_decode_error(&encoded, &error);
19247                                return Err(common::Error::JsonDecodeError(
19248                                    encoded.to_string(),
19249                                    error,
19250                                ));
19251                            }
19252                        }
19253                    };
19254
19255                    dlg.finished(true);
19256                    return Ok(response);
19257                }
19258            }
19259        }
19260    }
19261
19262    ///
19263    /// Sets the *request* property to the given value.
19264    ///
19265    /// Even though the property as already been set when instantiating this call,
19266    /// we provide this method for API completeness.
19267    pub fn request(
19268        mut self,
19269        new_value: ImportJob,
19270    ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
19271        self._request = new_value;
19272        self
19273    }
19274    /// Required. The name of the KeyRing associated with the ImportJobs.
19275    ///
19276    /// Sets the *parent* path property to the given value.
19277    ///
19278    /// Even though the property as already been set when instantiating this call,
19279    /// we provide this method for API completeness.
19280    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
19281        self._parent = new_value.to_string();
19282        self
19283    }
19284    /// Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`
19285    ///
19286    /// Sets the *import job id* query property to the given value.
19287    pub fn import_job_id(
19288        mut self,
19289        new_value: &str,
19290    ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
19291        self._import_job_id = Some(new_value.to_string());
19292        self
19293    }
19294    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19295    /// while executing the actual API request.
19296    ///
19297    /// ````text
19298    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19299    /// ````
19300    ///
19301    /// Sets the *delegate* property to the given value.
19302    pub fn delegate(
19303        mut self,
19304        new_value: &'a mut dyn common::Delegate,
19305    ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
19306        self._delegate = Some(new_value);
19307        self
19308    }
19309
19310    /// Set any additional parameter of the query string used in the request.
19311    /// It should be used to set parameters which are not yet available through their own
19312    /// setters.
19313    ///
19314    /// Please note that this method must not be used to set any of the known parameters
19315    /// which have their own setter method. If done anyway, the request will fail.
19316    ///
19317    /// # Additional Parameters
19318    ///
19319    /// * *$.xgafv* (query-string) - V1 error format.
19320    /// * *access_token* (query-string) - OAuth access token.
19321    /// * *alt* (query-string) - Data format for response.
19322    /// * *callback* (query-string) - JSONP
19323    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19324    /// * *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.
19325    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19326    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19327    /// * *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.
19328    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19329    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19330    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
19331    where
19332        T: AsRef<str>,
19333    {
19334        self._additional_params
19335            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19336        self
19337    }
19338
19339    /// Identifies the authorization scope for the method you are building.
19340    ///
19341    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19342    /// [`Scope::CloudPlatform`].
19343    ///
19344    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19345    /// tokens for more than one scope.
19346    ///
19347    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19348    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19349    /// sufficient, a read-write scope will do as well.
19350    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
19351    where
19352        St: AsRef<str>,
19353    {
19354        self._scopes.insert(String::from(scope.as_ref()));
19355        self
19356    }
19357    /// Identifies the authorization scope(s) for the method you are building.
19358    ///
19359    /// See [`Self::add_scope()`] for details.
19360    pub fn add_scopes<I, St>(
19361        mut self,
19362        scopes: I,
19363    ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
19364    where
19365        I: IntoIterator<Item = St>,
19366        St: AsRef<str>,
19367    {
19368        self._scopes
19369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19370        self
19371    }
19372
19373    /// Removes all scopes, and no default scope will be used either.
19374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19375    /// for details).
19376    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
19377        self._scopes.clear();
19378        self
19379    }
19380}
19381
19382/// Returns metadata for a given ImportJob.
19383///
19384/// A builder for the *locations.keyRings.importJobs.get* method supported by a *project* resource.
19385/// It is not used directly, but through a [`ProjectMethods`] instance.
19386///
19387/// # Example
19388///
19389/// Instantiate a resource method builder
19390///
19391/// ```test_harness,no_run
19392/// # extern crate hyper;
19393/// # extern crate hyper_rustls;
19394/// # extern crate google_cloudkms1 as cloudkms1;
19395/// # async fn dox() {
19396/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19397///
19398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19400/// #     .with_native_roots()
19401/// #     .unwrap()
19402/// #     .https_only()
19403/// #     .enable_http2()
19404/// #     .build();
19405///
19406/// # let executor = hyper_util::rt::TokioExecutor::new();
19407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19408/// #     secret,
19409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19412/// #     ),
19413/// # ).build().await.unwrap();
19414///
19415/// # let client = hyper_util::client::legacy::Client::builder(
19416/// #     hyper_util::rt::TokioExecutor::new()
19417/// # )
19418/// # .build(
19419/// #     hyper_rustls::HttpsConnectorBuilder::new()
19420/// #         .with_native_roots()
19421/// #         .unwrap()
19422/// #         .https_or_http()
19423/// #         .enable_http2()
19424/// #         .build()
19425/// # );
19426/// # let mut hub = CloudKMS::new(client, auth);
19427/// // You can configure optional parameters by calling the respective setters at will, and
19428/// // execute the final call using `doit()`.
19429/// // Values shown here are possibly random and not representative !
19430/// let result = hub.projects().locations_key_rings_import_jobs_get("name")
19431///              .doit().await;
19432/// # }
19433/// ```
19434pub struct ProjectLocationKeyRingImportJobGetCall<'a, C>
19435where
19436    C: 'a,
19437{
19438    hub: &'a CloudKMS<C>,
19439    _name: String,
19440    _delegate: Option<&'a mut dyn common::Delegate>,
19441    _additional_params: HashMap<String, String>,
19442    _scopes: BTreeSet<String>,
19443}
19444
19445impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobGetCall<'a, C> {}
19446
19447impl<'a, C> ProjectLocationKeyRingImportJobGetCall<'a, C>
19448where
19449    C: common::Connector,
19450{
19451    /// Perform the operation you have build so far.
19452    pub async fn doit(mut self) -> common::Result<(common::Response, ImportJob)> {
19453        use std::borrow::Cow;
19454        use std::io::{Read, Seek};
19455
19456        use common::{url::Params, ToParts};
19457        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19458
19459        let mut dd = common::DefaultDelegate;
19460        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19461        dlg.begin(common::MethodInfo {
19462            id: "cloudkms.projects.locations.keyRings.importJobs.get",
19463            http_method: hyper::Method::GET,
19464        });
19465
19466        for &field in ["alt", "name"].iter() {
19467            if self._additional_params.contains_key(field) {
19468                dlg.finished(false);
19469                return Err(common::Error::FieldClash(field));
19470            }
19471        }
19472
19473        let mut params = Params::with_capacity(3 + self._additional_params.len());
19474        params.push("name", self._name);
19475
19476        params.extend(self._additional_params.iter());
19477
19478        params.push("alt", "json");
19479        let mut url = self.hub._base_url.clone() + "v1/{+name}";
19480        if self._scopes.is_empty() {
19481            self._scopes
19482                .insert(Scope::CloudPlatform.as_ref().to_string());
19483        }
19484
19485        #[allow(clippy::single_element_loop)]
19486        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19487            url = params.uri_replacement(url, param_name, find_this, true);
19488        }
19489        {
19490            let to_remove = ["name"];
19491            params.remove_params(&to_remove);
19492        }
19493
19494        let url = params.parse_with_url(&url);
19495
19496        loop {
19497            let token = match self
19498                .hub
19499                .auth
19500                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19501                .await
19502            {
19503                Ok(token) => token,
19504                Err(e) => match dlg.token(e) {
19505                    Ok(token) => token,
19506                    Err(e) => {
19507                        dlg.finished(false);
19508                        return Err(common::Error::MissingToken(e));
19509                    }
19510                },
19511            };
19512            let mut req_result = {
19513                let client = &self.hub.client;
19514                dlg.pre_request();
19515                let mut req_builder = hyper::Request::builder()
19516                    .method(hyper::Method::GET)
19517                    .uri(url.as_str())
19518                    .header(USER_AGENT, self.hub._user_agent.clone());
19519
19520                if let Some(token) = token.as_ref() {
19521                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19522                }
19523
19524                let request = req_builder
19525                    .header(CONTENT_LENGTH, 0_u64)
19526                    .body(common::to_body::<String>(None));
19527
19528                client.request(request.unwrap()).await
19529            };
19530
19531            match req_result {
19532                Err(err) => {
19533                    if let common::Retry::After(d) = dlg.http_error(&err) {
19534                        sleep(d).await;
19535                        continue;
19536                    }
19537                    dlg.finished(false);
19538                    return Err(common::Error::HttpError(err));
19539                }
19540                Ok(res) => {
19541                    let (mut parts, body) = res.into_parts();
19542                    let mut body = common::Body::new(body);
19543                    if !parts.status.is_success() {
19544                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19545                        let error = serde_json::from_str(&common::to_string(&bytes));
19546                        let response = common::to_response(parts, bytes.into());
19547
19548                        if let common::Retry::After(d) =
19549                            dlg.http_failure(&response, error.as_ref().ok())
19550                        {
19551                            sleep(d).await;
19552                            continue;
19553                        }
19554
19555                        dlg.finished(false);
19556
19557                        return Err(match error {
19558                            Ok(value) => common::Error::BadRequest(value),
19559                            _ => common::Error::Failure(response),
19560                        });
19561                    }
19562                    let response = {
19563                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19564                        let encoded = common::to_string(&bytes);
19565                        match serde_json::from_str(&encoded) {
19566                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19567                            Err(error) => {
19568                                dlg.response_json_decode_error(&encoded, &error);
19569                                return Err(common::Error::JsonDecodeError(
19570                                    encoded.to_string(),
19571                                    error,
19572                                ));
19573                            }
19574                        }
19575                    };
19576
19577                    dlg.finished(true);
19578                    return Ok(response);
19579                }
19580            }
19581        }
19582    }
19583
19584    /// Required. The name of the ImportJob to get.
19585    ///
19586    /// Sets the *name* path property to the given value.
19587    ///
19588    /// Even though the property as already been set when instantiating this call,
19589    /// we provide this method for API completeness.
19590    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
19591        self._name = new_value.to_string();
19592        self
19593    }
19594    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19595    /// while executing the actual API request.
19596    ///
19597    /// ````text
19598    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19599    /// ````
19600    ///
19601    /// Sets the *delegate* property to the given value.
19602    pub fn delegate(
19603        mut self,
19604        new_value: &'a mut dyn common::Delegate,
19605    ) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
19606        self._delegate = Some(new_value);
19607        self
19608    }
19609
19610    /// Set any additional parameter of the query string used in the request.
19611    /// It should be used to set parameters which are not yet available through their own
19612    /// setters.
19613    ///
19614    /// Please note that this method must not be used to set any of the known parameters
19615    /// which have their own setter method. If done anyway, the request will fail.
19616    ///
19617    /// # Additional Parameters
19618    ///
19619    /// * *$.xgafv* (query-string) - V1 error format.
19620    /// * *access_token* (query-string) - OAuth access token.
19621    /// * *alt* (query-string) - Data format for response.
19622    /// * *callback* (query-string) - JSONP
19623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19624    /// * *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.
19625    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19626    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19627    /// * *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.
19628    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19629    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19630    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
19631    where
19632        T: AsRef<str>,
19633    {
19634        self._additional_params
19635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19636        self
19637    }
19638
19639    /// Identifies the authorization scope for the method you are building.
19640    ///
19641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19642    /// [`Scope::CloudPlatform`].
19643    ///
19644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19645    /// tokens for more than one scope.
19646    ///
19647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19649    /// sufficient, a read-write scope will do as well.
19650    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
19651    where
19652        St: AsRef<str>,
19653    {
19654        self._scopes.insert(String::from(scope.as_ref()));
19655        self
19656    }
19657    /// Identifies the authorization scope(s) for the method you are building.
19658    ///
19659    /// See [`Self::add_scope()`] for details.
19660    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
19661    where
19662        I: IntoIterator<Item = St>,
19663        St: AsRef<str>,
19664    {
19665        self._scopes
19666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19667        self
19668    }
19669
19670    /// Removes all scopes, and no default scope will be used either.
19671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19672    /// for details).
19673    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
19674        self._scopes.clear();
19675        self
19676    }
19677}
19678
19679/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
19680///
19681/// A builder for the *locations.keyRings.importJobs.getIamPolicy* method supported by a *project* resource.
19682/// It is not used directly, but through a [`ProjectMethods`] instance.
19683///
19684/// # Example
19685///
19686/// Instantiate a resource method builder
19687///
19688/// ```test_harness,no_run
19689/// # extern crate hyper;
19690/// # extern crate hyper_rustls;
19691/// # extern crate google_cloudkms1 as cloudkms1;
19692/// # async fn dox() {
19693/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19694///
19695/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19696/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19697/// #     .with_native_roots()
19698/// #     .unwrap()
19699/// #     .https_only()
19700/// #     .enable_http2()
19701/// #     .build();
19702///
19703/// # let executor = hyper_util::rt::TokioExecutor::new();
19704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19705/// #     secret,
19706/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19707/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19708/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19709/// #     ),
19710/// # ).build().await.unwrap();
19711///
19712/// # let client = hyper_util::client::legacy::Client::builder(
19713/// #     hyper_util::rt::TokioExecutor::new()
19714/// # )
19715/// # .build(
19716/// #     hyper_rustls::HttpsConnectorBuilder::new()
19717/// #         .with_native_roots()
19718/// #         .unwrap()
19719/// #         .https_or_http()
19720/// #         .enable_http2()
19721/// #         .build()
19722/// # );
19723/// # let mut hub = CloudKMS::new(client, auth);
19724/// // You can configure optional parameters by calling the respective setters at will, and
19725/// // execute the final call using `doit()`.
19726/// // Values shown here are possibly random and not representative !
19727/// let result = hub.projects().locations_key_rings_import_jobs_get_iam_policy("resource")
19728///              .options_requested_policy_version(-2)
19729///              .doit().await;
19730/// # }
19731/// ```
19732pub struct ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
19733where
19734    C: 'a,
19735{
19736    hub: &'a CloudKMS<C>,
19737    _resource: String,
19738    _options_requested_policy_version: Option<i32>,
19739    _delegate: Option<&'a mut dyn common::Delegate>,
19740    _additional_params: HashMap<String, String>,
19741    _scopes: BTreeSet<String>,
19742}
19743
19744impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {}
19745
19746impl<'a, C> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
19747where
19748    C: common::Connector,
19749{
19750    /// Perform the operation you have build so far.
19751    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19752        use std::borrow::Cow;
19753        use std::io::{Read, Seek};
19754
19755        use common::{url::Params, ToParts};
19756        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19757
19758        let mut dd = common::DefaultDelegate;
19759        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19760        dlg.begin(common::MethodInfo {
19761            id: "cloudkms.projects.locations.keyRings.importJobs.getIamPolicy",
19762            http_method: hyper::Method::GET,
19763        });
19764
19765        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
19766            if self._additional_params.contains_key(field) {
19767                dlg.finished(false);
19768                return Err(common::Error::FieldClash(field));
19769            }
19770        }
19771
19772        let mut params = Params::with_capacity(4 + self._additional_params.len());
19773        params.push("resource", self._resource);
19774        if let Some(value) = self._options_requested_policy_version.as_ref() {
19775            params.push("options.requestedPolicyVersion", value.to_string());
19776        }
19777
19778        params.extend(self._additional_params.iter());
19779
19780        params.push("alt", "json");
19781        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
19782        if self._scopes.is_empty() {
19783            self._scopes
19784                .insert(Scope::CloudPlatform.as_ref().to_string());
19785        }
19786
19787        #[allow(clippy::single_element_loop)]
19788        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19789            url = params.uri_replacement(url, param_name, find_this, true);
19790        }
19791        {
19792            let to_remove = ["resource"];
19793            params.remove_params(&to_remove);
19794        }
19795
19796        let url = params.parse_with_url(&url);
19797
19798        loop {
19799            let token = match self
19800                .hub
19801                .auth
19802                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19803                .await
19804            {
19805                Ok(token) => token,
19806                Err(e) => match dlg.token(e) {
19807                    Ok(token) => token,
19808                    Err(e) => {
19809                        dlg.finished(false);
19810                        return Err(common::Error::MissingToken(e));
19811                    }
19812                },
19813            };
19814            let mut req_result = {
19815                let client = &self.hub.client;
19816                dlg.pre_request();
19817                let mut req_builder = hyper::Request::builder()
19818                    .method(hyper::Method::GET)
19819                    .uri(url.as_str())
19820                    .header(USER_AGENT, self.hub._user_agent.clone());
19821
19822                if let Some(token) = token.as_ref() {
19823                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19824                }
19825
19826                let request = req_builder
19827                    .header(CONTENT_LENGTH, 0_u64)
19828                    .body(common::to_body::<String>(None));
19829
19830                client.request(request.unwrap()).await
19831            };
19832
19833            match req_result {
19834                Err(err) => {
19835                    if let common::Retry::After(d) = dlg.http_error(&err) {
19836                        sleep(d).await;
19837                        continue;
19838                    }
19839                    dlg.finished(false);
19840                    return Err(common::Error::HttpError(err));
19841                }
19842                Ok(res) => {
19843                    let (mut parts, body) = res.into_parts();
19844                    let mut body = common::Body::new(body);
19845                    if !parts.status.is_success() {
19846                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19847                        let error = serde_json::from_str(&common::to_string(&bytes));
19848                        let response = common::to_response(parts, bytes.into());
19849
19850                        if let common::Retry::After(d) =
19851                            dlg.http_failure(&response, error.as_ref().ok())
19852                        {
19853                            sleep(d).await;
19854                            continue;
19855                        }
19856
19857                        dlg.finished(false);
19858
19859                        return Err(match error {
19860                            Ok(value) => common::Error::BadRequest(value),
19861                            _ => common::Error::Failure(response),
19862                        });
19863                    }
19864                    let response = {
19865                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19866                        let encoded = common::to_string(&bytes);
19867                        match serde_json::from_str(&encoded) {
19868                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19869                            Err(error) => {
19870                                dlg.response_json_decode_error(&encoded, &error);
19871                                return Err(common::Error::JsonDecodeError(
19872                                    encoded.to_string(),
19873                                    error,
19874                                ));
19875                            }
19876                        }
19877                    };
19878
19879                    dlg.finished(true);
19880                    return Ok(response);
19881                }
19882            }
19883        }
19884    }
19885
19886    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
19887    ///
19888    /// Sets the *resource* path property to the given value.
19889    ///
19890    /// Even though the property as already been set when instantiating this call,
19891    /// we provide this method for API completeness.
19892    pub fn resource(
19893        mut self,
19894        new_value: &str,
19895    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
19896        self._resource = new_value.to_string();
19897        self
19898    }
19899    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
19900    ///
19901    /// Sets the *options.requested policy version* query property to the given value.
19902    pub fn options_requested_policy_version(
19903        mut self,
19904        new_value: i32,
19905    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
19906        self._options_requested_policy_version = Some(new_value);
19907        self
19908    }
19909    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19910    /// while executing the actual API request.
19911    ///
19912    /// ````text
19913    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19914    /// ````
19915    ///
19916    /// Sets the *delegate* property to the given value.
19917    pub fn delegate(
19918        mut self,
19919        new_value: &'a mut dyn common::Delegate,
19920    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
19921        self._delegate = Some(new_value);
19922        self
19923    }
19924
19925    /// Set any additional parameter of the query string used in the request.
19926    /// It should be used to set parameters which are not yet available through their own
19927    /// setters.
19928    ///
19929    /// Please note that this method must not be used to set any of the known parameters
19930    /// which have their own setter method. If done anyway, the request will fail.
19931    ///
19932    /// # Additional Parameters
19933    ///
19934    /// * *$.xgafv* (query-string) - V1 error format.
19935    /// * *access_token* (query-string) - OAuth access token.
19936    /// * *alt* (query-string) - Data format for response.
19937    /// * *callback* (query-string) - JSONP
19938    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19939    /// * *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.
19940    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19941    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19942    /// * *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.
19943    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19944    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19945    pub fn param<T>(
19946        mut self,
19947        name: T,
19948        value: T,
19949    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
19950    where
19951        T: AsRef<str>,
19952    {
19953        self._additional_params
19954            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19955        self
19956    }
19957
19958    /// Identifies the authorization scope for the method you are building.
19959    ///
19960    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19961    /// [`Scope::CloudPlatform`].
19962    ///
19963    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19964    /// tokens for more than one scope.
19965    ///
19966    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19967    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19968    /// sufficient, a read-write scope will do as well.
19969    pub fn add_scope<St>(
19970        mut self,
19971        scope: St,
19972    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
19973    where
19974        St: AsRef<str>,
19975    {
19976        self._scopes.insert(String::from(scope.as_ref()));
19977        self
19978    }
19979    /// Identifies the authorization scope(s) for the method you are building.
19980    ///
19981    /// See [`Self::add_scope()`] for details.
19982    pub fn add_scopes<I, St>(
19983        mut self,
19984        scopes: I,
19985    ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
19986    where
19987        I: IntoIterator<Item = St>,
19988        St: AsRef<str>,
19989    {
19990        self._scopes
19991            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19992        self
19993    }
19994
19995    /// Removes all scopes, and no default scope will be used either.
19996    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19997    /// for details).
19998    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
19999        self._scopes.clear();
20000        self
20001    }
20002}
20003
20004/// Lists ImportJobs.
20005///
20006/// A builder for the *locations.keyRings.importJobs.list* method supported by a *project* resource.
20007/// It is not used directly, but through a [`ProjectMethods`] instance.
20008///
20009/// # Example
20010///
20011/// Instantiate a resource method builder
20012///
20013/// ```test_harness,no_run
20014/// # extern crate hyper;
20015/// # extern crate hyper_rustls;
20016/// # extern crate google_cloudkms1 as cloudkms1;
20017/// # async fn dox() {
20018/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20019///
20020/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20021/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20022/// #     .with_native_roots()
20023/// #     .unwrap()
20024/// #     .https_only()
20025/// #     .enable_http2()
20026/// #     .build();
20027///
20028/// # let executor = hyper_util::rt::TokioExecutor::new();
20029/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20030/// #     secret,
20031/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20032/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20033/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20034/// #     ),
20035/// # ).build().await.unwrap();
20036///
20037/// # let client = hyper_util::client::legacy::Client::builder(
20038/// #     hyper_util::rt::TokioExecutor::new()
20039/// # )
20040/// # .build(
20041/// #     hyper_rustls::HttpsConnectorBuilder::new()
20042/// #         .with_native_roots()
20043/// #         .unwrap()
20044/// #         .https_or_http()
20045/// #         .enable_http2()
20046/// #         .build()
20047/// # );
20048/// # let mut hub = CloudKMS::new(client, auth);
20049/// // You can configure optional parameters by calling the respective setters at will, and
20050/// // execute the final call using `doit()`.
20051/// // Values shown here are possibly random and not representative !
20052/// let result = hub.projects().locations_key_rings_import_jobs_list("parent")
20053///              .page_token("takimata")
20054///              .page_size(-19)
20055///              .order_by("gubergren")
20056///              .filter("et")
20057///              .doit().await;
20058/// # }
20059/// ```
20060pub struct ProjectLocationKeyRingImportJobListCall<'a, C>
20061where
20062    C: 'a,
20063{
20064    hub: &'a CloudKMS<C>,
20065    _parent: String,
20066    _page_token: Option<String>,
20067    _page_size: Option<i32>,
20068    _order_by: Option<String>,
20069    _filter: Option<String>,
20070    _delegate: Option<&'a mut dyn common::Delegate>,
20071    _additional_params: HashMap<String, String>,
20072    _scopes: BTreeSet<String>,
20073}
20074
20075impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobListCall<'a, C> {}
20076
20077impl<'a, C> ProjectLocationKeyRingImportJobListCall<'a, C>
20078where
20079    C: common::Connector,
20080{
20081    /// Perform the operation you have build so far.
20082    pub async fn doit(mut self) -> common::Result<(common::Response, ListImportJobsResponse)> {
20083        use std::borrow::Cow;
20084        use std::io::{Read, Seek};
20085
20086        use common::{url::Params, ToParts};
20087        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20088
20089        let mut dd = common::DefaultDelegate;
20090        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20091        dlg.begin(common::MethodInfo {
20092            id: "cloudkms.projects.locations.keyRings.importJobs.list",
20093            http_method: hyper::Method::GET,
20094        });
20095
20096        for &field in [
20097            "alt",
20098            "parent",
20099            "pageToken",
20100            "pageSize",
20101            "orderBy",
20102            "filter",
20103        ]
20104        .iter()
20105        {
20106            if self._additional_params.contains_key(field) {
20107                dlg.finished(false);
20108                return Err(common::Error::FieldClash(field));
20109            }
20110        }
20111
20112        let mut params = Params::with_capacity(7 + self._additional_params.len());
20113        params.push("parent", self._parent);
20114        if let Some(value) = self._page_token.as_ref() {
20115            params.push("pageToken", value);
20116        }
20117        if let Some(value) = self._page_size.as_ref() {
20118            params.push("pageSize", value.to_string());
20119        }
20120        if let Some(value) = self._order_by.as_ref() {
20121            params.push("orderBy", value);
20122        }
20123        if let Some(value) = self._filter.as_ref() {
20124            params.push("filter", value);
20125        }
20126
20127        params.extend(self._additional_params.iter());
20128
20129        params.push("alt", "json");
20130        let mut url = self.hub._base_url.clone() + "v1/{+parent}/importJobs";
20131        if self._scopes.is_empty() {
20132            self._scopes
20133                .insert(Scope::CloudPlatform.as_ref().to_string());
20134        }
20135
20136        #[allow(clippy::single_element_loop)]
20137        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20138            url = params.uri_replacement(url, param_name, find_this, true);
20139        }
20140        {
20141            let to_remove = ["parent"];
20142            params.remove_params(&to_remove);
20143        }
20144
20145        let url = params.parse_with_url(&url);
20146
20147        loop {
20148            let token = match self
20149                .hub
20150                .auth
20151                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20152                .await
20153            {
20154                Ok(token) => token,
20155                Err(e) => match dlg.token(e) {
20156                    Ok(token) => token,
20157                    Err(e) => {
20158                        dlg.finished(false);
20159                        return Err(common::Error::MissingToken(e));
20160                    }
20161                },
20162            };
20163            let mut req_result = {
20164                let client = &self.hub.client;
20165                dlg.pre_request();
20166                let mut req_builder = hyper::Request::builder()
20167                    .method(hyper::Method::GET)
20168                    .uri(url.as_str())
20169                    .header(USER_AGENT, self.hub._user_agent.clone());
20170
20171                if let Some(token) = token.as_ref() {
20172                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20173                }
20174
20175                let request = req_builder
20176                    .header(CONTENT_LENGTH, 0_u64)
20177                    .body(common::to_body::<String>(None));
20178
20179                client.request(request.unwrap()).await
20180            };
20181
20182            match req_result {
20183                Err(err) => {
20184                    if let common::Retry::After(d) = dlg.http_error(&err) {
20185                        sleep(d).await;
20186                        continue;
20187                    }
20188                    dlg.finished(false);
20189                    return Err(common::Error::HttpError(err));
20190                }
20191                Ok(res) => {
20192                    let (mut parts, body) = res.into_parts();
20193                    let mut body = common::Body::new(body);
20194                    if !parts.status.is_success() {
20195                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20196                        let error = serde_json::from_str(&common::to_string(&bytes));
20197                        let response = common::to_response(parts, bytes.into());
20198
20199                        if let common::Retry::After(d) =
20200                            dlg.http_failure(&response, error.as_ref().ok())
20201                        {
20202                            sleep(d).await;
20203                            continue;
20204                        }
20205
20206                        dlg.finished(false);
20207
20208                        return Err(match error {
20209                            Ok(value) => common::Error::BadRequest(value),
20210                            _ => common::Error::Failure(response),
20211                        });
20212                    }
20213                    let response = {
20214                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20215                        let encoded = common::to_string(&bytes);
20216                        match serde_json::from_str(&encoded) {
20217                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20218                            Err(error) => {
20219                                dlg.response_json_decode_error(&encoded, &error);
20220                                return Err(common::Error::JsonDecodeError(
20221                                    encoded.to_string(),
20222                                    error,
20223                                ));
20224                            }
20225                        }
20226                    };
20227
20228                    dlg.finished(true);
20229                    return Ok(response);
20230                }
20231            }
20232        }
20233    }
20234
20235    /// Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
20236    ///
20237    /// Sets the *parent* path property to the given value.
20238    ///
20239    /// Even though the property as already been set when instantiating this call,
20240    /// we provide this method for API completeness.
20241    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20242        self._parent = new_value.to_string();
20243        self
20244    }
20245    /// Optional. Optional pagination token, returned earlier via ListImportJobsResponse.next_page_token.
20246    ///
20247    /// Sets the *page token* query property to the given value.
20248    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20249        self._page_token = Some(new_value.to_string());
20250        self
20251    }
20252    /// Optional. Optional limit on the number of ImportJobs to include in the response. Further ImportJobs can subsequently be obtained by including the ListImportJobsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.
20253    ///
20254    /// Sets the *page size* query property to the given value.
20255    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20256        self._page_size = Some(new_value);
20257        self
20258    }
20259    /// Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
20260    ///
20261    /// Sets the *order by* query property to the given value.
20262    pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20263        self._order_by = Some(new_value.to_string());
20264        self
20265    }
20266    /// Optional. Only include resources that match the filter in the response. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
20267    ///
20268    /// Sets the *filter* query property to the given value.
20269    pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20270        self._filter = Some(new_value.to_string());
20271        self
20272    }
20273    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20274    /// while executing the actual API request.
20275    ///
20276    /// ````text
20277    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20278    /// ````
20279    ///
20280    /// Sets the *delegate* property to the given value.
20281    pub fn delegate(
20282        mut self,
20283        new_value: &'a mut dyn common::Delegate,
20284    ) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20285        self._delegate = Some(new_value);
20286        self
20287    }
20288
20289    /// Set any additional parameter of the query string used in the request.
20290    /// It should be used to set parameters which are not yet available through their own
20291    /// setters.
20292    ///
20293    /// Please note that this method must not be used to set any of the known parameters
20294    /// which have their own setter method. If done anyway, the request will fail.
20295    ///
20296    /// # Additional Parameters
20297    ///
20298    /// * *$.xgafv* (query-string) - V1 error format.
20299    /// * *access_token* (query-string) - OAuth access token.
20300    /// * *alt* (query-string) - Data format for response.
20301    /// * *callback* (query-string) - JSONP
20302    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20303    /// * *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.
20304    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20305    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20306    /// * *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.
20307    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20308    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20309    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobListCall<'a, C>
20310    where
20311        T: AsRef<str>,
20312    {
20313        self._additional_params
20314            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20315        self
20316    }
20317
20318    /// Identifies the authorization scope for the method you are building.
20319    ///
20320    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20321    /// [`Scope::CloudPlatform`].
20322    ///
20323    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20324    /// tokens for more than one scope.
20325    ///
20326    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20327    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20328    /// sufficient, a read-write scope will do as well.
20329    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobListCall<'a, C>
20330    where
20331        St: AsRef<str>,
20332    {
20333        self._scopes.insert(String::from(scope.as_ref()));
20334        self
20335    }
20336    /// Identifies the authorization scope(s) for the method you are building.
20337    ///
20338    /// See [`Self::add_scope()`] for details.
20339    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingImportJobListCall<'a, C>
20340    where
20341        I: IntoIterator<Item = St>,
20342        St: AsRef<str>,
20343    {
20344        self._scopes
20345            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20346        self
20347    }
20348
20349    /// Removes all scopes, and no default scope will be used either.
20350    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20351    /// for details).
20352    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
20353        self._scopes.clear();
20354        self
20355    }
20356}
20357
20358/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
20359///
20360/// A builder for the *locations.keyRings.importJobs.setIamPolicy* method supported by a *project* resource.
20361/// It is not used directly, but through a [`ProjectMethods`] instance.
20362///
20363/// # Example
20364///
20365/// Instantiate a resource method builder
20366///
20367/// ```test_harness,no_run
20368/// # extern crate hyper;
20369/// # extern crate hyper_rustls;
20370/// # extern crate google_cloudkms1 as cloudkms1;
20371/// use cloudkms1::api::SetIamPolicyRequest;
20372/// # async fn dox() {
20373/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20374///
20375/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20376/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20377/// #     .with_native_roots()
20378/// #     .unwrap()
20379/// #     .https_only()
20380/// #     .enable_http2()
20381/// #     .build();
20382///
20383/// # let executor = hyper_util::rt::TokioExecutor::new();
20384/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20385/// #     secret,
20386/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20387/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20388/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20389/// #     ),
20390/// # ).build().await.unwrap();
20391///
20392/// # let client = hyper_util::client::legacy::Client::builder(
20393/// #     hyper_util::rt::TokioExecutor::new()
20394/// # )
20395/// # .build(
20396/// #     hyper_rustls::HttpsConnectorBuilder::new()
20397/// #         .with_native_roots()
20398/// #         .unwrap()
20399/// #         .https_or_http()
20400/// #         .enable_http2()
20401/// #         .build()
20402/// # );
20403/// # let mut hub = CloudKMS::new(client, auth);
20404/// // As the method needs a request, you would usually fill it with the desired information
20405/// // into the respective structure. Some of the parts shown here might not be applicable !
20406/// // Values shown here are possibly random and not representative !
20407/// let mut req = SetIamPolicyRequest::default();
20408///
20409/// // You can configure optional parameters by calling the respective setters at will, and
20410/// // execute the final call using `doit()`.
20411/// // Values shown here are possibly random and not representative !
20412/// let result = hub.projects().locations_key_rings_import_jobs_set_iam_policy(req, "resource")
20413///              .doit().await;
20414/// # }
20415/// ```
20416pub struct ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
20417where
20418    C: 'a,
20419{
20420    hub: &'a CloudKMS<C>,
20421    _request: SetIamPolicyRequest,
20422    _resource: String,
20423    _delegate: Option<&'a mut dyn common::Delegate>,
20424    _additional_params: HashMap<String, String>,
20425    _scopes: BTreeSet<String>,
20426}
20427
20428impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {}
20429
20430impl<'a, C> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
20431where
20432    C: common::Connector,
20433{
20434    /// Perform the operation you have build so far.
20435    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
20436        use std::borrow::Cow;
20437        use std::io::{Read, Seek};
20438
20439        use common::{url::Params, ToParts};
20440        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20441
20442        let mut dd = common::DefaultDelegate;
20443        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20444        dlg.begin(common::MethodInfo {
20445            id: "cloudkms.projects.locations.keyRings.importJobs.setIamPolicy",
20446            http_method: hyper::Method::POST,
20447        });
20448
20449        for &field in ["alt", "resource"].iter() {
20450            if self._additional_params.contains_key(field) {
20451                dlg.finished(false);
20452                return Err(common::Error::FieldClash(field));
20453            }
20454        }
20455
20456        let mut params = Params::with_capacity(4 + self._additional_params.len());
20457        params.push("resource", self._resource);
20458
20459        params.extend(self._additional_params.iter());
20460
20461        params.push("alt", "json");
20462        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
20463        if self._scopes.is_empty() {
20464            self._scopes
20465                .insert(Scope::CloudPlatform.as_ref().to_string());
20466        }
20467
20468        #[allow(clippy::single_element_loop)]
20469        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
20470            url = params.uri_replacement(url, param_name, find_this, true);
20471        }
20472        {
20473            let to_remove = ["resource"];
20474            params.remove_params(&to_remove);
20475        }
20476
20477        let url = params.parse_with_url(&url);
20478
20479        let mut json_mime_type = mime::APPLICATION_JSON;
20480        let mut request_value_reader = {
20481            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20482            common::remove_json_null_values(&mut value);
20483            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20484            serde_json::to_writer(&mut dst, &value).unwrap();
20485            dst
20486        };
20487        let request_size = request_value_reader
20488            .seek(std::io::SeekFrom::End(0))
20489            .unwrap();
20490        request_value_reader
20491            .seek(std::io::SeekFrom::Start(0))
20492            .unwrap();
20493
20494        loop {
20495            let token = match self
20496                .hub
20497                .auth
20498                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20499                .await
20500            {
20501                Ok(token) => token,
20502                Err(e) => match dlg.token(e) {
20503                    Ok(token) => token,
20504                    Err(e) => {
20505                        dlg.finished(false);
20506                        return Err(common::Error::MissingToken(e));
20507                    }
20508                },
20509            };
20510            request_value_reader
20511                .seek(std::io::SeekFrom::Start(0))
20512                .unwrap();
20513            let mut req_result = {
20514                let client = &self.hub.client;
20515                dlg.pre_request();
20516                let mut req_builder = hyper::Request::builder()
20517                    .method(hyper::Method::POST)
20518                    .uri(url.as_str())
20519                    .header(USER_AGENT, self.hub._user_agent.clone());
20520
20521                if let Some(token) = token.as_ref() {
20522                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20523                }
20524
20525                let request = req_builder
20526                    .header(CONTENT_TYPE, json_mime_type.to_string())
20527                    .header(CONTENT_LENGTH, request_size as u64)
20528                    .body(common::to_body(
20529                        request_value_reader.get_ref().clone().into(),
20530                    ));
20531
20532                client.request(request.unwrap()).await
20533            };
20534
20535            match req_result {
20536                Err(err) => {
20537                    if let common::Retry::After(d) = dlg.http_error(&err) {
20538                        sleep(d).await;
20539                        continue;
20540                    }
20541                    dlg.finished(false);
20542                    return Err(common::Error::HttpError(err));
20543                }
20544                Ok(res) => {
20545                    let (mut parts, body) = res.into_parts();
20546                    let mut body = common::Body::new(body);
20547                    if !parts.status.is_success() {
20548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20549                        let error = serde_json::from_str(&common::to_string(&bytes));
20550                        let response = common::to_response(parts, bytes.into());
20551
20552                        if let common::Retry::After(d) =
20553                            dlg.http_failure(&response, error.as_ref().ok())
20554                        {
20555                            sleep(d).await;
20556                            continue;
20557                        }
20558
20559                        dlg.finished(false);
20560
20561                        return Err(match error {
20562                            Ok(value) => common::Error::BadRequest(value),
20563                            _ => common::Error::Failure(response),
20564                        });
20565                    }
20566                    let response = {
20567                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20568                        let encoded = common::to_string(&bytes);
20569                        match serde_json::from_str(&encoded) {
20570                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20571                            Err(error) => {
20572                                dlg.response_json_decode_error(&encoded, &error);
20573                                return Err(common::Error::JsonDecodeError(
20574                                    encoded.to_string(),
20575                                    error,
20576                                ));
20577                            }
20578                        }
20579                    };
20580
20581                    dlg.finished(true);
20582                    return Ok(response);
20583                }
20584            }
20585        }
20586    }
20587
20588    ///
20589    /// Sets the *request* property to the given value.
20590    ///
20591    /// Even though the property as already been set when instantiating this call,
20592    /// we provide this method for API completeness.
20593    pub fn request(
20594        mut self,
20595        new_value: SetIamPolicyRequest,
20596    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
20597        self._request = new_value;
20598        self
20599    }
20600    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
20601    ///
20602    /// Sets the *resource* path property to the given value.
20603    ///
20604    /// Even though the property as already been set when instantiating this call,
20605    /// we provide this method for API completeness.
20606    pub fn resource(
20607        mut self,
20608        new_value: &str,
20609    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
20610        self._resource = new_value.to_string();
20611        self
20612    }
20613    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20614    /// while executing the actual API request.
20615    ///
20616    /// ````text
20617    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20618    /// ````
20619    ///
20620    /// Sets the *delegate* property to the given value.
20621    pub fn delegate(
20622        mut self,
20623        new_value: &'a mut dyn common::Delegate,
20624    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
20625        self._delegate = Some(new_value);
20626        self
20627    }
20628
20629    /// Set any additional parameter of the query string used in the request.
20630    /// It should be used to set parameters which are not yet available through their own
20631    /// setters.
20632    ///
20633    /// Please note that this method must not be used to set any of the known parameters
20634    /// which have their own setter method. If done anyway, the request will fail.
20635    ///
20636    /// # Additional Parameters
20637    ///
20638    /// * *$.xgafv* (query-string) - V1 error format.
20639    /// * *access_token* (query-string) - OAuth access token.
20640    /// * *alt* (query-string) - Data format for response.
20641    /// * *callback* (query-string) - JSONP
20642    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20643    /// * *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.
20644    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20645    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20646    /// * *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.
20647    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20648    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20649    pub fn param<T>(
20650        mut self,
20651        name: T,
20652        value: T,
20653    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
20654    where
20655        T: AsRef<str>,
20656    {
20657        self._additional_params
20658            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20659        self
20660    }
20661
20662    /// Identifies the authorization scope for the method you are building.
20663    ///
20664    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20665    /// [`Scope::CloudPlatform`].
20666    ///
20667    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20668    /// tokens for more than one scope.
20669    ///
20670    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20671    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20672    /// sufficient, a read-write scope will do as well.
20673    pub fn add_scope<St>(
20674        mut self,
20675        scope: St,
20676    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
20677    where
20678        St: AsRef<str>,
20679    {
20680        self._scopes.insert(String::from(scope.as_ref()));
20681        self
20682    }
20683    /// Identifies the authorization scope(s) for the method you are building.
20684    ///
20685    /// See [`Self::add_scope()`] for details.
20686    pub fn add_scopes<I, St>(
20687        mut self,
20688        scopes: I,
20689    ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
20690    where
20691        I: IntoIterator<Item = St>,
20692        St: AsRef<str>,
20693    {
20694        self._scopes
20695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20696        self
20697    }
20698
20699    /// Removes all scopes, and no default scope will be used either.
20700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20701    /// for details).
20702    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
20703        self._scopes.clear();
20704        self
20705    }
20706}
20707
20708/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
20709///
20710/// A builder for the *locations.keyRings.importJobs.testIamPermissions* method supported by a *project* resource.
20711/// It is not used directly, but through a [`ProjectMethods`] instance.
20712///
20713/// # Example
20714///
20715/// Instantiate a resource method builder
20716///
20717/// ```test_harness,no_run
20718/// # extern crate hyper;
20719/// # extern crate hyper_rustls;
20720/// # extern crate google_cloudkms1 as cloudkms1;
20721/// use cloudkms1::api::TestIamPermissionsRequest;
20722/// # async fn dox() {
20723/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20724///
20725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20726/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20727/// #     .with_native_roots()
20728/// #     .unwrap()
20729/// #     .https_only()
20730/// #     .enable_http2()
20731/// #     .build();
20732///
20733/// # let executor = hyper_util::rt::TokioExecutor::new();
20734/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20735/// #     secret,
20736/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20737/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20738/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20739/// #     ),
20740/// # ).build().await.unwrap();
20741///
20742/// # let client = hyper_util::client::legacy::Client::builder(
20743/// #     hyper_util::rt::TokioExecutor::new()
20744/// # )
20745/// # .build(
20746/// #     hyper_rustls::HttpsConnectorBuilder::new()
20747/// #         .with_native_roots()
20748/// #         .unwrap()
20749/// #         .https_or_http()
20750/// #         .enable_http2()
20751/// #         .build()
20752/// # );
20753/// # let mut hub = CloudKMS::new(client, auth);
20754/// // As the method needs a request, you would usually fill it with the desired information
20755/// // into the respective structure. Some of the parts shown here might not be applicable !
20756/// // Values shown here are possibly random and not representative !
20757/// let mut req = TestIamPermissionsRequest::default();
20758///
20759/// // You can configure optional parameters by calling the respective setters at will, and
20760/// // execute the final call using `doit()`.
20761/// // Values shown here are possibly random and not representative !
20762/// let result = hub.projects().locations_key_rings_import_jobs_test_iam_permissions(req, "resource")
20763///              .doit().await;
20764/// # }
20765/// ```
20766pub struct ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
20767where
20768    C: 'a,
20769{
20770    hub: &'a CloudKMS<C>,
20771    _request: TestIamPermissionsRequest,
20772    _resource: String,
20773    _delegate: Option<&'a mut dyn common::Delegate>,
20774    _additional_params: HashMap<String, String>,
20775    _scopes: BTreeSet<String>,
20776}
20777
20778impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {}
20779
20780impl<'a, C> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
20781where
20782    C: common::Connector,
20783{
20784    /// Perform the operation you have build so far.
20785    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
20786        use std::borrow::Cow;
20787        use std::io::{Read, Seek};
20788
20789        use common::{url::Params, ToParts};
20790        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20791
20792        let mut dd = common::DefaultDelegate;
20793        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20794        dlg.begin(common::MethodInfo {
20795            id: "cloudkms.projects.locations.keyRings.importJobs.testIamPermissions",
20796            http_method: hyper::Method::POST,
20797        });
20798
20799        for &field in ["alt", "resource"].iter() {
20800            if self._additional_params.contains_key(field) {
20801                dlg.finished(false);
20802                return Err(common::Error::FieldClash(field));
20803            }
20804        }
20805
20806        let mut params = Params::with_capacity(4 + self._additional_params.len());
20807        params.push("resource", self._resource);
20808
20809        params.extend(self._additional_params.iter());
20810
20811        params.push("alt", "json");
20812        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
20813        if self._scopes.is_empty() {
20814            self._scopes
20815                .insert(Scope::CloudPlatform.as_ref().to_string());
20816        }
20817
20818        #[allow(clippy::single_element_loop)]
20819        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
20820            url = params.uri_replacement(url, param_name, find_this, true);
20821        }
20822        {
20823            let to_remove = ["resource"];
20824            params.remove_params(&to_remove);
20825        }
20826
20827        let url = params.parse_with_url(&url);
20828
20829        let mut json_mime_type = mime::APPLICATION_JSON;
20830        let mut request_value_reader = {
20831            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20832            common::remove_json_null_values(&mut value);
20833            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20834            serde_json::to_writer(&mut dst, &value).unwrap();
20835            dst
20836        };
20837        let request_size = request_value_reader
20838            .seek(std::io::SeekFrom::End(0))
20839            .unwrap();
20840        request_value_reader
20841            .seek(std::io::SeekFrom::Start(0))
20842            .unwrap();
20843
20844        loop {
20845            let token = match self
20846                .hub
20847                .auth
20848                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20849                .await
20850            {
20851                Ok(token) => token,
20852                Err(e) => match dlg.token(e) {
20853                    Ok(token) => token,
20854                    Err(e) => {
20855                        dlg.finished(false);
20856                        return Err(common::Error::MissingToken(e));
20857                    }
20858                },
20859            };
20860            request_value_reader
20861                .seek(std::io::SeekFrom::Start(0))
20862                .unwrap();
20863            let mut req_result = {
20864                let client = &self.hub.client;
20865                dlg.pre_request();
20866                let mut req_builder = hyper::Request::builder()
20867                    .method(hyper::Method::POST)
20868                    .uri(url.as_str())
20869                    .header(USER_AGENT, self.hub._user_agent.clone());
20870
20871                if let Some(token) = token.as_ref() {
20872                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20873                }
20874
20875                let request = req_builder
20876                    .header(CONTENT_TYPE, json_mime_type.to_string())
20877                    .header(CONTENT_LENGTH, request_size as u64)
20878                    .body(common::to_body(
20879                        request_value_reader.get_ref().clone().into(),
20880                    ));
20881
20882                client.request(request.unwrap()).await
20883            };
20884
20885            match req_result {
20886                Err(err) => {
20887                    if let common::Retry::After(d) = dlg.http_error(&err) {
20888                        sleep(d).await;
20889                        continue;
20890                    }
20891                    dlg.finished(false);
20892                    return Err(common::Error::HttpError(err));
20893                }
20894                Ok(res) => {
20895                    let (mut parts, body) = res.into_parts();
20896                    let mut body = common::Body::new(body);
20897                    if !parts.status.is_success() {
20898                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20899                        let error = serde_json::from_str(&common::to_string(&bytes));
20900                        let response = common::to_response(parts, bytes.into());
20901
20902                        if let common::Retry::After(d) =
20903                            dlg.http_failure(&response, error.as_ref().ok())
20904                        {
20905                            sleep(d).await;
20906                            continue;
20907                        }
20908
20909                        dlg.finished(false);
20910
20911                        return Err(match error {
20912                            Ok(value) => common::Error::BadRequest(value),
20913                            _ => common::Error::Failure(response),
20914                        });
20915                    }
20916                    let response = {
20917                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20918                        let encoded = common::to_string(&bytes);
20919                        match serde_json::from_str(&encoded) {
20920                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20921                            Err(error) => {
20922                                dlg.response_json_decode_error(&encoded, &error);
20923                                return Err(common::Error::JsonDecodeError(
20924                                    encoded.to_string(),
20925                                    error,
20926                                ));
20927                            }
20928                        }
20929                    };
20930
20931                    dlg.finished(true);
20932                    return Ok(response);
20933                }
20934            }
20935        }
20936    }
20937
20938    ///
20939    /// Sets the *request* property to the given value.
20940    ///
20941    /// Even though the property as already been set when instantiating this call,
20942    /// we provide this method for API completeness.
20943    pub fn request(
20944        mut self,
20945        new_value: TestIamPermissionsRequest,
20946    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
20947        self._request = new_value;
20948        self
20949    }
20950    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
20951    ///
20952    /// Sets the *resource* path property to the given value.
20953    ///
20954    /// Even though the property as already been set when instantiating this call,
20955    /// we provide this method for API completeness.
20956    pub fn resource(
20957        mut self,
20958        new_value: &str,
20959    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
20960        self._resource = new_value.to_string();
20961        self
20962    }
20963    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20964    /// while executing the actual API request.
20965    ///
20966    /// ````text
20967    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20968    /// ````
20969    ///
20970    /// Sets the *delegate* property to the given value.
20971    pub fn delegate(
20972        mut self,
20973        new_value: &'a mut dyn common::Delegate,
20974    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
20975        self._delegate = Some(new_value);
20976        self
20977    }
20978
20979    /// Set any additional parameter of the query string used in the request.
20980    /// It should be used to set parameters which are not yet available through their own
20981    /// setters.
20982    ///
20983    /// Please note that this method must not be used to set any of the known parameters
20984    /// which have their own setter method. If done anyway, the request will fail.
20985    ///
20986    /// # Additional Parameters
20987    ///
20988    /// * *$.xgafv* (query-string) - V1 error format.
20989    /// * *access_token* (query-string) - OAuth access token.
20990    /// * *alt* (query-string) - Data format for response.
20991    /// * *callback* (query-string) - JSONP
20992    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20993    /// * *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.
20994    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20995    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20996    /// * *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.
20997    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20998    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20999    pub fn param<T>(
21000        mut self,
21001        name: T,
21002        value: T,
21003    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
21004    where
21005        T: AsRef<str>,
21006    {
21007        self._additional_params
21008            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21009        self
21010    }
21011
21012    /// Identifies the authorization scope for the method you are building.
21013    ///
21014    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21015    /// [`Scope::CloudPlatform`].
21016    ///
21017    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21018    /// tokens for more than one scope.
21019    ///
21020    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21021    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21022    /// sufficient, a read-write scope will do as well.
21023    pub fn add_scope<St>(
21024        mut self,
21025        scope: St,
21026    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
21027    where
21028        St: AsRef<str>,
21029    {
21030        self._scopes.insert(String::from(scope.as_ref()));
21031        self
21032    }
21033    /// Identifies the authorization scope(s) for the method you are building.
21034    ///
21035    /// See [`Self::add_scope()`] for details.
21036    pub fn add_scopes<I, St>(
21037        mut self,
21038        scopes: I,
21039    ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
21040    where
21041        I: IntoIterator<Item = St>,
21042        St: AsRef<str>,
21043    {
21044        self._scopes
21045            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21046        self
21047    }
21048
21049    /// Removes all scopes, and no default scope will be used either.
21050    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21051    /// for details).
21052    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
21053        self._scopes.clear();
21054        self
21055    }
21056}
21057
21058/// Create a new KeyRing in a given Project and Location.
21059///
21060/// A builder for the *locations.keyRings.create* method supported by a *project* resource.
21061/// It is not used directly, but through a [`ProjectMethods`] instance.
21062///
21063/// # Example
21064///
21065/// Instantiate a resource method builder
21066///
21067/// ```test_harness,no_run
21068/// # extern crate hyper;
21069/// # extern crate hyper_rustls;
21070/// # extern crate google_cloudkms1 as cloudkms1;
21071/// use cloudkms1::api::KeyRing;
21072/// # async fn dox() {
21073/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21074///
21075/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21076/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21077/// #     .with_native_roots()
21078/// #     .unwrap()
21079/// #     .https_only()
21080/// #     .enable_http2()
21081/// #     .build();
21082///
21083/// # let executor = hyper_util::rt::TokioExecutor::new();
21084/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21085/// #     secret,
21086/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21087/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21088/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21089/// #     ),
21090/// # ).build().await.unwrap();
21091///
21092/// # let client = hyper_util::client::legacy::Client::builder(
21093/// #     hyper_util::rt::TokioExecutor::new()
21094/// # )
21095/// # .build(
21096/// #     hyper_rustls::HttpsConnectorBuilder::new()
21097/// #         .with_native_roots()
21098/// #         .unwrap()
21099/// #         .https_or_http()
21100/// #         .enable_http2()
21101/// #         .build()
21102/// # );
21103/// # let mut hub = CloudKMS::new(client, auth);
21104/// // As the method needs a request, you would usually fill it with the desired information
21105/// // into the respective structure. Some of the parts shown here might not be applicable !
21106/// // Values shown here are possibly random and not representative !
21107/// let mut req = KeyRing::default();
21108///
21109/// // You can configure optional parameters by calling the respective setters at will, and
21110/// // execute the final call using `doit()`.
21111/// // Values shown here are possibly random and not representative !
21112/// let result = hub.projects().locations_key_rings_create(req, "parent")
21113///              .key_ring_id("dolore")
21114///              .doit().await;
21115/// # }
21116/// ```
21117pub struct ProjectLocationKeyRingCreateCall<'a, C>
21118where
21119    C: 'a,
21120{
21121    hub: &'a CloudKMS<C>,
21122    _request: KeyRing,
21123    _parent: String,
21124    _key_ring_id: Option<String>,
21125    _delegate: Option<&'a mut dyn common::Delegate>,
21126    _additional_params: HashMap<String, String>,
21127    _scopes: BTreeSet<String>,
21128}
21129
21130impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCreateCall<'a, C> {}
21131
21132impl<'a, C> ProjectLocationKeyRingCreateCall<'a, C>
21133where
21134    C: common::Connector,
21135{
21136    /// Perform the operation you have build so far.
21137    pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
21138        use std::borrow::Cow;
21139        use std::io::{Read, Seek};
21140
21141        use common::{url::Params, ToParts};
21142        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21143
21144        let mut dd = common::DefaultDelegate;
21145        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21146        dlg.begin(common::MethodInfo {
21147            id: "cloudkms.projects.locations.keyRings.create",
21148            http_method: hyper::Method::POST,
21149        });
21150
21151        for &field in ["alt", "parent", "keyRingId"].iter() {
21152            if self._additional_params.contains_key(field) {
21153                dlg.finished(false);
21154                return Err(common::Error::FieldClash(field));
21155            }
21156        }
21157
21158        let mut params = Params::with_capacity(5 + self._additional_params.len());
21159        params.push("parent", self._parent);
21160        if let Some(value) = self._key_ring_id.as_ref() {
21161            params.push("keyRingId", value);
21162        }
21163
21164        params.extend(self._additional_params.iter());
21165
21166        params.push("alt", "json");
21167        let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyRings";
21168        if self._scopes.is_empty() {
21169            self._scopes
21170                .insert(Scope::CloudPlatform.as_ref().to_string());
21171        }
21172
21173        #[allow(clippy::single_element_loop)]
21174        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21175            url = params.uri_replacement(url, param_name, find_this, true);
21176        }
21177        {
21178            let to_remove = ["parent"];
21179            params.remove_params(&to_remove);
21180        }
21181
21182        let url = params.parse_with_url(&url);
21183
21184        let mut json_mime_type = mime::APPLICATION_JSON;
21185        let mut request_value_reader = {
21186            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21187            common::remove_json_null_values(&mut value);
21188            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21189            serde_json::to_writer(&mut dst, &value).unwrap();
21190            dst
21191        };
21192        let request_size = request_value_reader
21193            .seek(std::io::SeekFrom::End(0))
21194            .unwrap();
21195        request_value_reader
21196            .seek(std::io::SeekFrom::Start(0))
21197            .unwrap();
21198
21199        loop {
21200            let token = match self
21201                .hub
21202                .auth
21203                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21204                .await
21205            {
21206                Ok(token) => token,
21207                Err(e) => match dlg.token(e) {
21208                    Ok(token) => token,
21209                    Err(e) => {
21210                        dlg.finished(false);
21211                        return Err(common::Error::MissingToken(e));
21212                    }
21213                },
21214            };
21215            request_value_reader
21216                .seek(std::io::SeekFrom::Start(0))
21217                .unwrap();
21218            let mut req_result = {
21219                let client = &self.hub.client;
21220                dlg.pre_request();
21221                let mut req_builder = hyper::Request::builder()
21222                    .method(hyper::Method::POST)
21223                    .uri(url.as_str())
21224                    .header(USER_AGENT, self.hub._user_agent.clone());
21225
21226                if let Some(token) = token.as_ref() {
21227                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21228                }
21229
21230                let request = req_builder
21231                    .header(CONTENT_TYPE, json_mime_type.to_string())
21232                    .header(CONTENT_LENGTH, request_size as u64)
21233                    .body(common::to_body(
21234                        request_value_reader.get_ref().clone().into(),
21235                    ));
21236
21237                client.request(request.unwrap()).await
21238            };
21239
21240            match req_result {
21241                Err(err) => {
21242                    if let common::Retry::After(d) = dlg.http_error(&err) {
21243                        sleep(d).await;
21244                        continue;
21245                    }
21246                    dlg.finished(false);
21247                    return Err(common::Error::HttpError(err));
21248                }
21249                Ok(res) => {
21250                    let (mut parts, body) = res.into_parts();
21251                    let mut body = common::Body::new(body);
21252                    if !parts.status.is_success() {
21253                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21254                        let error = serde_json::from_str(&common::to_string(&bytes));
21255                        let response = common::to_response(parts, bytes.into());
21256
21257                        if let common::Retry::After(d) =
21258                            dlg.http_failure(&response, error.as_ref().ok())
21259                        {
21260                            sleep(d).await;
21261                            continue;
21262                        }
21263
21264                        dlg.finished(false);
21265
21266                        return Err(match error {
21267                            Ok(value) => common::Error::BadRequest(value),
21268                            _ => common::Error::Failure(response),
21269                        });
21270                    }
21271                    let response = {
21272                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21273                        let encoded = common::to_string(&bytes);
21274                        match serde_json::from_str(&encoded) {
21275                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21276                            Err(error) => {
21277                                dlg.response_json_decode_error(&encoded, &error);
21278                                return Err(common::Error::JsonDecodeError(
21279                                    encoded.to_string(),
21280                                    error,
21281                                ));
21282                            }
21283                        }
21284                    };
21285
21286                    dlg.finished(true);
21287                    return Ok(response);
21288                }
21289            }
21290        }
21291    }
21292
21293    ///
21294    /// Sets the *request* property to the given value.
21295    ///
21296    /// Even though the property as already been set when instantiating this call,
21297    /// we provide this method for API completeness.
21298    pub fn request(mut self, new_value: KeyRing) -> ProjectLocationKeyRingCreateCall<'a, C> {
21299        self._request = new_value;
21300        self
21301    }
21302    /// Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
21303    ///
21304    /// Sets the *parent* path property to the given value.
21305    ///
21306    /// Even though the property as already been set when instantiating this call,
21307    /// we provide this method for API completeness.
21308    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
21309        self._parent = new_value.to_string();
21310        self
21311    }
21312    /// Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`
21313    ///
21314    /// Sets the *key ring id* query property to the given value.
21315    pub fn key_ring_id(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
21316        self._key_ring_id = Some(new_value.to_string());
21317        self
21318    }
21319    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21320    /// while executing the actual API request.
21321    ///
21322    /// ````text
21323    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21324    /// ````
21325    ///
21326    /// Sets the *delegate* property to the given value.
21327    pub fn delegate(
21328        mut self,
21329        new_value: &'a mut dyn common::Delegate,
21330    ) -> ProjectLocationKeyRingCreateCall<'a, C> {
21331        self._delegate = Some(new_value);
21332        self
21333    }
21334
21335    /// Set any additional parameter of the query string used in the request.
21336    /// It should be used to set parameters which are not yet available through their own
21337    /// setters.
21338    ///
21339    /// Please note that this method must not be used to set any of the known parameters
21340    /// which have their own setter method. If done anyway, the request will fail.
21341    ///
21342    /// # Additional Parameters
21343    ///
21344    /// * *$.xgafv* (query-string) - V1 error format.
21345    /// * *access_token* (query-string) - OAuth access token.
21346    /// * *alt* (query-string) - Data format for response.
21347    /// * *callback* (query-string) - JSONP
21348    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21349    /// * *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.
21350    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21351    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21352    /// * *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.
21353    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21354    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21355    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCreateCall<'a, C>
21356    where
21357        T: AsRef<str>,
21358    {
21359        self._additional_params
21360            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21361        self
21362    }
21363
21364    /// Identifies the authorization scope for the method you are building.
21365    ///
21366    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21367    /// [`Scope::CloudPlatform`].
21368    ///
21369    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21370    /// tokens for more than one scope.
21371    ///
21372    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21373    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21374    /// sufficient, a read-write scope will do as well.
21375    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCreateCall<'a, C>
21376    where
21377        St: AsRef<str>,
21378    {
21379        self._scopes.insert(String::from(scope.as_ref()));
21380        self
21381    }
21382    /// Identifies the authorization scope(s) for the method you are building.
21383    ///
21384    /// See [`Self::add_scope()`] for details.
21385    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCreateCall<'a, C>
21386    where
21387        I: IntoIterator<Item = St>,
21388        St: AsRef<str>,
21389    {
21390        self._scopes
21391            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21392        self
21393    }
21394
21395    /// Removes all scopes, and no default scope will be used either.
21396    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21397    /// for details).
21398    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCreateCall<'a, C> {
21399        self._scopes.clear();
21400        self
21401    }
21402}
21403
21404/// Returns metadata for a given KeyRing.
21405///
21406/// A builder for the *locations.keyRings.get* method supported by a *project* resource.
21407/// It is not used directly, but through a [`ProjectMethods`] instance.
21408///
21409/// # Example
21410///
21411/// Instantiate a resource method builder
21412///
21413/// ```test_harness,no_run
21414/// # extern crate hyper;
21415/// # extern crate hyper_rustls;
21416/// # extern crate google_cloudkms1 as cloudkms1;
21417/// # async fn dox() {
21418/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21419///
21420/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21421/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21422/// #     .with_native_roots()
21423/// #     .unwrap()
21424/// #     .https_only()
21425/// #     .enable_http2()
21426/// #     .build();
21427///
21428/// # let executor = hyper_util::rt::TokioExecutor::new();
21429/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21430/// #     secret,
21431/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21432/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21433/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21434/// #     ),
21435/// # ).build().await.unwrap();
21436///
21437/// # let client = hyper_util::client::legacy::Client::builder(
21438/// #     hyper_util::rt::TokioExecutor::new()
21439/// # )
21440/// # .build(
21441/// #     hyper_rustls::HttpsConnectorBuilder::new()
21442/// #         .with_native_roots()
21443/// #         .unwrap()
21444/// #         .https_or_http()
21445/// #         .enable_http2()
21446/// #         .build()
21447/// # );
21448/// # let mut hub = CloudKMS::new(client, auth);
21449/// // You can configure optional parameters by calling the respective setters at will, and
21450/// // execute the final call using `doit()`.
21451/// // Values shown here are possibly random and not representative !
21452/// let result = hub.projects().locations_key_rings_get("name")
21453///              .doit().await;
21454/// # }
21455/// ```
21456pub struct ProjectLocationKeyRingGetCall<'a, C>
21457where
21458    C: 'a,
21459{
21460    hub: &'a CloudKMS<C>,
21461    _name: String,
21462    _delegate: Option<&'a mut dyn common::Delegate>,
21463    _additional_params: HashMap<String, String>,
21464    _scopes: BTreeSet<String>,
21465}
21466
21467impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetCall<'a, C> {}
21468
21469impl<'a, C> ProjectLocationKeyRingGetCall<'a, C>
21470where
21471    C: common::Connector,
21472{
21473    /// Perform the operation you have build so far.
21474    pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
21475        use std::borrow::Cow;
21476        use std::io::{Read, Seek};
21477
21478        use common::{url::Params, ToParts};
21479        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21480
21481        let mut dd = common::DefaultDelegate;
21482        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21483        dlg.begin(common::MethodInfo {
21484            id: "cloudkms.projects.locations.keyRings.get",
21485            http_method: hyper::Method::GET,
21486        });
21487
21488        for &field in ["alt", "name"].iter() {
21489            if self._additional_params.contains_key(field) {
21490                dlg.finished(false);
21491                return Err(common::Error::FieldClash(field));
21492            }
21493        }
21494
21495        let mut params = Params::with_capacity(3 + self._additional_params.len());
21496        params.push("name", self._name);
21497
21498        params.extend(self._additional_params.iter());
21499
21500        params.push("alt", "json");
21501        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21502        if self._scopes.is_empty() {
21503            self._scopes
21504                .insert(Scope::CloudPlatform.as_ref().to_string());
21505        }
21506
21507        #[allow(clippy::single_element_loop)]
21508        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21509            url = params.uri_replacement(url, param_name, find_this, true);
21510        }
21511        {
21512            let to_remove = ["name"];
21513            params.remove_params(&to_remove);
21514        }
21515
21516        let url = params.parse_with_url(&url);
21517
21518        loop {
21519            let token = match self
21520                .hub
21521                .auth
21522                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21523                .await
21524            {
21525                Ok(token) => token,
21526                Err(e) => match dlg.token(e) {
21527                    Ok(token) => token,
21528                    Err(e) => {
21529                        dlg.finished(false);
21530                        return Err(common::Error::MissingToken(e));
21531                    }
21532                },
21533            };
21534            let mut req_result = {
21535                let client = &self.hub.client;
21536                dlg.pre_request();
21537                let mut req_builder = hyper::Request::builder()
21538                    .method(hyper::Method::GET)
21539                    .uri(url.as_str())
21540                    .header(USER_AGENT, self.hub._user_agent.clone());
21541
21542                if let Some(token) = token.as_ref() {
21543                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21544                }
21545
21546                let request = req_builder
21547                    .header(CONTENT_LENGTH, 0_u64)
21548                    .body(common::to_body::<String>(None));
21549
21550                client.request(request.unwrap()).await
21551            };
21552
21553            match req_result {
21554                Err(err) => {
21555                    if let common::Retry::After(d) = dlg.http_error(&err) {
21556                        sleep(d).await;
21557                        continue;
21558                    }
21559                    dlg.finished(false);
21560                    return Err(common::Error::HttpError(err));
21561                }
21562                Ok(res) => {
21563                    let (mut parts, body) = res.into_parts();
21564                    let mut body = common::Body::new(body);
21565                    if !parts.status.is_success() {
21566                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21567                        let error = serde_json::from_str(&common::to_string(&bytes));
21568                        let response = common::to_response(parts, bytes.into());
21569
21570                        if let common::Retry::After(d) =
21571                            dlg.http_failure(&response, error.as_ref().ok())
21572                        {
21573                            sleep(d).await;
21574                            continue;
21575                        }
21576
21577                        dlg.finished(false);
21578
21579                        return Err(match error {
21580                            Ok(value) => common::Error::BadRequest(value),
21581                            _ => common::Error::Failure(response),
21582                        });
21583                    }
21584                    let response = {
21585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21586                        let encoded = common::to_string(&bytes);
21587                        match serde_json::from_str(&encoded) {
21588                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21589                            Err(error) => {
21590                                dlg.response_json_decode_error(&encoded, &error);
21591                                return Err(common::Error::JsonDecodeError(
21592                                    encoded.to_string(),
21593                                    error,
21594                                ));
21595                            }
21596                        }
21597                    };
21598
21599                    dlg.finished(true);
21600                    return Ok(response);
21601                }
21602            }
21603        }
21604    }
21605
21606    /// Required. The name of the KeyRing to get.
21607    ///
21608    /// Sets the *name* path property to the given value.
21609    ///
21610    /// Even though the property as already been set when instantiating this call,
21611    /// we provide this method for API completeness.
21612    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
21613        self._name = new_value.to_string();
21614        self
21615    }
21616    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21617    /// while executing the actual API request.
21618    ///
21619    /// ````text
21620    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21621    /// ````
21622    ///
21623    /// Sets the *delegate* property to the given value.
21624    pub fn delegate(
21625        mut self,
21626        new_value: &'a mut dyn common::Delegate,
21627    ) -> ProjectLocationKeyRingGetCall<'a, C> {
21628        self._delegate = Some(new_value);
21629        self
21630    }
21631
21632    /// Set any additional parameter of the query string used in the request.
21633    /// It should be used to set parameters which are not yet available through their own
21634    /// setters.
21635    ///
21636    /// Please note that this method must not be used to set any of the known parameters
21637    /// which have their own setter method. If done anyway, the request will fail.
21638    ///
21639    /// # Additional Parameters
21640    ///
21641    /// * *$.xgafv* (query-string) - V1 error format.
21642    /// * *access_token* (query-string) - OAuth access token.
21643    /// * *alt* (query-string) - Data format for response.
21644    /// * *callback* (query-string) - JSONP
21645    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21646    /// * *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.
21647    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21648    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21649    /// * *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.
21650    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21651    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21652    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetCall<'a, C>
21653    where
21654        T: AsRef<str>,
21655    {
21656        self._additional_params
21657            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21658        self
21659    }
21660
21661    /// Identifies the authorization scope for the method you are building.
21662    ///
21663    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21664    /// [`Scope::CloudPlatform`].
21665    ///
21666    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21667    /// tokens for more than one scope.
21668    ///
21669    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21670    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21671    /// sufficient, a read-write scope will do as well.
21672    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetCall<'a, C>
21673    where
21674        St: AsRef<str>,
21675    {
21676        self._scopes.insert(String::from(scope.as_ref()));
21677        self
21678    }
21679    /// Identifies the authorization scope(s) for the method you are building.
21680    ///
21681    /// See [`Self::add_scope()`] for details.
21682    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetCall<'a, C>
21683    where
21684        I: IntoIterator<Item = St>,
21685        St: AsRef<str>,
21686    {
21687        self._scopes
21688            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21689        self
21690    }
21691
21692    /// Removes all scopes, and no default scope will be used either.
21693    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21694    /// for details).
21695    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetCall<'a, C> {
21696        self._scopes.clear();
21697        self
21698    }
21699}
21700
21701/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
21702///
21703/// A builder for the *locations.keyRings.getIamPolicy* method supported by a *project* resource.
21704/// It is not used directly, but through a [`ProjectMethods`] instance.
21705///
21706/// # Example
21707///
21708/// Instantiate a resource method builder
21709///
21710/// ```test_harness,no_run
21711/// # extern crate hyper;
21712/// # extern crate hyper_rustls;
21713/// # extern crate google_cloudkms1 as cloudkms1;
21714/// # async fn dox() {
21715/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21716///
21717/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21718/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21719/// #     .with_native_roots()
21720/// #     .unwrap()
21721/// #     .https_only()
21722/// #     .enable_http2()
21723/// #     .build();
21724///
21725/// # let executor = hyper_util::rt::TokioExecutor::new();
21726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21727/// #     secret,
21728/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21729/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21730/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21731/// #     ),
21732/// # ).build().await.unwrap();
21733///
21734/// # let client = hyper_util::client::legacy::Client::builder(
21735/// #     hyper_util::rt::TokioExecutor::new()
21736/// # )
21737/// # .build(
21738/// #     hyper_rustls::HttpsConnectorBuilder::new()
21739/// #         .with_native_roots()
21740/// #         .unwrap()
21741/// #         .https_or_http()
21742/// #         .enable_http2()
21743/// #         .build()
21744/// # );
21745/// # let mut hub = CloudKMS::new(client, auth);
21746/// // You can configure optional parameters by calling the respective setters at will, and
21747/// // execute the final call using `doit()`.
21748/// // Values shown here are possibly random and not representative !
21749/// let result = hub.projects().locations_key_rings_get_iam_policy("resource")
21750///              .options_requested_policy_version(-2)
21751///              .doit().await;
21752/// # }
21753/// ```
21754pub struct ProjectLocationKeyRingGetIamPolicyCall<'a, C>
21755where
21756    C: 'a,
21757{
21758    hub: &'a CloudKMS<C>,
21759    _resource: String,
21760    _options_requested_policy_version: Option<i32>,
21761    _delegate: Option<&'a mut dyn common::Delegate>,
21762    _additional_params: HashMap<String, String>,
21763    _scopes: BTreeSet<String>,
21764}
21765
21766impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetIamPolicyCall<'a, C> {}
21767
21768impl<'a, C> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
21769where
21770    C: common::Connector,
21771{
21772    /// Perform the operation you have build so far.
21773    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
21774        use std::borrow::Cow;
21775        use std::io::{Read, Seek};
21776
21777        use common::{url::Params, ToParts};
21778        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21779
21780        let mut dd = common::DefaultDelegate;
21781        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21782        dlg.begin(common::MethodInfo {
21783            id: "cloudkms.projects.locations.keyRings.getIamPolicy",
21784            http_method: hyper::Method::GET,
21785        });
21786
21787        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
21788            if self._additional_params.contains_key(field) {
21789                dlg.finished(false);
21790                return Err(common::Error::FieldClash(field));
21791            }
21792        }
21793
21794        let mut params = Params::with_capacity(4 + self._additional_params.len());
21795        params.push("resource", self._resource);
21796        if let Some(value) = self._options_requested_policy_version.as_ref() {
21797            params.push("options.requestedPolicyVersion", value.to_string());
21798        }
21799
21800        params.extend(self._additional_params.iter());
21801
21802        params.push("alt", "json");
21803        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
21804        if self._scopes.is_empty() {
21805            self._scopes
21806                .insert(Scope::CloudPlatform.as_ref().to_string());
21807        }
21808
21809        #[allow(clippy::single_element_loop)]
21810        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
21811            url = params.uri_replacement(url, param_name, find_this, true);
21812        }
21813        {
21814            let to_remove = ["resource"];
21815            params.remove_params(&to_remove);
21816        }
21817
21818        let url = params.parse_with_url(&url);
21819
21820        loop {
21821            let token = match self
21822                .hub
21823                .auth
21824                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21825                .await
21826            {
21827                Ok(token) => token,
21828                Err(e) => match dlg.token(e) {
21829                    Ok(token) => token,
21830                    Err(e) => {
21831                        dlg.finished(false);
21832                        return Err(common::Error::MissingToken(e));
21833                    }
21834                },
21835            };
21836            let mut req_result = {
21837                let client = &self.hub.client;
21838                dlg.pre_request();
21839                let mut req_builder = hyper::Request::builder()
21840                    .method(hyper::Method::GET)
21841                    .uri(url.as_str())
21842                    .header(USER_AGENT, self.hub._user_agent.clone());
21843
21844                if let Some(token) = token.as_ref() {
21845                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21846                }
21847
21848                let request = req_builder
21849                    .header(CONTENT_LENGTH, 0_u64)
21850                    .body(common::to_body::<String>(None));
21851
21852                client.request(request.unwrap()).await
21853            };
21854
21855            match req_result {
21856                Err(err) => {
21857                    if let common::Retry::After(d) = dlg.http_error(&err) {
21858                        sleep(d).await;
21859                        continue;
21860                    }
21861                    dlg.finished(false);
21862                    return Err(common::Error::HttpError(err));
21863                }
21864                Ok(res) => {
21865                    let (mut parts, body) = res.into_parts();
21866                    let mut body = common::Body::new(body);
21867                    if !parts.status.is_success() {
21868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21869                        let error = serde_json::from_str(&common::to_string(&bytes));
21870                        let response = common::to_response(parts, bytes.into());
21871
21872                        if let common::Retry::After(d) =
21873                            dlg.http_failure(&response, error.as_ref().ok())
21874                        {
21875                            sleep(d).await;
21876                            continue;
21877                        }
21878
21879                        dlg.finished(false);
21880
21881                        return Err(match error {
21882                            Ok(value) => common::Error::BadRequest(value),
21883                            _ => common::Error::Failure(response),
21884                        });
21885                    }
21886                    let response = {
21887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21888                        let encoded = common::to_string(&bytes);
21889                        match serde_json::from_str(&encoded) {
21890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21891                            Err(error) => {
21892                                dlg.response_json_decode_error(&encoded, &error);
21893                                return Err(common::Error::JsonDecodeError(
21894                                    encoded.to_string(),
21895                                    error,
21896                                ));
21897                            }
21898                        }
21899                    };
21900
21901                    dlg.finished(true);
21902                    return Ok(response);
21903                }
21904            }
21905        }
21906    }
21907
21908    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
21909    ///
21910    /// Sets the *resource* path property to the given value.
21911    ///
21912    /// Even though the property as already been set when instantiating this call,
21913    /// we provide this method for API completeness.
21914    pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
21915        self._resource = new_value.to_string();
21916        self
21917    }
21918    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
21919    ///
21920    /// Sets the *options.requested policy version* query property to the given value.
21921    pub fn options_requested_policy_version(
21922        mut self,
21923        new_value: i32,
21924    ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
21925        self._options_requested_policy_version = Some(new_value);
21926        self
21927    }
21928    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21929    /// while executing the actual API request.
21930    ///
21931    /// ````text
21932    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21933    /// ````
21934    ///
21935    /// Sets the *delegate* property to the given value.
21936    pub fn delegate(
21937        mut self,
21938        new_value: &'a mut dyn common::Delegate,
21939    ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
21940        self._delegate = Some(new_value);
21941        self
21942    }
21943
21944    /// Set any additional parameter of the query string used in the request.
21945    /// It should be used to set parameters which are not yet available through their own
21946    /// setters.
21947    ///
21948    /// Please note that this method must not be used to set any of the known parameters
21949    /// which have their own setter method. If done anyway, the request will fail.
21950    ///
21951    /// # Additional Parameters
21952    ///
21953    /// * *$.xgafv* (query-string) - V1 error format.
21954    /// * *access_token* (query-string) - OAuth access token.
21955    /// * *alt* (query-string) - Data format for response.
21956    /// * *callback* (query-string) - JSONP
21957    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21958    /// * *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.
21959    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21960    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21961    /// * *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.
21962    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21963    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21964    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
21965    where
21966        T: AsRef<str>,
21967    {
21968        self._additional_params
21969            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21970        self
21971    }
21972
21973    /// Identifies the authorization scope for the method you are building.
21974    ///
21975    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21976    /// [`Scope::CloudPlatform`].
21977    ///
21978    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21979    /// tokens for more than one scope.
21980    ///
21981    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21982    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21983    /// sufficient, a read-write scope will do as well.
21984    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
21985    where
21986        St: AsRef<str>,
21987    {
21988        self._scopes.insert(String::from(scope.as_ref()));
21989        self
21990    }
21991    /// Identifies the authorization scope(s) for the method you are building.
21992    ///
21993    /// See [`Self::add_scope()`] for details.
21994    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
21995    where
21996        I: IntoIterator<Item = St>,
21997        St: AsRef<str>,
21998    {
21999        self._scopes
22000            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22001        self
22002    }
22003
22004    /// Removes all scopes, and no default scope will be used either.
22005    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22006    /// for details).
22007    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
22008        self._scopes.clear();
22009        self
22010    }
22011}
22012
22013/// Lists KeyRings.
22014///
22015/// A builder for the *locations.keyRings.list* method supported by a *project* resource.
22016/// It is not used directly, but through a [`ProjectMethods`] instance.
22017///
22018/// # Example
22019///
22020/// Instantiate a resource method builder
22021///
22022/// ```test_harness,no_run
22023/// # extern crate hyper;
22024/// # extern crate hyper_rustls;
22025/// # extern crate google_cloudkms1 as cloudkms1;
22026/// # async fn dox() {
22027/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22028///
22029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22030/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22031/// #     .with_native_roots()
22032/// #     .unwrap()
22033/// #     .https_only()
22034/// #     .enable_http2()
22035/// #     .build();
22036///
22037/// # let executor = hyper_util::rt::TokioExecutor::new();
22038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22039/// #     secret,
22040/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22041/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22042/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22043/// #     ),
22044/// # ).build().await.unwrap();
22045///
22046/// # let client = hyper_util::client::legacy::Client::builder(
22047/// #     hyper_util::rt::TokioExecutor::new()
22048/// # )
22049/// # .build(
22050/// #     hyper_rustls::HttpsConnectorBuilder::new()
22051/// #         .with_native_roots()
22052/// #         .unwrap()
22053/// #         .https_or_http()
22054/// #         .enable_http2()
22055/// #         .build()
22056/// # );
22057/// # let mut hub = CloudKMS::new(client, auth);
22058/// // You can configure optional parameters by calling the respective setters at will, and
22059/// // execute the final call using `doit()`.
22060/// // Values shown here are possibly random and not representative !
22061/// let result = hub.projects().locations_key_rings_list("parent")
22062///              .page_token("sadipscing")
22063///              .page_size(-6)
22064///              .order_by("invidunt")
22065///              .filter("no")
22066///              .doit().await;
22067/// # }
22068/// ```
22069pub struct ProjectLocationKeyRingListCall<'a, C>
22070where
22071    C: 'a,
22072{
22073    hub: &'a CloudKMS<C>,
22074    _parent: String,
22075    _page_token: Option<String>,
22076    _page_size: Option<i32>,
22077    _order_by: Option<String>,
22078    _filter: Option<String>,
22079    _delegate: Option<&'a mut dyn common::Delegate>,
22080    _additional_params: HashMap<String, String>,
22081    _scopes: BTreeSet<String>,
22082}
22083
22084impl<'a, C> common::CallBuilder for ProjectLocationKeyRingListCall<'a, C> {}
22085
22086impl<'a, C> ProjectLocationKeyRingListCall<'a, C>
22087where
22088    C: common::Connector,
22089{
22090    /// Perform the operation you have build so far.
22091    pub async fn doit(mut self) -> common::Result<(common::Response, ListKeyRingsResponse)> {
22092        use std::borrow::Cow;
22093        use std::io::{Read, Seek};
22094
22095        use common::{url::Params, ToParts};
22096        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22097
22098        let mut dd = common::DefaultDelegate;
22099        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22100        dlg.begin(common::MethodInfo {
22101            id: "cloudkms.projects.locations.keyRings.list",
22102            http_method: hyper::Method::GET,
22103        });
22104
22105        for &field in [
22106            "alt",
22107            "parent",
22108            "pageToken",
22109            "pageSize",
22110            "orderBy",
22111            "filter",
22112        ]
22113        .iter()
22114        {
22115            if self._additional_params.contains_key(field) {
22116                dlg.finished(false);
22117                return Err(common::Error::FieldClash(field));
22118            }
22119        }
22120
22121        let mut params = Params::with_capacity(7 + self._additional_params.len());
22122        params.push("parent", self._parent);
22123        if let Some(value) = self._page_token.as_ref() {
22124            params.push("pageToken", value);
22125        }
22126        if let Some(value) = self._page_size.as_ref() {
22127            params.push("pageSize", value.to_string());
22128        }
22129        if let Some(value) = self._order_by.as_ref() {
22130            params.push("orderBy", value);
22131        }
22132        if let Some(value) = self._filter.as_ref() {
22133            params.push("filter", value);
22134        }
22135
22136        params.extend(self._additional_params.iter());
22137
22138        params.push("alt", "json");
22139        let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyRings";
22140        if self._scopes.is_empty() {
22141            self._scopes
22142                .insert(Scope::CloudPlatform.as_ref().to_string());
22143        }
22144
22145        #[allow(clippy::single_element_loop)]
22146        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22147            url = params.uri_replacement(url, param_name, find_this, true);
22148        }
22149        {
22150            let to_remove = ["parent"];
22151            params.remove_params(&to_remove);
22152        }
22153
22154        let url = params.parse_with_url(&url);
22155
22156        loop {
22157            let token = match self
22158                .hub
22159                .auth
22160                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22161                .await
22162            {
22163                Ok(token) => token,
22164                Err(e) => match dlg.token(e) {
22165                    Ok(token) => token,
22166                    Err(e) => {
22167                        dlg.finished(false);
22168                        return Err(common::Error::MissingToken(e));
22169                    }
22170                },
22171            };
22172            let mut req_result = {
22173                let client = &self.hub.client;
22174                dlg.pre_request();
22175                let mut req_builder = hyper::Request::builder()
22176                    .method(hyper::Method::GET)
22177                    .uri(url.as_str())
22178                    .header(USER_AGENT, self.hub._user_agent.clone());
22179
22180                if let Some(token) = token.as_ref() {
22181                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22182                }
22183
22184                let request = req_builder
22185                    .header(CONTENT_LENGTH, 0_u64)
22186                    .body(common::to_body::<String>(None));
22187
22188                client.request(request.unwrap()).await
22189            };
22190
22191            match req_result {
22192                Err(err) => {
22193                    if let common::Retry::After(d) = dlg.http_error(&err) {
22194                        sleep(d).await;
22195                        continue;
22196                    }
22197                    dlg.finished(false);
22198                    return Err(common::Error::HttpError(err));
22199                }
22200                Ok(res) => {
22201                    let (mut parts, body) = res.into_parts();
22202                    let mut body = common::Body::new(body);
22203                    if !parts.status.is_success() {
22204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22205                        let error = serde_json::from_str(&common::to_string(&bytes));
22206                        let response = common::to_response(parts, bytes.into());
22207
22208                        if let common::Retry::After(d) =
22209                            dlg.http_failure(&response, error.as_ref().ok())
22210                        {
22211                            sleep(d).await;
22212                            continue;
22213                        }
22214
22215                        dlg.finished(false);
22216
22217                        return Err(match error {
22218                            Ok(value) => common::Error::BadRequest(value),
22219                            _ => common::Error::Failure(response),
22220                        });
22221                    }
22222                    let response = {
22223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22224                        let encoded = common::to_string(&bytes);
22225                        match serde_json::from_str(&encoded) {
22226                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22227                            Err(error) => {
22228                                dlg.response_json_decode_error(&encoded, &error);
22229                                return Err(common::Error::JsonDecodeError(
22230                                    encoded.to_string(),
22231                                    error,
22232                                ));
22233                            }
22234                        }
22235                    };
22236
22237                    dlg.finished(true);
22238                    return Ok(response);
22239                }
22240            }
22241        }
22242    }
22243
22244    /// Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
22245    ///
22246    /// Sets the *parent* path property to the given value.
22247    ///
22248    /// Even though the property as already been set when instantiating this call,
22249    /// we provide this method for API completeness.
22250    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
22251        self._parent = new_value.to_string();
22252        self
22253    }
22254    /// Optional. Optional pagination token, returned earlier via ListKeyRingsResponse.next_page_token.
22255    ///
22256    /// Sets the *page token* query property to the given value.
22257    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
22258        self._page_token = Some(new_value.to_string());
22259        self
22260    }
22261    /// Optional. Optional limit on the number of KeyRings to include in the response. Further KeyRings can subsequently be obtained by including the ListKeyRingsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.
22262    ///
22263    /// Sets the *page size* query property to the given value.
22264    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingListCall<'a, C> {
22265        self._page_size = Some(new_value);
22266        self
22267    }
22268    /// Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
22269    ///
22270    /// Sets the *order by* query property to the given value.
22271    pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
22272        self._order_by = Some(new_value.to_string());
22273        self
22274    }
22275    /// Optional. Only include resources that match the filter in the response. For more information, see [Sorting and filtering list results](https://cloud.google.com/kms/docs/sorting-and-filtering).
22276    ///
22277    /// Sets the *filter* query property to the given value.
22278    pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
22279        self._filter = Some(new_value.to_string());
22280        self
22281    }
22282    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22283    /// while executing the actual API request.
22284    ///
22285    /// ````text
22286    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22287    /// ````
22288    ///
22289    /// Sets the *delegate* property to the given value.
22290    pub fn delegate(
22291        mut self,
22292        new_value: &'a mut dyn common::Delegate,
22293    ) -> ProjectLocationKeyRingListCall<'a, C> {
22294        self._delegate = Some(new_value);
22295        self
22296    }
22297
22298    /// Set any additional parameter of the query string used in the request.
22299    /// It should be used to set parameters which are not yet available through their own
22300    /// setters.
22301    ///
22302    /// Please note that this method must not be used to set any of the known parameters
22303    /// which have their own setter method. If done anyway, the request will fail.
22304    ///
22305    /// # Additional Parameters
22306    ///
22307    /// * *$.xgafv* (query-string) - V1 error format.
22308    /// * *access_token* (query-string) - OAuth access token.
22309    /// * *alt* (query-string) - Data format for response.
22310    /// * *callback* (query-string) - JSONP
22311    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22312    /// * *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.
22313    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22314    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22315    /// * *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.
22316    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22317    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22318    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingListCall<'a, C>
22319    where
22320        T: AsRef<str>,
22321    {
22322        self._additional_params
22323            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22324        self
22325    }
22326
22327    /// Identifies the authorization scope for the method you are building.
22328    ///
22329    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22330    /// [`Scope::CloudPlatform`].
22331    ///
22332    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22333    /// tokens for more than one scope.
22334    ///
22335    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22336    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22337    /// sufficient, a read-write scope will do as well.
22338    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingListCall<'a, C>
22339    where
22340        St: AsRef<str>,
22341    {
22342        self._scopes.insert(String::from(scope.as_ref()));
22343        self
22344    }
22345    /// Identifies the authorization scope(s) for the method you are building.
22346    ///
22347    /// See [`Self::add_scope()`] for details.
22348    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingListCall<'a, C>
22349    where
22350        I: IntoIterator<Item = St>,
22351        St: AsRef<str>,
22352    {
22353        self._scopes
22354            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22355        self
22356    }
22357
22358    /// Removes all scopes, and no default scope will be used either.
22359    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22360    /// for details).
22361    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingListCall<'a, C> {
22362        self._scopes.clear();
22363        self
22364    }
22365}
22366
22367/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
22368///
22369/// A builder for the *locations.keyRings.setIamPolicy* method supported by a *project* resource.
22370/// It is not used directly, but through a [`ProjectMethods`] instance.
22371///
22372/// # Example
22373///
22374/// Instantiate a resource method builder
22375///
22376/// ```test_harness,no_run
22377/// # extern crate hyper;
22378/// # extern crate hyper_rustls;
22379/// # extern crate google_cloudkms1 as cloudkms1;
22380/// use cloudkms1::api::SetIamPolicyRequest;
22381/// # async fn dox() {
22382/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22383///
22384/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22385/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22386/// #     .with_native_roots()
22387/// #     .unwrap()
22388/// #     .https_only()
22389/// #     .enable_http2()
22390/// #     .build();
22391///
22392/// # let executor = hyper_util::rt::TokioExecutor::new();
22393/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22394/// #     secret,
22395/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22396/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22397/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22398/// #     ),
22399/// # ).build().await.unwrap();
22400///
22401/// # let client = hyper_util::client::legacy::Client::builder(
22402/// #     hyper_util::rt::TokioExecutor::new()
22403/// # )
22404/// # .build(
22405/// #     hyper_rustls::HttpsConnectorBuilder::new()
22406/// #         .with_native_roots()
22407/// #         .unwrap()
22408/// #         .https_or_http()
22409/// #         .enable_http2()
22410/// #         .build()
22411/// # );
22412/// # let mut hub = CloudKMS::new(client, auth);
22413/// // As the method needs a request, you would usually fill it with the desired information
22414/// // into the respective structure. Some of the parts shown here might not be applicable !
22415/// // Values shown here are possibly random and not representative !
22416/// let mut req = SetIamPolicyRequest::default();
22417///
22418/// // You can configure optional parameters by calling the respective setters at will, and
22419/// // execute the final call using `doit()`.
22420/// // Values shown here are possibly random and not representative !
22421/// let result = hub.projects().locations_key_rings_set_iam_policy(req, "resource")
22422///              .doit().await;
22423/// # }
22424/// ```
22425pub struct ProjectLocationKeyRingSetIamPolicyCall<'a, C>
22426where
22427    C: 'a,
22428{
22429    hub: &'a CloudKMS<C>,
22430    _request: SetIamPolicyRequest,
22431    _resource: String,
22432    _delegate: Option<&'a mut dyn common::Delegate>,
22433    _additional_params: HashMap<String, String>,
22434    _scopes: BTreeSet<String>,
22435}
22436
22437impl<'a, C> common::CallBuilder for ProjectLocationKeyRingSetIamPolicyCall<'a, C> {}
22438
22439impl<'a, C> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
22440where
22441    C: common::Connector,
22442{
22443    /// Perform the operation you have build so far.
22444    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
22445        use std::borrow::Cow;
22446        use std::io::{Read, Seek};
22447
22448        use common::{url::Params, ToParts};
22449        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22450
22451        let mut dd = common::DefaultDelegate;
22452        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22453        dlg.begin(common::MethodInfo {
22454            id: "cloudkms.projects.locations.keyRings.setIamPolicy",
22455            http_method: hyper::Method::POST,
22456        });
22457
22458        for &field in ["alt", "resource"].iter() {
22459            if self._additional_params.contains_key(field) {
22460                dlg.finished(false);
22461                return Err(common::Error::FieldClash(field));
22462            }
22463        }
22464
22465        let mut params = Params::with_capacity(4 + self._additional_params.len());
22466        params.push("resource", self._resource);
22467
22468        params.extend(self._additional_params.iter());
22469
22470        params.push("alt", "json");
22471        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
22472        if self._scopes.is_empty() {
22473            self._scopes
22474                .insert(Scope::CloudPlatform.as_ref().to_string());
22475        }
22476
22477        #[allow(clippy::single_element_loop)]
22478        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
22479            url = params.uri_replacement(url, param_name, find_this, true);
22480        }
22481        {
22482            let to_remove = ["resource"];
22483            params.remove_params(&to_remove);
22484        }
22485
22486        let url = params.parse_with_url(&url);
22487
22488        let mut json_mime_type = mime::APPLICATION_JSON;
22489        let mut request_value_reader = {
22490            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22491            common::remove_json_null_values(&mut value);
22492            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22493            serde_json::to_writer(&mut dst, &value).unwrap();
22494            dst
22495        };
22496        let request_size = request_value_reader
22497            .seek(std::io::SeekFrom::End(0))
22498            .unwrap();
22499        request_value_reader
22500            .seek(std::io::SeekFrom::Start(0))
22501            .unwrap();
22502
22503        loop {
22504            let token = match self
22505                .hub
22506                .auth
22507                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22508                .await
22509            {
22510                Ok(token) => token,
22511                Err(e) => match dlg.token(e) {
22512                    Ok(token) => token,
22513                    Err(e) => {
22514                        dlg.finished(false);
22515                        return Err(common::Error::MissingToken(e));
22516                    }
22517                },
22518            };
22519            request_value_reader
22520                .seek(std::io::SeekFrom::Start(0))
22521                .unwrap();
22522            let mut req_result = {
22523                let client = &self.hub.client;
22524                dlg.pre_request();
22525                let mut req_builder = hyper::Request::builder()
22526                    .method(hyper::Method::POST)
22527                    .uri(url.as_str())
22528                    .header(USER_AGENT, self.hub._user_agent.clone());
22529
22530                if let Some(token) = token.as_ref() {
22531                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22532                }
22533
22534                let request = req_builder
22535                    .header(CONTENT_TYPE, json_mime_type.to_string())
22536                    .header(CONTENT_LENGTH, request_size as u64)
22537                    .body(common::to_body(
22538                        request_value_reader.get_ref().clone().into(),
22539                    ));
22540
22541                client.request(request.unwrap()).await
22542            };
22543
22544            match req_result {
22545                Err(err) => {
22546                    if let common::Retry::After(d) = dlg.http_error(&err) {
22547                        sleep(d).await;
22548                        continue;
22549                    }
22550                    dlg.finished(false);
22551                    return Err(common::Error::HttpError(err));
22552                }
22553                Ok(res) => {
22554                    let (mut parts, body) = res.into_parts();
22555                    let mut body = common::Body::new(body);
22556                    if !parts.status.is_success() {
22557                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22558                        let error = serde_json::from_str(&common::to_string(&bytes));
22559                        let response = common::to_response(parts, bytes.into());
22560
22561                        if let common::Retry::After(d) =
22562                            dlg.http_failure(&response, error.as_ref().ok())
22563                        {
22564                            sleep(d).await;
22565                            continue;
22566                        }
22567
22568                        dlg.finished(false);
22569
22570                        return Err(match error {
22571                            Ok(value) => common::Error::BadRequest(value),
22572                            _ => common::Error::Failure(response),
22573                        });
22574                    }
22575                    let response = {
22576                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22577                        let encoded = common::to_string(&bytes);
22578                        match serde_json::from_str(&encoded) {
22579                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22580                            Err(error) => {
22581                                dlg.response_json_decode_error(&encoded, &error);
22582                                return Err(common::Error::JsonDecodeError(
22583                                    encoded.to_string(),
22584                                    error,
22585                                ));
22586                            }
22587                        }
22588                    };
22589
22590                    dlg.finished(true);
22591                    return Ok(response);
22592                }
22593            }
22594        }
22595    }
22596
22597    ///
22598    /// Sets the *request* property to the given value.
22599    ///
22600    /// Even though the property as already been set when instantiating this call,
22601    /// we provide this method for API completeness.
22602    pub fn request(
22603        mut self,
22604        new_value: SetIamPolicyRequest,
22605    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
22606        self._request = new_value;
22607        self
22608    }
22609    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
22610    ///
22611    /// Sets the *resource* path property to the given value.
22612    ///
22613    /// Even though the property as already been set when instantiating this call,
22614    /// we provide this method for API completeness.
22615    pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
22616        self._resource = new_value.to_string();
22617        self
22618    }
22619    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22620    /// while executing the actual API request.
22621    ///
22622    /// ````text
22623    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22624    /// ````
22625    ///
22626    /// Sets the *delegate* property to the given value.
22627    pub fn delegate(
22628        mut self,
22629        new_value: &'a mut dyn common::Delegate,
22630    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
22631        self._delegate = Some(new_value);
22632        self
22633    }
22634
22635    /// Set any additional parameter of the query string used in the request.
22636    /// It should be used to set parameters which are not yet available through their own
22637    /// setters.
22638    ///
22639    /// Please note that this method must not be used to set any of the known parameters
22640    /// which have their own setter method. If done anyway, the request will fail.
22641    ///
22642    /// # Additional Parameters
22643    ///
22644    /// * *$.xgafv* (query-string) - V1 error format.
22645    /// * *access_token* (query-string) - OAuth access token.
22646    /// * *alt* (query-string) - Data format for response.
22647    /// * *callback* (query-string) - JSONP
22648    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22649    /// * *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.
22650    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22651    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22652    /// * *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.
22653    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22654    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22655    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
22656    where
22657        T: AsRef<str>,
22658    {
22659        self._additional_params
22660            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22661        self
22662    }
22663
22664    /// Identifies the authorization scope for the method you are building.
22665    ///
22666    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22667    /// [`Scope::CloudPlatform`].
22668    ///
22669    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22670    /// tokens for more than one scope.
22671    ///
22672    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22673    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22674    /// sufficient, a read-write scope will do as well.
22675    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
22676    where
22677        St: AsRef<str>,
22678    {
22679        self._scopes.insert(String::from(scope.as_ref()));
22680        self
22681    }
22682    /// Identifies the authorization scope(s) for the method you are building.
22683    ///
22684    /// See [`Self::add_scope()`] for details.
22685    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
22686    where
22687        I: IntoIterator<Item = St>,
22688        St: AsRef<str>,
22689    {
22690        self._scopes
22691            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22692        self
22693    }
22694
22695    /// Removes all scopes, and no default scope will be used either.
22696    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22697    /// for details).
22698    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
22699        self._scopes.clear();
22700        self
22701    }
22702}
22703
22704/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
22705///
22706/// A builder for the *locations.keyRings.testIamPermissions* method supported by a *project* resource.
22707/// It is not used directly, but through a [`ProjectMethods`] instance.
22708///
22709/// # Example
22710///
22711/// Instantiate a resource method builder
22712///
22713/// ```test_harness,no_run
22714/// # extern crate hyper;
22715/// # extern crate hyper_rustls;
22716/// # extern crate google_cloudkms1 as cloudkms1;
22717/// use cloudkms1::api::TestIamPermissionsRequest;
22718/// # async fn dox() {
22719/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22720///
22721/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22722/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22723/// #     .with_native_roots()
22724/// #     .unwrap()
22725/// #     .https_only()
22726/// #     .enable_http2()
22727/// #     .build();
22728///
22729/// # let executor = hyper_util::rt::TokioExecutor::new();
22730/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22731/// #     secret,
22732/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22733/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22734/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22735/// #     ),
22736/// # ).build().await.unwrap();
22737///
22738/// # let client = hyper_util::client::legacy::Client::builder(
22739/// #     hyper_util::rt::TokioExecutor::new()
22740/// # )
22741/// # .build(
22742/// #     hyper_rustls::HttpsConnectorBuilder::new()
22743/// #         .with_native_roots()
22744/// #         .unwrap()
22745/// #         .https_or_http()
22746/// #         .enable_http2()
22747/// #         .build()
22748/// # );
22749/// # let mut hub = CloudKMS::new(client, auth);
22750/// // As the method needs a request, you would usually fill it with the desired information
22751/// // into the respective structure. Some of the parts shown here might not be applicable !
22752/// // Values shown here are possibly random and not representative !
22753/// let mut req = TestIamPermissionsRequest::default();
22754///
22755/// // You can configure optional parameters by calling the respective setters at will, and
22756/// // execute the final call using `doit()`.
22757/// // Values shown here are possibly random and not representative !
22758/// let result = hub.projects().locations_key_rings_test_iam_permissions(req, "resource")
22759///              .doit().await;
22760/// # }
22761/// ```
22762pub struct ProjectLocationKeyRingTestIamPermissionCall<'a, C>
22763where
22764    C: 'a,
22765{
22766    hub: &'a CloudKMS<C>,
22767    _request: TestIamPermissionsRequest,
22768    _resource: String,
22769    _delegate: Option<&'a mut dyn common::Delegate>,
22770    _additional_params: HashMap<String, String>,
22771    _scopes: BTreeSet<String>,
22772}
22773
22774impl<'a, C> common::CallBuilder for ProjectLocationKeyRingTestIamPermissionCall<'a, C> {}
22775
22776impl<'a, C> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
22777where
22778    C: common::Connector,
22779{
22780    /// Perform the operation you have build so far.
22781    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
22782        use std::borrow::Cow;
22783        use std::io::{Read, Seek};
22784
22785        use common::{url::Params, ToParts};
22786        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22787
22788        let mut dd = common::DefaultDelegate;
22789        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22790        dlg.begin(common::MethodInfo {
22791            id: "cloudkms.projects.locations.keyRings.testIamPermissions",
22792            http_method: hyper::Method::POST,
22793        });
22794
22795        for &field in ["alt", "resource"].iter() {
22796            if self._additional_params.contains_key(field) {
22797                dlg.finished(false);
22798                return Err(common::Error::FieldClash(field));
22799            }
22800        }
22801
22802        let mut params = Params::with_capacity(4 + self._additional_params.len());
22803        params.push("resource", self._resource);
22804
22805        params.extend(self._additional_params.iter());
22806
22807        params.push("alt", "json");
22808        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
22809        if self._scopes.is_empty() {
22810            self._scopes
22811                .insert(Scope::CloudPlatform.as_ref().to_string());
22812        }
22813
22814        #[allow(clippy::single_element_loop)]
22815        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
22816            url = params.uri_replacement(url, param_name, find_this, true);
22817        }
22818        {
22819            let to_remove = ["resource"];
22820            params.remove_params(&to_remove);
22821        }
22822
22823        let url = params.parse_with_url(&url);
22824
22825        let mut json_mime_type = mime::APPLICATION_JSON;
22826        let mut request_value_reader = {
22827            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22828            common::remove_json_null_values(&mut value);
22829            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22830            serde_json::to_writer(&mut dst, &value).unwrap();
22831            dst
22832        };
22833        let request_size = request_value_reader
22834            .seek(std::io::SeekFrom::End(0))
22835            .unwrap();
22836        request_value_reader
22837            .seek(std::io::SeekFrom::Start(0))
22838            .unwrap();
22839
22840        loop {
22841            let token = match self
22842                .hub
22843                .auth
22844                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22845                .await
22846            {
22847                Ok(token) => token,
22848                Err(e) => match dlg.token(e) {
22849                    Ok(token) => token,
22850                    Err(e) => {
22851                        dlg.finished(false);
22852                        return Err(common::Error::MissingToken(e));
22853                    }
22854                },
22855            };
22856            request_value_reader
22857                .seek(std::io::SeekFrom::Start(0))
22858                .unwrap();
22859            let mut req_result = {
22860                let client = &self.hub.client;
22861                dlg.pre_request();
22862                let mut req_builder = hyper::Request::builder()
22863                    .method(hyper::Method::POST)
22864                    .uri(url.as_str())
22865                    .header(USER_AGENT, self.hub._user_agent.clone());
22866
22867                if let Some(token) = token.as_ref() {
22868                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22869                }
22870
22871                let request = req_builder
22872                    .header(CONTENT_TYPE, json_mime_type.to_string())
22873                    .header(CONTENT_LENGTH, request_size as u64)
22874                    .body(common::to_body(
22875                        request_value_reader.get_ref().clone().into(),
22876                    ));
22877
22878                client.request(request.unwrap()).await
22879            };
22880
22881            match req_result {
22882                Err(err) => {
22883                    if let common::Retry::After(d) = dlg.http_error(&err) {
22884                        sleep(d).await;
22885                        continue;
22886                    }
22887                    dlg.finished(false);
22888                    return Err(common::Error::HttpError(err));
22889                }
22890                Ok(res) => {
22891                    let (mut parts, body) = res.into_parts();
22892                    let mut body = common::Body::new(body);
22893                    if !parts.status.is_success() {
22894                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22895                        let error = serde_json::from_str(&common::to_string(&bytes));
22896                        let response = common::to_response(parts, bytes.into());
22897
22898                        if let common::Retry::After(d) =
22899                            dlg.http_failure(&response, error.as_ref().ok())
22900                        {
22901                            sleep(d).await;
22902                            continue;
22903                        }
22904
22905                        dlg.finished(false);
22906
22907                        return Err(match error {
22908                            Ok(value) => common::Error::BadRequest(value),
22909                            _ => common::Error::Failure(response),
22910                        });
22911                    }
22912                    let response = {
22913                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22914                        let encoded = common::to_string(&bytes);
22915                        match serde_json::from_str(&encoded) {
22916                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22917                            Err(error) => {
22918                                dlg.response_json_decode_error(&encoded, &error);
22919                                return Err(common::Error::JsonDecodeError(
22920                                    encoded.to_string(),
22921                                    error,
22922                                ));
22923                            }
22924                        }
22925                    };
22926
22927                    dlg.finished(true);
22928                    return Ok(response);
22929                }
22930            }
22931        }
22932    }
22933
22934    ///
22935    /// Sets the *request* property to the given value.
22936    ///
22937    /// Even though the property as already been set when instantiating this call,
22938    /// we provide this method for API completeness.
22939    pub fn request(
22940        mut self,
22941        new_value: TestIamPermissionsRequest,
22942    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
22943        self._request = new_value;
22944        self
22945    }
22946    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
22947    ///
22948    /// Sets the *resource* path property to the given value.
22949    ///
22950    /// Even though the property as already been set when instantiating this call,
22951    /// we provide this method for API completeness.
22952    pub fn resource(
22953        mut self,
22954        new_value: &str,
22955    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
22956        self._resource = new_value.to_string();
22957        self
22958    }
22959    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22960    /// while executing the actual API request.
22961    ///
22962    /// ````text
22963    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22964    /// ````
22965    ///
22966    /// Sets the *delegate* property to the given value.
22967    pub fn delegate(
22968        mut self,
22969        new_value: &'a mut dyn common::Delegate,
22970    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
22971        self._delegate = Some(new_value);
22972        self
22973    }
22974
22975    /// Set any additional parameter of the query string used in the request.
22976    /// It should be used to set parameters which are not yet available through their own
22977    /// setters.
22978    ///
22979    /// Please note that this method must not be used to set any of the known parameters
22980    /// which have their own setter method. If done anyway, the request will fail.
22981    ///
22982    /// # Additional Parameters
22983    ///
22984    /// * *$.xgafv* (query-string) - V1 error format.
22985    /// * *access_token* (query-string) - OAuth access token.
22986    /// * *alt* (query-string) - Data format for response.
22987    /// * *callback* (query-string) - JSONP
22988    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22989    /// * *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.
22990    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22991    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22992    /// * *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.
22993    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22994    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22995    pub fn param<T>(
22996        mut self,
22997        name: T,
22998        value: T,
22999    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
23000    where
23001        T: AsRef<str>,
23002    {
23003        self._additional_params
23004            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23005        self
23006    }
23007
23008    /// Identifies the authorization scope for the method you are building.
23009    ///
23010    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23011    /// [`Scope::CloudPlatform`].
23012    ///
23013    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23014    /// tokens for more than one scope.
23015    ///
23016    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23017    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23018    /// sufficient, a read-write scope will do as well.
23019    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
23020    where
23021        St: AsRef<str>,
23022    {
23023        self._scopes.insert(String::from(scope.as_ref()));
23024        self
23025    }
23026    /// Identifies the authorization scope(s) for the method you are building.
23027    ///
23028    /// See [`Self::add_scope()`] for details.
23029    pub fn add_scopes<I, St>(
23030        mut self,
23031        scopes: I,
23032    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
23033    where
23034        I: IntoIterator<Item = St>,
23035        St: AsRef<str>,
23036    {
23037        self._scopes
23038            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23039        self
23040    }
23041
23042    /// Removes all scopes, and no default scope will be used either.
23043    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23044    /// for details).
23045    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
23046        self._scopes.clear();
23047        self
23048    }
23049}
23050
23051/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
23052///
23053/// A builder for the *locations.operations.get* method supported by a *project* resource.
23054/// It is not used directly, but through a [`ProjectMethods`] instance.
23055///
23056/// # Example
23057///
23058/// Instantiate a resource method builder
23059///
23060/// ```test_harness,no_run
23061/// # extern crate hyper;
23062/// # extern crate hyper_rustls;
23063/// # extern crate google_cloudkms1 as cloudkms1;
23064/// # async fn dox() {
23065/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23066///
23067/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23068/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23069/// #     .with_native_roots()
23070/// #     .unwrap()
23071/// #     .https_only()
23072/// #     .enable_http2()
23073/// #     .build();
23074///
23075/// # let executor = hyper_util::rt::TokioExecutor::new();
23076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23077/// #     secret,
23078/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23079/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23080/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23081/// #     ),
23082/// # ).build().await.unwrap();
23083///
23084/// # let client = hyper_util::client::legacy::Client::builder(
23085/// #     hyper_util::rt::TokioExecutor::new()
23086/// # )
23087/// # .build(
23088/// #     hyper_rustls::HttpsConnectorBuilder::new()
23089/// #         .with_native_roots()
23090/// #         .unwrap()
23091/// #         .https_or_http()
23092/// #         .enable_http2()
23093/// #         .build()
23094/// # );
23095/// # let mut hub = CloudKMS::new(client, auth);
23096/// // You can configure optional parameters by calling the respective setters at will, and
23097/// // execute the final call using `doit()`.
23098/// // Values shown here are possibly random and not representative !
23099/// let result = hub.projects().locations_operations_get("name")
23100///              .doit().await;
23101/// # }
23102/// ```
23103pub struct ProjectLocationOperationGetCall<'a, C>
23104where
23105    C: 'a,
23106{
23107    hub: &'a CloudKMS<C>,
23108    _name: String,
23109    _delegate: Option<&'a mut dyn common::Delegate>,
23110    _additional_params: HashMap<String, String>,
23111    _scopes: BTreeSet<String>,
23112}
23113
23114impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
23115
23116impl<'a, C> ProjectLocationOperationGetCall<'a, C>
23117where
23118    C: common::Connector,
23119{
23120    /// Perform the operation you have build so far.
23121    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23122        use std::borrow::Cow;
23123        use std::io::{Read, Seek};
23124
23125        use common::{url::Params, ToParts};
23126        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23127
23128        let mut dd = common::DefaultDelegate;
23129        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23130        dlg.begin(common::MethodInfo {
23131            id: "cloudkms.projects.locations.operations.get",
23132            http_method: hyper::Method::GET,
23133        });
23134
23135        for &field in ["alt", "name"].iter() {
23136            if self._additional_params.contains_key(field) {
23137                dlg.finished(false);
23138                return Err(common::Error::FieldClash(field));
23139            }
23140        }
23141
23142        let mut params = Params::with_capacity(3 + self._additional_params.len());
23143        params.push("name", self._name);
23144
23145        params.extend(self._additional_params.iter());
23146
23147        params.push("alt", "json");
23148        let mut url = self.hub._base_url.clone() + "v1/{+name}";
23149        if self._scopes.is_empty() {
23150            self._scopes
23151                .insert(Scope::CloudPlatform.as_ref().to_string());
23152        }
23153
23154        #[allow(clippy::single_element_loop)]
23155        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23156            url = params.uri_replacement(url, param_name, find_this, true);
23157        }
23158        {
23159            let to_remove = ["name"];
23160            params.remove_params(&to_remove);
23161        }
23162
23163        let url = params.parse_with_url(&url);
23164
23165        loop {
23166            let token = match self
23167                .hub
23168                .auth
23169                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23170                .await
23171            {
23172                Ok(token) => token,
23173                Err(e) => match dlg.token(e) {
23174                    Ok(token) => token,
23175                    Err(e) => {
23176                        dlg.finished(false);
23177                        return Err(common::Error::MissingToken(e));
23178                    }
23179                },
23180            };
23181            let mut req_result = {
23182                let client = &self.hub.client;
23183                dlg.pre_request();
23184                let mut req_builder = hyper::Request::builder()
23185                    .method(hyper::Method::GET)
23186                    .uri(url.as_str())
23187                    .header(USER_AGENT, self.hub._user_agent.clone());
23188
23189                if let Some(token) = token.as_ref() {
23190                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23191                }
23192
23193                let request = req_builder
23194                    .header(CONTENT_LENGTH, 0_u64)
23195                    .body(common::to_body::<String>(None));
23196
23197                client.request(request.unwrap()).await
23198            };
23199
23200            match req_result {
23201                Err(err) => {
23202                    if let common::Retry::After(d) = dlg.http_error(&err) {
23203                        sleep(d).await;
23204                        continue;
23205                    }
23206                    dlg.finished(false);
23207                    return Err(common::Error::HttpError(err));
23208                }
23209                Ok(res) => {
23210                    let (mut parts, body) = res.into_parts();
23211                    let mut body = common::Body::new(body);
23212                    if !parts.status.is_success() {
23213                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23214                        let error = serde_json::from_str(&common::to_string(&bytes));
23215                        let response = common::to_response(parts, bytes.into());
23216
23217                        if let common::Retry::After(d) =
23218                            dlg.http_failure(&response, error.as_ref().ok())
23219                        {
23220                            sleep(d).await;
23221                            continue;
23222                        }
23223
23224                        dlg.finished(false);
23225
23226                        return Err(match error {
23227                            Ok(value) => common::Error::BadRequest(value),
23228                            _ => common::Error::Failure(response),
23229                        });
23230                    }
23231                    let response = {
23232                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23233                        let encoded = common::to_string(&bytes);
23234                        match serde_json::from_str(&encoded) {
23235                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23236                            Err(error) => {
23237                                dlg.response_json_decode_error(&encoded, &error);
23238                                return Err(common::Error::JsonDecodeError(
23239                                    encoded.to_string(),
23240                                    error,
23241                                ));
23242                            }
23243                        }
23244                    };
23245
23246                    dlg.finished(true);
23247                    return Ok(response);
23248                }
23249            }
23250        }
23251    }
23252
23253    /// The name of the operation resource.
23254    ///
23255    /// Sets the *name* path property to the given value.
23256    ///
23257    /// Even though the property as already been set when instantiating this call,
23258    /// we provide this method for API completeness.
23259    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
23260        self._name = new_value.to_string();
23261        self
23262    }
23263    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23264    /// while executing the actual API request.
23265    ///
23266    /// ````text
23267    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23268    /// ````
23269    ///
23270    /// Sets the *delegate* property to the given value.
23271    pub fn delegate(
23272        mut self,
23273        new_value: &'a mut dyn common::Delegate,
23274    ) -> ProjectLocationOperationGetCall<'a, C> {
23275        self._delegate = Some(new_value);
23276        self
23277    }
23278
23279    /// Set any additional parameter of the query string used in the request.
23280    /// It should be used to set parameters which are not yet available through their own
23281    /// setters.
23282    ///
23283    /// Please note that this method must not be used to set any of the known parameters
23284    /// which have their own setter method. If done anyway, the request will fail.
23285    ///
23286    /// # Additional Parameters
23287    ///
23288    /// * *$.xgafv* (query-string) - V1 error format.
23289    /// * *access_token* (query-string) - OAuth access token.
23290    /// * *alt* (query-string) - Data format for response.
23291    /// * *callback* (query-string) - JSONP
23292    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23293    /// * *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.
23294    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23295    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23296    /// * *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.
23297    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23298    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23299    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
23300    where
23301        T: AsRef<str>,
23302    {
23303        self._additional_params
23304            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23305        self
23306    }
23307
23308    /// Identifies the authorization scope for the method you are building.
23309    ///
23310    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23311    /// [`Scope::CloudPlatform`].
23312    ///
23313    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23314    /// tokens for more than one scope.
23315    ///
23316    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23317    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23318    /// sufficient, a read-write scope will do as well.
23319    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
23320    where
23321        St: AsRef<str>,
23322    {
23323        self._scopes.insert(String::from(scope.as_ref()));
23324        self
23325    }
23326    /// Identifies the authorization scope(s) for the method you are building.
23327    ///
23328    /// See [`Self::add_scope()`] for details.
23329    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
23330    where
23331        I: IntoIterator<Item = St>,
23332        St: AsRef<str>,
23333    {
23334        self._scopes
23335            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23336        self
23337    }
23338
23339    /// Removes all scopes, and no default scope will be used either.
23340    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23341    /// for details).
23342    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
23343        self._scopes.clear();
23344        self
23345    }
23346}
23347
23348/// Generate random bytes using the Cloud KMS randomness source in the provided location.
23349///
23350/// A builder for the *locations.generateRandomBytes* method supported by a *project* resource.
23351/// It is not used directly, but through a [`ProjectMethods`] instance.
23352///
23353/// # Example
23354///
23355/// Instantiate a resource method builder
23356///
23357/// ```test_harness,no_run
23358/// # extern crate hyper;
23359/// # extern crate hyper_rustls;
23360/// # extern crate google_cloudkms1 as cloudkms1;
23361/// use cloudkms1::api::GenerateRandomBytesRequest;
23362/// # async fn dox() {
23363/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23364///
23365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23366/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23367/// #     .with_native_roots()
23368/// #     .unwrap()
23369/// #     .https_only()
23370/// #     .enable_http2()
23371/// #     .build();
23372///
23373/// # let executor = hyper_util::rt::TokioExecutor::new();
23374/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23375/// #     secret,
23376/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23377/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23378/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23379/// #     ),
23380/// # ).build().await.unwrap();
23381///
23382/// # let client = hyper_util::client::legacy::Client::builder(
23383/// #     hyper_util::rt::TokioExecutor::new()
23384/// # )
23385/// # .build(
23386/// #     hyper_rustls::HttpsConnectorBuilder::new()
23387/// #         .with_native_roots()
23388/// #         .unwrap()
23389/// #         .https_or_http()
23390/// #         .enable_http2()
23391/// #         .build()
23392/// # );
23393/// # let mut hub = CloudKMS::new(client, auth);
23394/// // As the method needs a request, you would usually fill it with the desired information
23395/// // into the respective structure. Some of the parts shown here might not be applicable !
23396/// // Values shown here are possibly random and not representative !
23397/// let mut req = GenerateRandomBytesRequest::default();
23398///
23399/// // You can configure optional parameters by calling the respective setters at will, and
23400/// // execute the final call using `doit()`.
23401/// // Values shown here are possibly random and not representative !
23402/// let result = hub.projects().locations_generate_random_bytes(req, "location")
23403///              .doit().await;
23404/// # }
23405/// ```
23406pub struct ProjectLocationGenerateRandomByteCall<'a, C>
23407where
23408    C: 'a,
23409{
23410    hub: &'a CloudKMS<C>,
23411    _request: GenerateRandomBytesRequest,
23412    _location: String,
23413    _delegate: Option<&'a mut dyn common::Delegate>,
23414    _additional_params: HashMap<String, String>,
23415    _scopes: BTreeSet<String>,
23416}
23417
23418impl<'a, C> common::CallBuilder for ProjectLocationGenerateRandomByteCall<'a, C> {}
23419
23420impl<'a, C> ProjectLocationGenerateRandomByteCall<'a, C>
23421where
23422    C: common::Connector,
23423{
23424    /// Perform the operation you have build so far.
23425    pub async fn doit(mut self) -> common::Result<(common::Response, GenerateRandomBytesResponse)> {
23426        use std::borrow::Cow;
23427        use std::io::{Read, Seek};
23428
23429        use common::{url::Params, ToParts};
23430        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23431
23432        let mut dd = common::DefaultDelegate;
23433        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23434        dlg.begin(common::MethodInfo {
23435            id: "cloudkms.projects.locations.generateRandomBytes",
23436            http_method: hyper::Method::POST,
23437        });
23438
23439        for &field in ["alt", "location"].iter() {
23440            if self._additional_params.contains_key(field) {
23441                dlg.finished(false);
23442                return Err(common::Error::FieldClash(field));
23443            }
23444        }
23445
23446        let mut params = Params::with_capacity(4 + self._additional_params.len());
23447        params.push("location", self._location);
23448
23449        params.extend(self._additional_params.iter());
23450
23451        params.push("alt", "json");
23452        let mut url = self.hub._base_url.clone() + "v1/{+location}:generateRandomBytes";
23453        if self._scopes.is_empty() {
23454            self._scopes
23455                .insert(Scope::CloudPlatform.as_ref().to_string());
23456        }
23457
23458        #[allow(clippy::single_element_loop)]
23459        for &(find_this, param_name) in [("{+location}", "location")].iter() {
23460            url = params.uri_replacement(url, param_name, find_this, true);
23461        }
23462        {
23463            let to_remove = ["location"];
23464            params.remove_params(&to_remove);
23465        }
23466
23467        let url = params.parse_with_url(&url);
23468
23469        let mut json_mime_type = mime::APPLICATION_JSON;
23470        let mut request_value_reader = {
23471            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23472            common::remove_json_null_values(&mut value);
23473            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23474            serde_json::to_writer(&mut dst, &value).unwrap();
23475            dst
23476        };
23477        let request_size = request_value_reader
23478            .seek(std::io::SeekFrom::End(0))
23479            .unwrap();
23480        request_value_reader
23481            .seek(std::io::SeekFrom::Start(0))
23482            .unwrap();
23483
23484        loop {
23485            let token = match self
23486                .hub
23487                .auth
23488                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23489                .await
23490            {
23491                Ok(token) => token,
23492                Err(e) => match dlg.token(e) {
23493                    Ok(token) => token,
23494                    Err(e) => {
23495                        dlg.finished(false);
23496                        return Err(common::Error::MissingToken(e));
23497                    }
23498                },
23499            };
23500            request_value_reader
23501                .seek(std::io::SeekFrom::Start(0))
23502                .unwrap();
23503            let mut req_result = {
23504                let client = &self.hub.client;
23505                dlg.pre_request();
23506                let mut req_builder = hyper::Request::builder()
23507                    .method(hyper::Method::POST)
23508                    .uri(url.as_str())
23509                    .header(USER_AGENT, self.hub._user_agent.clone());
23510
23511                if let Some(token) = token.as_ref() {
23512                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23513                }
23514
23515                let request = req_builder
23516                    .header(CONTENT_TYPE, json_mime_type.to_string())
23517                    .header(CONTENT_LENGTH, request_size as u64)
23518                    .body(common::to_body(
23519                        request_value_reader.get_ref().clone().into(),
23520                    ));
23521
23522                client.request(request.unwrap()).await
23523            };
23524
23525            match req_result {
23526                Err(err) => {
23527                    if let common::Retry::After(d) = dlg.http_error(&err) {
23528                        sleep(d).await;
23529                        continue;
23530                    }
23531                    dlg.finished(false);
23532                    return Err(common::Error::HttpError(err));
23533                }
23534                Ok(res) => {
23535                    let (mut parts, body) = res.into_parts();
23536                    let mut body = common::Body::new(body);
23537                    if !parts.status.is_success() {
23538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23539                        let error = serde_json::from_str(&common::to_string(&bytes));
23540                        let response = common::to_response(parts, bytes.into());
23541
23542                        if let common::Retry::After(d) =
23543                            dlg.http_failure(&response, error.as_ref().ok())
23544                        {
23545                            sleep(d).await;
23546                            continue;
23547                        }
23548
23549                        dlg.finished(false);
23550
23551                        return Err(match error {
23552                            Ok(value) => common::Error::BadRequest(value),
23553                            _ => common::Error::Failure(response),
23554                        });
23555                    }
23556                    let response = {
23557                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23558                        let encoded = common::to_string(&bytes);
23559                        match serde_json::from_str(&encoded) {
23560                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23561                            Err(error) => {
23562                                dlg.response_json_decode_error(&encoded, &error);
23563                                return Err(common::Error::JsonDecodeError(
23564                                    encoded.to_string(),
23565                                    error,
23566                                ));
23567                            }
23568                        }
23569                    };
23570
23571                    dlg.finished(true);
23572                    return Ok(response);
23573                }
23574            }
23575        }
23576    }
23577
23578    ///
23579    /// Sets the *request* property to the given value.
23580    ///
23581    /// Even though the property as already been set when instantiating this call,
23582    /// we provide this method for API completeness.
23583    pub fn request(
23584        mut self,
23585        new_value: GenerateRandomBytesRequest,
23586    ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
23587        self._request = new_value;
23588        self
23589    }
23590    /// The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".
23591    ///
23592    /// Sets the *location* path property to the given value.
23593    ///
23594    /// Even though the property as already been set when instantiating this call,
23595    /// we provide this method for API completeness.
23596    pub fn location(mut self, new_value: &str) -> ProjectLocationGenerateRandomByteCall<'a, C> {
23597        self._location = new_value.to_string();
23598        self
23599    }
23600    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23601    /// while executing the actual API request.
23602    ///
23603    /// ````text
23604    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23605    /// ````
23606    ///
23607    /// Sets the *delegate* property to the given value.
23608    pub fn delegate(
23609        mut self,
23610        new_value: &'a mut dyn common::Delegate,
23611    ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
23612        self._delegate = Some(new_value);
23613        self
23614    }
23615
23616    /// Set any additional parameter of the query string used in the request.
23617    /// It should be used to set parameters which are not yet available through their own
23618    /// setters.
23619    ///
23620    /// Please note that this method must not be used to set any of the known parameters
23621    /// which have their own setter method. If done anyway, the request will fail.
23622    ///
23623    /// # Additional Parameters
23624    ///
23625    /// * *$.xgafv* (query-string) - V1 error format.
23626    /// * *access_token* (query-string) - OAuth access token.
23627    /// * *alt* (query-string) - Data format for response.
23628    /// * *callback* (query-string) - JSONP
23629    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23630    /// * *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.
23631    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23632    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23633    /// * *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.
23634    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23635    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23636    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGenerateRandomByteCall<'a, C>
23637    where
23638        T: AsRef<str>,
23639    {
23640        self._additional_params
23641            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23642        self
23643    }
23644
23645    /// Identifies the authorization scope for the method you are building.
23646    ///
23647    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23648    /// [`Scope::CloudPlatform`].
23649    ///
23650    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23651    /// tokens for more than one scope.
23652    ///
23653    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23654    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23655    /// sufficient, a read-write scope will do as well.
23656    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGenerateRandomByteCall<'a, C>
23657    where
23658        St: AsRef<str>,
23659    {
23660        self._scopes.insert(String::from(scope.as_ref()));
23661        self
23662    }
23663    /// Identifies the authorization scope(s) for the method you are building.
23664    ///
23665    /// See [`Self::add_scope()`] for details.
23666    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGenerateRandomByteCall<'a, C>
23667    where
23668        I: IntoIterator<Item = St>,
23669        St: AsRef<str>,
23670    {
23671        self._scopes
23672            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23673        self
23674    }
23675
23676    /// Removes all scopes, and no default scope will be used either.
23677    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23678    /// for details).
23679    pub fn clear_scopes(mut self) -> ProjectLocationGenerateRandomByteCall<'a, C> {
23680        self._scopes.clear();
23681        self
23682    }
23683}
23684
23685/// Gets information about a location.
23686///
23687/// A builder for the *locations.get* method supported by a *project* resource.
23688/// It is not used directly, but through a [`ProjectMethods`] instance.
23689///
23690/// # Example
23691///
23692/// Instantiate a resource method builder
23693///
23694/// ```test_harness,no_run
23695/// # extern crate hyper;
23696/// # extern crate hyper_rustls;
23697/// # extern crate google_cloudkms1 as cloudkms1;
23698/// # async fn dox() {
23699/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23700///
23701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23703/// #     .with_native_roots()
23704/// #     .unwrap()
23705/// #     .https_only()
23706/// #     .enable_http2()
23707/// #     .build();
23708///
23709/// # let executor = hyper_util::rt::TokioExecutor::new();
23710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23711/// #     secret,
23712/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23713/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23714/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23715/// #     ),
23716/// # ).build().await.unwrap();
23717///
23718/// # let client = hyper_util::client::legacy::Client::builder(
23719/// #     hyper_util::rt::TokioExecutor::new()
23720/// # )
23721/// # .build(
23722/// #     hyper_rustls::HttpsConnectorBuilder::new()
23723/// #         .with_native_roots()
23724/// #         .unwrap()
23725/// #         .https_or_http()
23726/// #         .enable_http2()
23727/// #         .build()
23728/// # );
23729/// # let mut hub = CloudKMS::new(client, auth);
23730/// // You can configure optional parameters by calling the respective setters at will, and
23731/// // execute the final call using `doit()`.
23732/// // Values shown here are possibly random and not representative !
23733/// let result = hub.projects().locations_get("name")
23734///              .doit().await;
23735/// # }
23736/// ```
23737pub struct ProjectLocationGetCall<'a, C>
23738where
23739    C: 'a,
23740{
23741    hub: &'a CloudKMS<C>,
23742    _name: String,
23743    _delegate: Option<&'a mut dyn common::Delegate>,
23744    _additional_params: HashMap<String, String>,
23745    _scopes: BTreeSet<String>,
23746}
23747
23748impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
23749
23750impl<'a, C> ProjectLocationGetCall<'a, C>
23751where
23752    C: common::Connector,
23753{
23754    /// Perform the operation you have build so far.
23755    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
23756        use std::borrow::Cow;
23757        use std::io::{Read, Seek};
23758
23759        use common::{url::Params, ToParts};
23760        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23761
23762        let mut dd = common::DefaultDelegate;
23763        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23764        dlg.begin(common::MethodInfo {
23765            id: "cloudkms.projects.locations.get",
23766            http_method: hyper::Method::GET,
23767        });
23768
23769        for &field in ["alt", "name"].iter() {
23770            if self._additional_params.contains_key(field) {
23771                dlg.finished(false);
23772                return Err(common::Error::FieldClash(field));
23773            }
23774        }
23775
23776        let mut params = Params::with_capacity(3 + self._additional_params.len());
23777        params.push("name", self._name);
23778
23779        params.extend(self._additional_params.iter());
23780
23781        params.push("alt", "json");
23782        let mut url = self.hub._base_url.clone() + "v1/{+name}";
23783        if self._scopes.is_empty() {
23784            self._scopes
23785                .insert(Scope::CloudPlatform.as_ref().to_string());
23786        }
23787
23788        #[allow(clippy::single_element_loop)]
23789        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23790            url = params.uri_replacement(url, param_name, find_this, true);
23791        }
23792        {
23793            let to_remove = ["name"];
23794            params.remove_params(&to_remove);
23795        }
23796
23797        let url = params.parse_with_url(&url);
23798
23799        loop {
23800            let token = match self
23801                .hub
23802                .auth
23803                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23804                .await
23805            {
23806                Ok(token) => token,
23807                Err(e) => match dlg.token(e) {
23808                    Ok(token) => token,
23809                    Err(e) => {
23810                        dlg.finished(false);
23811                        return Err(common::Error::MissingToken(e));
23812                    }
23813                },
23814            };
23815            let mut req_result = {
23816                let client = &self.hub.client;
23817                dlg.pre_request();
23818                let mut req_builder = hyper::Request::builder()
23819                    .method(hyper::Method::GET)
23820                    .uri(url.as_str())
23821                    .header(USER_AGENT, self.hub._user_agent.clone());
23822
23823                if let Some(token) = token.as_ref() {
23824                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23825                }
23826
23827                let request = req_builder
23828                    .header(CONTENT_LENGTH, 0_u64)
23829                    .body(common::to_body::<String>(None));
23830
23831                client.request(request.unwrap()).await
23832            };
23833
23834            match req_result {
23835                Err(err) => {
23836                    if let common::Retry::After(d) = dlg.http_error(&err) {
23837                        sleep(d).await;
23838                        continue;
23839                    }
23840                    dlg.finished(false);
23841                    return Err(common::Error::HttpError(err));
23842                }
23843                Ok(res) => {
23844                    let (mut parts, body) = res.into_parts();
23845                    let mut body = common::Body::new(body);
23846                    if !parts.status.is_success() {
23847                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23848                        let error = serde_json::from_str(&common::to_string(&bytes));
23849                        let response = common::to_response(parts, bytes.into());
23850
23851                        if let common::Retry::After(d) =
23852                            dlg.http_failure(&response, error.as_ref().ok())
23853                        {
23854                            sleep(d).await;
23855                            continue;
23856                        }
23857
23858                        dlg.finished(false);
23859
23860                        return Err(match error {
23861                            Ok(value) => common::Error::BadRequest(value),
23862                            _ => common::Error::Failure(response),
23863                        });
23864                    }
23865                    let response = {
23866                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23867                        let encoded = common::to_string(&bytes);
23868                        match serde_json::from_str(&encoded) {
23869                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23870                            Err(error) => {
23871                                dlg.response_json_decode_error(&encoded, &error);
23872                                return Err(common::Error::JsonDecodeError(
23873                                    encoded.to_string(),
23874                                    error,
23875                                ));
23876                            }
23877                        }
23878                    };
23879
23880                    dlg.finished(true);
23881                    return Ok(response);
23882                }
23883            }
23884        }
23885    }
23886
23887    /// Resource name for the location.
23888    ///
23889    /// Sets the *name* path property to the given value.
23890    ///
23891    /// Even though the property as already been set when instantiating this call,
23892    /// we provide this method for API completeness.
23893    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
23894        self._name = new_value.to_string();
23895        self
23896    }
23897    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23898    /// while executing the actual API request.
23899    ///
23900    /// ````text
23901    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23902    /// ````
23903    ///
23904    /// Sets the *delegate* property to the given value.
23905    pub fn delegate(
23906        mut self,
23907        new_value: &'a mut dyn common::Delegate,
23908    ) -> ProjectLocationGetCall<'a, C> {
23909        self._delegate = Some(new_value);
23910        self
23911    }
23912
23913    /// Set any additional parameter of the query string used in the request.
23914    /// It should be used to set parameters which are not yet available through their own
23915    /// setters.
23916    ///
23917    /// Please note that this method must not be used to set any of the known parameters
23918    /// which have their own setter method. If done anyway, the request will fail.
23919    ///
23920    /// # Additional Parameters
23921    ///
23922    /// * *$.xgafv* (query-string) - V1 error format.
23923    /// * *access_token* (query-string) - OAuth access token.
23924    /// * *alt* (query-string) - Data format for response.
23925    /// * *callback* (query-string) - JSONP
23926    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23927    /// * *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.
23928    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23929    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23930    /// * *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.
23931    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23932    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23933    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
23934    where
23935        T: AsRef<str>,
23936    {
23937        self._additional_params
23938            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23939        self
23940    }
23941
23942    /// Identifies the authorization scope for the method you are building.
23943    ///
23944    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23945    /// [`Scope::CloudPlatform`].
23946    ///
23947    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23948    /// tokens for more than one scope.
23949    ///
23950    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23951    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23952    /// sufficient, a read-write scope will do as well.
23953    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
23954    where
23955        St: AsRef<str>,
23956    {
23957        self._scopes.insert(String::from(scope.as_ref()));
23958        self
23959    }
23960    /// Identifies the authorization scope(s) for the method you are building.
23961    ///
23962    /// See [`Self::add_scope()`] for details.
23963    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
23964    where
23965        I: IntoIterator<Item = St>,
23966        St: AsRef<str>,
23967    {
23968        self._scopes
23969            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23970        self
23971    }
23972
23973    /// Removes all scopes, and no default scope will be used either.
23974    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23975    /// for details).
23976    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
23977        self._scopes.clear();
23978        self
23979    }
23980}
23981
23982/// Returns the EkmConfig singleton resource for a given project and location.
23983///
23984/// A builder for the *locations.getEkmConfig* method supported by a *project* resource.
23985/// It is not used directly, but through a [`ProjectMethods`] instance.
23986///
23987/// # Example
23988///
23989/// Instantiate a resource method builder
23990///
23991/// ```test_harness,no_run
23992/// # extern crate hyper;
23993/// # extern crate hyper_rustls;
23994/// # extern crate google_cloudkms1 as cloudkms1;
23995/// # async fn dox() {
23996/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23997///
23998/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23999/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24000/// #     .with_native_roots()
24001/// #     .unwrap()
24002/// #     .https_only()
24003/// #     .enable_http2()
24004/// #     .build();
24005///
24006/// # let executor = hyper_util::rt::TokioExecutor::new();
24007/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24008/// #     secret,
24009/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24010/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24011/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24012/// #     ),
24013/// # ).build().await.unwrap();
24014///
24015/// # let client = hyper_util::client::legacy::Client::builder(
24016/// #     hyper_util::rt::TokioExecutor::new()
24017/// # )
24018/// # .build(
24019/// #     hyper_rustls::HttpsConnectorBuilder::new()
24020/// #         .with_native_roots()
24021/// #         .unwrap()
24022/// #         .https_or_http()
24023/// #         .enable_http2()
24024/// #         .build()
24025/// # );
24026/// # let mut hub = CloudKMS::new(client, auth);
24027/// // You can configure optional parameters by calling the respective setters at will, and
24028/// // execute the final call using `doit()`.
24029/// // Values shown here are possibly random and not representative !
24030/// let result = hub.projects().locations_get_ekm_config("name")
24031///              .doit().await;
24032/// # }
24033/// ```
24034pub struct ProjectLocationGetEkmConfigCall<'a, C>
24035where
24036    C: 'a,
24037{
24038    hub: &'a CloudKMS<C>,
24039    _name: String,
24040    _delegate: Option<&'a mut dyn common::Delegate>,
24041    _additional_params: HashMap<String, String>,
24042    _scopes: BTreeSet<String>,
24043}
24044
24045impl<'a, C> common::CallBuilder for ProjectLocationGetEkmConfigCall<'a, C> {}
24046
24047impl<'a, C> ProjectLocationGetEkmConfigCall<'a, C>
24048where
24049    C: common::Connector,
24050{
24051    /// Perform the operation you have build so far.
24052    pub async fn doit(mut self) -> common::Result<(common::Response, EkmConfig)> {
24053        use std::borrow::Cow;
24054        use std::io::{Read, Seek};
24055
24056        use common::{url::Params, ToParts};
24057        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24058
24059        let mut dd = common::DefaultDelegate;
24060        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24061        dlg.begin(common::MethodInfo {
24062            id: "cloudkms.projects.locations.getEkmConfig",
24063            http_method: hyper::Method::GET,
24064        });
24065
24066        for &field in ["alt", "name"].iter() {
24067            if self._additional_params.contains_key(field) {
24068                dlg.finished(false);
24069                return Err(common::Error::FieldClash(field));
24070            }
24071        }
24072
24073        let mut params = Params::with_capacity(3 + self._additional_params.len());
24074        params.push("name", self._name);
24075
24076        params.extend(self._additional_params.iter());
24077
24078        params.push("alt", "json");
24079        let mut url = self.hub._base_url.clone() + "v1/{+name}";
24080        if self._scopes.is_empty() {
24081            self._scopes
24082                .insert(Scope::CloudPlatform.as_ref().to_string());
24083        }
24084
24085        #[allow(clippy::single_element_loop)]
24086        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24087            url = params.uri_replacement(url, param_name, find_this, true);
24088        }
24089        {
24090            let to_remove = ["name"];
24091            params.remove_params(&to_remove);
24092        }
24093
24094        let url = params.parse_with_url(&url);
24095
24096        loop {
24097            let token = match self
24098                .hub
24099                .auth
24100                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24101                .await
24102            {
24103                Ok(token) => token,
24104                Err(e) => match dlg.token(e) {
24105                    Ok(token) => token,
24106                    Err(e) => {
24107                        dlg.finished(false);
24108                        return Err(common::Error::MissingToken(e));
24109                    }
24110                },
24111            };
24112            let mut req_result = {
24113                let client = &self.hub.client;
24114                dlg.pre_request();
24115                let mut req_builder = hyper::Request::builder()
24116                    .method(hyper::Method::GET)
24117                    .uri(url.as_str())
24118                    .header(USER_AGENT, self.hub._user_agent.clone());
24119
24120                if let Some(token) = token.as_ref() {
24121                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24122                }
24123
24124                let request = req_builder
24125                    .header(CONTENT_LENGTH, 0_u64)
24126                    .body(common::to_body::<String>(None));
24127
24128                client.request(request.unwrap()).await
24129            };
24130
24131            match req_result {
24132                Err(err) => {
24133                    if let common::Retry::After(d) = dlg.http_error(&err) {
24134                        sleep(d).await;
24135                        continue;
24136                    }
24137                    dlg.finished(false);
24138                    return Err(common::Error::HttpError(err));
24139                }
24140                Ok(res) => {
24141                    let (mut parts, body) = res.into_parts();
24142                    let mut body = common::Body::new(body);
24143                    if !parts.status.is_success() {
24144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24145                        let error = serde_json::from_str(&common::to_string(&bytes));
24146                        let response = common::to_response(parts, bytes.into());
24147
24148                        if let common::Retry::After(d) =
24149                            dlg.http_failure(&response, error.as_ref().ok())
24150                        {
24151                            sleep(d).await;
24152                            continue;
24153                        }
24154
24155                        dlg.finished(false);
24156
24157                        return Err(match error {
24158                            Ok(value) => common::Error::BadRequest(value),
24159                            _ => common::Error::Failure(response),
24160                        });
24161                    }
24162                    let response = {
24163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24164                        let encoded = common::to_string(&bytes);
24165                        match serde_json::from_str(&encoded) {
24166                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24167                            Err(error) => {
24168                                dlg.response_json_decode_error(&encoded, &error);
24169                                return Err(common::Error::JsonDecodeError(
24170                                    encoded.to_string(),
24171                                    error,
24172                                ));
24173                            }
24174                        }
24175                    };
24176
24177                    dlg.finished(true);
24178                    return Ok(response);
24179                }
24180            }
24181        }
24182    }
24183
24184    /// Required. The name of the EkmConfig to get.
24185    ///
24186    /// Sets the *name* path property to the given value.
24187    ///
24188    /// Even though the property as already been set when instantiating this call,
24189    /// we provide this method for API completeness.
24190    pub fn name(mut self, new_value: &str) -> ProjectLocationGetEkmConfigCall<'a, C> {
24191        self._name = new_value.to_string();
24192        self
24193    }
24194    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24195    /// while executing the actual API request.
24196    ///
24197    /// ````text
24198    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24199    /// ````
24200    ///
24201    /// Sets the *delegate* property to the given value.
24202    pub fn delegate(
24203        mut self,
24204        new_value: &'a mut dyn common::Delegate,
24205    ) -> ProjectLocationGetEkmConfigCall<'a, C> {
24206        self._delegate = Some(new_value);
24207        self
24208    }
24209
24210    /// Set any additional parameter of the query string used in the request.
24211    /// It should be used to set parameters which are not yet available through their own
24212    /// setters.
24213    ///
24214    /// Please note that this method must not be used to set any of the known parameters
24215    /// which have their own setter method. If done anyway, the request will fail.
24216    ///
24217    /// # Additional Parameters
24218    ///
24219    /// * *$.xgafv* (query-string) - V1 error format.
24220    /// * *access_token* (query-string) - OAuth access token.
24221    /// * *alt* (query-string) - Data format for response.
24222    /// * *callback* (query-string) - JSONP
24223    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24224    /// * *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.
24225    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24226    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24227    /// * *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.
24228    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24229    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24230    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetEkmConfigCall<'a, C>
24231    where
24232        T: AsRef<str>,
24233    {
24234        self._additional_params
24235            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24236        self
24237    }
24238
24239    /// Identifies the authorization scope for the method you are building.
24240    ///
24241    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24242    /// [`Scope::CloudPlatform`].
24243    ///
24244    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24245    /// tokens for more than one scope.
24246    ///
24247    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24248    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24249    /// sufficient, a read-write scope will do as well.
24250    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetEkmConfigCall<'a, C>
24251    where
24252        St: AsRef<str>,
24253    {
24254        self._scopes.insert(String::from(scope.as_ref()));
24255        self
24256    }
24257    /// Identifies the authorization scope(s) for the method you are building.
24258    ///
24259    /// See [`Self::add_scope()`] for details.
24260    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetEkmConfigCall<'a, C>
24261    where
24262        I: IntoIterator<Item = St>,
24263        St: AsRef<str>,
24264    {
24265        self._scopes
24266            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24267        self
24268    }
24269
24270    /// Removes all scopes, and no default scope will be used either.
24271    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24272    /// for details).
24273    pub fn clear_scopes(mut self) -> ProjectLocationGetEkmConfigCall<'a, C> {
24274        self._scopes.clear();
24275        self
24276    }
24277}
24278
24279/// Lists information about the supported locations for this service.
24280///
24281/// A builder for the *locations.list* method supported by a *project* resource.
24282/// It is not used directly, but through a [`ProjectMethods`] instance.
24283///
24284/// # Example
24285///
24286/// Instantiate a resource method builder
24287///
24288/// ```test_harness,no_run
24289/// # extern crate hyper;
24290/// # extern crate hyper_rustls;
24291/// # extern crate google_cloudkms1 as cloudkms1;
24292/// # async fn dox() {
24293/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24294///
24295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24297/// #     .with_native_roots()
24298/// #     .unwrap()
24299/// #     .https_only()
24300/// #     .enable_http2()
24301/// #     .build();
24302///
24303/// # let executor = hyper_util::rt::TokioExecutor::new();
24304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24305/// #     secret,
24306/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24307/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24308/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24309/// #     ),
24310/// # ).build().await.unwrap();
24311///
24312/// # let client = hyper_util::client::legacy::Client::builder(
24313/// #     hyper_util::rt::TokioExecutor::new()
24314/// # )
24315/// # .build(
24316/// #     hyper_rustls::HttpsConnectorBuilder::new()
24317/// #         .with_native_roots()
24318/// #         .unwrap()
24319/// #         .https_or_http()
24320/// #         .enable_http2()
24321/// #         .build()
24322/// # );
24323/// # let mut hub = CloudKMS::new(client, auth);
24324/// // You can configure optional parameters by calling the respective setters at will, and
24325/// // execute the final call using `doit()`.
24326/// // Values shown here are possibly random and not representative !
24327/// let result = hub.projects().locations_list("name")
24328///              .page_token("ipsum")
24329///              .page_size(-18)
24330///              .filter("sanctus")
24331///              .add_extra_location_types("Lorem")
24332///              .doit().await;
24333/// # }
24334/// ```
24335pub struct ProjectLocationListCall<'a, C>
24336where
24337    C: 'a,
24338{
24339    hub: &'a CloudKMS<C>,
24340    _name: String,
24341    _page_token: Option<String>,
24342    _page_size: Option<i32>,
24343    _filter: Option<String>,
24344    _extra_location_types: Vec<String>,
24345    _delegate: Option<&'a mut dyn common::Delegate>,
24346    _additional_params: HashMap<String, String>,
24347    _scopes: BTreeSet<String>,
24348}
24349
24350impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
24351
24352impl<'a, C> ProjectLocationListCall<'a, C>
24353where
24354    C: common::Connector,
24355{
24356    /// Perform the operation you have build so far.
24357    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
24358        use std::borrow::Cow;
24359        use std::io::{Read, Seek};
24360
24361        use common::{url::Params, ToParts};
24362        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24363
24364        let mut dd = common::DefaultDelegate;
24365        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24366        dlg.begin(common::MethodInfo {
24367            id: "cloudkms.projects.locations.list",
24368            http_method: hyper::Method::GET,
24369        });
24370
24371        for &field in [
24372            "alt",
24373            "name",
24374            "pageToken",
24375            "pageSize",
24376            "filter",
24377            "extraLocationTypes",
24378        ]
24379        .iter()
24380        {
24381            if self._additional_params.contains_key(field) {
24382                dlg.finished(false);
24383                return Err(common::Error::FieldClash(field));
24384            }
24385        }
24386
24387        let mut params = Params::with_capacity(7 + self._additional_params.len());
24388        params.push("name", self._name);
24389        if let Some(value) = self._page_token.as_ref() {
24390            params.push("pageToken", value);
24391        }
24392        if let Some(value) = self._page_size.as_ref() {
24393            params.push("pageSize", value.to_string());
24394        }
24395        if let Some(value) = self._filter.as_ref() {
24396            params.push("filter", value);
24397        }
24398        if !self._extra_location_types.is_empty() {
24399            for f in self._extra_location_types.iter() {
24400                params.push("extraLocationTypes", f);
24401            }
24402        }
24403
24404        params.extend(self._additional_params.iter());
24405
24406        params.push("alt", "json");
24407        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
24408        if self._scopes.is_empty() {
24409            self._scopes
24410                .insert(Scope::CloudPlatform.as_ref().to_string());
24411        }
24412
24413        #[allow(clippy::single_element_loop)]
24414        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24415            url = params.uri_replacement(url, param_name, find_this, true);
24416        }
24417        {
24418            let to_remove = ["name"];
24419            params.remove_params(&to_remove);
24420        }
24421
24422        let url = params.parse_with_url(&url);
24423
24424        loop {
24425            let token = match self
24426                .hub
24427                .auth
24428                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24429                .await
24430            {
24431                Ok(token) => token,
24432                Err(e) => match dlg.token(e) {
24433                    Ok(token) => token,
24434                    Err(e) => {
24435                        dlg.finished(false);
24436                        return Err(common::Error::MissingToken(e));
24437                    }
24438                },
24439            };
24440            let mut req_result = {
24441                let client = &self.hub.client;
24442                dlg.pre_request();
24443                let mut req_builder = hyper::Request::builder()
24444                    .method(hyper::Method::GET)
24445                    .uri(url.as_str())
24446                    .header(USER_AGENT, self.hub._user_agent.clone());
24447
24448                if let Some(token) = token.as_ref() {
24449                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24450                }
24451
24452                let request = req_builder
24453                    .header(CONTENT_LENGTH, 0_u64)
24454                    .body(common::to_body::<String>(None));
24455
24456                client.request(request.unwrap()).await
24457            };
24458
24459            match req_result {
24460                Err(err) => {
24461                    if let common::Retry::After(d) = dlg.http_error(&err) {
24462                        sleep(d).await;
24463                        continue;
24464                    }
24465                    dlg.finished(false);
24466                    return Err(common::Error::HttpError(err));
24467                }
24468                Ok(res) => {
24469                    let (mut parts, body) = res.into_parts();
24470                    let mut body = common::Body::new(body);
24471                    if !parts.status.is_success() {
24472                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24473                        let error = serde_json::from_str(&common::to_string(&bytes));
24474                        let response = common::to_response(parts, bytes.into());
24475
24476                        if let common::Retry::After(d) =
24477                            dlg.http_failure(&response, error.as_ref().ok())
24478                        {
24479                            sleep(d).await;
24480                            continue;
24481                        }
24482
24483                        dlg.finished(false);
24484
24485                        return Err(match error {
24486                            Ok(value) => common::Error::BadRequest(value),
24487                            _ => common::Error::Failure(response),
24488                        });
24489                    }
24490                    let response = {
24491                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24492                        let encoded = common::to_string(&bytes);
24493                        match serde_json::from_str(&encoded) {
24494                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24495                            Err(error) => {
24496                                dlg.response_json_decode_error(&encoded, &error);
24497                                return Err(common::Error::JsonDecodeError(
24498                                    encoded.to_string(),
24499                                    error,
24500                                ));
24501                            }
24502                        }
24503                    };
24504
24505                    dlg.finished(true);
24506                    return Ok(response);
24507                }
24508            }
24509        }
24510    }
24511
24512    /// The resource that owns the locations collection, if applicable.
24513    ///
24514    /// Sets the *name* path property to the given value.
24515    ///
24516    /// Even though the property as already been set when instantiating this call,
24517    /// we provide this method for API completeness.
24518    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24519        self._name = new_value.to_string();
24520        self
24521    }
24522    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
24523    ///
24524    /// Sets the *page token* query property to the given value.
24525    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24526        self._page_token = Some(new_value.to_string());
24527        self
24528    }
24529    /// The maximum number of results to return. If not set, the service selects a default.
24530    ///
24531    /// Sets the *page size* query property to the given value.
24532    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
24533        self._page_size = Some(new_value);
24534        self
24535    }
24536    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
24537    ///
24538    /// Sets the *filter* query property to the given value.
24539    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24540        self._filter = Some(new_value.to_string());
24541        self
24542    }
24543    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
24544    ///
24545    /// Append the given value to the *extra location types* query property.
24546    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
24547    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24548        self._extra_location_types.push(new_value.to_string());
24549        self
24550    }
24551    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24552    /// while executing the actual API request.
24553    ///
24554    /// ````text
24555    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24556    /// ````
24557    ///
24558    /// Sets the *delegate* property to the given value.
24559    pub fn delegate(
24560        mut self,
24561        new_value: &'a mut dyn common::Delegate,
24562    ) -> ProjectLocationListCall<'a, C> {
24563        self._delegate = Some(new_value);
24564        self
24565    }
24566
24567    /// Set any additional parameter of the query string used in the request.
24568    /// It should be used to set parameters which are not yet available through their own
24569    /// setters.
24570    ///
24571    /// Please note that this method must not be used to set any of the known parameters
24572    /// which have their own setter method. If done anyway, the request will fail.
24573    ///
24574    /// # Additional Parameters
24575    ///
24576    /// * *$.xgafv* (query-string) - V1 error format.
24577    /// * *access_token* (query-string) - OAuth access token.
24578    /// * *alt* (query-string) - Data format for response.
24579    /// * *callback* (query-string) - JSONP
24580    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24581    /// * *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.
24582    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24583    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24584    /// * *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.
24585    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24586    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24587    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
24588    where
24589        T: AsRef<str>,
24590    {
24591        self._additional_params
24592            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24593        self
24594    }
24595
24596    /// Identifies the authorization scope for the method you are building.
24597    ///
24598    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24599    /// [`Scope::CloudPlatform`].
24600    ///
24601    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24602    /// tokens for more than one scope.
24603    ///
24604    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24605    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24606    /// sufficient, a read-write scope will do as well.
24607    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
24608    where
24609        St: AsRef<str>,
24610    {
24611        self._scopes.insert(String::from(scope.as_ref()));
24612        self
24613    }
24614    /// Identifies the authorization scope(s) for the method you are building.
24615    ///
24616    /// See [`Self::add_scope()`] for details.
24617    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
24618    where
24619        I: IntoIterator<Item = St>,
24620        St: AsRef<str>,
24621    {
24622        self._scopes
24623            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24624        self
24625    }
24626
24627    /// Removes all scopes, and no default scope will be used either.
24628    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24629    /// for details).
24630    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
24631        self._scopes.clear();
24632        self
24633    }
24634}
24635
24636/// Updates the EkmConfig singleton resource for a given project and location.
24637///
24638/// A builder for the *locations.updateEkmConfig* method supported by a *project* resource.
24639/// It is not used directly, but through a [`ProjectMethods`] instance.
24640///
24641/// # Example
24642///
24643/// Instantiate a resource method builder
24644///
24645/// ```test_harness,no_run
24646/// # extern crate hyper;
24647/// # extern crate hyper_rustls;
24648/// # extern crate google_cloudkms1 as cloudkms1;
24649/// use cloudkms1::api::EkmConfig;
24650/// # async fn dox() {
24651/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24652///
24653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24654/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24655/// #     .with_native_roots()
24656/// #     .unwrap()
24657/// #     .https_only()
24658/// #     .enable_http2()
24659/// #     .build();
24660///
24661/// # let executor = hyper_util::rt::TokioExecutor::new();
24662/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24663/// #     secret,
24664/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24665/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24666/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24667/// #     ),
24668/// # ).build().await.unwrap();
24669///
24670/// # let client = hyper_util::client::legacy::Client::builder(
24671/// #     hyper_util::rt::TokioExecutor::new()
24672/// # )
24673/// # .build(
24674/// #     hyper_rustls::HttpsConnectorBuilder::new()
24675/// #         .with_native_roots()
24676/// #         .unwrap()
24677/// #         .https_or_http()
24678/// #         .enable_http2()
24679/// #         .build()
24680/// # );
24681/// # let mut hub = CloudKMS::new(client, auth);
24682/// // As the method needs a request, you would usually fill it with the desired information
24683/// // into the respective structure. Some of the parts shown here might not be applicable !
24684/// // Values shown here are possibly random and not representative !
24685/// let mut req = EkmConfig::default();
24686///
24687/// // You can configure optional parameters by calling the respective setters at will, and
24688/// // execute the final call using `doit()`.
24689/// // Values shown here are possibly random and not representative !
24690/// let result = hub.projects().locations_update_ekm_config(req, "name")
24691///              .update_mask(FieldMask::new::<&str>(&[]))
24692///              .doit().await;
24693/// # }
24694/// ```
24695pub struct ProjectLocationUpdateEkmConfigCall<'a, C>
24696where
24697    C: 'a,
24698{
24699    hub: &'a CloudKMS<C>,
24700    _request: EkmConfig,
24701    _name: String,
24702    _update_mask: Option<common::FieldMask>,
24703    _delegate: Option<&'a mut dyn common::Delegate>,
24704    _additional_params: HashMap<String, String>,
24705    _scopes: BTreeSet<String>,
24706}
24707
24708impl<'a, C> common::CallBuilder for ProjectLocationUpdateEkmConfigCall<'a, C> {}
24709
24710impl<'a, C> ProjectLocationUpdateEkmConfigCall<'a, C>
24711where
24712    C: common::Connector,
24713{
24714    /// Perform the operation you have build so far.
24715    pub async fn doit(mut self) -> common::Result<(common::Response, EkmConfig)> {
24716        use std::borrow::Cow;
24717        use std::io::{Read, Seek};
24718
24719        use common::{url::Params, ToParts};
24720        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24721
24722        let mut dd = common::DefaultDelegate;
24723        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24724        dlg.begin(common::MethodInfo {
24725            id: "cloudkms.projects.locations.updateEkmConfig",
24726            http_method: hyper::Method::PATCH,
24727        });
24728
24729        for &field in ["alt", "name", "updateMask"].iter() {
24730            if self._additional_params.contains_key(field) {
24731                dlg.finished(false);
24732                return Err(common::Error::FieldClash(field));
24733            }
24734        }
24735
24736        let mut params = Params::with_capacity(5 + self._additional_params.len());
24737        params.push("name", self._name);
24738        if let Some(value) = self._update_mask.as_ref() {
24739            params.push("updateMask", value.to_string());
24740        }
24741
24742        params.extend(self._additional_params.iter());
24743
24744        params.push("alt", "json");
24745        let mut url = self.hub._base_url.clone() + "v1/{+name}";
24746        if self._scopes.is_empty() {
24747            self._scopes
24748                .insert(Scope::CloudPlatform.as_ref().to_string());
24749        }
24750
24751        #[allow(clippy::single_element_loop)]
24752        for &(find_this, param_name) in [("{+name}", "name")].iter() {
24753            url = params.uri_replacement(url, param_name, find_this, true);
24754        }
24755        {
24756            let to_remove = ["name"];
24757            params.remove_params(&to_remove);
24758        }
24759
24760        let url = params.parse_with_url(&url);
24761
24762        let mut json_mime_type = mime::APPLICATION_JSON;
24763        let mut request_value_reader = {
24764            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24765            common::remove_json_null_values(&mut value);
24766            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24767            serde_json::to_writer(&mut dst, &value).unwrap();
24768            dst
24769        };
24770        let request_size = request_value_reader
24771            .seek(std::io::SeekFrom::End(0))
24772            .unwrap();
24773        request_value_reader
24774            .seek(std::io::SeekFrom::Start(0))
24775            .unwrap();
24776
24777        loop {
24778            let token = match self
24779                .hub
24780                .auth
24781                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24782                .await
24783            {
24784                Ok(token) => token,
24785                Err(e) => match dlg.token(e) {
24786                    Ok(token) => token,
24787                    Err(e) => {
24788                        dlg.finished(false);
24789                        return Err(common::Error::MissingToken(e));
24790                    }
24791                },
24792            };
24793            request_value_reader
24794                .seek(std::io::SeekFrom::Start(0))
24795                .unwrap();
24796            let mut req_result = {
24797                let client = &self.hub.client;
24798                dlg.pre_request();
24799                let mut req_builder = hyper::Request::builder()
24800                    .method(hyper::Method::PATCH)
24801                    .uri(url.as_str())
24802                    .header(USER_AGENT, self.hub._user_agent.clone());
24803
24804                if let Some(token) = token.as_ref() {
24805                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24806                }
24807
24808                let request = req_builder
24809                    .header(CONTENT_TYPE, json_mime_type.to_string())
24810                    .header(CONTENT_LENGTH, request_size as u64)
24811                    .body(common::to_body(
24812                        request_value_reader.get_ref().clone().into(),
24813                    ));
24814
24815                client.request(request.unwrap()).await
24816            };
24817
24818            match req_result {
24819                Err(err) => {
24820                    if let common::Retry::After(d) = dlg.http_error(&err) {
24821                        sleep(d).await;
24822                        continue;
24823                    }
24824                    dlg.finished(false);
24825                    return Err(common::Error::HttpError(err));
24826                }
24827                Ok(res) => {
24828                    let (mut parts, body) = res.into_parts();
24829                    let mut body = common::Body::new(body);
24830                    if !parts.status.is_success() {
24831                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24832                        let error = serde_json::from_str(&common::to_string(&bytes));
24833                        let response = common::to_response(parts, bytes.into());
24834
24835                        if let common::Retry::After(d) =
24836                            dlg.http_failure(&response, error.as_ref().ok())
24837                        {
24838                            sleep(d).await;
24839                            continue;
24840                        }
24841
24842                        dlg.finished(false);
24843
24844                        return Err(match error {
24845                            Ok(value) => common::Error::BadRequest(value),
24846                            _ => common::Error::Failure(response),
24847                        });
24848                    }
24849                    let response = {
24850                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24851                        let encoded = common::to_string(&bytes);
24852                        match serde_json::from_str(&encoded) {
24853                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24854                            Err(error) => {
24855                                dlg.response_json_decode_error(&encoded, &error);
24856                                return Err(common::Error::JsonDecodeError(
24857                                    encoded.to_string(),
24858                                    error,
24859                                ));
24860                            }
24861                        }
24862                    };
24863
24864                    dlg.finished(true);
24865                    return Ok(response);
24866                }
24867            }
24868        }
24869    }
24870
24871    ///
24872    /// Sets the *request* property to the given value.
24873    ///
24874    /// Even though the property as already been set when instantiating this call,
24875    /// we provide this method for API completeness.
24876    pub fn request(mut self, new_value: EkmConfig) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
24877        self._request = new_value;
24878        self
24879    }
24880    /// Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
24881    ///
24882    /// Sets the *name* path property to the given value.
24883    ///
24884    /// Even though the property as already been set when instantiating this call,
24885    /// we provide this method for API completeness.
24886    pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
24887        self._name = new_value.to_string();
24888        self
24889    }
24890    /// Required. List of fields to be updated in this request.
24891    ///
24892    /// Sets the *update mask* query property to the given value.
24893    pub fn update_mask(
24894        mut self,
24895        new_value: common::FieldMask,
24896    ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
24897        self._update_mask = Some(new_value);
24898        self
24899    }
24900    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24901    /// while executing the actual API request.
24902    ///
24903    /// ````text
24904    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24905    /// ````
24906    ///
24907    /// Sets the *delegate* property to the given value.
24908    pub fn delegate(
24909        mut self,
24910        new_value: &'a mut dyn common::Delegate,
24911    ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
24912        self._delegate = Some(new_value);
24913        self
24914    }
24915
24916    /// Set any additional parameter of the query string used in the request.
24917    /// It should be used to set parameters which are not yet available through their own
24918    /// setters.
24919    ///
24920    /// Please note that this method must not be used to set any of the known parameters
24921    /// which have their own setter method. If done anyway, the request will fail.
24922    ///
24923    /// # Additional Parameters
24924    ///
24925    /// * *$.xgafv* (query-string) - V1 error format.
24926    /// * *access_token* (query-string) - OAuth access token.
24927    /// * *alt* (query-string) - Data format for response.
24928    /// * *callback* (query-string) - JSONP
24929    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24930    /// * *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.
24931    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24932    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24933    /// * *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.
24934    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24935    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24936    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateEkmConfigCall<'a, C>
24937    where
24938        T: AsRef<str>,
24939    {
24940        self._additional_params
24941            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24942        self
24943    }
24944
24945    /// Identifies the authorization scope for the method you are building.
24946    ///
24947    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24948    /// [`Scope::CloudPlatform`].
24949    ///
24950    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24951    /// tokens for more than one scope.
24952    ///
24953    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24954    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24955    /// sufficient, a read-write scope will do as well.
24956    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateEkmConfigCall<'a, C>
24957    where
24958        St: AsRef<str>,
24959    {
24960        self._scopes.insert(String::from(scope.as_ref()));
24961        self
24962    }
24963    /// Identifies the authorization scope(s) for the method you are building.
24964    ///
24965    /// See [`Self::add_scope()`] for details.
24966    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateEkmConfigCall<'a, C>
24967    where
24968        I: IntoIterator<Item = St>,
24969        St: AsRef<str>,
24970    {
24971        self._scopes
24972            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24973        self
24974    }
24975
24976    /// Removes all scopes, and no default scope will be used either.
24977    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24978    /// for details).
24979    pub fn clear_scopes(mut self) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
24980        self._scopes.clear();
24981        self
24982    }
24983}
24984
24985/// Gets the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
24986///
24987/// A builder for the *getKajPolicyConfig* method supported by a *project* resource.
24988/// It is not used directly, but through a [`ProjectMethods`] instance.
24989///
24990/// # Example
24991///
24992/// Instantiate a resource method builder
24993///
24994/// ```test_harness,no_run
24995/// # extern crate hyper;
24996/// # extern crate hyper_rustls;
24997/// # extern crate google_cloudkms1 as cloudkms1;
24998/// # async fn dox() {
24999/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25000///
25001/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25002/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25003/// #     .with_native_roots()
25004/// #     .unwrap()
25005/// #     .https_only()
25006/// #     .enable_http2()
25007/// #     .build();
25008///
25009/// # let executor = hyper_util::rt::TokioExecutor::new();
25010/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25011/// #     secret,
25012/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25013/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25014/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25015/// #     ),
25016/// # ).build().await.unwrap();
25017///
25018/// # let client = hyper_util::client::legacy::Client::builder(
25019/// #     hyper_util::rt::TokioExecutor::new()
25020/// # )
25021/// # .build(
25022/// #     hyper_rustls::HttpsConnectorBuilder::new()
25023/// #         .with_native_roots()
25024/// #         .unwrap()
25025/// #         .https_or_http()
25026/// #         .enable_http2()
25027/// #         .build()
25028/// # );
25029/// # let mut hub = CloudKMS::new(client, auth);
25030/// // You can configure optional parameters by calling the respective setters at will, and
25031/// // execute the final call using `doit()`.
25032/// // Values shown here are possibly random and not representative !
25033/// let result = hub.projects().get_kaj_policy_config("name")
25034///              .doit().await;
25035/// # }
25036/// ```
25037pub struct ProjectGetKajPolicyConfigCall<'a, C>
25038where
25039    C: 'a,
25040{
25041    hub: &'a CloudKMS<C>,
25042    _name: String,
25043    _delegate: Option<&'a mut dyn common::Delegate>,
25044    _additional_params: HashMap<String, String>,
25045    _scopes: BTreeSet<String>,
25046}
25047
25048impl<'a, C> common::CallBuilder for ProjectGetKajPolicyConfigCall<'a, C> {}
25049
25050impl<'a, C> ProjectGetKajPolicyConfigCall<'a, C>
25051where
25052    C: common::Connector,
25053{
25054    /// Perform the operation you have build so far.
25055    pub async fn doit(
25056        mut self,
25057    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
25058        use std::borrow::Cow;
25059        use std::io::{Read, Seek};
25060
25061        use common::{url::Params, ToParts};
25062        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25063
25064        let mut dd = common::DefaultDelegate;
25065        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25066        dlg.begin(common::MethodInfo {
25067            id: "cloudkms.projects.getKajPolicyConfig",
25068            http_method: hyper::Method::GET,
25069        });
25070
25071        for &field in ["alt", "name"].iter() {
25072            if self._additional_params.contains_key(field) {
25073                dlg.finished(false);
25074                return Err(common::Error::FieldClash(field));
25075            }
25076        }
25077
25078        let mut params = Params::with_capacity(3 + self._additional_params.len());
25079        params.push("name", self._name);
25080
25081        params.extend(self._additional_params.iter());
25082
25083        params.push("alt", "json");
25084        let mut url = self.hub._base_url.clone() + "v1/{+name}";
25085        if self._scopes.is_empty() {
25086            self._scopes
25087                .insert(Scope::CloudPlatform.as_ref().to_string());
25088        }
25089
25090        #[allow(clippy::single_element_loop)]
25091        for &(find_this, param_name) in [("{+name}", "name")].iter() {
25092            url = params.uri_replacement(url, param_name, find_this, true);
25093        }
25094        {
25095            let to_remove = ["name"];
25096            params.remove_params(&to_remove);
25097        }
25098
25099        let url = params.parse_with_url(&url);
25100
25101        loop {
25102            let token = match self
25103                .hub
25104                .auth
25105                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25106                .await
25107            {
25108                Ok(token) => token,
25109                Err(e) => match dlg.token(e) {
25110                    Ok(token) => token,
25111                    Err(e) => {
25112                        dlg.finished(false);
25113                        return Err(common::Error::MissingToken(e));
25114                    }
25115                },
25116            };
25117            let mut req_result = {
25118                let client = &self.hub.client;
25119                dlg.pre_request();
25120                let mut req_builder = hyper::Request::builder()
25121                    .method(hyper::Method::GET)
25122                    .uri(url.as_str())
25123                    .header(USER_AGENT, self.hub._user_agent.clone());
25124
25125                if let Some(token) = token.as_ref() {
25126                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25127                }
25128
25129                let request = req_builder
25130                    .header(CONTENT_LENGTH, 0_u64)
25131                    .body(common::to_body::<String>(None));
25132
25133                client.request(request.unwrap()).await
25134            };
25135
25136            match req_result {
25137                Err(err) => {
25138                    if let common::Retry::After(d) = dlg.http_error(&err) {
25139                        sleep(d).await;
25140                        continue;
25141                    }
25142                    dlg.finished(false);
25143                    return Err(common::Error::HttpError(err));
25144                }
25145                Ok(res) => {
25146                    let (mut parts, body) = res.into_parts();
25147                    let mut body = common::Body::new(body);
25148                    if !parts.status.is_success() {
25149                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25150                        let error = serde_json::from_str(&common::to_string(&bytes));
25151                        let response = common::to_response(parts, bytes.into());
25152
25153                        if let common::Retry::After(d) =
25154                            dlg.http_failure(&response, error.as_ref().ok())
25155                        {
25156                            sleep(d).await;
25157                            continue;
25158                        }
25159
25160                        dlg.finished(false);
25161
25162                        return Err(match error {
25163                            Ok(value) => common::Error::BadRequest(value),
25164                            _ => common::Error::Failure(response),
25165                        });
25166                    }
25167                    let response = {
25168                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25169                        let encoded = common::to_string(&bytes);
25170                        match serde_json::from_str(&encoded) {
25171                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25172                            Err(error) => {
25173                                dlg.response_json_decode_error(&encoded, &error);
25174                                return Err(common::Error::JsonDecodeError(
25175                                    encoded.to_string(),
25176                                    error,
25177                                ));
25178                            }
25179                        }
25180                    };
25181
25182                    dlg.finished(true);
25183                    return Ok(response);
25184                }
25185            }
25186        }
25187    }
25188
25189    /// Required. The name of the KeyAccessJustificationsPolicyConfig to get.
25190    ///
25191    /// Sets the *name* path property to the given value.
25192    ///
25193    /// Even though the property as already been set when instantiating this call,
25194    /// we provide this method for API completeness.
25195    pub fn name(mut self, new_value: &str) -> ProjectGetKajPolicyConfigCall<'a, C> {
25196        self._name = new_value.to_string();
25197        self
25198    }
25199    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25200    /// while executing the actual API request.
25201    ///
25202    /// ````text
25203    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25204    /// ````
25205    ///
25206    /// Sets the *delegate* property to the given value.
25207    pub fn delegate(
25208        mut self,
25209        new_value: &'a mut dyn common::Delegate,
25210    ) -> ProjectGetKajPolicyConfigCall<'a, C> {
25211        self._delegate = Some(new_value);
25212        self
25213    }
25214
25215    /// Set any additional parameter of the query string used in the request.
25216    /// It should be used to set parameters which are not yet available through their own
25217    /// setters.
25218    ///
25219    /// Please note that this method must not be used to set any of the known parameters
25220    /// which have their own setter method. If done anyway, the request will fail.
25221    ///
25222    /// # Additional Parameters
25223    ///
25224    /// * *$.xgafv* (query-string) - V1 error format.
25225    /// * *access_token* (query-string) - OAuth access token.
25226    /// * *alt* (query-string) - Data format for response.
25227    /// * *callback* (query-string) - JSONP
25228    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25229    /// * *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.
25230    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25231    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25232    /// * *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.
25233    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25234    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25235    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetKajPolicyConfigCall<'a, C>
25236    where
25237        T: AsRef<str>,
25238    {
25239        self._additional_params
25240            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25241        self
25242    }
25243
25244    /// Identifies the authorization scope for the method you are building.
25245    ///
25246    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25247    /// [`Scope::CloudPlatform`].
25248    ///
25249    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25250    /// tokens for more than one scope.
25251    ///
25252    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25253    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25254    /// sufficient, a read-write scope will do as well.
25255    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetKajPolicyConfigCall<'a, C>
25256    where
25257        St: AsRef<str>,
25258    {
25259        self._scopes.insert(String::from(scope.as_ref()));
25260        self
25261    }
25262    /// Identifies the authorization scope(s) for the method you are building.
25263    ///
25264    /// See [`Self::add_scope()`] for details.
25265    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetKajPolicyConfigCall<'a, C>
25266    where
25267        I: IntoIterator<Item = St>,
25268        St: AsRef<str>,
25269    {
25270        self._scopes
25271            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25272        self
25273    }
25274
25275    /// Removes all scopes, and no default scope will be used either.
25276    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25277    /// for details).
25278    pub fn clear_scopes(mut self) -> ProjectGetKajPolicyConfigCall<'a, C> {
25279        self._scopes.clear();
25280        self
25281    }
25282}
25283
25284/// Returns the effective Cloud KMS Autokey configuration for a given project.
25285///
25286/// A builder for the *showEffectiveAutokeyConfig* method supported by a *project* resource.
25287/// It is not used directly, but through a [`ProjectMethods`] instance.
25288///
25289/// # Example
25290///
25291/// Instantiate a resource method builder
25292///
25293/// ```test_harness,no_run
25294/// # extern crate hyper;
25295/// # extern crate hyper_rustls;
25296/// # extern crate google_cloudkms1 as cloudkms1;
25297/// # async fn dox() {
25298/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25299///
25300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25301/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25302/// #     .with_native_roots()
25303/// #     .unwrap()
25304/// #     .https_only()
25305/// #     .enable_http2()
25306/// #     .build();
25307///
25308/// # let executor = hyper_util::rt::TokioExecutor::new();
25309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25310/// #     secret,
25311/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25312/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25313/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25314/// #     ),
25315/// # ).build().await.unwrap();
25316///
25317/// # let client = hyper_util::client::legacy::Client::builder(
25318/// #     hyper_util::rt::TokioExecutor::new()
25319/// # )
25320/// # .build(
25321/// #     hyper_rustls::HttpsConnectorBuilder::new()
25322/// #         .with_native_roots()
25323/// #         .unwrap()
25324/// #         .https_or_http()
25325/// #         .enable_http2()
25326/// #         .build()
25327/// # );
25328/// # let mut hub = CloudKMS::new(client, auth);
25329/// // You can configure optional parameters by calling the respective setters at will, and
25330/// // execute the final call using `doit()`.
25331/// // Values shown here are possibly random and not representative !
25332/// let result = hub.projects().show_effective_autokey_config("parent")
25333///              .doit().await;
25334/// # }
25335/// ```
25336pub struct ProjectShowEffectiveAutokeyConfigCall<'a, C>
25337where
25338    C: 'a,
25339{
25340    hub: &'a CloudKMS<C>,
25341    _parent: String,
25342    _delegate: Option<&'a mut dyn common::Delegate>,
25343    _additional_params: HashMap<String, String>,
25344    _scopes: BTreeSet<String>,
25345}
25346
25347impl<'a, C> common::CallBuilder for ProjectShowEffectiveAutokeyConfigCall<'a, C> {}
25348
25349impl<'a, C> ProjectShowEffectiveAutokeyConfigCall<'a, C>
25350where
25351    C: common::Connector,
25352{
25353    /// Perform the operation you have build so far.
25354    pub async fn doit(
25355        mut self,
25356    ) -> common::Result<(common::Response, ShowEffectiveAutokeyConfigResponse)> {
25357        use std::borrow::Cow;
25358        use std::io::{Read, Seek};
25359
25360        use common::{url::Params, ToParts};
25361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25362
25363        let mut dd = common::DefaultDelegate;
25364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25365        dlg.begin(common::MethodInfo {
25366            id: "cloudkms.projects.showEffectiveAutokeyConfig",
25367            http_method: hyper::Method::GET,
25368        });
25369
25370        for &field in ["alt", "parent"].iter() {
25371            if self._additional_params.contains_key(field) {
25372                dlg.finished(false);
25373                return Err(common::Error::FieldClash(field));
25374            }
25375        }
25376
25377        let mut params = Params::with_capacity(3 + self._additional_params.len());
25378        params.push("parent", self._parent);
25379
25380        params.extend(self._additional_params.iter());
25381
25382        params.push("alt", "json");
25383        let mut url = self.hub._base_url.clone() + "v1/{+parent}:showEffectiveAutokeyConfig";
25384        if self._scopes.is_empty() {
25385            self._scopes
25386                .insert(Scope::CloudPlatform.as_ref().to_string());
25387        }
25388
25389        #[allow(clippy::single_element_loop)]
25390        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25391            url = params.uri_replacement(url, param_name, find_this, true);
25392        }
25393        {
25394            let to_remove = ["parent"];
25395            params.remove_params(&to_remove);
25396        }
25397
25398        let url = params.parse_with_url(&url);
25399
25400        loop {
25401            let token = match self
25402                .hub
25403                .auth
25404                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25405                .await
25406            {
25407                Ok(token) => token,
25408                Err(e) => match dlg.token(e) {
25409                    Ok(token) => token,
25410                    Err(e) => {
25411                        dlg.finished(false);
25412                        return Err(common::Error::MissingToken(e));
25413                    }
25414                },
25415            };
25416            let mut req_result = {
25417                let client = &self.hub.client;
25418                dlg.pre_request();
25419                let mut req_builder = hyper::Request::builder()
25420                    .method(hyper::Method::GET)
25421                    .uri(url.as_str())
25422                    .header(USER_AGENT, self.hub._user_agent.clone());
25423
25424                if let Some(token) = token.as_ref() {
25425                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25426                }
25427
25428                let request = req_builder
25429                    .header(CONTENT_LENGTH, 0_u64)
25430                    .body(common::to_body::<String>(None));
25431
25432                client.request(request.unwrap()).await
25433            };
25434
25435            match req_result {
25436                Err(err) => {
25437                    if let common::Retry::After(d) = dlg.http_error(&err) {
25438                        sleep(d).await;
25439                        continue;
25440                    }
25441                    dlg.finished(false);
25442                    return Err(common::Error::HttpError(err));
25443                }
25444                Ok(res) => {
25445                    let (mut parts, body) = res.into_parts();
25446                    let mut body = common::Body::new(body);
25447                    if !parts.status.is_success() {
25448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25449                        let error = serde_json::from_str(&common::to_string(&bytes));
25450                        let response = common::to_response(parts, bytes.into());
25451
25452                        if let common::Retry::After(d) =
25453                            dlg.http_failure(&response, error.as_ref().ok())
25454                        {
25455                            sleep(d).await;
25456                            continue;
25457                        }
25458
25459                        dlg.finished(false);
25460
25461                        return Err(match error {
25462                            Ok(value) => common::Error::BadRequest(value),
25463                            _ => common::Error::Failure(response),
25464                        });
25465                    }
25466                    let response = {
25467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25468                        let encoded = common::to_string(&bytes);
25469                        match serde_json::from_str(&encoded) {
25470                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25471                            Err(error) => {
25472                                dlg.response_json_decode_error(&encoded, &error);
25473                                return Err(common::Error::JsonDecodeError(
25474                                    encoded.to_string(),
25475                                    error,
25476                                ));
25477                            }
25478                        }
25479                    };
25480
25481                    dlg.finished(true);
25482                    return Ok(response);
25483                }
25484            }
25485        }
25486    }
25487
25488    /// Required. Name of the resource project to the show effective Cloud KMS Autokey configuration for. This may be helpful for interrogating the effect of nested folder configurations on a given resource project.
25489    ///
25490    /// Sets the *parent* path property to the given value.
25491    ///
25492    /// Even though the property as already been set when instantiating this call,
25493    /// we provide this method for API completeness.
25494    pub fn parent(mut self, new_value: &str) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
25495        self._parent = new_value.to_string();
25496        self
25497    }
25498    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25499    /// while executing the actual API request.
25500    ///
25501    /// ````text
25502    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25503    /// ````
25504    ///
25505    /// Sets the *delegate* property to the given value.
25506    pub fn delegate(
25507        mut self,
25508        new_value: &'a mut dyn common::Delegate,
25509    ) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
25510        self._delegate = Some(new_value);
25511        self
25512    }
25513
25514    /// Set any additional parameter of the query string used in the request.
25515    /// It should be used to set parameters which are not yet available through their own
25516    /// setters.
25517    ///
25518    /// Please note that this method must not be used to set any of the known parameters
25519    /// which have their own setter method. If done anyway, the request will fail.
25520    ///
25521    /// # Additional Parameters
25522    ///
25523    /// * *$.xgafv* (query-string) - V1 error format.
25524    /// * *access_token* (query-string) - OAuth access token.
25525    /// * *alt* (query-string) - Data format for response.
25526    /// * *callback* (query-string) - JSONP
25527    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25528    /// * *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.
25529    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25530    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25531    /// * *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.
25532    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25533    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25534    pub fn param<T>(mut self, name: T, value: T) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
25535    where
25536        T: AsRef<str>,
25537    {
25538        self._additional_params
25539            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25540        self
25541    }
25542
25543    /// Identifies the authorization scope for the method you are building.
25544    ///
25545    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25546    /// [`Scope::CloudPlatform`].
25547    ///
25548    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25549    /// tokens for more than one scope.
25550    ///
25551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25553    /// sufficient, a read-write scope will do as well.
25554    pub fn add_scope<St>(mut self, scope: St) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
25555    where
25556        St: AsRef<str>,
25557    {
25558        self._scopes.insert(String::from(scope.as_ref()));
25559        self
25560    }
25561    /// Identifies the authorization scope(s) for the method you are building.
25562    ///
25563    /// See [`Self::add_scope()`] for details.
25564    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
25565    where
25566        I: IntoIterator<Item = St>,
25567        St: AsRef<str>,
25568    {
25569        self._scopes
25570            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25571        self
25572    }
25573
25574    /// Removes all scopes, and no default scope will be used either.
25575    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25576    /// for details).
25577    pub fn clear_scopes(mut self) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
25578        self._scopes.clear();
25579        self
25580    }
25581}
25582
25583/// Returns the KeyAccessJustificationsEnrollmentConfig of the resource closest to the given project in hierarchy.
25584///
25585/// A builder for the *showEffectiveKeyAccessJustificationsEnrollmentConfig* method supported by a *project* resource.
25586/// It is not used directly, but through a [`ProjectMethods`] instance.
25587///
25588/// # Example
25589///
25590/// Instantiate a resource method builder
25591///
25592/// ```test_harness,no_run
25593/// # extern crate hyper;
25594/// # extern crate hyper_rustls;
25595/// # extern crate google_cloudkms1 as cloudkms1;
25596/// # async fn dox() {
25597/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25598///
25599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25600/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25601/// #     .with_native_roots()
25602/// #     .unwrap()
25603/// #     .https_only()
25604/// #     .enable_http2()
25605/// #     .build();
25606///
25607/// # let executor = hyper_util::rt::TokioExecutor::new();
25608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25609/// #     secret,
25610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25611/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25612/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25613/// #     ),
25614/// # ).build().await.unwrap();
25615///
25616/// # let client = hyper_util::client::legacy::Client::builder(
25617/// #     hyper_util::rt::TokioExecutor::new()
25618/// # )
25619/// # .build(
25620/// #     hyper_rustls::HttpsConnectorBuilder::new()
25621/// #         .with_native_roots()
25622/// #         .unwrap()
25623/// #         .https_or_http()
25624/// #         .enable_http2()
25625/// #         .build()
25626/// # );
25627/// # let mut hub = CloudKMS::new(client, auth);
25628/// // You can configure optional parameters by calling the respective setters at will, and
25629/// // execute the final call using `doit()`.
25630/// // Values shown here are possibly random and not representative !
25631/// let result = hub.projects().show_effective_key_access_justifications_enrollment_config("project")
25632///              .doit().await;
25633/// # }
25634/// ```
25635pub struct ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25636where
25637    C: 'a,
25638{
25639    hub: &'a CloudKMS<C>,
25640    _project: String,
25641    _delegate: Option<&'a mut dyn common::Delegate>,
25642    _additional_params: HashMap<String, String>,
25643    _scopes: BTreeSet<String>,
25644}
25645
25646impl<'a, C> common::CallBuilder
25647    for ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25648{
25649}
25650
25651impl<'a, C> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25652where
25653    C: common::Connector,
25654{
25655    /// Perform the operation you have build so far.
25656    pub async fn doit(
25657        mut self,
25658    ) -> common::Result<(
25659        common::Response,
25660        ShowEffectiveKeyAccessJustificationsEnrollmentConfigResponse,
25661    )> {
25662        use std::borrow::Cow;
25663        use std::io::{Read, Seek};
25664
25665        use common::{url::Params, ToParts};
25666        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25667
25668        let mut dd = common::DefaultDelegate;
25669        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25670        dlg.begin(common::MethodInfo {
25671            id: "cloudkms.projects.showEffectiveKeyAccessJustificationsEnrollmentConfig",
25672            http_method: hyper::Method::GET,
25673        });
25674
25675        for &field in ["alt", "project"].iter() {
25676            if self._additional_params.contains_key(field) {
25677                dlg.finished(false);
25678                return Err(common::Error::FieldClash(field));
25679            }
25680        }
25681
25682        let mut params = Params::with_capacity(3 + self._additional_params.len());
25683        params.push("project", self._project);
25684
25685        params.extend(self._additional_params.iter());
25686
25687        params.push("alt", "json");
25688        let mut url = self.hub._base_url.clone()
25689            + "v1/{+project}:showEffectiveKeyAccessJustificationsEnrollmentConfig";
25690        if self._scopes.is_empty() {
25691            self._scopes
25692                .insert(Scope::CloudPlatform.as_ref().to_string());
25693        }
25694
25695        #[allow(clippy::single_element_loop)]
25696        for &(find_this, param_name) in [("{+project}", "project")].iter() {
25697            url = params.uri_replacement(url, param_name, find_this, true);
25698        }
25699        {
25700            let to_remove = ["project"];
25701            params.remove_params(&to_remove);
25702        }
25703
25704        let url = params.parse_with_url(&url);
25705
25706        loop {
25707            let token = match self
25708                .hub
25709                .auth
25710                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25711                .await
25712            {
25713                Ok(token) => token,
25714                Err(e) => match dlg.token(e) {
25715                    Ok(token) => token,
25716                    Err(e) => {
25717                        dlg.finished(false);
25718                        return Err(common::Error::MissingToken(e));
25719                    }
25720                },
25721            };
25722            let mut req_result = {
25723                let client = &self.hub.client;
25724                dlg.pre_request();
25725                let mut req_builder = hyper::Request::builder()
25726                    .method(hyper::Method::GET)
25727                    .uri(url.as_str())
25728                    .header(USER_AGENT, self.hub._user_agent.clone());
25729
25730                if let Some(token) = token.as_ref() {
25731                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25732                }
25733
25734                let request = req_builder
25735                    .header(CONTENT_LENGTH, 0_u64)
25736                    .body(common::to_body::<String>(None));
25737
25738                client.request(request.unwrap()).await
25739            };
25740
25741            match req_result {
25742                Err(err) => {
25743                    if let common::Retry::After(d) = dlg.http_error(&err) {
25744                        sleep(d).await;
25745                        continue;
25746                    }
25747                    dlg.finished(false);
25748                    return Err(common::Error::HttpError(err));
25749                }
25750                Ok(res) => {
25751                    let (mut parts, body) = res.into_parts();
25752                    let mut body = common::Body::new(body);
25753                    if !parts.status.is_success() {
25754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25755                        let error = serde_json::from_str(&common::to_string(&bytes));
25756                        let response = common::to_response(parts, bytes.into());
25757
25758                        if let common::Retry::After(d) =
25759                            dlg.http_failure(&response, error.as_ref().ok())
25760                        {
25761                            sleep(d).await;
25762                            continue;
25763                        }
25764
25765                        dlg.finished(false);
25766
25767                        return Err(match error {
25768                            Ok(value) => common::Error::BadRequest(value),
25769                            _ => common::Error::Failure(response),
25770                        });
25771                    }
25772                    let response = {
25773                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25774                        let encoded = common::to_string(&bytes);
25775                        match serde_json::from_str(&encoded) {
25776                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25777                            Err(error) => {
25778                                dlg.response_json_decode_error(&encoded, &error);
25779                                return Err(common::Error::JsonDecodeError(
25780                                    encoded.to_string(),
25781                                    error,
25782                                ));
25783                            }
25784                        }
25785                    };
25786
25787                    dlg.finished(true);
25788                    return Ok(response);
25789                }
25790            }
25791        }
25792    }
25793
25794    /// Required. The number or id of the project to get the effective KeyAccessJustificationsEnrollmentConfig for.
25795    ///
25796    /// Sets the *project* path property to the given value.
25797    ///
25798    /// Even though the property as already been set when instantiating this call,
25799    /// we provide this method for API completeness.
25800    pub fn project(
25801        mut self,
25802        new_value: &str,
25803    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C> {
25804        self._project = new_value.to_string();
25805        self
25806    }
25807    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25808    /// while executing the actual API request.
25809    ///
25810    /// ````text
25811    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25812    /// ````
25813    ///
25814    /// Sets the *delegate* property to the given value.
25815    pub fn delegate(
25816        mut self,
25817        new_value: &'a mut dyn common::Delegate,
25818    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C> {
25819        self._delegate = Some(new_value);
25820        self
25821    }
25822
25823    /// Set any additional parameter of the query string used in the request.
25824    /// It should be used to set parameters which are not yet available through their own
25825    /// setters.
25826    ///
25827    /// Please note that this method must not be used to set any of the known parameters
25828    /// which have their own setter method. If done anyway, the request will fail.
25829    ///
25830    /// # Additional Parameters
25831    ///
25832    /// * *$.xgafv* (query-string) - V1 error format.
25833    /// * *access_token* (query-string) - OAuth access token.
25834    /// * *alt* (query-string) - Data format for response.
25835    /// * *callback* (query-string) - JSONP
25836    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25837    /// * *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.
25838    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25839    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25840    /// * *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.
25841    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25842    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25843    pub fn param<T>(
25844        mut self,
25845        name: T,
25846        value: T,
25847    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25848    where
25849        T: AsRef<str>,
25850    {
25851        self._additional_params
25852            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25853        self
25854    }
25855
25856    /// Identifies the authorization scope for the method you are building.
25857    ///
25858    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25859    /// [`Scope::CloudPlatform`].
25860    ///
25861    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25862    /// tokens for more than one scope.
25863    ///
25864    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25865    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25866    /// sufficient, a read-write scope will do as well.
25867    pub fn add_scope<St>(
25868        mut self,
25869        scope: St,
25870    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25871    where
25872        St: AsRef<str>,
25873    {
25874        self._scopes.insert(String::from(scope.as_ref()));
25875        self
25876    }
25877    /// Identifies the authorization scope(s) for the method you are building.
25878    ///
25879    /// See [`Self::add_scope()`] for details.
25880    pub fn add_scopes<I, St>(
25881        mut self,
25882        scopes: I,
25883    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C>
25884    where
25885        I: IntoIterator<Item = St>,
25886        St: AsRef<str>,
25887    {
25888        self._scopes
25889            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25890        self
25891    }
25892
25893    /// Removes all scopes, and no default scope will be used either.
25894    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25895    /// for details).
25896    pub fn clear_scopes(
25897        mut self,
25898    ) -> ProjectShowEffectiveKeyAccessJustificationsEnrollmentConfigCall<'a, C> {
25899        self._scopes.clear();
25900        self
25901    }
25902}
25903
25904/// Returns the KeyAccessJustificationsPolicyConfig of the resource closest to the given project in hierarchy.
25905///
25906/// A builder for the *showEffectiveKeyAccessJustificationsPolicyConfig* method supported by a *project* resource.
25907/// It is not used directly, but through a [`ProjectMethods`] instance.
25908///
25909/// # Example
25910///
25911/// Instantiate a resource method builder
25912///
25913/// ```test_harness,no_run
25914/// # extern crate hyper;
25915/// # extern crate hyper_rustls;
25916/// # extern crate google_cloudkms1 as cloudkms1;
25917/// # async fn dox() {
25918/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25919///
25920/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25921/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25922/// #     .with_native_roots()
25923/// #     .unwrap()
25924/// #     .https_only()
25925/// #     .enable_http2()
25926/// #     .build();
25927///
25928/// # let executor = hyper_util::rt::TokioExecutor::new();
25929/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25930/// #     secret,
25931/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25932/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25933/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25934/// #     ),
25935/// # ).build().await.unwrap();
25936///
25937/// # let client = hyper_util::client::legacy::Client::builder(
25938/// #     hyper_util::rt::TokioExecutor::new()
25939/// # )
25940/// # .build(
25941/// #     hyper_rustls::HttpsConnectorBuilder::new()
25942/// #         .with_native_roots()
25943/// #         .unwrap()
25944/// #         .https_or_http()
25945/// #         .enable_http2()
25946/// #         .build()
25947/// # );
25948/// # let mut hub = CloudKMS::new(client, auth);
25949/// // You can configure optional parameters by calling the respective setters at will, and
25950/// // execute the final call using `doit()`.
25951/// // Values shown here are possibly random and not representative !
25952/// let result = hub.projects().show_effective_key_access_justifications_policy_config("project")
25953///              .doit().await;
25954/// # }
25955/// ```
25956pub struct ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
25957where
25958    C: 'a,
25959{
25960    hub: &'a CloudKMS<C>,
25961    _project: String,
25962    _delegate: Option<&'a mut dyn common::Delegate>,
25963    _additional_params: HashMap<String, String>,
25964    _scopes: BTreeSet<String>,
25965}
25966
25967impl<'a, C> common::CallBuilder
25968    for ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
25969{
25970}
25971
25972impl<'a, C> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
25973where
25974    C: common::Connector,
25975{
25976    /// Perform the operation you have build so far.
25977    pub async fn doit(
25978        mut self,
25979    ) -> common::Result<(
25980        common::Response,
25981        ShowEffectiveKeyAccessJustificationsPolicyConfigResponse,
25982    )> {
25983        use std::borrow::Cow;
25984        use std::io::{Read, Seek};
25985
25986        use common::{url::Params, ToParts};
25987        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25988
25989        let mut dd = common::DefaultDelegate;
25990        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25991        dlg.begin(common::MethodInfo {
25992            id: "cloudkms.projects.showEffectiveKeyAccessJustificationsPolicyConfig",
25993            http_method: hyper::Method::GET,
25994        });
25995
25996        for &field in ["alt", "project"].iter() {
25997            if self._additional_params.contains_key(field) {
25998                dlg.finished(false);
25999                return Err(common::Error::FieldClash(field));
26000            }
26001        }
26002
26003        let mut params = Params::with_capacity(3 + self._additional_params.len());
26004        params.push("project", self._project);
26005
26006        params.extend(self._additional_params.iter());
26007
26008        params.push("alt", "json");
26009        let mut url = self.hub._base_url.clone()
26010            + "v1/{+project}:showEffectiveKeyAccessJustificationsPolicyConfig";
26011        if self._scopes.is_empty() {
26012            self._scopes
26013                .insert(Scope::CloudPlatform.as_ref().to_string());
26014        }
26015
26016        #[allow(clippy::single_element_loop)]
26017        for &(find_this, param_name) in [("{+project}", "project")].iter() {
26018            url = params.uri_replacement(url, param_name, find_this, true);
26019        }
26020        {
26021            let to_remove = ["project"];
26022            params.remove_params(&to_remove);
26023        }
26024
26025        let url = params.parse_with_url(&url);
26026
26027        loop {
26028            let token = match self
26029                .hub
26030                .auth
26031                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26032                .await
26033            {
26034                Ok(token) => token,
26035                Err(e) => match dlg.token(e) {
26036                    Ok(token) => token,
26037                    Err(e) => {
26038                        dlg.finished(false);
26039                        return Err(common::Error::MissingToken(e));
26040                    }
26041                },
26042            };
26043            let mut req_result = {
26044                let client = &self.hub.client;
26045                dlg.pre_request();
26046                let mut req_builder = hyper::Request::builder()
26047                    .method(hyper::Method::GET)
26048                    .uri(url.as_str())
26049                    .header(USER_AGENT, self.hub._user_agent.clone());
26050
26051                if let Some(token) = token.as_ref() {
26052                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26053                }
26054
26055                let request = req_builder
26056                    .header(CONTENT_LENGTH, 0_u64)
26057                    .body(common::to_body::<String>(None));
26058
26059                client.request(request.unwrap()).await
26060            };
26061
26062            match req_result {
26063                Err(err) => {
26064                    if let common::Retry::After(d) = dlg.http_error(&err) {
26065                        sleep(d).await;
26066                        continue;
26067                    }
26068                    dlg.finished(false);
26069                    return Err(common::Error::HttpError(err));
26070                }
26071                Ok(res) => {
26072                    let (mut parts, body) = res.into_parts();
26073                    let mut body = common::Body::new(body);
26074                    if !parts.status.is_success() {
26075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26076                        let error = serde_json::from_str(&common::to_string(&bytes));
26077                        let response = common::to_response(parts, bytes.into());
26078
26079                        if let common::Retry::After(d) =
26080                            dlg.http_failure(&response, error.as_ref().ok())
26081                        {
26082                            sleep(d).await;
26083                            continue;
26084                        }
26085
26086                        dlg.finished(false);
26087
26088                        return Err(match error {
26089                            Ok(value) => common::Error::BadRequest(value),
26090                            _ => common::Error::Failure(response),
26091                        });
26092                    }
26093                    let response = {
26094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26095                        let encoded = common::to_string(&bytes);
26096                        match serde_json::from_str(&encoded) {
26097                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26098                            Err(error) => {
26099                                dlg.response_json_decode_error(&encoded, &error);
26100                                return Err(common::Error::JsonDecodeError(
26101                                    encoded.to_string(),
26102                                    error,
26103                                ));
26104                            }
26105                        }
26106                    };
26107
26108                    dlg.finished(true);
26109                    return Ok(response);
26110                }
26111            }
26112        }
26113    }
26114
26115    /// Required. The number or id of the project to get the effective KeyAccessJustificationsPolicyConfig. In the format of "projects/{|}"
26116    ///
26117    /// Sets the *project* path property to the given value.
26118    ///
26119    /// Even though the property as already been set when instantiating this call,
26120    /// we provide this method for API completeness.
26121    pub fn project(
26122        mut self,
26123        new_value: &str,
26124    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C> {
26125        self._project = new_value.to_string();
26126        self
26127    }
26128    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26129    /// while executing the actual API request.
26130    ///
26131    /// ````text
26132    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26133    /// ````
26134    ///
26135    /// Sets the *delegate* property to the given value.
26136    pub fn delegate(
26137        mut self,
26138        new_value: &'a mut dyn common::Delegate,
26139    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C> {
26140        self._delegate = Some(new_value);
26141        self
26142    }
26143
26144    /// Set any additional parameter of the query string used in the request.
26145    /// It should be used to set parameters which are not yet available through their own
26146    /// setters.
26147    ///
26148    /// Please note that this method must not be used to set any of the known parameters
26149    /// which have their own setter method. If done anyway, the request will fail.
26150    ///
26151    /// # Additional Parameters
26152    ///
26153    /// * *$.xgafv* (query-string) - V1 error format.
26154    /// * *access_token* (query-string) - OAuth access token.
26155    /// * *alt* (query-string) - Data format for response.
26156    /// * *callback* (query-string) - JSONP
26157    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26158    /// * *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.
26159    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26160    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26161    /// * *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.
26162    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26163    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26164    pub fn param<T>(
26165        mut self,
26166        name: T,
26167        value: T,
26168    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
26169    where
26170        T: AsRef<str>,
26171    {
26172        self._additional_params
26173            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26174        self
26175    }
26176
26177    /// Identifies the authorization scope for the method you are building.
26178    ///
26179    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26180    /// [`Scope::CloudPlatform`].
26181    ///
26182    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26183    /// tokens for more than one scope.
26184    ///
26185    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26186    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26187    /// sufficient, a read-write scope will do as well.
26188    pub fn add_scope<St>(
26189        mut self,
26190        scope: St,
26191    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
26192    where
26193        St: AsRef<str>,
26194    {
26195        self._scopes.insert(String::from(scope.as_ref()));
26196        self
26197    }
26198    /// Identifies the authorization scope(s) for the method you are building.
26199    ///
26200    /// See [`Self::add_scope()`] for details.
26201    pub fn add_scopes<I, St>(
26202        mut self,
26203        scopes: I,
26204    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C>
26205    where
26206        I: IntoIterator<Item = St>,
26207        St: AsRef<str>,
26208    {
26209        self._scopes
26210            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26211        self
26212    }
26213
26214    /// Removes all scopes, and no default scope will be used either.
26215    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26216    /// for details).
26217    pub fn clear_scopes(
26218        mut self,
26219    ) -> ProjectShowEffectiveKeyAccessJustificationsPolicyConfigCall<'a, C> {
26220        self._scopes.clear();
26221        self
26222    }
26223}
26224
26225/// Updates the KeyAccessJustificationsPolicyConfig for a given organization, folder, or project.
26226///
26227/// A builder for the *updateKajPolicyConfig* method supported by a *project* resource.
26228/// It is not used directly, but through a [`ProjectMethods`] instance.
26229///
26230/// # Example
26231///
26232/// Instantiate a resource method builder
26233///
26234/// ```test_harness,no_run
26235/// # extern crate hyper;
26236/// # extern crate hyper_rustls;
26237/// # extern crate google_cloudkms1 as cloudkms1;
26238/// use cloudkms1::api::KeyAccessJustificationsPolicyConfig;
26239/// # async fn dox() {
26240/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26241///
26242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26244/// #     .with_native_roots()
26245/// #     .unwrap()
26246/// #     .https_only()
26247/// #     .enable_http2()
26248/// #     .build();
26249///
26250/// # let executor = hyper_util::rt::TokioExecutor::new();
26251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26252/// #     secret,
26253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26254/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26255/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26256/// #     ),
26257/// # ).build().await.unwrap();
26258///
26259/// # let client = hyper_util::client::legacy::Client::builder(
26260/// #     hyper_util::rt::TokioExecutor::new()
26261/// # )
26262/// # .build(
26263/// #     hyper_rustls::HttpsConnectorBuilder::new()
26264/// #         .with_native_roots()
26265/// #         .unwrap()
26266/// #         .https_or_http()
26267/// #         .enable_http2()
26268/// #         .build()
26269/// # );
26270/// # let mut hub = CloudKMS::new(client, auth);
26271/// // As the method needs a request, you would usually fill it with the desired information
26272/// // into the respective structure. Some of the parts shown here might not be applicable !
26273/// // Values shown here are possibly random and not representative !
26274/// let mut req = KeyAccessJustificationsPolicyConfig::default();
26275///
26276/// // You can configure optional parameters by calling the respective setters at will, and
26277/// // execute the final call using `doit()`.
26278/// // Values shown here are possibly random and not representative !
26279/// let result = hub.projects().update_kaj_policy_config(req, "name")
26280///              .update_mask(FieldMask::new::<&str>(&[]))
26281///              .doit().await;
26282/// # }
26283/// ```
26284pub struct ProjectUpdateKajPolicyConfigCall<'a, C>
26285where
26286    C: 'a,
26287{
26288    hub: &'a CloudKMS<C>,
26289    _request: KeyAccessJustificationsPolicyConfig,
26290    _name: String,
26291    _update_mask: Option<common::FieldMask>,
26292    _delegate: Option<&'a mut dyn common::Delegate>,
26293    _additional_params: HashMap<String, String>,
26294    _scopes: BTreeSet<String>,
26295}
26296
26297impl<'a, C> common::CallBuilder for ProjectUpdateKajPolicyConfigCall<'a, C> {}
26298
26299impl<'a, C> ProjectUpdateKajPolicyConfigCall<'a, C>
26300where
26301    C: common::Connector,
26302{
26303    /// Perform the operation you have build so far.
26304    pub async fn doit(
26305        mut self,
26306    ) -> common::Result<(common::Response, KeyAccessJustificationsPolicyConfig)> {
26307        use std::borrow::Cow;
26308        use std::io::{Read, Seek};
26309
26310        use common::{url::Params, ToParts};
26311        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26312
26313        let mut dd = common::DefaultDelegate;
26314        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26315        dlg.begin(common::MethodInfo {
26316            id: "cloudkms.projects.updateKajPolicyConfig",
26317            http_method: hyper::Method::PATCH,
26318        });
26319
26320        for &field in ["alt", "name", "updateMask"].iter() {
26321            if self._additional_params.contains_key(field) {
26322                dlg.finished(false);
26323                return Err(common::Error::FieldClash(field));
26324            }
26325        }
26326
26327        let mut params = Params::with_capacity(5 + self._additional_params.len());
26328        params.push("name", self._name);
26329        if let Some(value) = self._update_mask.as_ref() {
26330            params.push("updateMask", value.to_string());
26331        }
26332
26333        params.extend(self._additional_params.iter());
26334
26335        params.push("alt", "json");
26336        let mut url = self.hub._base_url.clone() + "v1/{+name}";
26337        if self._scopes.is_empty() {
26338            self._scopes
26339                .insert(Scope::CloudPlatform.as_ref().to_string());
26340        }
26341
26342        #[allow(clippy::single_element_loop)]
26343        for &(find_this, param_name) in [("{+name}", "name")].iter() {
26344            url = params.uri_replacement(url, param_name, find_this, true);
26345        }
26346        {
26347            let to_remove = ["name"];
26348            params.remove_params(&to_remove);
26349        }
26350
26351        let url = params.parse_with_url(&url);
26352
26353        let mut json_mime_type = mime::APPLICATION_JSON;
26354        let mut request_value_reader = {
26355            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26356            common::remove_json_null_values(&mut value);
26357            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26358            serde_json::to_writer(&mut dst, &value).unwrap();
26359            dst
26360        };
26361        let request_size = request_value_reader
26362            .seek(std::io::SeekFrom::End(0))
26363            .unwrap();
26364        request_value_reader
26365            .seek(std::io::SeekFrom::Start(0))
26366            .unwrap();
26367
26368        loop {
26369            let token = match self
26370                .hub
26371                .auth
26372                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26373                .await
26374            {
26375                Ok(token) => token,
26376                Err(e) => match dlg.token(e) {
26377                    Ok(token) => token,
26378                    Err(e) => {
26379                        dlg.finished(false);
26380                        return Err(common::Error::MissingToken(e));
26381                    }
26382                },
26383            };
26384            request_value_reader
26385                .seek(std::io::SeekFrom::Start(0))
26386                .unwrap();
26387            let mut req_result = {
26388                let client = &self.hub.client;
26389                dlg.pre_request();
26390                let mut req_builder = hyper::Request::builder()
26391                    .method(hyper::Method::PATCH)
26392                    .uri(url.as_str())
26393                    .header(USER_AGENT, self.hub._user_agent.clone());
26394
26395                if let Some(token) = token.as_ref() {
26396                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26397                }
26398
26399                let request = req_builder
26400                    .header(CONTENT_TYPE, json_mime_type.to_string())
26401                    .header(CONTENT_LENGTH, request_size as u64)
26402                    .body(common::to_body(
26403                        request_value_reader.get_ref().clone().into(),
26404                    ));
26405
26406                client.request(request.unwrap()).await
26407            };
26408
26409            match req_result {
26410                Err(err) => {
26411                    if let common::Retry::After(d) = dlg.http_error(&err) {
26412                        sleep(d).await;
26413                        continue;
26414                    }
26415                    dlg.finished(false);
26416                    return Err(common::Error::HttpError(err));
26417                }
26418                Ok(res) => {
26419                    let (mut parts, body) = res.into_parts();
26420                    let mut body = common::Body::new(body);
26421                    if !parts.status.is_success() {
26422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26423                        let error = serde_json::from_str(&common::to_string(&bytes));
26424                        let response = common::to_response(parts, bytes.into());
26425
26426                        if let common::Retry::After(d) =
26427                            dlg.http_failure(&response, error.as_ref().ok())
26428                        {
26429                            sleep(d).await;
26430                            continue;
26431                        }
26432
26433                        dlg.finished(false);
26434
26435                        return Err(match error {
26436                            Ok(value) => common::Error::BadRequest(value),
26437                            _ => common::Error::Failure(response),
26438                        });
26439                    }
26440                    let response = {
26441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26442                        let encoded = common::to_string(&bytes);
26443                        match serde_json::from_str(&encoded) {
26444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26445                            Err(error) => {
26446                                dlg.response_json_decode_error(&encoded, &error);
26447                                return Err(common::Error::JsonDecodeError(
26448                                    encoded.to_string(),
26449                                    error,
26450                                ));
26451                            }
26452                        }
26453                    };
26454
26455                    dlg.finished(true);
26456                    return Ok(response);
26457                }
26458            }
26459        }
26460    }
26461
26462    ///
26463    /// Sets the *request* property to the given value.
26464    ///
26465    /// Even though the property as already been set when instantiating this call,
26466    /// we provide this method for API completeness.
26467    pub fn request(
26468        mut self,
26469        new_value: KeyAccessJustificationsPolicyConfig,
26470    ) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
26471        self._request = new_value;
26472        self
26473    }
26474    /// Identifier. The resource name for this KeyAccessJustificationsPolicyConfig in the format of "{organizations|folders|projects}/*/kajPolicyConfig".
26475    ///
26476    /// Sets the *name* path property to the given value.
26477    ///
26478    /// Even though the property as already been set when instantiating this call,
26479    /// we provide this method for API completeness.
26480    pub fn name(mut self, new_value: &str) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
26481        self._name = new_value.to_string();
26482        self
26483    }
26484    /// Optional. The list of fields to update.
26485    ///
26486    /// Sets the *update mask* query property to the given value.
26487    pub fn update_mask(
26488        mut self,
26489        new_value: common::FieldMask,
26490    ) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
26491        self._update_mask = Some(new_value);
26492        self
26493    }
26494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26495    /// while executing the actual API request.
26496    ///
26497    /// ````text
26498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26499    /// ````
26500    ///
26501    /// Sets the *delegate* property to the given value.
26502    pub fn delegate(
26503        mut self,
26504        new_value: &'a mut dyn common::Delegate,
26505    ) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
26506        self._delegate = Some(new_value);
26507        self
26508    }
26509
26510    /// Set any additional parameter of the query string used in the request.
26511    /// It should be used to set parameters which are not yet available through their own
26512    /// setters.
26513    ///
26514    /// Please note that this method must not be used to set any of the known parameters
26515    /// which have their own setter method. If done anyway, the request will fail.
26516    ///
26517    /// # Additional Parameters
26518    ///
26519    /// * *$.xgafv* (query-string) - V1 error format.
26520    /// * *access_token* (query-string) - OAuth access token.
26521    /// * *alt* (query-string) - Data format for response.
26522    /// * *callback* (query-string) - JSONP
26523    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26524    /// * *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.
26525    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26526    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26527    /// * *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.
26528    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26529    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26530    pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateKajPolicyConfigCall<'a, C>
26531    where
26532        T: AsRef<str>,
26533    {
26534        self._additional_params
26535            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26536        self
26537    }
26538
26539    /// Identifies the authorization scope for the method you are building.
26540    ///
26541    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26542    /// [`Scope::CloudPlatform`].
26543    ///
26544    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26545    /// tokens for more than one scope.
26546    ///
26547    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26548    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26549    /// sufficient, a read-write scope will do as well.
26550    pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateKajPolicyConfigCall<'a, C>
26551    where
26552        St: AsRef<str>,
26553    {
26554        self._scopes.insert(String::from(scope.as_ref()));
26555        self
26556    }
26557    /// Identifies the authorization scope(s) for the method you are building.
26558    ///
26559    /// See [`Self::add_scope()`] for details.
26560    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateKajPolicyConfigCall<'a, C>
26561    where
26562        I: IntoIterator<Item = St>,
26563        St: AsRef<str>,
26564    {
26565        self._scopes
26566            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26567        self
26568    }
26569
26570    /// Removes all scopes, and no default scope will be used either.
26571    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26572    /// for details).
26573    pub fn clear_scopes(mut self) -> ProjectUpdateKajPolicyConfigCall<'a, C> {
26574        self._scopes.clear();
26575        self
26576    }
26577}