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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
66/// secret,
67/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
68/// ).build().await.unwrap();
69///
70/// let client = hyper_util::client::legacy::Client::builder(
71/// hyper_util::rt::TokioExecutor::new()
72/// )
73/// .build(
74/// hyper_rustls::HttpsConnectorBuilder::new()
75/// .with_native_roots()
76/// .unwrap()
77/// .https_or_http()
78/// .enable_http1()
79/// .build()
80/// );
81/// let mut hub = CloudKMS::new(client, auth);
82/// // You can configure optional parameters by calling the respective setters at will, and
83/// // execute the final call using `doit()`.
84/// // Values shown here are possibly random and not representative !
85/// let result = hub.projects().locations_ekm_config_get_iam_policy("resource")
86/// .options_requested_policy_version(-27)
87/// .doit().await;
88///
89/// match result {
90/// Err(e) => match e {
91/// // The Error enum provides details about what exactly happened.
92/// // You can also just use its `Debug`, `Display` or `Error` traits
93/// Error::HttpError(_)
94/// |Error::Io(_)
95/// |Error::MissingAPIKey
96/// |Error::MissingToken(_)
97/// |Error::Cancelled
98/// |Error::UploadSizeLimitExceeded(_, _)
99/// |Error::Failure(_)
100/// |Error::BadRequest(_)
101/// |Error::FieldClash(_)
102/// |Error::JsonDecodeError(_, _) => println!("{}", e),
103/// },
104/// Ok(res) => println!("Success: {:?}", res),
105/// }
106/// # }
107/// ```
108#[derive(Clone)]
109pub struct CloudKMS<C> {
110 pub client: common::Client<C>,
111 pub auth: Box<dyn common::GetToken>,
112 _user_agent: String,
113 _base_url: String,
114 _root_url: String,
115}
116
117impl<C> common::Hub for CloudKMS<C> {}
118
119impl<'a, C> CloudKMS<C> {
120 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudKMS<C> {
121 CloudKMS {
122 client,
123 auth: Box::new(auth),
124 _user_agent: "google-api-rust-client/6.0.0".to_string(),
125 _base_url: "https://cloudkms.googleapis.com/".to_string(),
126 _root_url: "https://cloudkms.googleapis.com/".to_string(),
127 }
128 }
129
130 pub fn folders(&'a self) -> FolderMethods<'a, C> {
131 FolderMethods { hub: self }
132 }
133 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
134 ProjectMethods { hub: self }
135 }
136
137 /// Set the user-agent header field to use in all requests to the server.
138 /// It defaults to `google-api-rust-client/6.0.0`.
139 ///
140 /// Returns the previously set user-agent.
141 pub fn user_agent(&mut self, agent_name: String) -> String {
142 std::mem::replace(&mut self._user_agent, agent_name)
143 }
144
145 /// Set the base url to use in all requests to the server.
146 /// It defaults to `https://cloudkms.googleapis.com/`.
147 ///
148 /// Returns the previously set base url.
149 pub fn base_url(&mut self, new_base_url: String) -> String {
150 std::mem::replace(&mut self._base_url, new_base_url)
151 }
152
153 /// Set the root url to use in all requests to the server.
154 /// It defaults to `https://cloudkms.googleapis.com/`.
155 ///
156 /// Returns the previously set root url.
157 pub fn root_url(&mut self, new_root_url: String) -> String {
158 std::mem::replace(&mut self._root_url, new_root_url)
159 }
160}
161
162// ############
163// SCHEMAS ###
164// ##########
165/// Request message for KeyManagementService.AsymmetricDecrypt.
166///
167/// # Activities
168///
169/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
170/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
171///
172/// * [locations key rings crypto keys crypto key versions asymmetric decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall) (request)
173#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
174#[serde_with::serde_as]
175#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
176pub struct AsymmetricDecryptRequest {
177 /// Required. The data encrypted with the named CryptoKeyVersion's public key using OAEP.
178 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
179 pub ciphertext: Option<Vec<u8>>,
180 /// 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.
181 #[serde(rename = "ciphertextCrc32c")]
182 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
183 pub ciphertext_crc32c: Option<i64>,
184}
185
186impl common::RequestValue for AsymmetricDecryptRequest {}
187
188/// Response message for KeyManagementService.AsymmetricDecrypt.
189///
190/// # Activities
191///
192/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
193/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
194///
195/// * [locations key rings crypto keys crypto key versions asymmetric decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall) (response)
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct AsymmetricDecryptResponse {
200 /// The decrypted data originally encrypted with the matching public key.
201 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
202 pub plaintext: Option<Vec<u8>>,
203 /// 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.
204 #[serde(rename = "plaintextCrc32c")]
205 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
206 pub plaintext_crc32c: Option<i64>,
207 /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
208 #[serde(rename = "protectionLevel")]
209 pub protection_level: Option<String>,
210 /// 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.
211 #[serde(rename = "verifiedCiphertextCrc32c")]
212 pub verified_ciphertext_crc32c: Option<bool>,
213}
214
215impl common::ResponseResult for AsymmetricDecryptResponse {}
216
217/// Request message for KeyManagementService.AsymmetricSign.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [locations key rings crypto keys crypto key versions asymmetric sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall) (request)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct AsymmetricSignRequest {
229 /// Optional. The data to sign. It can't be supplied if AsymmetricSignRequest.digest is supplied.
230 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
231 pub data: Option<Vec<u8>>,
232 /// 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.
233 #[serde(rename = "dataCrc32c")]
234 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
235 pub data_crc32c: Option<i64>,
236 /// 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.
237 pub digest: Option<Digest>,
238 /// 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.
239 #[serde(rename = "digestCrc32c")]
240 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
241 pub digest_crc32c: Option<i64>,
242}
243
244impl common::RequestValue for AsymmetricSignRequest {}
245
246/// Response message for KeyManagementService.AsymmetricSign.
247///
248/// # Activities
249///
250/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
251/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
252///
253/// * [locations key rings crypto keys crypto key versions asymmetric sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall) (response)
254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
255#[serde_with::serde_as]
256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
257pub struct AsymmetricSignResponse {
258 /// The resource name of the CryptoKeyVersion used for signing. Check this field to verify that the intended resource was used for signing.
259 pub name: Option<String>,
260 /// The ProtectionLevel of the CryptoKeyVersion used for signing.
261 #[serde(rename = "protectionLevel")]
262 pub protection_level: Option<String>,
263 /// The created signature.
264 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
265 pub signature: Option<Vec<u8>>,
266 /// 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.
267 #[serde(rename = "signatureCrc32c")]
268 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
269 pub signature_crc32c: Option<i64>,
270 /// 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.
271 #[serde(rename = "verifiedDataCrc32c")]
272 pub verified_data_crc32c: Option<bool>,
273 /// 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.
274 #[serde(rename = "verifiedDigestCrc32c")]
275 pub verified_digest_crc32c: Option<bool>,
276}
277
278impl common::ResponseResult for AsymmetricSignResponse {}
279
280/// 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.
281///
282/// This type is not used in any activity, and only used as *part* of another schema.
283///
284#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
285#[serde_with::serde_as]
286#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
287pub struct AuditConfig {
288 /// The configuration for logging of each type of permission.
289 #[serde(rename = "auditLogConfigs")]
290 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
291 /// 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.
292 pub service: Option<String>,
293}
294
295impl common::Part for AuditConfig {}
296
297/// 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.
298///
299/// This type is not used in any activity, and only used as *part* of another schema.
300///
301#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
302#[serde_with::serde_as]
303#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
304pub struct AuditLogConfig {
305 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
306 #[serde(rename = "exemptedMembers")]
307 pub exempted_members: Option<Vec<String>>,
308 /// The log type that this config enables.
309 #[serde(rename = "logType")]
310 pub log_type: Option<String>,
311}
312
313impl common::Part for AuditLogConfig {}
314
315/// Cloud KMS Autokey configuration for a folder.
316///
317/// # Activities
318///
319/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
320/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
321///
322/// * [get autokey config folders](FolderGetAutokeyConfigCall) (response)
323/// * [update autokey config folders](FolderUpdateAutokeyConfigCall) (request|response)
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct AutokeyConfig {
328 /// 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.
329 #[serde(rename = "keyProject")]
330 pub key_project: Option<String>,
331 /// Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
332 pub name: Option<String>,
333}
334
335impl common::RequestValue for AutokeyConfig {}
336impl common::ResponseResult for AutokeyConfig {}
337
338/// Associates `members`, or principals, with a `role`.
339///
340/// This type is not used in any activity, and only used as *part* of another schema.
341///
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct Binding {
346 /// 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).
347 pub condition: Option<Expr>,
348 /// 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`.
349 pub members: Option<Vec<String>>,
350 /// 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).
351 pub role: Option<String>,
352}
353
354impl common::Part for Binding {}
355
356/// A Certificate represents an X.509 certificate used to authenticate HTTPS connections to EKM replicas.
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 Certificate {
364 /// Output only. The issuer distinguished name in RFC 2253 format. Only present if parsed is true.
365 pub issuer: Option<String>,
366 /// Output only. The certificate is not valid after this time. Only present if parsed is true.
367 #[serde(rename = "notAfterTime")]
368 pub not_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
369 /// Output only. The certificate is not valid before this time. Only present if parsed is true.
370 #[serde(rename = "notBeforeTime")]
371 pub not_before_time: Option<chrono::DateTime<chrono::offset::Utc>>,
372 /// Output only. True if the certificate was parsed successfully.
373 pub parsed: Option<bool>,
374 /// Required. The raw certificate bytes in DER format.
375 #[serde(rename = "rawDer")]
376 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
377 pub raw_der: Option<Vec<u8>>,
378 /// Output only. The certificate serial number as a hex string. Only present if parsed is true.
379 #[serde(rename = "serialNumber")]
380 pub serial_number: Option<String>,
381 /// Output only. The SHA-256 certificate fingerprint as a hex string. Only present if parsed is true.
382 #[serde(rename = "sha256Fingerprint")]
383 pub sha256_fingerprint: Option<String>,
384 /// Output only. The subject distinguished name in RFC 2253 format. Only present if parsed is true.
385 pub subject: Option<String>,
386 /// Output only. The subject Alternative DNS names. Only present if parsed is true.
387 #[serde(rename = "subjectAlternativeDnsNames")]
388 pub subject_alternative_dns_names: Option<Vec<String>>,
389}
390
391impl common::Part for Certificate {}
392
393/// 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.
394///
395/// This type is not used in any activity, and only used as *part* of another schema.
396///
397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
398#[serde_with::serde_as]
399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
400pub struct CertificateChains {
401 /// Cavium certificate chain corresponding to the attestation.
402 #[serde(rename = "caviumCerts")]
403 pub cavium_certs: Option<Vec<String>>,
404 /// Google card certificate chain corresponding to the attestation.
405 #[serde(rename = "googleCardCerts")]
406 pub google_card_certs: Option<Vec<String>>,
407 /// Google partition certificate chain corresponding to the attestation.
408 #[serde(rename = "googlePartitionCerts")]
409 pub google_partition_certs: Option<Vec<String>>,
410}
411
412impl common::Part for CertificateChains {}
413
414/// 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.
415///
416/// # Activities
417///
418/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
419/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
420///
421/// * [locations key rings crypto keys create projects](ProjectLocationKeyRingCryptoKeyCreateCall) (request|response)
422/// * [locations key rings crypto keys get projects](ProjectLocationKeyRingCryptoKeyGetCall) (response)
423/// * [locations key rings crypto keys patch projects](ProjectLocationKeyRingCryptoKeyPatchCall) (request|response)
424/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (response)
425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
426#[serde_with::serde_as]
427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
428pub struct CryptoKey {
429 /// Output only. The time at which this CryptoKey was created.
430 #[serde(rename = "createTime")]
431 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
432 /// 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/*`. Note, this list is non-exhaustive and may apply to additional ProtectionLevels in the future.
433 #[serde(rename = "cryptoKeyBackend")]
434 pub crypto_key_backend: Option<String>,
435 /// 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 24 hours.
436 #[serde(rename = "destroyScheduledDuration")]
437 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
438 pub destroy_scheduled_duration: Option<chrono::Duration>,
439 /// Immutable. Whether this key may contain imported versions only.
440 #[serde(rename = "importOnly")]
441 pub import_only: Option<bool>,
442 /// 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.
443 #[serde(rename = "keyAccessJustificationsPolicy")]
444 pub key_access_justifications_policy: Option<KeyAccessJustificationsPolicy>,
445 /// Labels with user-defined metadata. For more information, see [Labeling Keys](https://cloud.google.com/kms/docs/labeling-keys).
446 pub labels: Option<HashMap<String, String>>,
447 /// Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
448 pub name: Option<String>,
449 /// 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.
450 #[serde(rename = "nextRotationTime")]
451 pub next_rotation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
452 /// 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.
453 pub primary: Option<CryptoKeyVersion>,
454 /// Immutable. The immutable purpose of this CryptoKey.
455 pub purpose: Option<String>,
456 /// 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.
457 #[serde(rename = "rotationPeriod")]
458 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
459 pub rotation_period: Option<chrono::Duration>,
460 /// 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.
461 #[serde(rename = "versionTemplate")]
462 pub version_template: Option<CryptoKeyVersionTemplate>,
463}
464
465impl common::RequestValue for CryptoKey {}
466impl common::ResponseResult for CryptoKey {}
467
468/// 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.
469///
470/// # Activities
471///
472/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
473/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
474///
475/// * [locations key rings crypto keys crypto key versions create projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall) (request|response)
476/// * [locations key rings crypto keys crypto key versions destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (response)
477/// * [locations key rings crypto keys crypto key versions get projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall) (response)
478/// * [locations key rings crypto keys crypto key versions import projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall) (response)
479/// * [locations key rings crypto keys crypto key versions patch projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall) (request|response)
480/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (response)
481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
482#[serde_with::serde_as]
483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
484pub struct CryptoKeyVersion {
485 /// Output only. The CryptoKeyVersionAlgorithm that this CryptoKeyVersion supports.
486 pub algorithm: Option<String>,
487 /// 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.
488 pub attestation: Option<KeyOperationAttestation>,
489 /// Output only. The time at which this CryptoKeyVersion was created.
490 #[serde(rename = "createTime")]
491 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
492 /// Output only. The time this CryptoKeyVersion's key material was destroyed. Only present if state is DESTROYED.
493 #[serde(rename = "destroyEventTime")]
494 pub destroy_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
495 /// Output only. The time this CryptoKeyVersion's key material is scheduled for destruction. Only present if state is DESTROY_SCHEDULED.
496 #[serde(rename = "destroyTime")]
497 pub destroy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
498 /// Output only. The root cause of the most recent external destruction failure. Only present if state is EXTERNAL_DESTRUCTION_FAILED.
499 #[serde(rename = "externalDestructionFailureReason")]
500 pub external_destruction_failure_reason: Option<String>,
501 /// ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
502 #[serde(rename = "externalProtectionLevelOptions")]
503 pub external_protection_level_options: Option<ExternalProtectionLevelOptions>,
504 /// Output only. The time this CryptoKeyVersion's key material was generated.
505 #[serde(rename = "generateTime")]
506 pub generate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
507 /// Output only. The root cause of the most recent generation failure. Only present if state is GENERATION_FAILED.
508 #[serde(rename = "generationFailureReason")]
509 pub generation_failure_reason: Option<String>,
510 /// Output only. The root cause of the most recent import failure. Only present if state is IMPORT_FAILED.
511 #[serde(rename = "importFailureReason")]
512 pub import_failure_reason: Option<String>,
513 /// 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.
514 #[serde(rename = "importJob")]
515 pub import_job: Option<String>,
516 /// Output only. The time at which this CryptoKeyVersion's key material was most recently imported.
517 #[serde(rename = "importTime")]
518 pub import_time: Option<chrono::DateTime<chrono::offset::Utc>>,
519 /// Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
520 pub name: Option<String>,
521 /// Output only. The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion.
522 #[serde(rename = "protectionLevel")]
523 pub protection_level: Option<String>,
524 /// Output only. Whether or not this key version is eligible for reimport, by being specified as a target in ImportCryptoKeyVersionRequest.crypto_key_version.
525 #[serde(rename = "reimportEligible")]
526 pub reimport_eligible: Option<bool>,
527 /// The current state of the CryptoKeyVersion.
528 pub state: Option<String>,
529}
530
531impl common::RequestValue for CryptoKeyVersion {}
532impl common::ResponseResult for CryptoKeyVersion {}
533
534/// A CryptoKeyVersionTemplate specifies the properties to use when creating a new CryptoKeyVersion, either manually with CreateCryptoKeyVersion or automatically as a result of auto-rotation.
535///
536/// This type is not used in any activity, and only used as *part* of another schema.
537///
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct CryptoKeyVersionTemplate {
542 /// 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.
543 pub algorithm: Option<String>,
544 /// ProtectionLevel to use when creating a CryptoKeyVersion based on this template. Immutable. Defaults to SOFTWARE.
545 #[serde(rename = "protectionLevel")]
546 pub protection_level: Option<String>,
547}
548
549impl common::Part for CryptoKeyVersionTemplate {}
550
551/// Request message for KeyManagementService.Decrypt.
552///
553/// # Activities
554///
555/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
556/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
557///
558/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (request)
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct DecryptRequest {
563 /// Optional. Optional data that must match the data originally supplied in EncryptRequest.additional_authenticated_data.
564 #[serde(rename = "additionalAuthenticatedData")]
565 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
566 pub additional_authenticated_data: Option<Vec<u8>>,
567 /// 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.
568 #[serde(rename = "additionalAuthenticatedDataCrc32c")]
569 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
570 pub additional_authenticated_data_crc32c: Option<i64>,
571 /// Required. The encrypted data originally returned in EncryptResponse.ciphertext.
572 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
573 pub ciphertext: Option<Vec<u8>>,
574 /// 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.
575 #[serde(rename = "ciphertextCrc32c")]
576 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
577 pub ciphertext_crc32c: Option<i64>,
578}
579
580impl common::RequestValue for DecryptRequest {}
581
582/// Response message for KeyManagementService.Decrypt.
583///
584/// # Activities
585///
586/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
587/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
588///
589/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (response)
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct DecryptResponse {
594 /// The decrypted data originally supplied in EncryptRequest.plaintext.
595 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
596 pub plaintext: Option<Vec<u8>>,
597 /// 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.
598 #[serde(rename = "plaintextCrc32c")]
599 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
600 pub plaintext_crc32c: Option<i64>,
601 /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
602 #[serde(rename = "protectionLevel")]
603 pub protection_level: Option<String>,
604 /// Whether the Decryption was performed using the primary key version.
605 #[serde(rename = "usedPrimary")]
606 pub used_primary: Option<bool>,
607}
608
609impl common::ResponseResult for DecryptResponse {}
610
611/// Request message for KeyManagementService.DestroyCryptoKeyVersion.
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 destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (request)
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct DestroyCryptoKeyVersionRequest {
623 _never_set: Option<bool>,
624}
625
626impl common::RequestValue for DestroyCryptoKeyVersionRequest {}
627
628/// A Digest holds a cryptographic message digest.
629///
630/// This type is not used in any activity, and only used as *part* of another schema.
631///
632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
633#[serde_with::serde_as]
634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
635pub struct Digest {
636 /// A message digest produced with the SHA-256 algorithm.
637 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
638 pub sha256: Option<Vec<u8>>,
639 /// A message digest produced with the SHA-384 algorithm.
640 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
641 pub sha384: Option<Vec<u8>>,
642 /// A message digest produced with the SHA-512 algorithm.
643 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
644 pub sha512: Option<Vec<u8>>,
645}
646
647impl common::Part for Digest {}
648
649/// 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.
650///
651/// # Activities
652///
653/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
654/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
655///
656/// * [locations get ekm config projects](ProjectLocationGetEkmConfigCall) (response)
657/// * [locations update ekm config projects](ProjectLocationUpdateEkmConfigCall) (request|response)
658#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
659#[serde_with::serde_as]
660#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
661pub struct EkmConfig {
662 /// Optional. Resource name of the default EkmConnection. Setting this field to the empty string removes the default.
663 #[serde(rename = "defaultEkmConnection")]
664 pub default_ekm_connection: Option<String>,
665 /// Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
666 pub name: Option<String>,
667}
668
669impl common::RequestValue for EkmConfig {}
670impl common::ResponseResult for EkmConfig {}
671
672/// 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.
673///
674/// # Activities
675///
676/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
677/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
678///
679/// * [locations ekm connections create projects](ProjectLocationEkmConnectionCreateCall) (request|response)
680/// * [locations ekm connections get projects](ProjectLocationEkmConnectionGetCall) (response)
681/// * [locations ekm connections patch projects](ProjectLocationEkmConnectionPatchCall) (request|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 EkmConnection {
686 /// Output only. The time at which the EkmConnection was created.
687 #[serde(rename = "createTime")]
688 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
689 /// Optional. Identifies the EKM Crypto Space that this EkmConnection maps to. Note: This field is required if KeyManagementMode is CLOUD_KMS.
690 #[serde(rename = "cryptoSpacePath")]
691 pub crypto_space_path: Option<String>,
692 /// Optional. Etag of the currently stored EkmConnection.
693 pub etag: Option<String>,
694 /// Optional. Describes who can perform control plane operations on the EKM. If unset, this defaults to MANUAL.
695 #[serde(rename = "keyManagementMode")]
696 pub key_management_mode: Option<String>,
697 /// Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
698 pub name: Option<String>,
699 /// 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.
700 #[serde(rename = "serviceResolvers")]
701 pub service_resolvers: Option<Vec<ServiceResolver>>,
702}
703
704impl common::RequestValue for EkmConnection {}
705impl common::ResponseResult for EkmConnection {}
706
707/// Request message for KeyManagementService.Encrypt.
708///
709/// # Activities
710///
711/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
712/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
713///
714/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (request)
715#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
716#[serde_with::serde_as]
717#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
718pub struct EncryptRequest {
719 /// 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.
720 #[serde(rename = "additionalAuthenticatedData")]
721 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
722 pub additional_authenticated_data: Option<Vec<u8>>,
723 /// 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.
724 #[serde(rename = "additionalAuthenticatedDataCrc32c")]
725 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
726 pub additional_authenticated_data_crc32c: Option<i64>,
727 /// 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.
728 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
729 pub plaintext: Option<Vec<u8>>,
730 /// 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.
731 #[serde(rename = "plaintextCrc32c")]
732 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
733 pub plaintext_crc32c: Option<i64>,
734}
735
736impl common::RequestValue for EncryptRequest {}
737
738/// Response message for KeyManagementService.Encrypt.
739///
740/// # Activities
741///
742/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
743/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
744///
745/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (response)
746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
747#[serde_with::serde_as]
748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
749pub struct EncryptResponse {
750 /// The encrypted data.
751 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
752 pub ciphertext: Option<Vec<u8>>,
753 /// 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.
754 #[serde(rename = "ciphertextCrc32c")]
755 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
756 pub ciphertext_crc32c: Option<i64>,
757 /// The resource name of the CryptoKeyVersion used in encryption. Check this field to verify that the intended resource was used for encryption.
758 pub name: Option<String>,
759 /// The ProtectionLevel of the CryptoKeyVersion used in encryption.
760 #[serde(rename = "protectionLevel")]
761 pub protection_level: Option<String>,
762 /// 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.
763 #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
764 pub verified_additional_authenticated_data_crc32c: Option<bool>,
765 /// 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.
766 #[serde(rename = "verifiedPlaintextCrc32c")]
767 pub verified_plaintext_crc32c: Option<bool>,
768}
769
770impl common::ResponseResult for EncryptResponse {}
771
772/// 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.
773///
774/// This type is not used in any activity, and only used as *part* of another schema.
775///
776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
777#[serde_with::serde_as]
778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
779pub struct Expr {
780 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
781 pub description: Option<String>,
782 /// Textual representation of an expression in Common Expression Language syntax.
783 pub expression: Option<String>,
784 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
785 pub location: Option<String>,
786 /// 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.
787 pub title: Option<String>,
788}
789
790impl common::Part for Expr {}
791
792/// ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
793///
794/// This type is not used in any activity, and only used as *part* of another schema.
795///
796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
797#[serde_with::serde_as]
798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
799pub struct ExternalProtectionLevelOptions {
800 /// 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.
801 #[serde(rename = "ekmConnectionKeyPath")]
802 pub ekm_connection_key_path: Option<String>,
803 /// The URI for an external resource that this CryptoKeyVersion represents.
804 #[serde(rename = "externalKeyUri")]
805 pub external_key_uri: Option<String>,
806}
807
808impl common::Part for ExternalProtectionLevelOptions {}
809
810/// Request message for KeyManagementService.GenerateRandomBytes.
811///
812/// # Activities
813///
814/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
815/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
816///
817/// * [locations generate random bytes projects](ProjectLocationGenerateRandomByteCall) (request)
818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
819#[serde_with::serde_as]
820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
821pub struct GenerateRandomBytesRequest {
822 /// The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes.
823 #[serde(rename = "lengthBytes")]
824 pub length_bytes: Option<i32>,
825 /// The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported.
826 #[serde(rename = "protectionLevel")]
827 pub protection_level: Option<String>,
828}
829
830impl common::RequestValue for GenerateRandomBytesRequest {}
831
832/// Response message for KeyManagementService.GenerateRandomBytes.
833///
834/// # Activities
835///
836/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
837/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
838///
839/// * [locations generate random bytes projects](ProjectLocationGenerateRandomByteCall) (response)
840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
841#[serde_with::serde_as]
842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
843pub struct GenerateRandomBytesResponse {
844 /// The generated data.
845 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
846 pub data: Option<Vec<u8>>,
847 /// 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.
848 #[serde(rename = "dataCrc32c")]
849 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
850 pub data_crc32c: Option<i64>,
851}
852
853impl common::ResponseResult for GenerateRandomBytesResponse {}
854
855/// Request message for KeyManagementService.ImportCryptoKeyVersion.
856///
857/// # Activities
858///
859/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
860/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
861///
862/// * [locations key rings crypto keys crypto key versions import projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall) (request)
863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
864#[serde_with::serde_as]
865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
866pub struct ImportCryptoKeyVersionRequest {
867 /// Required. The algorithm of the key being imported. This does not need to match the version_template of the CryptoKey this version imports into.
868 pub algorithm: Option<String>,
869 /// 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.
870 #[serde(rename = "cryptoKeyVersion")]
871 pub crypto_key_version: Option<String>,
872 /// Required. The name of the ImportJob that was used to wrap this key material.
873 #[serde(rename = "importJob")]
874 pub import_job: Option<String>,
875 /// 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.
876 #[serde(rename = "rsaAesWrappedKey")]
877 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
878 pub rsa_aes_wrapped_key: Option<Vec<u8>>,
879 /// 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.
880 #[serde(rename = "wrappedKey")]
881 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
882 pub wrapped_key: Option<Vec<u8>>,
883}
884
885impl common::RequestValue for ImportCryptoKeyVersionRequest {}
886
887/// 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).
888///
889/// # Activities
890///
891/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
892/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
893///
894/// * [locations key rings import jobs create projects](ProjectLocationKeyRingImportJobCreateCall) (request|response)
895/// * [locations key rings import jobs get projects](ProjectLocationKeyRingImportJobGetCall) (response)
896#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
897#[serde_with::serde_as]
898#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
899pub struct ImportJob {
900 /// 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.
901 pub attestation: Option<KeyOperationAttestation>,
902 /// Output only. The time at which this ImportJob was created.
903 #[serde(rename = "createTime")]
904 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
905 /// Output only. The time this ImportJob expired. Only present if state is EXPIRED.
906 #[serde(rename = "expireEventTime")]
907 pub expire_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
908 /// Output only. The time at which this ImportJob is scheduled for expiration and can no longer be used to import key material.
909 #[serde(rename = "expireTime")]
910 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
911 /// Output only. The time this ImportJob's key material was generated.
912 #[serde(rename = "generateTime")]
913 pub generate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
914 /// Required. Immutable. The wrapping method to be used for incoming key material.
915 #[serde(rename = "importMethod")]
916 pub import_method: Option<String>,
917 /// Output only. The resource name for this ImportJob in the format `projects/*/locations/*/keyRings/*/importJobs/*`.
918 pub name: Option<String>,
919 /// 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.
920 #[serde(rename = "protectionLevel")]
921 pub protection_level: Option<String>,
922 /// Output only. The public key with which to wrap key material prior to import. Only returned if state is ACTIVE.
923 #[serde(rename = "publicKey")]
924 pub public_key: Option<WrappingPublicKey>,
925 /// Output only. The current state of the ImportJob, indicating if it can be used.
926 pub state: Option<String>,
927}
928
929impl common::RequestValue for ImportJob {}
930impl common::ResponseResult for ImportJob {}
931
932/// A KeyAccessJustificationsPolicy specifies zero or more allowed AccessReason values for encrypt, decrypt, and sign operations on a CryptoKey.
933///
934/// This type is not used in any activity, and only used as *part* of another schema.
935///
936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
937#[serde_with::serde_as]
938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
939pub struct KeyAccessJustificationsPolicy {
940 /// 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.
941 #[serde(rename = "allowedAccessReasons")]
942 pub allowed_access_reasons: Option<Vec<String>>,
943}
944
945impl common::Part for KeyAccessJustificationsPolicy {}
946
947/// Resource-oriented representation of a request to Cloud KMS Autokey and the resulting provisioning of a CryptoKey.
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 handles create projects](ProjectLocationKeyHandleCreateCall) (request)
955/// * [locations key handles get projects](ProjectLocationKeyHandleGetCall) (response)
956#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
957#[serde_with::serde_as]
958#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
959pub struct KeyHandle {
960 /// 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.
961 #[serde(rename = "kmsKey")]
962 pub kms_key: Option<String>,
963 /// Identifier. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
964 pub name: Option<String>,
965 /// 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.
966 #[serde(rename = "resourceTypeSelector")]
967 pub resource_type_selector: Option<String>,
968}
969
970impl common::RequestValue for KeyHandle {}
971impl common::ResponseResult for KeyHandle {}
972
973/// Contains an HSM-generated attestation about a key operation. For more information, see [Verifying attestations] (https://cloud.google.com/kms/docs/attest-key).
974///
975/// This type is not used in any activity, and only used as *part* of another schema.
976///
977#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
978#[serde_with::serde_as]
979#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
980pub struct KeyOperationAttestation {
981 /// Output only. The certificate chains needed to validate the attestation
982 #[serde(rename = "certChains")]
983 pub cert_chains: Option<CertificateChains>,
984 /// Output only. The attestation data provided by the HSM when the key operation was performed.
985 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
986 pub content: Option<Vec<u8>>,
987 /// Output only. The format of the attestation data.
988 pub format: Option<String>,
989}
990
991impl common::Part for KeyOperationAttestation {}
992
993/// A KeyRing is a toplevel logical grouping of CryptoKeys.
994///
995/// # Activities
996///
997/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
998/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
999///
1000/// * [locations key rings create projects](ProjectLocationKeyRingCreateCall) (request|response)
1001/// * [locations key rings get projects](ProjectLocationKeyRingGetCall) (response)
1002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1003#[serde_with::serde_as]
1004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1005pub struct KeyRing {
1006 /// Output only. The time at which this KeyRing was created.
1007 #[serde(rename = "createTime")]
1008 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1009 /// Output only. The resource name for the KeyRing in the format `projects/*/locations/*/keyRings/*`.
1010 pub name: Option<String>,
1011}
1012
1013impl common::RequestValue for KeyRing {}
1014impl common::ResponseResult for KeyRing {}
1015
1016/// Response message for KeyManagementService.ListCryptoKeyVersions.
1017///
1018/// # Activities
1019///
1020/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1021/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1022///
1023/// * [locations key rings crypto keys crypto key versions list projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall) (response)
1024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1025#[serde_with::serde_as]
1026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1027pub struct ListCryptoKeyVersionsResponse {
1028 /// The list of CryptoKeyVersions.
1029 #[serde(rename = "cryptoKeyVersions")]
1030 pub crypto_key_versions: Option<Vec<CryptoKeyVersion>>,
1031 /// A token to retrieve next page of results. Pass this value in ListCryptoKeyVersionsRequest.page_token to retrieve the next page of results.
1032 #[serde(rename = "nextPageToken")]
1033 pub next_page_token: Option<String>,
1034 /// The total number of CryptoKeyVersions that matched the query.
1035 #[serde(rename = "totalSize")]
1036 pub total_size: Option<i32>,
1037}
1038
1039impl common::ResponseResult for ListCryptoKeyVersionsResponse {}
1040
1041/// Response message for KeyManagementService.ListCryptoKeys.
1042///
1043/// # Activities
1044///
1045/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1047///
1048/// * [locations key rings crypto keys list projects](ProjectLocationKeyRingCryptoKeyListCall) (response)
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct ListCryptoKeysResponse {
1053 /// The list of CryptoKeys.
1054 #[serde(rename = "cryptoKeys")]
1055 pub crypto_keys: Option<Vec<CryptoKey>>,
1056 /// A token to retrieve next page of results. Pass this value in ListCryptoKeysRequest.page_token to retrieve the next page of results.
1057 #[serde(rename = "nextPageToken")]
1058 pub next_page_token: Option<String>,
1059 /// The total number of CryptoKeys that matched the query.
1060 #[serde(rename = "totalSize")]
1061 pub total_size: Option<i32>,
1062}
1063
1064impl common::ResponseResult for ListCryptoKeysResponse {}
1065
1066/// Response message for EkmService.ListEkmConnections.
1067///
1068/// # Activities
1069///
1070/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1071/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1072///
1073/// * [locations ekm connections list projects](ProjectLocationEkmConnectionListCall) (response)
1074#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1075#[serde_with::serde_as]
1076#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1077pub struct ListEkmConnectionsResponse {
1078 /// The list of EkmConnections.
1079 #[serde(rename = "ekmConnections")]
1080 pub ekm_connections: Option<Vec<EkmConnection>>,
1081 /// A token to retrieve next page of results. Pass this value in ListEkmConnectionsRequest.page_token to retrieve the next page of results.
1082 #[serde(rename = "nextPageToken")]
1083 pub next_page_token: Option<String>,
1084 /// The total number of EkmConnections that matched the query.
1085 #[serde(rename = "totalSize")]
1086 pub total_size: Option<i32>,
1087}
1088
1089impl common::ResponseResult for ListEkmConnectionsResponse {}
1090
1091/// Response message for KeyManagementService.ListImportJobs.
1092///
1093/// # Activities
1094///
1095/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1096/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1097///
1098/// * [locations key rings import jobs list projects](ProjectLocationKeyRingImportJobListCall) (response)
1099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1100#[serde_with::serde_as]
1101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1102pub struct ListImportJobsResponse {
1103 /// The list of ImportJobs.
1104 #[serde(rename = "importJobs")]
1105 pub import_jobs: Option<Vec<ImportJob>>,
1106 /// A token to retrieve next page of results. Pass this value in ListImportJobsRequest.page_token to retrieve the next page of results.
1107 #[serde(rename = "nextPageToken")]
1108 pub next_page_token: Option<String>,
1109 /// The total number of ImportJobs that matched the query.
1110 #[serde(rename = "totalSize")]
1111 pub total_size: Option<i32>,
1112}
1113
1114impl common::ResponseResult for ListImportJobsResponse {}
1115
1116/// Response message for Autokey.ListKeyHandles.
1117///
1118/// # Activities
1119///
1120/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1121/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1122///
1123/// * [locations key handles list projects](ProjectLocationKeyHandleListCall) (response)
1124#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1125#[serde_with::serde_as]
1126#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1127pub struct ListKeyHandlesResponse {
1128 /// Resulting KeyHandles.
1129 #[serde(rename = "keyHandles")]
1130 pub key_handles: Option<Vec<KeyHandle>>,
1131}
1132
1133impl common::ResponseResult for ListKeyHandlesResponse {}
1134
1135/// Response message for KeyManagementService.ListKeyRings.
1136///
1137/// # Activities
1138///
1139/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1140/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1141///
1142/// * [locations key rings list projects](ProjectLocationKeyRingListCall) (response)
1143#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1144#[serde_with::serde_as]
1145#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1146pub struct ListKeyRingsResponse {
1147 /// The list of KeyRings.
1148 #[serde(rename = "keyRings")]
1149 pub key_rings: Option<Vec<KeyRing>>,
1150 /// A token to retrieve next page of results. Pass this value in ListKeyRingsRequest.page_token to retrieve the next page of results.
1151 #[serde(rename = "nextPageToken")]
1152 pub next_page_token: Option<String>,
1153 /// The total number of KeyRings that matched the query.
1154 #[serde(rename = "totalSize")]
1155 pub total_size: Option<i32>,
1156}
1157
1158impl common::ResponseResult for ListKeyRingsResponse {}
1159
1160/// The response message for Locations.ListLocations.
1161///
1162/// # Activities
1163///
1164/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1165/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1166///
1167/// * [locations list projects](ProjectLocationListCall) (response)
1168#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1169#[serde_with::serde_as]
1170#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1171pub struct ListLocationsResponse {
1172 /// A list of locations that matches the specified filter in the request.
1173 pub locations: Option<Vec<Location>>,
1174 /// The standard List next-page token.
1175 #[serde(rename = "nextPageToken")]
1176 pub next_page_token: Option<String>,
1177}
1178
1179impl common::ResponseResult for ListLocationsResponse {}
1180
1181/// A resource that represents a Google Cloud location.
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 get projects](ProjectLocationGetCall) (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 Location {
1193 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1194 #[serde(rename = "displayName")]
1195 pub display_name: Option<String>,
1196 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1197 pub labels: Option<HashMap<String, String>>,
1198 /// The canonical id for this location. For example: `"us-east1"`.
1199 #[serde(rename = "locationId")]
1200 pub location_id: Option<String>,
1201 /// Service-specific metadata. For example the available capacity at the given location.
1202 pub metadata: Option<HashMap<String, serde_json::Value>>,
1203 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1204 pub name: Option<String>,
1205}
1206
1207impl common::ResponseResult for Location {}
1208
1209/// Request message for KeyManagementService.MacSign.
1210///
1211/// # Activities
1212///
1213/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1214/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1215///
1216/// * [locations key rings crypto keys crypto key versions mac sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall) (request)
1217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1218#[serde_with::serde_as]
1219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1220pub struct MacSignRequest {
1221 /// Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm.
1222 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1223 pub data: Option<Vec<u8>>,
1224 /// 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.
1225 #[serde(rename = "dataCrc32c")]
1226 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1227 pub data_crc32c: Option<i64>,
1228}
1229
1230impl common::RequestValue for MacSignRequest {}
1231
1232/// Response message for KeyManagementService.MacSign.
1233///
1234/// # Activities
1235///
1236/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1237/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1238///
1239/// * [locations key rings crypto keys crypto key versions mac sign projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall) (response)
1240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1241#[serde_with::serde_as]
1242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1243pub struct MacSignResponse {
1244 /// The created signature.
1245 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1246 pub mac: Option<Vec<u8>>,
1247 /// 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.
1248 #[serde(rename = "macCrc32c")]
1249 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1250 pub mac_crc32c: Option<i64>,
1251 /// The resource name of the CryptoKeyVersion used for signing. Check this field to verify that the intended resource was used for signing.
1252 pub name: Option<String>,
1253 /// The ProtectionLevel of the CryptoKeyVersion used for signing.
1254 #[serde(rename = "protectionLevel")]
1255 pub protection_level: Option<String>,
1256 /// 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.
1257 #[serde(rename = "verifiedDataCrc32c")]
1258 pub verified_data_crc32c: Option<bool>,
1259}
1260
1261impl common::ResponseResult for MacSignResponse {}
1262
1263/// Request message for KeyManagementService.MacVerify.
1264///
1265/// # Activities
1266///
1267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1269///
1270/// * [locations key rings crypto keys crypto key versions mac verify projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall) (request)
1271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1272#[serde_with::serde_as]
1273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1274pub struct MacVerifyRequest {
1275 /// Required. The data used previously as a MacSignRequest.data to generate the MAC tag.
1276 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1277 pub data: Option<Vec<u8>>,
1278 /// 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.
1279 #[serde(rename = "dataCrc32c")]
1280 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1281 pub data_crc32c: Option<i64>,
1282 /// Required. The signature to verify.
1283 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1284 pub mac: Option<Vec<u8>>,
1285 /// 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.tag) 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.
1286 #[serde(rename = "macCrc32c")]
1287 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1288 pub mac_crc32c: Option<i64>,
1289}
1290
1291impl common::RequestValue for MacVerifyRequest {}
1292
1293/// Response message for KeyManagementService.MacVerify.
1294///
1295/// # Activities
1296///
1297/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1298/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1299///
1300/// * [locations key rings crypto keys crypto key versions mac verify projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall) (response)
1301#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1302#[serde_with::serde_as]
1303#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1304pub struct MacVerifyResponse {
1305 /// The resource name of the CryptoKeyVersion used for verification. Check this field to verify that the intended resource was used for verification.
1306 pub name: Option<String>,
1307 /// The ProtectionLevel of the CryptoKeyVersion used for verification.
1308 #[serde(rename = "protectionLevel")]
1309 pub protection_level: Option<String>,
1310 /// This field indicates whether or not the verification operation for MacVerifyRequest.mac over MacVerifyRequest.data was successful.
1311 pub success: Option<bool>,
1312 /// 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.
1313 #[serde(rename = "verifiedDataCrc32c")]
1314 pub verified_data_crc32c: Option<bool>,
1315 /// 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.
1316 #[serde(rename = "verifiedMacCrc32c")]
1317 pub verified_mac_crc32c: Option<bool>,
1318 /// 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.
1319 #[serde(rename = "verifiedSuccessIntegrity")]
1320 pub verified_success_integrity: Option<bool>,
1321}
1322
1323impl common::ResponseResult for MacVerifyResponse {}
1324
1325/// This resource represents a long-running operation that is the result of a network API call.
1326///
1327/// # Activities
1328///
1329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1331///
1332/// * [locations key handles create projects](ProjectLocationKeyHandleCreateCall) (response)
1333/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1335#[serde_with::serde_as]
1336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1337pub struct Operation {
1338 /// 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.
1339 pub done: Option<bool>,
1340 /// The error result of the operation in case of failure or cancellation.
1341 pub error: Option<Status>,
1342 /// 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.
1343 pub metadata: Option<HashMap<String, serde_json::Value>>,
1344 /// 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}`.
1345 pub name: Option<String>,
1346 /// 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`.
1347 pub response: Option<HashMap<String, serde_json::Value>>,
1348}
1349
1350impl common::ResponseResult for Operation {}
1351
1352/// 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/).
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 ekm config get iam policy projects](ProjectLocationEkmConfigGetIamPolicyCall) (response)
1360/// * [locations ekm config set iam policy projects](ProjectLocationEkmConfigSetIamPolicyCall) (response)
1361/// * [locations ekm connections get iam policy projects](ProjectLocationEkmConnectionGetIamPolicyCall) (response)
1362/// * [locations ekm connections set iam policy projects](ProjectLocationEkmConnectionSetIamPolicyCall) (response)
1363/// * [locations key rings crypto keys get iam policy projects](ProjectLocationKeyRingCryptoKeyGetIamPolicyCall) (response)
1364/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (response)
1365/// * [locations key rings import jobs get iam policy projects](ProjectLocationKeyRingImportJobGetIamPolicyCall) (response)
1366/// * [locations key rings import jobs set iam policy projects](ProjectLocationKeyRingImportJobSetIamPolicyCall) (response)
1367/// * [locations key rings get iam policy projects](ProjectLocationKeyRingGetIamPolicyCall) (response)
1368/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (response)
1369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1370#[serde_with::serde_as]
1371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1372pub struct Policy {
1373 /// Specifies cloud audit logging configuration for this policy.
1374 #[serde(rename = "auditConfigs")]
1375 pub audit_configs: Option<Vec<AuditConfig>>,
1376 /// 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`.
1377 pub bindings: Option<Vec<Binding>>,
1378 /// `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.
1379 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1380 pub etag: Option<Vec<u8>>,
1381 /// 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).
1382 pub version: Option<i32>,
1383}
1384
1385impl common::ResponseResult for Policy {}
1386
1387/// The public keys for a given CryptoKeyVersion. Obtained via GetPublicKey.
1388///
1389/// # Activities
1390///
1391/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1392/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1393///
1394/// * [locations key rings crypto keys crypto key versions get public key projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall) (response)
1395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1396#[serde_with::serde_as]
1397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1398pub struct PublicKey {
1399 /// The Algorithm associated with this key.
1400 pub algorithm: Option<String>,
1401 /// The name of the CryptoKeyVersion public key. Provided here for verification. NOTE: This field is in Beta.
1402 pub name: Option<String>,
1403 /// 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).
1404 pub pem: Option<String>,
1405 /// 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.
1406 #[serde(rename = "pemCrc32c")]
1407 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1408 pub pem_crc32c: Option<i64>,
1409 /// The ProtectionLevel of the CryptoKeyVersion public key.
1410 #[serde(rename = "protectionLevel")]
1411 pub protection_level: Option<String>,
1412}
1413
1414impl common::ResponseResult for PublicKey {}
1415
1416/// Request message for KeyManagementService.RawDecrypt.
1417///
1418/// # Activities
1419///
1420/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1421/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1422///
1423/// * [locations key rings crypto keys crypto key versions raw decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall) (request)
1424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1425#[serde_with::serde_as]
1426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1427pub struct RawDecryptRequest {
1428 /// Optional. Optional data that must match the data originally supplied in RawEncryptRequest.additional_authenticated_data.
1429 #[serde(rename = "additionalAuthenticatedData")]
1430 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1431 pub additional_authenticated_data: Option<Vec<u8>>,
1432 /// 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.
1433 #[serde(rename = "additionalAuthenticatedDataCrc32c")]
1434 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1435 pub additional_authenticated_data_crc32c: Option<i64>,
1436 /// Required. The encrypted data originally returned in RawEncryptResponse.ciphertext.
1437 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1438 pub ciphertext: Option<Vec<u8>>,
1439 /// 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.
1440 #[serde(rename = "ciphertextCrc32c")]
1441 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1442 pub ciphertext_crc32c: Option<i64>,
1443 /// Required. The initialization vector (IV) used during encryption, which must match the data originally provided in RawEncryptResponse.initialization_vector.
1444 #[serde(rename = "initializationVector")]
1445 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1446 pub initialization_vector: Option<Vec<u8>>,
1447 /// 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.
1448 #[serde(rename = "initializationVectorCrc32c")]
1449 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1450 pub initialization_vector_crc32c: Option<i64>,
1451 /// 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).
1452 #[serde(rename = "tagLength")]
1453 pub tag_length: Option<i32>,
1454}
1455
1456impl common::RequestValue for RawDecryptRequest {}
1457
1458/// Response message for KeyManagementService.RawDecrypt.
1459///
1460/// # Activities
1461///
1462/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1463/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1464///
1465/// * [locations key rings crypto keys crypto key versions raw decrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall) (response)
1466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1467#[serde_with::serde_as]
1468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1469pub struct RawDecryptResponse {
1470 /// The decrypted data.
1471 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1472 pub plaintext: Option<Vec<u8>>,
1473 /// 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.
1474 #[serde(rename = "plaintextCrc32c")]
1475 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1476 pub plaintext_crc32c: Option<i64>,
1477 /// The ProtectionLevel of the CryptoKeyVersion used in decryption.
1478 #[serde(rename = "protectionLevel")]
1479 pub protection_level: Option<String>,
1480 /// 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.
1481 #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
1482 pub verified_additional_authenticated_data_crc32c: Option<bool>,
1483 /// 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.
1484 #[serde(rename = "verifiedCiphertextCrc32c")]
1485 pub verified_ciphertext_crc32c: Option<bool>,
1486 /// 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.
1487 #[serde(rename = "verifiedInitializationVectorCrc32c")]
1488 pub verified_initialization_vector_crc32c: Option<bool>,
1489}
1490
1491impl common::ResponseResult for RawDecryptResponse {}
1492
1493/// Request message for KeyManagementService.RawEncrypt.
1494///
1495/// # Activities
1496///
1497/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1498/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1499///
1500/// * [locations key rings crypto keys crypto key versions raw encrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall) (request)
1501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1502#[serde_with::serde_as]
1503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1504pub struct RawEncryptRequest {
1505 /// 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.
1506 #[serde(rename = "additionalAuthenticatedData")]
1507 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1508 pub additional_authenticated_data: Option<Vec<u8>>,
1509 /// 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.
1510 #[serde(rename = "additionalAuthenticatedDataCrc32c")]
1511 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1512 pub additional_authenticated_data_crc32c: Option<i64>,
1513 /// 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.
1514 #[serde(rename = "initializationVector")]
1515 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1516 pub initialization_vector: Option<Vec<u8>>,
1517 /// 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.
1518 #[serde(rename = "initializationVectorCrc32c")]
1519 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1520 pub initialization_vector_crc32c: Option<i64>,
1521 /// 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.
1522 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1523 pub plaintext: Option<Vec<u8>>,
1524 /// 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.
1525 #[serde(rename = "plaintextCrc32c")]
1526 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1527 pub plaintext_crc32c: Option<i64>,
1528}
1529
1530impl common::RequestValue for RawEncryptRequest {}
1531
1532/// Response message for KeyManagementService.RawEncrypt.
1533///
1534/// # Activities
1535///
1536/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1537/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1538///
1539/// * [locations key rings crypto keys crypto key versions raw encrypt projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall) (response)
1540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1541#[serde_with::serde_as]
1542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1543pub struct RawEncryptResponse {
1544 /// The encrypted data. In the case of AES-GCM, the authentication tag is the tag_length bytes at the end of this field.
1545 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1546 pub ciphertext: Option<Vec<u8>>,
1547 /// 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.
1548 #[serde(rename = "ciphertextCrc32c")]
1549 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1550 pub ciphertext_crc32c: Option<i64>,
1551 /// The initialization vector (IV) generated by the service during encryption. This value must be stored and provided in RawDecryptRequest.initialization_vector at decryption time.
1552 #[serde(rename = "initializationVector")]
1553 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1554 pub initialization_vector: Option<Vec<u8>>,
1555 /// 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.
1556 #[serde(rename = "initializationVectorCrc32c")]
1557 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1558 pub initialization_vector_crc32c: Option<i64>,
1559 /// The resource name of the CryptoKeyVersion used in encryption. Check this field to verify that the intended resource was used for encryption.
1560 pub name: Option<String>,
1561 /// The ProtectionLevel of the CryptoKeyVersion used in encryption.
1562 #[serde(rename = "protectionLevel")]
1563 pub protection_level: Option<String>,
1564 /// The length of the authentication tag that is appended to the end of the ciphertext.
1565 #[serde(rename = "tagLength")]
1566 pub tag_length: Option<i32>,
1567 /// 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.
1568 #[serde(rename = "verifiedAdditionalAuthenticatedDataCrc32c")]
1569 pub verified_additional_authenticated_data_crc32c: Option<bool>,
1570 /// 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.
1571 #[serde(rename = "verifiedInitializationVectorCrc32c")]
1572 pub verified_initialization_vector_crc32c: Option<bool>,
1573 /// 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.
1574 #[serde(rename = "verifiedPlaintextCrc32c")]
1575 pub verified_plaintext_crc32c: Option<bool>,
1576}
1577
1578impl common::ResponseResult for RawEncryptResponse {}
1579
1580/// Request message for KeyManagementService.RestoreCryptoKeyVersion.
1581///
1582/// # Activities
1583///
1584/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1585/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1586///
1587/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (request)
1588#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1589#[serde_with::serde_as]
1590#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1591pub struct RestoreCryptoKeyVersionRequest {
1592 _never_set: Option<bool>,
1593}
1594
1595impl common::RequestValue for RestoreCryptoKeyVersionRequest {}
1596
1597/// A ServiceResolver represents an EKM replica that can be reached within an EkmConnection.
1598///
1599/// This type is not used in any activity, and only used as *part* of another schema.
1600///
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct ServiceResolver {
1605 /// 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.
1606 #[serde(rename = "endpointFilter")]
1607 pub endpoint_filter: Option<String>,
1608 /// Required. The hostname of the EKM replica used at TLS and HTTP layers.
1609 pub hostname: Option<String>,
1610 /// Required. A list of leaf server certificates used to authenticate HTTPS connections to the EKM replica. Currently, a maximum of 10 Certificate is supported.
1611 #[serde(rename = "serverCertificates")]
1612 pub server_certificates: Option<Vec<Certificate>>,
1613 /// Required. The resource name of the Service Directory service pointing to an EKM replica, in the format `projects/*/locations/*/namespaces/*/services/*`.
1614 #[serde(rename = "serviceDirectoryService")]
1615 pub service_directory_service: Option<String>,
1616}
1617
1618impl common::Part for ServiceResolver {}
1619
1620/// Request message for `SetIamPolicy` method.
1621///
1622/// # Activities
1623///
1624/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1625/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1626///
1627/// * [locations ekm config set iam policy projects](ProjectLocationEkmConfigSetIamPolicyCall) (request)
1628/// * [locations ekm connections set iam policy projects](ProjectLocationEkmConnectionSetIamPolicyCall) (request)
1629/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (request)
1630/// * [locations key rings import jobs set iam policy projects](ProjectLocationKeyRingImportJobSetIamPolicyCall) (request)
1631/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (request)
1632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1633#[serde_with::serde_as]
1634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1635pub struct SetIamPolicyRequest {
1636 /// 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.
1637 pub policy: Option<Policy>,
1638 /// 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"`
1639 #[serde(rename = "updateMask")]
1640 pub update_mask: Option<common::FieldMask>,
1641}
1642
1643impl common::RequestValue for SetIamPolicyRequest {}
1644
1645/// Response message for ShowEffectiveAutokeyConfig.
1646///
1647/// # Activities
1648///
1649/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1650/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1651///
1652/// * [show effective autokey config projects](ProjectShowEffectiveAutokeyConfigCall) (response)
1653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1654#[serde_with::serde_as]
1655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1656pub struct ShowEffectiveAutokeyConfigResponse {
1657 /// Name of the key project configured in the resource project's folder ancestry.
1658 #[serde(rename = "keyProject")]
1659 pub key_project: Option<String>,
1660}
1661
1662impl common::ResponseResult for ShowEffectiveAutokeyConfigResponse {}
1663
1664/// 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).
1665///
1666/// This type is not used in any activity, and only used as *part* of another schema.
1667///
1668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1669#[serde_with::serde_as]
1670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1671pub struct Status {
1672 /// The status code, which should be an enum value of google.rpc.Code.
1673 pub code: Option<i32>,
1674 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1675 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1676 /// 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.
1677 pub message: Option<String>,
1678}
1679
1680impl common::Part for Status {}
1681
1682/// Request message for `TestIamPermissions` method.
1683///
1684/// # Activities
1685///
1686/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1687/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1688///
1689/// * [locations ekm config test iam permissions projects](ProjectLocationEkmConfigTestIamPermissionCall) (request)
1690/// * [locations ekm connections test iam permissions projects](ProjectLocationEkmConnectionTestIamPermissionCall) (request)
1691/// * [locations key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (request)
1692/// * [locations key rings import jobs test iam permissions projects](ProjectLocationKeyRingImportJobTestIamPermissionCall) (request)
1693/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (request)
1694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1695#[serde_with::serde_as]
1696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1697pub struct TestIamPermissionsRequest {
1698 /// 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).
1699 pub permissions: Option<Vec<String>>,
1700}
1701
1702impl common::RequestValue for TestIamPermissionsRequest {}
1703
1704/// Response message for `TestIamPermissions` method.
1705///
1706/// # Activities
1707///
1708/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1709/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1710///
1711/// * [locations ekm config test iam permissions projects](ProjectLocationEkmConfigTestIamPermissionCall) (response)
1712/// * [locations ekm connections test iam permissions projects](ProjectLocationEkmConnectionTestIamPermissionCall) (response)
1713/// * [locations key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (response)
1714/// * [locations key rings import jobs test iam permissions projects](ProjectLocationKeyRingImportJobTestIamPermissionCall) (response)
1715/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (response)
1716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1717#[serde_with::serde_as]
1718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1719pub struct TestIamPermissionsResponse {
1720 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1721 pub permissions: Option<Vec<String>>,
1722}
1723
1724impl common::ResponseResult for TestIamPermissionsResponse {}
1725
1726/// Request message for KeyManagementService.UpdateCryptoKeyPrimaryVersion.
1727///
1728/// # Activities
1729///
1730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1732///
1733/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (request)
1734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1735#[serde_with::serde_as]
1736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1737pub struct UpdateCryptoKeyPrimaryVersionRequest {
1738 /// Required. The id of the child CryptoKeyVersion to use as primary.
1739 #[serde(rename = "cryptoKeyVersionId")]
1740 pub crypto_key_version_id: Option<String>,
1741}
1742
1743impl common::RequestValue for UpdateCryptoKeyPrimaryVersionRequest {}
1744
1745/// Response message for EkmService.VerifyConnectivity.
1746///
1747/// # Activities
1748///
1749/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1750/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1751///
1752/// * [locations ekm connections verify connectivity projects](ProjectLocationEkmConnectionVerifyConnectivityCall) (response)
1753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1754#[serde_with::serde_as]
1755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1756pub struct VerifyConnectivityResponse {
1757 _never_set: Option<bool>,
1758}
1759
1760impl common::ResponseResult for VerifyConnectivityResponse {}
1761
1762/// The public key component of the wrapping key. For details of the type of key this public key corresponds to, see the ImportMethod.
1763///
1764/// This type is not used in any activity, and only used as *part* of another schema.
1765///
1766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1767#[serde_with::serde_as]
1768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1769pub struct WrappingPublicKey {
1770 /// 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).
1771 pub pem: Option<String>,
1772}
1773
1774impl common::Part for WrappingPublicKey {}
1775
1776// ###################
1777// MethodBuilders ###
1778// #################
1779
1780/// A builder providing access to all methods supported on *folder* resources.
1781/// It is not used directly, but through the [`CloudKMS`] hub.
1782///
1783/// # Example
1784///
1785/// Instantiate a resource builder
1786///
1787/// ```test_harness,no_run
1788/// extern crate hyper;
1789/// extern crate hyper_rustls;
1790/// extern crate google_cloudkms1 as cloudkms1;
1791///
1792/// # async fn dox() {
1793/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1794///
1795/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1796/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1797/// secret,
1798/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1799/// ).build().await.unwrap();
1800///
1801/// let client = hyper_util::client::legacy::Client::builder(
1802/// hyper_util::rt::TokioExecutor::new()
1803/// )
1804/// .build(
1805/// hyper_rustls::HttpsConnectorBuilder::new()
1806/// .with_native_roots()
1807/// .unwrap()
1808/// .https_or_http()
1809/// .enable_http1()
1810/// .build()
1811/// );
1812/// let mut hub = CloudKMS::new(client, auth);
1813/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1814/// // like `get_autokey_config(...)` and `update_autokey_config(...)`
1815/// // to build up your call.
1816/// let rb = hub.folders();
1817/// # }
1818/// ```
1819pub struct FolderMethods<'a, C>
1820where
1821 C: 'a,
1822{
1823 hub: &'a CloudKMS<C>,
1824}
1825
1826impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
1827
1828impl<'a, C> FolderMethods<'a, C> {
1829 /// Create a builder to help you perform the following task:
1830 ///
1831 /// Returns the AutokeyConfig for a folder.
1832 ///
1833 /// # Arguments
1834 ///
1835 /// * `name` - Required. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
1836 pub fn get_autokey_config(&self, name: &str) -> FolderGetAutokeyConfigCall<'a, C> {
1837 FolderGetAutokeyConfigCall {
1838 hub: self.hub,
1839 _name: name.to_string(),
1840 _delegate: Default::default(),
1841 _additional_params: Default::default(),
1842 _scopes: Default::default(),
1843 }
1844 }
1845
1846 /// Create a builder to help you perform the following task:
1847 ///
1848 /// 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.
1849 ///
1850 /// # Arguments
1851 ///
1852 /// * `request` - No description provided.
1853 /// * `name` - Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
1854 pub fn update_autokey_config(
1855 &self,
1856 request: AutokeyConfig,
1857 name: &str,
1858 ) -> FolderUpdateAutokeyConfigCall<'a, C> {
1859 FolderUpdateAutokeyConfigCall {
1860 hub: self.hub,
1861 _request: request,
1862 _name: name.to_string(),
1863 _update_mask: Default::default(),
1864 _delegate: Default::default(),
1865 _additional_params: Default::default(),
1866 _scopes: Default::default(),
1867 }
1868 }
1869}
1870
1871/// A builder providing access to all methods supported on *project* resources.
1872/// It is not used directly, but through the [`CloudKMS`] hub.
1873///
1874/// # Example
1875///
1876/// Instantiate a resource builder
1877///
1878/// ```test_harness,no_run
1879/// extern crate hyper;
1880/// extern crate hyper_rustls;
1881/// extern crate google_cloudkms1 as cloudkms1;
1882///
1883/// # async fn dox() {
1884/// use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1885///
1886/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1887/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1888/// secret,
1889/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1890/// ).build().await.unwrap();
1891///
1892/// let client = hyper_util::client::legacy::Client::builder(
1893/// hyper_util::rt::TokioExecutor::new()
1894/// )
1895/// .build(
1896/// hyper_rustls::HttpsConnectorBuilder::new()
1897/// .with_native_roots()
1898/// .unwrap()
1899/// .https_or_http()
1900/// .enable_http1()
1901/// .build()
1902/// );
1903/// let mut hub = CloudKMS::new(client, auth);
1904/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1905/// // like `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_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(...)` and `show_effective_autokey_config(...)`
1906/// // to build up your call.
1907/// let rb = hub.projects();
1908/// # }
1909/// ```
1910pub struct ProjectMethods<'a, C>
1911where
1912 C: 'a,
1913{
1914 hub: &'a CloudKMS<C>,
1915}
1916
1917impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1918
1919impl<'a, C> ProjectMethods<'a, C> {
1920 /// Create a builder to help you perform the following task:
1921 ///
1922 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1923 ///
1924 /// # Arguments
1925 ///
1926 /// * `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.
1927 pub fn locations_ekm_config_get_iam_policy(
1928 &self,
1929 resource: &str,
1930 ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
1931 ProjectLocationEkmConfigGetIamPolicyCall {
1932 hub: self.hub,
1933 _resource: resource.to_string(),
1934 _options_requested_policy_version: Default::default(),
1935 _delegate: Default::default(),
1936 _additional_params: Default::default(),
1937 _scopes: Default::default(),
1938 }
1939 }
1940
1941 /// Create a builder to help you perform the following task:
1942 ///
1943 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
1944 ///
1945 /// # Arguments
1946 ///
1947 /// * `request` - No description provided.
1948 /// * `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.
1949 pub fn locations_ekm_config_set_iam_policy(
1950 &self,
1951 request: SetIamPolicyRequest,
1952 resource: &str,
1953 ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
1954 ProjectLocationEkmConfigSetIamPolicyCall {
1955 hub: self.hub,
1956 _request: request,
1957 _resource: resource.to_string(),
1958 _delegate: Default::default(),
1959 _additional_params: Default::default(),
1960 _scopes: Default::default(),
1961 }
1962 }
1963
1964 /// Create a builder to help you perform the following task:
1965 ///
1966 /// 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.
1967 ///
1968 /// # Arguments
1969 ///
1970 /// * `request` - No description provided.
1971 /// * `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.
1972 pub fn locations_ekm_config_test_iam_permissions(
1973 &self,
1974 request: TestIamPermissionsRequest,
1975 resource: &str,
1976 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
1977 ProjectLocationEkmConfigTestIamPermissionCall {
1978 hub: self.hub,
1979 _request: request,
1980 _resource: resource.to_string(),
1981 _delegate: Default::default(),
1982 _additional_params: Default::default(),
1983 _scopes: Default::default(),
1984 }
1985 }
1986
1987 /// Create a builder to help you perform the following task:
1988 ///
1989 /// Creates a new EkmConnection in a given Project and Location.
1990 ///
1991 /// # Arguments
1992 ///
1993 /// * `request` - No description provided.
1994 /// * `parent` - Required. The resource name of the location associated with the EkmConnection, in the format `projects/*/locations/*`.
1995 pub fn locations_ekm_connections_create(
1996 &self,
1997 request: EkmConnection,
1998 parent: &str,
1999 ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
2000 ProjectLocationEkmConnectionCreateCall {
2001 hub: self.hub,
2002 _request: request,
2003 _parent: parent.to_string(),
2004 _ekm_connection_id: Default::default(),
2005 _delegate: Default::default(),
2006 _additional_params: Default::default(),
2007 _scopes: Default::default(),
2008 }
2009 }
2010
2011 /// Create a builder to help you perform the following task:
2012 ///
2013 /// Returns metadata for a given EkmConnection.
2014 ///
2015 /// # Arguments
2016 ///
2017 /// * `name` - Required. The name of the EkmConnection to get.
2018 pub fn locations_ekm_connections_get(
2019 &self,
2020 name: &str,
2021 ) -> ProjectLocationEkmConnectionGetCall<'a, C> {
2022 ProjectLocationEkmConnectionGetCall {
2023 hub: self.hub,
2024 _name: name.to_string(),
2025 _delegate: Default::default(),
2026 _additional_params: Default::default(),
2027 _scopes: Default::default(),
2028 }
2029 }
2030
2031 /// Create a builder to help you perform the following task:
2032 ///
2033 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2034 ///
2035 /// # Arguments
2036 ///
2037 /// * `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.
2038 pub fn locations_ekm_connections_get_iam_policy(
2039 &self,
2040 resource: &str,
2041 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
2042 ProjectLocationEkmConnectionGetIamPolicyCall {
2043 hub: self.hub,
2044 _resource: resource.to_string(),
2045 _options_requested_policy_version: Default::default(),
2046 _delegate: Default::default(),
2047 _additional_params: Default::default(),
2048 _scopes: Default::default(),
2049 }
2050 }
2051
2052 /// Create a builder to help you perform the following task:
2053 ///
2054 /// Lists EkmConnections.
2055 ///
2056 /// # Arguments
2057 ///
2058 /// * `parent` - Required. The resource name of the location associated with the EkmConnections to list, in the format `projects/*/locations/*`.
2059 pub fn locations_ekm_connections_list(
2060 &self,
2061 parent: &str,
2062 ) -> ProjectLocationEkmConnectionListCall<'a, C> {
2063 ProjectLocationEkmConnectionListCall {
2064 hub: self.hub,
2065 _parent: parent.to_string(),
2066 _page_token: Default::default(),
2067 _page_size: Default::default(),
2068 _order_by: Default::default(),
2069 _filter: Default::default(),
2070 _delegate: Default::default(),
2071 _additional_params: Default::default(),
2072 _scopes: Default::default(),
2073 }
2074 }
2075
2076 /// Create a builder to help you perform the following task:
2077 ///
2078 /// Updates an EkmConnection's metadata.
2079 ///
2080 /// # Arguments
2081 ///
2082 /// * `request` - No description provided.
2083 /// * `name` - Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
2084 pub fn locations_ekm_connections_patch(
2085 &self,
2086 request: EkmConnection,
2087 name: &str,
2088 ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
2089 ProjectLocationEkmConnectionPatchCall {
2090 hub: self.hub,
2091 _request: request,
2092 _name: name.to_string(),
2093 _update_mask: Default::default(),
2094 _delegate: Default::default(),
2095 _additional_params: Default::default(),
2096 _scopes: Default::default(),
2097 }
2098 }
2099
2100 /// Create a builder to help you perform the following task:
2101 ///
2102 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2103 ///
2104 /// # Arguments
2105 ///
2106 /// * `request` - No description provided.
2107 /// * `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.
2108 pub fn locations_ekm_connections_set_iam_policy(
2109 &self,
2110 request: SetIamPolicyRequest,
2111 resource: &str,
2112 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
2113 ProjectLocationEkmConnectionSetIamPolicyCall {
2114 hub: self.hub,
2115 _request: request,
2116 _resource: resource.to_string(),
2117 _delegate: Default::default(),
2118 _additional_params: Default::default(),
2119 _scopes: Default::default(),
2120 }
2121 }
2122
2123 /// Create a builder to help you perform the following task:
2124 ///
2125 /// 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.
2126 ///
2127 /// # Arguments
2128 ///
2129 /// * `request` - No description provided.
2130 /// * `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.
2131 pub fn locations_ekm_connections_test_iam_permissions(
2132 &self,
2133 request: TestIamPermissionsRequest,
2134 resource: &str,
2135 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
2136 ProjectLocationEkmConnectionTestIamPermissionCall {
2137 hub: self.hub,
2138 _request: request,
2139 _resource: resource.to_string(),
2140 _delegate: Default::default(),
2141 _additional_params: Default::default(),
2142 _scopes: Default::default(),
2143 }
2144 }
2145
2146 /// Create a builder to help you perform the following task:
2147 ///
2148 /// 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.
2149 ///
2150 /// # Arguments
2151 ///
2152 /// * `name` - Required. The name of the EkmConnection to verify.
2153 pub fn locations_ekm_connections_verify_connectivity(
2154 &self,
2155 name: &str,
2156 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
2157 ProjectLocationEkmConnectionVerifyConnectivityCall {
2158 hub: self.hub,
2159 _name: name.to_string(),
2160 _delegate: Default::default(),
2161 _additional_params: Default::default(),
2162 _scopes: Default::default(),
2163 }
2164 }
2165
2166 /// Create a builder to help you perform the following task:
2167 ///
2168 /// 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.
2169 ///
2170 /// # Arguments
2171 ///
2172 /// * `request` - No description provided.
2173 /// * `parent` - Required. Name of the resource project and location to create the KeyHandle in, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
2174 pub fn locations_key_handles_create(
2175 &self,
2176 request: KeyHandle,
2177 parent: &str,
2178 ) -> ProjectLocationKeyHandleCreateCall<'a, C> {
2179 ProjectLocationKeyHandleCreateCall {
2180 hub: self.hub,
2181 _request: request,
2182 _parent: parent.to_string(),
2183 _key_handle_id: Default::default(),
2184 _delegate: Default::default(),
2185 _additional_params: Default::default(),
2186 _scopes: Default::default(),
2187 }
2188 }
2189
2190 /// Create a builder to help you perform the following task:
2191 ///
2192 /// Returns the KeyHandle.
2193 ///
2194 /// # Arguments
2195 ///
2196 /// * `name` - Required. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
2197 pub fn locations_key_handles_get(&self, name: &str) -> ProjectLocationKeyHandleGetCall<'a, C> {
2198 ProjectLocationKeyHandleGetCall {
2199 hub: self.hub,
2200 _name: name.to_string(),
2201 _delegate: Default::default(),
2202 _additional_params: Default::default(),
2203 _scopes: Default::default(),
2204 }
2205 }
2206
2207 /// Create a builder to help you perform the following task:
2208 ///
2209 /// Lists KeyHandles.
2210 ///
2211 /// # Arguments
2212 ///
2213 /// * `parent` - Required. Name of the resource project and location from which to list KeyHandles, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
2214 pub fn locations_key_handles_list(
2215 &self,
2216 parent: &str,
2217 ) -> ProjectLocationKeyHandleListCall<'a, C> {
2218 ProjectLocationKeyHandleListCall {
2219 hub: self.hub,
2220 _parent: parent.to_string(),
2221 _filter: Default::default(),
2222 _delegate: Default::default(),
2223 _additional_params: Default::default(),
2224 _scopes: Default::default(),
2225 }
2226 }
2227
2228 /// Create a builder to help you perform the following task:
2229 ///
2230 /// Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.
2231 ///
2232 /// # Arguments
2233 ///
2234 /// * `request` - No description provided.
2235 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for decryption.
2236 pub fn locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_decrypt(
2237 &self,
2238 request: AsymmetricDecryptRequest,
2239 name: &str,
2240 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
2241 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall {
2242 hub: self.hub,
2243 _request: request,
2244 _name: name.to_string(),
2245 _delegate: Default::default(),
2246 _additional_params: Default::default(),
2247 _scopes: Default::default(),
2248 }
2249 }
2250
2251 /// Create a builder to help you perform the following task:
2252 ///
2253 /// Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.
2254 ///
2255 /// # Arguments
2256 ///
2257 /// * `request` - No description provided.
2258 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for signing.
2259 pub fn locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_sign(
2260 &self,
2261 request: AsymmetricSignRequest,
2262 name: &str,
2263 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
2264 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall {
2265 hub: self.hub,
2266 _request: request,
2267 _name: name.to_string(),
2268 _delegate: Default::default(),
2269 _additional_params: Default::default(),
2270 _scopes: Default::default(),
2271 }
2272 }
2273
2274 /// Create a builder to help you perform the following task:
2275 ///
2276 /// Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next sequential id. If unset, state will be set to ENABLED.
2277 ///
2278 /// # Arguments
2279 ///
2280 /// * `request` - No description provided.
2281 /// * `parent` - Required. The name of the CryptoKey associated with the CryptoKeyVersions.
2282 pub fn locations_key_rings_crypto_keys_crypto_key_versions_create(
2283 &self,
2284 request: CryptoKeyVersion,
2285 parent: &str,
2286 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2287 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall {
2288 hub: self.hub,
2289 _request: request,
2290 _parent: parent.to_string(),
2291 _delegate: Default::default(),
2292 _additional_params: Default::default(),
2293 _scopes: Default::default(),
2294 }
2295 }
2296
2297 /// Create a builder to help you perform the following task:
2298 ///
2299 /// 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.
2300 ///
2301 /// # Arguments
2302 ///
2303 /// * `request` - No description provided.
2304 /// * `name` - Required. The resource name of the CryptoKeyVersion to destroy.
2305 pub fn locations_key_rings_crypto_keys_crypto_key_versions_destroy(
2306 &self,
2307 request: DestroyCryptoKeyVersionRequest,
2308 name: &str,
2309 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2310 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall {
2311 hub: self.hub,
2312 _request: request,
2313 _name: name.to_string(),
2314 _delegate: Default::default(),
2315 _additional_params: Default::default(),
2316 _scopes: Default::default(),
2317 }
2318 }
2319
2320 /// Create a builder to help you perform the following task:
2321 ///
2322 /// Returns metadata for a given CryptoKeyVersion.
2323 ///
2324 /// # Arguments
2325 ///
2326 /// * `name` - Required. The name of the CryptoKeyVersion to get.
2327 pub fn locations_key_rings_crypto_keys_crypto_key_versions_get(
2328 &self,
2329 name: &str,
2330 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
2331 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall {
2332 hub: self.hub,
2333 _name: name.to_string(),
2334 _delegate: Default::default(),
2335 _additional_params: Default::default(),
2336 _scopes: Default::default(),
2337 }
2338 }
2339
2340 /// Create a builder to help you perform the following task:
2341 ///
2342 /// Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.
2343 ///
2344 /// # Arguments
2345 ///
2346 /// * `name` - Required. The name of the CryptoKeyVersion public key to get.
2347 pub fn locations_key_rings_crypto_keys_crypto_key_versions_get_public_key(
2348 &self,
2349 name: &str,
2350 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
2351 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall {
2352 hub: self.hub,
2353 _name: name.to_string(),
2354 _delegate: Default::default(),
2355 _additional_params: Default::default(),
2356 _scopes: Default::default(),
2357 }
2358 }
2359
2360 /// Create a builder to help you perform the following task:
2361 ///
2362 /// 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.
2363 ///
2364 /// # Arguments
2365 ///
2366 /// * `request` - No description provided.
2367 /// * `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.
2368 pub fn locations_key_rings_crypto_keys_crypto_key_versions_import(
2369 &self,
2370 request: ImportCryptoKeyVersionRequest,
2371 parent: &str,
2372 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
2373 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall {
2374 hub: self.hub,
2375 _request: request,
2376 _parent: parent.to_string(),
2377 _delegate: Default::default(),
2378 _additional_params: Default::default(),
2379 _scopes: Default::default(),
2380 }
2381 }
2382
2383 /// Create a builder to help you perform the following task:
2384 ///
2385 /// Lists CryptoKeyVersions.
2386 ///
2387 /// # Arguments
2388 ///
2389 /// * `parent` - Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
2390 pub fn locations_key_rings_crypto_keys_crypto_key_versions_list(
2391 &self,
2392 parent: &str,
2393 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
2394 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall {
2395 hub: self.hub,
2396 _parent: parent.to_string(),
2397 _view: Default::default(),
2398 _page_token: Default::default(),
2399 _page_size: Default::default(),
2400 _order_by: Default::default(),
2401 _filter: Default::default(),
2402 _delegate: Default::default(),
2403 _additional_params: Default::default(),
2404 _scopes: Default::default(),
2405 }
2406 }
2407
2408 /// Create a builder to help you perform the following task:
2409 ///
2410 /// Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key.
2411 ///
2412 /// # Arguments
2413 ///
2414 /// * `request` - No description provided.
2415 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for signing.
2416 pub fn locations_key_rings_crypto_keys_crypto_key_versions_mac_sign(
2417 &self,
2418 request: MacSignRequest,
2419 name: &str,
2420 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
2421 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall {
2422 hub: self.hub,
2423 _request: request,
2424 _name: name.to_string(),
2425 _delegate: Default::default(),
2426 _additional_params: Default::default(),
2427 _scopes: Default::default(),
2428 }
2429 }
2430
2431 /// Create a builder to help you perform the following task:
2432 ///
2433 /// Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful.
2434 ///
2435 /// # Arguments
2436 ///
2437 /// * `request` - No description provided.
2438 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for verification.
2439 pub fn locations_key_rings_crypto_keys_crypto_key_versions_mac_verify(
2440 &self,
2441 request: MacVerifyRequest,
2442 name: &str,
2443 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
2444 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall {
2445 hub: self.hub,
2446 _request: request,
2447 _name: name.to_string(),
2448 _delegate: Default::default(),
2449 _additional_params: Default::default(),
2450 _scopes: Default::default(),
2451 }
2452 }
2453
2454 /// Create a builder to help you perform the following task:
2455 ///
2456 /// 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.
2457 ///
2458 /// # Arguments
2459 ///
2460 /// * `request` - No description provided.
2461 /// * `name` - Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
2462 pub fn locations_key_rings_crypto_keys_crypto_key_versions_patch(
2463 &self,
2464 request: CryptoKeyVersion,
2465 name: &str,
2466 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
2467 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall {
2468 hub: self.hub,
2469 _request: request,
2470 _name: name.to_string(),
2471 _update_mask: Default::default(),
2472 _delegate: Default::default(),
2473 _additional_params: Default::default(),
2474 _scopes: Default::default(),
2475 }
2476 }
2477
2478 /// Create a builder to help you perform the following task:
2479 ///
2480 /// Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
2481 ///
2482 /// # Arguments
2483 ///
2484 /// * `request` - No description provided.
2485 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for decryption.
2486 pub fn locations_key_rings_crypto_keys_crypto_key_versions_raw_decrypt(
2487 &self,
2488 request: RawDecryptRequest,
2489 name: &str,
2490 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
2491 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall {
2492 hub: self.hub,
2493 _request: request,
2494 _name: name.to_string(),
2495 _delegate: Default::default(),
2496 _additional_params: Default::default(),
2497 _scopes: Default::default(),
2498 }
2499 }
2500
2501 /// Create a builder to help you perform the following task:
2502 ///
2503 /// 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.
2504 ///
2505 /// # Arguments
2506 ///
2507 /// * `request` - No description provided.
2508 /// * `name` - Required. The resource name of the CryptoKeyVersion to use for encryption.
2509 pub fn locations_key_rings_crypto_keys_crypto_key_versions_raw_encrypt(
2510 &self,
2511 request: RawEncryptRequest,
2512 name: &str,
2513 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
2514 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall {
2515 hub: self.hub,
2516 _request: request,
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 /// 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.
2527 ///
2528 /// # Arguments
2529 ///
2530 /// * `request` - No description provided.
2531 /// * `name` - Required. The resource name of the CryptoKeyVersion to restore.
2532 pub fn locations_key_rings_crypto_keys_crypto_key_versions_restore(
2533 &self,
2534 request: RestoreCryptoKeyVersionRequest,
2535 name: &str,
2536 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
2537 ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall {
2538 hub: self.hub,
2539 _request: request,
2540 _name: name.to_string(),
2541 _delegate: Default::default(),
2542 _additional_params: Default::default(),
2543 _scopes: Default::default(),
2544 }
2545 }
2546
2547 /// Create a builder to help you perform the following task:
2548 ///
2549 /// Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required.
2550 ///
2551 /// # Arguments
2552 ///
2553 /// * `request` - No description provided.
2554 /// * `parent` - Required. The name of the KeyRing associated with the CryptoKeys.
2555 pub fn locations_key_rings_crypto_keys_create(
2556 &self,
2557 request: CryptoKey,
2558 parent: &str,
2559 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
2560 ProjectLocationKeyRingCryptoKeyCreateCall {
2561 hub: self.hub,
2562 _request: request,
2563 _parent: parent.to_string(),
2564 _skip_initial_version_creation: Default::default(),
2565 _crypto_key_id: Default::default(),
2566 _delegate: Default::default(),
2567 _additional_params: Default::default(),
2568 _scopes: Default::default(),
2569 }
2570 }
2571
2572 /// Create a builder to help you perform the following task:
2573 ///
2574 /// Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
2575 ///
2576 /// # Arguments
2577 ///
2578 /// * `request` - No description provided.
2579 /// * `name` - Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version.
2580 pub fn locations_key_rings_crypto_keys_decrypt(
2581 &self,
2582 request: DecryptRequest,
2583 name: &str,
2584 ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
2585 ProjectLocationKeyRingCryptoKeyDecryptCall {
2586 hub: self.hub,
2587 _request: request,
2588 _name: name.to_string(),
2589 _delegate: Default::default(),
2590 _additional_params: Default::default(),
2591 _scopes: Default::default(),
2592 }
2593 }
2594
2595 /// Create a builder to help you perform the following task:
2596 ///
2597 /// Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
2598 ///
2599 /// # Arguments
2600 ///
2601 /// * `request` - No description provided.
2602 /// * `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.
2603 pub fn locations_key_rings_crypto_keys_encrypt(
2604 &self,
2605 request: EncryptRequest,
2606 name: &str,
2607 ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
2608 ProjectLocationKeyRingCryptoKeyEncryptCall {
2609 hub: self.hub,
2610 _request: request,
2611 _name: name.to_string(),
2612 _delegate: Default::default(),
2613 _additional_params: Default::default(),
2614 _scopes: Default::default(),
2615 }
2616 }
2617
2618 /// Create a builder to help you perform the following task:
2619 ///
2620 /// Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
2621 ///
2622 /// # Arguments
2623 ///
2624 /// * `name` - Required. The name of the CryptoKey to get.
2625 pub fn locations_key_rings_crypto_keys_get(
2626 &self,
2627 name: &str,
2628 ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
2629 ProjectLocationKeyRingCryptoKeyGetCall {
2630 hub: self.hub,
2631 _name: name.to_string(),
2632 _delegate: Default::default(),
2633 _additional_params: Default::default(),
2634 _scopes: Default::default(),
2635 }
2636 }
2637
2638 /// Create a builder to help you perform the following task:
2639 ///
2640 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2641 ///
2642 /// # Arguments
2643 ///
2644 /// * `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.
2645 pub fn locations_key_rings_crypto_keys_get_iam_policy(
2646 &self,
2647 resource: &str,
2648 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
2649 ProjectLocationKeyRingCryptoKeyGetIamPolicyCall {
2650 hub: self.hub,
2651 _resource: resource.to_string(),
2652 _options_requested_policy_version: Default::default(),
2653 _delegate: Default::default(),
2654 _additional_params: Default::default(),
2655 _scopes: Default::default(),
2656 }
2657 }
2658
2659 /// Create a builder to help you perform the following task:
2660 ///
2661 /// Lists CryptoKeys.
2662 ///
2663 /// # Arguments
2664 ///
2665 /// * `parent` - Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
2666 pub fn locations_key_rings_crypto_keys_list(
2667 &self,
2668 parent: &str,
2669 ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
2670 ProjectLocationKeyRingCryptoKeyListCall {
2671 hub: self.hub,
2672 _parent: parent.to_string(),
2673 _version_view: Default::default(),
2674 _page_token: Default::default(),
2675 _page_size: Default::default(),
2676 _order_by: Default::default(),
2677 _filter: Default::default(),
2678 _delegate: Default::default(),
2679 _additional_params: Default::default(),
2680 _scopes: Default::default(),
2681 }
2682 }
2683
2684 /// Create a builder to help you perform the following task:
2685 ///
2686 /// Update a CryptoKey.
2687 ///
2688 /// # Arguments
2689 ///
2690 /// * `request` - No description provided.
2691 /// * `name` - Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
2692 pub fn locations_key_rings_crypto_keys_patch(
2693 &self,
2694 request: CryptoKey,
2695 name: &str,
2696 ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
2697 ProjectLocationKeyRingCryptoKeyPatchCall {
2698 hub: self.hub,
2699 _request: request,
2700 _name: name.to_string(),
2701 _update_mask: Default::default(),
2702 _delegate: Default::default(),
2703 _additional_params: Default::default(),
2704 _scopes: Default::default(),
2705 }
2706 }
2707
2708 /// Create a builder to help you perform the following task:
2709 ///
2710 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2711 ///
2712 /// # Arguments
2713 ///
2714 /// * `request` - No description provided.
2715 /// * `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.
2716 pub fn locations_key_rings_crypto_keys_set_iam_policy(
2717 &self,
2718 request: SetIamPolicyRequest,
2719 resource: &str,
2720 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
2721 ProjectLocationKeyRingCryptoKeySetIamPolicyCall {
2722 hub: self.hub,
2723 _request: request,
2724 _resource: resource.to_string(),
2725 _delegate: Default::default(),
2726 _additional_params: Default::default(),
2727 _scopes: Default::default(),
2728 }
2729 }
2730
2731 /// Create a builder to help you perform the following task:
2732 ///
2733 /// 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.
2734 ///
2735 /// # Arguments
2736 ///
2737 /// * `request` - No description provided.
2738 /// * `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.
2739 pub fn locations_key_rings_crypto_keys_test_iam_permissions(
2740 &self,
2741 request: TestIamPermissionsRequest,
2742 resource: &str,
2743 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
2744 ProjectLocationKeyRingCryptoKeyTestIamPermissionCall {
2745 hub: self.hub,
2746 _request: request,
2747 _resource: resource.to_string(),
2748 _delegate: Default::default(),
2749 _additional_params: Default::default(),
2750 _scopes: Default::default(),
2751 }
2752 }
2753
2754 /// Create a builder to help you perform the following task:
2755 ///
2756 /// 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.
2757 ///
2758 /// # Arguments
2759 ///
2760 /// * `request` - No description provided.
2761 /// * `name` - Required. The resource name of the CryptoKey to update.
2762 pub fn locations_key_rings_crypto_keys_update_primary_version(
2763 &self,
2764 request: UpdateCryptoKeyPrimaryVersionRequest,
2765 name: &str,
2766 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
2767 ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall {
2768 hub: self.hub,
2769 _request: request,
2770 _name: name.to_string(),
2771 _delegate: Default::default(),
2772 _additional_params: Default::default(),
2773 _scopes: Default::default(),
2774 }
2775 }
2776
2777 /// Create a builder to help you perform the following task:
2778 ///
2779 /// Create a new ImportJob within a KeyRing. ImportJob.import_method is required.
2780 ///
2781 /// # Arguments
2782 ///
2783 /// * `request` - No description provided.
2784 /// * `parent` - Required. The name of the KeyRing associated with the ImportJobs.
2785 pub fn locations_key_rings_import_jobs_create(
2786 &self,
2787 request: ImportJob,
2788 parent: &str,
2789 ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
2790 ProjectLocationKeyRingImportJobCreateCall {
2791 hub: self.hub,
2792 _request: request,
2793 _parent: parent.to_string(),
2794 _import_job_id: Default::default(),
2795 _delegate: Default::default(),
2796 _additional_params: Default::default(),
2797 _scopes: Default::default(),
2798 }
2799 }
2800
2801 /// Create a builder to help you perform the following task:
2802 ///
2803 /// Returns metadata for a given ImportJob.
2804 ///
2805 /// # Arguments
2806 ///
2807 /// * `name` - Required. The name of the ImportJob to get.
2808 pub fn locations_key_rings_import_jobs_get(
2809 &self,
2810 name: &str,
2811 ) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
2812 ProjectLocationKeyRingImportJobGetCall {
2813 hub: self.hub,
2814 _name: name.to_string(),
2815 _delegate: Default::default(),
2816 _additional_params: Default::default(),
2817 _scopes: Default::default(),
2818 }
2819 }
2820
2821 /// Create a builder to help you perform the following task:
2822 ///
2823 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2824 ///
2825 /// # Arguments
2826 ///
2827 /// * `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.
2828 pub fn locations_key_rings_import_jobs_get_iam_policy(
2829 &self,
2830 resource: &str,
2831 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
2832 ProjectLocationKeyRingImportJobGetIamPolicyCall {
2833 hub: self.hub,
2834 _resource: resource.to_string(),
2835 _options_requested_policy_version: Default::default(),
2836 _delegate: Default::default(),
2837 _additional_params: Default::default(),
2838 _scopes: Default::default(),
2839 }
2840 }
2841
2842 /// Create a builder to help you perform the following task:
2843 ///
2844 /// Lists ImportJobs.
2845 ///
2846 /// # Arguments
2847 ///
2848 /// * `parent` - Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
2849 pub fn locations_key_rings_import_jobs_list(
2850 &self,
2851 parent: &str,
2852 ) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
2853 ProjectLocationKeyRingImportJobListCall {
2854 hub: self.hub,
2855 _parent: parent.to_string(),
2856 _page_token: Default::default(),
2857 _page_size: Default::default(),
2858 _order_by: Default::default(),
2859 _filter: Default::default(),
2860 _delegate: Default::default(),
2861 _additional_params: Default::default(),
2862 _scopes: Default::default(),
2863 }
2864 }
2865
2866 /// Create a builder to help you perform the following task:
2867 ///
2868 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2869 ///
2870 /// # Arguments
2871 ///
2872 /// * `request` - No description provided.
2873 /// * `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.
2874 pub fn locations_key_rings_import_jobs_set_iam_policy(
2875 &self,
2876 request: SetIamPolicyRequest,
2877 resource: &str,
2878 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
2879 ProjectLocationKeyRingImportJobSetIamPolicyCall {
2880 hub: self.hub,
2881 _request: request,
2882 _resource: resource.to_string(),
2883 _delegate: Default::default(),
2884 _additional_params: Default::default(),
2885 _scopes: Default::default(),
2886 }
2887 }
2888
2889 /// Create a builder to help you perform the following task:
2890 ///
2891 /// 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.
2892 ///
2893 /// # Arguments
2894 ///
2895 /// * `request` - No description provided.
2896 /// * `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.
2897 pub fn locations_key_rings_import_jobs_test_iam_permissions(
2898 &self,
2899 request: TestIamPermissionsRequest,
2900 resource: &str,
2901 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
2902 ProjectLocationKeyRingImportJobTestIamPermissionCall {
2903 hub: self.hub,
2904 _request: request,
2905 _resource: resource.to_string(),
2906 _delegate: Default::default(),
2907 _additional_params: Default::default(),
2908 _scopes: Default::default(),
2909 }
2910 }
2911
2912 /// Create a builder to help you perform the following task:
2913 ///
2914 /// Create a new KeyRing in a given Project and Location.
2915 ///
2916 /// # Arguments
2917 ///
2918 /// * `request` - No description provided.
2919 /// * `parent` - Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
2920 pub fn locations_key_rings_create(
2921 &self,
2922 request: KeyRing,
2923 parent: &str,
2924 ) -> ProjectLocationKeyRingCreateCall<'a, C> {
2925 ProjectLocationKeyRingCreateCall {
2926 hub: self.hub,
2927 _request: request,
2928 _parent: parent.to_string(),
2929 _key_ring_id: Default::default(),
2930 _delegate: Default::default(),
2931 _additional_params: Default::default(),
2932 _scopes: Default::default(),
2933 }
2934 }
2935
2936 /// Create a builder to help you perform the following task:
2937 ///
2938 /// Returns metadata for a given KeyRing.
2939 ///
2940 /// # Arguments
2941 ///
2942 /// * `name` - Required. The name of the KeyRing to get.
2943 pub fn locations_key_rings_get(&self, name: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
2944 ProjectLocationKeyRingGetCall {
2945 hub: self.hub,
2946 _name: name.to_string(),
2947 _delegate: Default::default(),
2948 _additional_params: Default::default(),
2949 _scopes: Default::default(),
2950 }
2951 }
2952
2953 /// Create a builder to help you perform the following task:
2954 ///
2955 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2956 ///
2957 /// # Arguments
2958 ///
2959 /// * `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.
2960 pub fn locations_key_rings_get_iam_policy(
2961 &self,
2962 resource: &str,
2963 ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
2964 ProjectLocationKeyRingGetIamPolicyCall {
2965 hub: self.hub,
2966 _resource: resource.to_string(),
2967 _options_requested_policy_version: Default::default(),
2968 _delegate: Default::default(),
2969 _additional_params: Default::default(),
2970 _scopes: Default::default(),
2971 }
2972 }
2973
2974 /// Create a builder to help you perform the following task:
2975 ///
2976 /// Lists KeyRings.
2977 ///
2978 /// # Arguments
2979 ///
2980 /// * `parent` - Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
2981 pub fn locations_key_rings_list(&self, parent: &str) -> ProjectLocationKeyRingListCall<'a, C> {
2982 ProjectLocationKeyRingListCall {
2983 hub: self.hub,
2984 _parent: parent.to_string(),
2985 _page_token: Default::default(),
2986 _page_size: Default::default(),
2987 _order_by: Default::default(),
2988 _filter: Default::default(),
2989 _delegate: Default::default(),
2990 _additional_params: Default::default(),
2991 _scopes: Default::default(),
2992 }
2993 }
2994
2995 /// Create a builder to help you perform the following task:
2996 ///
2997 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2998 ///
2999 /// # Arguments
3000 ///
3001 /// * `request` - No description provided.
3002 /// * `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.
3003 pub fn locations_key_rings_set_iam_policy(
3004 &self,
3005 request: SetIamPolicyRequest,
3006 resource: &str,
3007 ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
3008 ProjectLocationKeyRingSetIamPolicyCall {
3009 hub: self.hub,
3010 _request: request,
3011 _resource: resource.to_string(),
3012 _delegate: Default::default(),
3013 _additional_params: Default::default(),
3014 _scopes: Default::default(),
3015 }
3016 }
3017
3018 /// Create a builder to help you perform the following task:
3019 ///
3020 /// 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.
3021 ///
3022 /// # Arguments
3023 ///
3024 /// * `request` - No description provided.
3025 /// * `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.
3026 pub fn locations_key_rings_test_iam_permissions(
3027 &self,
3028 request: TestIamPermissionsRequest,
3029 resource: &str,
3030 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
3031 ProjectLocationKeyRingTestIamPermissionCall {
3032 hub: self.hub,
3033 _request: request,
3034 _resource: resource.to_string(),
3035 _delegate: Default::default(),
3036 _additional_params: Default::default(),
3037 _scopes: Default::default(),
3038 }
3039 }
3040
3041 /// Create a builder to help you perform the following task:
3042 ///
3043 /// 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.
3044 ///
3045 /// # Arguments
3046 ///
3047 /// * `name` - The name of the operation resource.
3048 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3049 ProjectLocationOperationGetCall {
3050 hub: self.hub,
3051 _name: name.to_string(),
3052 _delegate: Default::default(),
3053 _additional_params: Default::default(),
3054 _scopes: Default::default(),
3055 }
3056 }
3057
3058 /// Create a builder to help you perform the following task:
3059 ///
3060 /// Generate random bytes using the Cloud KMS randomness source in the provided location.
3061 ///
3062 /// # Arguments
3063 ///
3064 /// * `request` - No description provided.
3065 /// * `location` - The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".
3066 pub fn locations_generate_random_bytes(
3067 &self,
3068 request: GenerateRandomBytesRequest,
3069 location: &str,
3070 ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
3071 ProjectLocationGenerateRandomByteCall {
3072 hub: self.hub,
3073 _request: request,
3074 _location: location.to_string(),
3075 _delegate: Default::default(),
3076 _additional_params: Default::default(),
3077 _scopes: Default::default(),
3078 }
3079 }
3080
3081 /// Create a builder to help you perform the following task:
3082 ///
3083 /// Gets information about a location.
3084 ///
3085 /// # Arguments
3086 ///
3087 /// * `name` - Resource name for the location.
3088 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3089 ProjectLocationGetCall {
3090 hub: self.hub,
3091 _name: name.to_string(),
3092 _delegate: Default::default(),
3093 _additional_params: Default::default(),
3094 _scopes: Default::default(),
3095 }
3096 }
3097
3098 /// Create a builder to help you perform the following task:
3099 ///
3100 /// Returns the EkmConfig singleton resource for a given project and location.
3101 ///
3102 /// # Arguments
3103 ///
3104 /// * `name` - Required. The name of the EkmConfig to get.
3105 pub fn locations_get_ekm_config(&self, name: &str) -> ProjectLocationGetEkmConfigCall<'a, C> {
3106 ProjectLocationGetEkmConfigCall {
3107 hub: self.hub,
3108 _name: name.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 /// Lists information about the supported locations for this service.
3118 ///
3119 /// # Arguments
3120 ///
3121 /// * `name` - The resource that owns the locations collection, if applicable.
3122 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3123 ProjectLocationListCall {
3124 hub: self.hub,
3125 _name: name.to_string(),
3126 _page_token: Default::default(),
3127 _page_size: Default::default(),
3128 _filter: Default::default(),
3129 _delegate: Default::default(),
3130 _additional_params: Default::default(),
3131 _scopes: Default::default(),
3132 }
3133 }
3134
3135 /// Create a builder to help you perform the following task:
3136 ///
3137 /// Updates the EkmConfig singleton resource for a given project and location.
3138 ///
3139 /// # Arguments
3140 ///
3141 /// * `request` - No description provided.
3142 /// * `name` - Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
3143 pub fn locations_update_ekm_config(
3144 &self,
3145 request: EkmConfig,
3146 name: &str,
3147 ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
3148 ProjectLocationUpdateEkmConfigCall {
3149 hub: self.hub,
3150 _request: request,
3151 _name: name.to_string(),
3152 _update_mask: Default::default(),
3153 _delegate: Default::default(),
3154 _additional_params: Default::default(),
3155 _scopes: Default::default(),
3156 }
3157 }
3158
3159 /// Create a builder to help you perform the following task:
3160 ///
3161 /// Returns the effective Cloud KMS Autokey configuration for a given project.
3162 ///
3163 /// # Arguments
3164 ///
3165 /// * `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.
3166 pub fn show_effective_autokey_config(
3167 &self,
3168 parent: &str,
3169 ) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
3170 ProjectShowEffectiveAutokeyConfigCall {
3171 hub: self.hub,
3172 _parent: parent.to_string(),
3173 _delegate: Default::default(),
3174 _additional_params: Default::default(),
3175 _scopes: Default::default(),
3176 }
3177 }
3178}
3179
3180// ###################
3181// CallBuilders ###
3182// #################
3183
3184/// Returns the AutokeyConfig for a folder.
3185///
3186/// A builder for the *getAutokeyConfig* method supported by a *folder* resource.
3187/// It is not used directly, but through a [`FolderMethods`] instance.
3188///
3189/// # Example
3190///
3191/// Instantiate a resource method builder
3192///
3193/// ```test_harness,no_run
3194/// # extern crate hyper;
3195/// # extern crate hyper_rustls;
3196/// # extern crate google_cloudkms1 as cloudkms1;
3197/// # async fn dox() {
3198/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3199///
3200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3202/// # secret,
3203/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3204/// # ).build().await.unwrap();
3205///
3206/// # let client = hyper_util::client::legacy::Client::builder(
3207/// # hyper_util::rt::TokioExecutor::new()
3208/// # )
3209/// # .build(
3210/// # hyper_rustls::HttpsConnectorBuilder::new()
3211/// # .with_native_roots()
3212/// # .unwrap()
3213/// # .https_or_http()
3214/// # .enable_http1()
3215/// # .build()
3216/// # );
3217/// # let mut hub = CloudKMS::new(client, auth);
3218/// // You can configure optional parameters by calling the respective setters at will, and
3219/// // execute the final call using `doit()`.
3220/// // Values shown here are possibly random and not representative !
3221/// let result = hub.folders().get_autokey_config("name")
3222/// .doit().await;
3223/// # }
3224/// ```
3225pub struct FolderGetAutokeyConfigCall<'a, C>
3226where
3227 C: 'a,
3228{
3229 hub: &'a CloudKMS<C>,
3230 _name: String,
3231 _delegate: Option<&'a mut dyn common::Delegate>,
3232 _additional_params: HashMap<String, String>,
3233 _scopes: BTreeSet<String>,
3234}
3235
3236impl<'a, C> common::CallBuilder for FolderGetAutokeyConfigCall<'a, C> {}
3237
3238impl<'a, C> FolderGetAutokeyConfigCall<'a, C>
3239where
3240 C: common::Connector,
3241{
3242 /// Perform the operation you have build so far.
3243 pub async fn doit(mut self) -> common::Result<(common::Response, AutokeyConfig)> {
3244 use std::borrow::Cow;
3245 use std::io::{Read, Seek};
3246
3247 use common::{url::Params, ToParts};
3248 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3249
3250 let mut dd = common::DefaultDelegate;
3251 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3252 dlg.begin(common::MethodInfo {
3253 id: "cloudkms.folders.getAutokeyConfig",
3254 http_method: hyper::Method::GET,
3255 });
3256
3257 for &field in ["alt", "name"].iter() {
3258 if self._additional_params.contains_key(field) {
3259 dlg.finished(false);
3260 return Err(common::Error::FieldClash(field));
3261 }
3262 }
3263
3264 let mut params = Params::with_capacity(3 + self._additional_params.len());
3265 params.push("name", self._name);
3266
3267 params.extend(self._additional_params.iter());
3268
3269 params.push("alt", "json");
3270 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3271 if self._scopes.is_empty() {
3272 self._scopes
3273 .insert(Scope::CloudPlatform.as_ref().to_string());
3274 }
3275
3276 #[allow(clippy::single_element_loop)]
3277 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3278 url = params.uri_replacement(url, param_name, find_this, true);
3279 }
3280 {
3281 let to_remove = ["name"];
3282 params.remove_params(&to_remove);
3283 }
3284
3285 let url = params.parse_with_url(&url);
3286
3287 loop {
3288 let token = match self
3289 .hub
3290 .auth
3291 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3292 .await
3293 {
3294 Ok(token) => token,
3295 Err(e) => match dlg.token(e) {
3296 Ok(token) => token,
3297 Err(e) => {
3298 dlg.finished(false);
3299 return Err(common::Error::MissingToken(e));
3300 }
3301 },
3302 };
3303 let mut req_result = {
3304 let client = &self.hub.client;
3305 dlg.pre_request();
3306 let mut req_builder = hyper::Request::builder()
3307 .method(hyper::Method::GET)
3308 .uri(url.as_str())
3309 .header(USER_AGENT, self.hub._user_agent.clone());
3310
3311 if let Some(token) = token.as_ref() {
3312 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3313 }
3314
3315 let request = req_builder
3316 .header(CONTENT_LENGTH, 0_u64)
3317 .body(common::to_body::<String>(None));
3318
3319 client.request(request.unwrap()).await
3320 };
3321
3322 match req_result {
3323 Err(err) => {
3324 if let common::Retry::After(d) = dlg.http_error(&err) {
3325 sleep(d).await;
3326 continue;
3327 }
3328 dlg.finished(false);
3329 return Err(common::Error::HttpError(err));
3330 }
3331 Ok(res) => {
3332 let (mut parts, body) = res.into_parts();
3333 let mut body = common::Body::new(body);
3334 if !parts.status.is_success() {
3335 let bytes = common::to_bytes(body).await.unwrap_or_default();
3336 let error = serde_json::from_str(&common::to_string(&bytes));
3337 let response = common::to_response(parts, bytes.into());
3338
3339 if let common::Retry::After(d) =
3340 dlg.http_failure(&response, error.as_ref().ok())
3341 {
3342 sleep(d).await;
3343 continue;
3344 }
3345
3346 dlg.finished(false);
3347
3348 return Err(match error {
3349 Ok(value) => common::Error::BadRequest(value),
3350 _ => common::Error::Failure(response),
3351 });
3352 }
3353 let response = {
3354 let bytes = common::to_bytes(body).await.unwrap_or_default();
3355 let encoded = common::to_string(&bytes);
3356 match serde_json::from_str(&encoded) {
3357 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3358 Err(error) => {
3359 dlg.response_json_decode_error(&encoded, &error);
3360 return Err(common::Error::JsonDecodeError(
3361 encoded.to_string(),
3362 error,
3363 ));
3364 }
3365 }
3366 };
3367
3368 dlg.finished(true);
3369 return Ok(response);
3370 }
3371 }
3372 }
3373 }
3374
3375 /// Required. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
3376 ///
3377 /// Sets the *name* path property to the given value.
3378 ///
3379 /// Even though the property as already been set when instantiating this call,
3380 /// we provide this method for API completeness.
3381 pub fn name(mut self, new_value: &str) -> FolderGetAutokeyConfigCall<'a, C> {
3382 self._name = new_value.to_string();
3383 self
3384 }
3385 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3386 /// while executing the actual API request.
3387 ///
3388 /// ````text
3389 /// It should be used to handle progress information, and to implement a certain level of resilience.
3390 /// ````
3391 ///
3392 /// Sets the *delegate* property to the given value.
3393 pub fn delegate(
3394 mut self,
3395 new_value: &'a mut dyn common::Delegate,
3396 ) -> FolderGetAutokeyConfigCall<'a, C> {
3397 self._delegate = Some(new_value);
3398 self
3399 }
3400
3401 /// Set any additional parameter of the query string used in the request.
3402 /// It should be used to set parameters which are not yet available through their own
3403 /// setters.
3404 ///
3405 /// Please note that this method must not be used to set any of the known parameters
3406 /// which have their own setter method. If done anyway, the request will fail.
3407 ///
3408 /// # Additional Parameters
3409 ///
3410 /// * *$.xgafv* (query-string) - V1 error format.
3411 /// * *access_token* (query-string) - OAuth access token.
3412 /// * *alt* (query-string) - Data format for response.
3413 /// * *callback* (query-string) - JSONP
3414 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3415 /// * *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.
3416 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3417 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3418 /// * *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.
3419 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3420 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3421 pub fn param<T>(mut self, name: T, value: T) -> FolderGetAutokeyConfigCall<'a, C>
3422 where
3423 T: AsRef<str>,
3424 {
3425 self._additional_params
3426 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3427 self
3428 }
3429
3430 /// Identifies the authorization scope for the method you are building.
3431 ///
3432 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3433 /// [`Scope::CloudPlatform`].
3434 ///
3435 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3436 /// tokens for more than one scope.
3437 ///
3438 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3439 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3440 /// sufficient, a read-write scope will do as well.
3441 pub fn add_scope<St>(mut self, scope: St) -> FolderGetAutokeyConfigCall<'a, C>
3442 where
3443 St: AsRef<str>,
3444 {
3445 self._scopes.insert(String::from(scope.as_ref()));
3446 self
3447 }
3448 /// Identifies the authorization scope(s) for the method you are building.
3449 ///
3450 /// See [`Self::add_scope()`] for details.
3451 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetAutokeyConfigCall<'a, C>
3452 where
3453 I: IntoIterator<Item = St>,
3454 St: AsRef<str>,
3455 {
3456 self._scopes
3457 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3458 self
3459 }
3460
3461 /// Removes all scopes, and no default scope will be used either.
3462 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3463 /// for details).
3464 pub fn clear_scopes(mut self) -> FolderGetAutokeyConfigCall<'a, C> {
3465 self._scopes.clear();
3466 self
3467 }
3468}
3469
3470/// 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.
3471///
3472/// A builder for the *updateAutokeyConfig* method supported by a *folder* resource.
3473/// It is not used directly, but through a [`FolderMethods`] instance.
3474///
3475/// # Example
3476///
3477/// Instantiate a resource method builder
3478///
3479/// ```test_harness,no_run
3480/// # extern crate hyper;
3481/// # extern crate hyper_rustls;
3482/// # extern crate google_cloudkms1 as cloudkms1;
3483/// use cloudkms1::api::AutokeyConfig;
3484/// # async fn dox() {
3485/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3486///
3487/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3488/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3489/// # secret,
3490/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3491/// # ).build().await.unwrap();
3492///
3493/// # let client = hyper_util::client::legacy::Client::builder(
3494/// # hyper_util::rt::TokioExecutor::new()
3495/// # )
3496/// # .build(
3497/// # hyper_rustls::HttpsConnectorBuilder::new()
3498/// # .with_native_roots()
3499/// # .unwrap()
3500/// # .https_or_http()
3501/// # .enable_http1()
3502/// # .build()
3503/// # );
3504/// # let mut hub = CloudKMS::new(client, auth);
3505/// // As the method needs a request, you would usually fill it with the desired information
3506/// // into the respective structure. Some of the parts shown here might not be applicable !
3507/// // Values shown here are possibly random and not representative !
3508/// let mut req = AutokeyConfig::default();
3509///
3510/// // You can configure optional parameters by calling the respective setters at will, and
3511/// // execute the final call using `doit()`.
3512/// // Values shown here are possibly random and not representative !
3513/// let result = hub.folders().update_autokey_config(req, "name")
3514/// .update_mask(FieldMask::new::<&str>(&[]))
3515/// .doit().await;
3516/// # }
3517/// ```
3518pub struct FolderUpdateAutokeyConfigCall<'a, C>
3519where
3520 C: 'a,
3521{
3522 hub: &'a CloudKMS<C>,
3523 _request: AutokeyConfig,
3524 _name: String,
3525 _update_mask: Option<common::FieldMask>,
3526 _delegate: Option<&'a mut dyn common::Delegate>,
3527 _additional_params: HashMap<String, String>,
3528 _scopes: BTreeSet<String>,
3529}
3530
3531impl<'a, C> common::CallBuilder for FolderUpdateAutokeyConfigCall<'a, C> {}
3532
3533impl<'a, C> FolderUpdateAutokeyConfigCall<'a, C>
3534where
3535 C: common::Connector,
3536{
3537 /// Perform the operation you have build so far.
3538 pub async fn doit(mut self) -> common::Result<(common::Response, AutokeyConfig)> {
3539 use std::borrow::Cow;
3540 use std::io::{Read, Seek};
3541
3542 use common::{url::Params, ToParts};
3543 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3544
3545 let mut dd = common::DefaultDelegate;
3546 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3547 dlg.begin(common::MethodInfo {
3548 id: "cloudkms.folders.updateAutokeyConfig",
3549 http_method: hyper::Method::PATCH,
3550 });
3551
3552 for &field in ["alt", "name", "updateMask"].iter() {
3553 if self._additional_params.contains_key(field) {
3554 dlg.finished(false);
3555 return Err(common::Error::FieldClash(field));
3556 }
3557 }
3558
3559 let mut params = Params::with_capacity(5 + self._additional_params.len());
3560 params.push("name", self._name);
3561 if let Some(value) = self._update_mask.as_ref() {
3562 params.push("updateMask", value.to_string());
3563 }
3564
3565 params.extend(self._additional_params.iter());
3566
3567 params.push("alt", "json");
3568 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3569 if self._scopes.is_empty() {
3570 self._scopes
3571 .insert(Scope::CloudPlatform.as_ref().to_string());
3572 }
3573
3574 #[allow(clippy::single_element_loop)]
3575 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3576 url = params.uri_replacement(url, param_name, find_this, true);
3577 }
3578 {
3579 let to_remove = ["name"];
3580 params.remove_params(&to_remove);
3581 }
3582
3583 let url = params.parse_with_url(&url);
3584
3585 let mut json_mime_type = mime::APPLICATION_JSON;
3586 let mut request_value_reader = {
3587 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3588 common::remove_json_null_values(&mut value);
3589 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3590 serde_json::to_writer(&mut dst, &value).unwrap();
3591 dst
3592 };
3593 let request_size = request_value_reader
3594 .seek(std::io::SeekFrom::End(0))
3595 .unwrap();
3596 request_value_reader
3597 .seek(std::io::SeekFrom::Start(0))
3598 .unwrap();
3599
3600 loop {
3601 let token = match self
3602 .hub
3603 .auth
3604 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3605 .await
3606 {
3607 Ok(token) => token,
3608 Err(e) => match dlg.token(e) {
3609 Ok(token) => token,
3610 Err(e) => {
3611 dlg.finished(false);
3612 return Err(common::Error::MissingToken(e));
3613 }
3614 },
3615 };
3616 request_value_reader
3617 .seek(std::io::SeekFrom::Start(0))
3618 .unwrap();
3619 let mut req_result = {
3620 let client = &self.hub.client;
3621 dlg.pre_request();
3622 let mut req_builder = hyper::Request::builder()
3623 .method(hyper::Method::PATCH)
3624 .uri(url.as_str())
3625 .header(USER_AGENT, self.hub._user_agent.clone());
3626
3627 if let Some(token) = token.as_ref() {
3628 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3629 }
3630
3631 let request = req_builder
3632 .header(CONTENT_TYPE, json_mime_type.to_string())
3633 .header(CONTENT_LENGTH, request_size as u64)
3634 .body(common::to_body(
3635 request_value_reader.get_ref().clone().into(),
3636 ));
3637
3638 client.request(request.unwrap()).await
3639 };
3640
3641 match req_result {
3642 Err(err) => {
3643 if let common::Retry::After(d) = dlg.http_error(&err) {
3644 sleep(d).await;
3645 continue;
3646 }
3647 dlg.finished(false);
3648 return Err(common::Error::HttpError(err));
3649 }
3650 Ok(res) => {
3651 let (mut parts, body) = res.into_parts();
3652 let mut body = common::Body::new(body);
3653 if !parts.status.is_success() {
3654 let bytes = common::to_bytes(body).await.unwrap_or_default();
3655 let error = serde_json::from_str(&common::to_string(&bytes));
3656 let response = common::to_response(parts, bytes.into());
3657
3658 if let common::Retry::After(d) =
3659 dlg.http_failure(&response, error.as_ref().ok())
3660 {
3661 sleep(d).await;
3662 continue;
3663 }
3664
3665 dlg.finished(false);
3666
3667 return Err(match error {
3668 Ok(value) => common::Error::BadRequest(value),
3669 _ => common::Error::Failure(response),
3670 });
3671 }
3672 let response = {
3673 let bytes = common::to_bytes(body).await.unwrap_or_default();
3674 let encoded = common::to_string(&bytes);
3675 match serde_json::from_str(&encoded) {
3676 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3677 Err(error) => {
3678 dlg.response_json_decode_error(&encoded, &error);
3679 return Err(common::Error::JsonDecodeError(
3680 encoded.to_string(),
3681 error,
3682 ));
3683 }
3684 }
3685 };
3686
3687 dlg.finished(true);
3688 return Ok(response);
3689 }
3690 }
3691 }
3692 }
3693
3694 ///
3695 /// Sets the *request* property to the given value.
3696 ///
3697 /// Even though the property as already been set when instantiating this call,
3698 /// we provide this method for API completeness.
3699 pub fn request(mut self, new_value: AutokeyConfig) -> FolderUpdateAutokeyConfigCall<'a, C> {
3700 self._request = new_value;
3701 self
3702 }
3703 /// Identifier. Name of the AutokeyConfig resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig`.
3704 ///
3705 /// Sets the *name* path property to the given value.
3706 ///
3707 /// Even though the property as already been set when instantiating this call,
3708 /// we provide this method for API completeness.
3709 pub fn name(mut self, new_value: &str) -> FolderUpdateAutokeyConfigCall<'a, C> {
3710 self._name = new_value.to_string();
3711 self
3712 }
3713 /// Required. Masks which fields of the AutokeyConfig to update, e.g. `keyProject`.
3714 ///
3715 /// Sets the *update mask* query property to the given value.
3716 pub fn update_mask(
3717 mut self,
3718 new_value: common::FieldMask,
3719 ) -> FolderUpdateAutokeyConfigCall<'a, C> {
3720 self._update_mask = Some(new_value);
3721 self
3722 }
3723 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3724 /// while executing the actual API request.
3725 ///
3726 /// ````text
3727 /// It should be used to handle progress information, and to implement a certain level of resilience.
3728 /// ````
3729 ///
3730 /// Sets the *delegate* property to the given value.
3731 pub fn delegate(
3732 mut self,
3733 new_value: &'a mut dyn common::Delegate,
3734 ) -> FolderUpdateAutokeyConfigCall<'a, C> {
3735 self._delegate = Some(new_value);
3736 self
3737 }
3738
3739 /// Set any additional parameter of the query string used in the request.
3740 /// It should be used to set parameters which are not yet available through their own
3741 /// setters.
3742 ///
3743 /// Please note that this method must not be used to set any of the known parameters
3744 /// which have their own setter method. If done anyway, the request will fail.
3745 ///
3746 /// # Additional Parameters
3747 ///
3748 /// * *$.xgafv* (query-string) - V1 error format.
3749 /// * *access_token* (query-string) - OAuth access token.
3750 /// * *alt* (query-string) - Data format for response.
3751 /// * *callback* (query-string) - JSONP
3752 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3753 /// * *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.
3754 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3755 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3756 /// * *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.
3757 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3758 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3759 pub fn param<T>(mut self, name: T, value: T) -> FolderUpdateAutokeyConfigCall<'a, C>
3760 where
3761 T: AsRef<str>,
3762 {
3763 self._additional_params
3764 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3765 self
3766 }
3767
3768 /// Identifies the authorization scope for the method you are building.
3769 ///
3770 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3771 /// [`Scope::CloudPlatform`].
3772 ///
3773 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3774 /// tokens for more than one scope.
3775 ///
3776 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3777 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3778 /// sufficient, a read-write scope will do as well.
3779 pub fn add_scope<St>(mut self, scope: St) -> FolderUpdateAutokeyConfigCall<'a, C>
3780 where
3781 St: AsRef<str>,
3782 {
3783 self._scopes.insert(String::from(scope.as_ref()));
3784 self
3785 }
3786 /// Identifies the authorization scope(s) for the method you are building.
3787 ///
3788 /// See [`Self::add_scope()`] for details.
3789 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUpdateAutokeyConfigCall<'a, C>
3790 where
3791 I: IntoIterator<Item = St>,
3792 St: AsRef<str>,
3793 {
3794 self._scopes
3795 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3796 self
3797 }
3798
3799 /// Removes all scopes, and no default scope will be used either.
3800 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3801 /// for details).
3802 pub fn clear_scopes(mut self) -> FolderUpdateAutokeyConfigCall<'a, C> {
3803 self._scopes.clear();
3804 self
3805 }
3806}
3807
3808/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3809///
3810/// A builder for the *locations.ekmConfig.getIamPolicy* method supported by a *project* resource.
3811/// It is not used directly, but through a [`ProjectMethods`] instance.
3812///
3813/// # Example
3814///
3815/// Instantiate a resource method builder
3816///
3817/// ```test_harness,no_run
3818/// # extern crate hyper;
3819/// # extern crate hyper_rustls;
3820/// # extern crate google_cloudkms1 as cloudkms1;
3821/// # async fn dox() {
3822/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3823///
3824/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3825/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3826/// # secret,
3827/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3828/// # ).build().await.unwrap();
3829///
3830/// # let client = hyper_util::client::legacy::Client::builder(
3831/// # hyper_util::rt::TokioExecutor::new()
3832/// # )
3833/// # .build(
3834/// # hyper_rustls::HttpsConnectorBuilder::new()
3835/// # .with_native_roots()
3836/// # .unwrap()
3837/// # .https_or_http()
3838/// # .enable_http1()
3839/// # .build()
3840/// # );
3841/// # let mut hub = CloudKMS::new(client, auth);
3842/// // You can configure optional parameters by calling the respective setters at will, and
3843/// // execute the final call using `doit()`.
3844/// // Values shown here are possibly random and not representative !
3845/// let result = hub.projects().locations_ekm_config_get_iam_policy("resource")
3846/// .options_requested_policy_version(-59)
3847/// .doit().await;
3848/// # }
3849/// ```
3850pub struct ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
3851where
3852 C: 'a,
3853{
3854 hub: &'a CloudKMS<C>,
3855 _resource: String,
3856 _options_requested_policy_version: Option<i32>,
3857 _delegate: Option<&'a mut dyn common::Delegate>,
3858 _additional_params: HashMap<String, String>,
3859 _scopes: BTreeSet<String>,
3860}
3861
3862impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {}
3863
3864impl<'a, C> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
3865where
3866 C: common::Connector,
3867{
3868 /// Perform the operation you have build so far.
3869 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
3870 use std::borrow::Cow;
3871 use std::io::{Read, Seek};
3872
3873 use common::{url::Params, ToParts};
3874 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3875
3876 let mut dd = common::DefaultDelegate;
3877 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3878 dlg.begin(common::MethodInfo {
3879 id: "cloudkms.projects.locations.ekmConfig.getIamPolicy",
3880 http_method: hyper::Method::GET,
3881 });
3882
3883 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
3884 if self._additional_params.contains_key(field) {
3885 dlg.finished(false);
3886 return Err(common::Error::FieldClash(field));
3887 }
3888 }
3889
3890 let mut params = Params::with_capacity(4 + self._additional_params.len());
3891 params.push("resource", self._resource);
3892 if let Some(value) = self._options_requested_policy_version.as_ref() {
3893 params.push("options.requestedPolicyVersion", value.to_string());
3894 }
3895
3896 params.extend(self._additional_params.iter());
3897
3898 params.push("alt", "json");
3899 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
3900 if self._scopes.is_empty() {
3901 self._scopes
3902 .insert(Scope::CloudPlatform.as_ref().to_string());
3903 }
3904
3905 #[allow(clippy::single_element_loop)]
3906 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3907 url = params.uri_replacement(url, param_name, find_this, true);
3908 }
3909 {
3910 let to_remove = ["resource"];
3911 params.remove_params(&to_remove);
3912 }
3913
3914 let url = params.parse_with_url(&url);
3915
3916 loop {
3917 let token = match self
3918 .hub
3919 .auth
3920 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3921 .await
3922 {
3923 Ok(token) => token,
3924 Err(e) => match dlg.token(e) {
3925 Ok(token) => token,
3926 Err(e) => {
3927 dlg.finished(false);
3928 return Err(common::Error::MissingToken(e));
3929 }
3930 },
3931 };
3932 let mut req_result = {
3933 let client = &self.hub.client;
3934 dlg.pre_request();
3935 let mut req_builder = hyper::Request::builder()
3936 .method(hyper::Method::GET)
3937 .uri(url.as_str())
3938 .header(USER_AGENT, self.hub._user_agent.clone());
3939
3940 if let Some(token) = token.as_ref() {
3941 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3942 }
3943
3944 let request = req_builder
3945 .header(CONTENT_LENGTH, 0_u64)
3946 .body(common::to_body::<String>(None));
3947
3948 client.request(request.unwrap()).await
3949 };
3950
3951 match req_result {
3952 Err(err) => {
3953 if let common::Retry::After(d) = dlg.http_error(&err) {
3954 sleep(d).await;
3955 continue;
3956 }
3957 dlg.finished(false);
3958 return Err(common::Error::HttpError(err));
3959 }
3960 Ok(res) => {
3961 let (mut parts, body) = res.into_parts();
3962 let mut body = common::Body::new(body);
3963 if !parts.status.is_success() {
3964 let bytes = common::to_bytes(body).await.unwrap_or_default();
3965 let error = serde_json::from_str(&common::to_string(&bytes));
3966 let response = common::to_response(parts, bytes.into());
3967
3968 if let common::Retry::After(d) =
3969 dlg.http_failure(&response, error.as_ref().ok())
3970 {
3971 sleep(d).await;
3972 continue;
3973 }
3974
3975 dlg.finished(false);
3976
3977 return Err(match error {
3978 Ok(value) => common::Error::BadRequest(value),
3979 _ => common::Error::Failure(response),
3980 });
3981 }
3982 let response = {
3983 let bytes = common::to_bytes(body).await.unwrap_or_default();
3984 let encoded = common::to_string(&bytes);
3985 match serde_json::from_str(&encoded) {
3986 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3987 Err(error) => {
3988 dlg.response_json_decode_error(&encoded, &error);
3989 return Err(common::Error::JsonDecodeError(
3990 encoded.to_string(),
3991 error,
3992 ));
3993 }
3994 }
3995 };
3996
3997 dlg.finished(true);
3998 return Ok(response);
3999 }
4000 }
4001 }
4002 }
4003
4004 /// 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.
4005 ///
4006 /// Sets the *resource* path property to the given value.
4007 ///
4008 /// Even though the property as already been set when instantiating this call,
4009 /// we provide this method for API completeness.
4010 pub fn resource(mut self, new_value: &str) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
4011 self._resource = new_value.to_string();
4012 self
4013 }
4014 /// 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).
4015 ///
4016 /// Sets the *options.requested policy version* query property to the given value.
4017 pub fn options_requested_policy_version(
4018 mut self,
4019 new_value: i32,
4020 ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
4021 self._options_requested_policy_version = Some(new_value);
4022 self
4023 }
4024 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4025 /// while executing the actual API request.
4026 ///
4027 /// ````text
4028 /// It should be used to handle progress information, and to implement a certain level of resilience.
4029 /// ````
4030 ///
4031 /// Sets the *delegate* property to the given value.
4032 pub fn delegate(
4033 mut self,
4034 new_value: &'a mut dyn common::Delegate,
4035 ) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
4036 self._delegate = Some(new_value);
4037 self
4038 }
4039
4040 /// Set any additional parameter of the query string used in the request.
4041 /// It should be used to set parameters which are not yet available through their own
4042 /// setters.
4043 ///
4044 /// Please note that this method must not be used to set any of the known parameters
4045 /// which have their own setter method. If done anyway, the request will fail.
4046 ///
4047 /// # Additional Parameters
4048 ///
4049 /// * *$.xgafv* (query-string) - V1 error format.
4050 /// * *access_token* (query-string) - OAuth access token.
4051 /// * *alt* (query-string) - Data format for response.
4052 /// * *callback* (query-string) - JSONP
4053 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4054 /// * *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.
4055 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4056 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4057 /// * *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.
4058 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4059 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4060 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
4061 where
4062 T: AsRef<str>,
4063 {
4064 self._additional_params
4065 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4066 self
4067 }
4068
4069 /// Identifies the authorization scope for the method you are building.
4070 ///
4071 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4072 /// [`Scope::CloudPlatform`].
4073 ///
4074 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4075 /// tokens for more than one scope.
4076 ///
4077 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4078 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4079 /// sufficient, a read-write scope will do as well.
4080 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
4081 where
4082 St: AsRef<str>,
4083 {
4084 self._scopes.insert(String::from(scope.as_ref()));
4085 self
4086 }
4087 /// Identifies the authorization scope(s) for the method you are building.
4088 ///
4089 /// See [`Self::add_scope()`] for details.
4090 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C>
4091 where
4092 I: IntoIterator<Item = St>,
4093 St: AsRef<str>,
4094 {
4095 self._scopes
4096 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4097 self
4098 }
4099
4100 /// Removes all scopes, and no default scope will be used either.
4101 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4102 /// for details).
4103 pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigGetIamPolicyCall<'a, C> {
4104 self._scopes.clear();
4105 self
4106 }
4107}
4108
4109/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
4110///
4111/// A builder for the *locations.ekmConfig.setIamPolicy* method supported by a *project* resource.
4112/// It is not used directly, but through a [`ProjectMethods`] instance.
4113///
4114/// # Example
4115///
4116/// Instantiate a resource method builder
4117///
4118/// ```test_harness,no_run
4119/// # extern crate hyper;
4120/// # extern crate hyper_rustls;
4121/// # extern crate google_cloudkms1 as cloudkms1;
4122/// use cloudkms1::api::SetIamPolicyRequest;
4123/// # async fn dox() {
4124/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4125///
4126/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4127/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4128/// # secret,
4129/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4130/// # ).build().await.unwrap();
4131///
4132/// # let client = hyper_util::client::legacy::Client::builder(
4133/// # hyper_util::rt::TokioExecutor::new()
4134/// # )
4135/// # .build(
4136/// # hyper_rustls::HttpsConnectorBuilder::new()
4137/// # .with_native_roots()
4138/// # .unwrap()
4139/// # .https_or_http()
4140/// # .enable_http1()
4141/// # .build()
4142/// # );
4143/// # let mut hub = CloudKMS::new(client, auth);
4144/// // As the method needs a request, you would usually fill it with the desired information
4145/// // into the respective structure. Some of the parts shown here might not be applicable !
4146/// // Values shown here are possibly random and not representative !
4147/// let mut req = SetIamPolicyRequest::default();
4148///
4149/// // You can configure optional parameters by calling the respective setters at will, and
4150/// // execute the final call using `doit()`.
4151/// // Values shown here are possibly random and not representative !
4152/// let result = hub.projects().locations_ekm_config_set_iam_policy(req, "resource")
4153/// .doit().await;
4154/// # }
4155/// ```
4156pub struct ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
4157where
4158 C: 'a,
4159{
4160 hub: &'a CloudKMS<C>,
4161 _request: SetIamPolicyRequest,
4162 _resource: String,
4163 _delegate: Option<&'a mut dyn common::Delegate>,
4164 _additional_params: HashMap<String, String>,
4165 _scopes: BTreeSet<String>,
4166}
4167
4168impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {}
4169
4170impl<'a, C> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
4171where
4172 C: common::Connector,
4173{
4174 /// Perform the operation you have build so far.
4175 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4176 use std::borrow::Cow;
4177 use std::io::{Read, Seek};
4178
4179 use common::{url::Params, ToParts};
4180 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4181
4182 let mut dd = common::DefaultDelegate;
4183 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4184 dlg.begin(common::MethodInfo {
4185 id: "cloudkms.projects.locations.ekmConfig.setIamPolicy",
4186 http_method: hyper::Method::POST,
4187 });
4188
4189 for &field in ["alt", "resource"].iter() {
4190 if self._additional_params.contains_key(field) {
4191 dlg.finished(false);
4192 return Err(common::Error::FieldClash(field));
4193 }
4194 }
4195
4196 let mut params = Params::with_capacity(4 + self._additional_params.len());
4197 params.push("resource", self._resource);
4198
4199 params.extend(self._additional_params.iter());
4200
4201 params.push("alt", "json");
4202 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
4203 if self._scopes.is_empty() {
4204 self._scopes
4205 .insert(Scope::CloudPlatform.as_ref().to_string());
4206 }
4207
4208 #[allow(clippy::single_element_loop)]
4209 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4210 url = params.uri_replacement(url, param_name, find_this, true);
4211 }
4212 {
4213 let to_remove = ["resource"];
4214 params.remove_params(&to_remove);
4215 }
4216
4217 let url = params.parse_with_url(&url);
4218
4219 let mut json_mime_type = mime::APPLICATION_JSON;
4220 let mut request_value_reader = {
4221 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4222 common::remove_json_null_values(&mut value);
4223 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4224 serde_json::to_writer(&mut dst, &value).unwrap();
4225 dst
4226 };
4227 let request_size = request_value_reader
4228 .seek(std::io::SeekFrom::End(0))
4229 .unwrap();
4230 request_value_reader
4231 .seek(std::io::SeekFrom::Start(0))
4232 .unwrap();
4233
4234 loop {
4235 let token = match self
4236 .hub
4237 .auth
4238 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4239 .await
4240 {
4241 Ok(token) => token,
4242 Err(e) => match dlg.token(e) {
4243 Ok(token) => token,
4244 Err(e) => {
4245 dlg.finished(false);
4246 return Err(common::Error::MissingToken(e));
4247 }
4248 },
4249 };
4250 request_value_reader
4251 .seek(std::io::SeekFrom::Start(0))
4252 .unwrap();
4253 let mut req_result = {
4254 let client = &self.hub.client;
4255 dlg.pre_request();
4256 let mut req_builder = hyper::Request::builder()
4257 .method(hyper::Method::POST)
4258 .uri(url.as_str())
4259 .header(USER_AGENT, self.hub._user_agent.clone());
4260
4261 if let Some(token) = token.as_ref() {
4262 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4263 }
4264
4265 let request = req_builder
4266 .header(CONTENT_TYPE, json_mime_type.to_string())
4267 .header(CONTENT_LENGTH, request_size as u64)
4268 .body(common::to_body(
4269 request_value_reader.get_ref().clone().into(),
4270 ));
4271
4272 client.request(request.unwrap()).await
4273 };
4274
4275 match req_result {
4276 Err(err) => {
4277 if let common::Retry::After(d) = dlg.http_error(&err) {
4278 sleep(d).await;
4279 continue;
4280 }
4281 dlg.finished(false);
4282 return Err(common::Error::HttpError(err));
4283 }
4284 Ok(res) => {
4285 let (mut parts, body) = res.into_parts();
4286 let mut body = common::Body::new(body);
4287 if !parts.status.is_success() {
4288 let bytes = common::to_bytes(body).await.unwrap_or_default();
4289 let error = serde_json::from_str(&common::to_string(&bytes));
4290 let response = common::to_response(parts, bytes.into());
4291
4292 if let common::Retry::After(d) =
4293 dlg.http_failure(&response, error.as_ref().ok())
4294 {
4295 sleep(d).await;
4296 continue;
4297 }
4298
4299 dlg.finished(false);
4300
4301 return Err(match error {
4302 Ok(value) => common::Error::BadRequest(value),
4303 _ => common::Error::Failure(response),
4304 });
4305 }
4306 let response = {
4307 let bytes = common::to_bytes(body).await.unwrap_or_default();
4308 let encoded = common::to_string(&bytes);
4309 match serde_json::from_str(&encoded) {
4310 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4311 Err(error) => {
4312 dlg.response_json_decode_error(&encoded, &error);
4313 return Err(common::Error::JsonDecodeError(
4314 encoded.to_string(),
4315 error,
4316 ));
4317 }
4318 }
4319 };
4320
4321 dlg.finished(true);
4322 return Ok(response);
4323 }
4324 }
4325 }
4326 }
4327
4328 ///
4329 /// Sets the *request* property to the given value.
4330 ///
4331 /// Even though the property as already been set when instantiating this call,
4332 /// we provide this method for API completeness.
4333 pub fn request(
4334 mut self,
4335 new_value: SetIamPolicyRequest,
4336 ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
4337 self._request = new_value;
4338 self
4339 }
4340 /// 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.
4341 ///
4342 /// Sets the *resource* path property to the given value.
4343 ///
4344 /// Even though the property as already been set when instantiating this call,
4345 /// we provide this method for API completeness.
4346 pub fn resource(mut self, new_value: &str) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
4347 self._resource = new_value.to_string();
4348 self
4349 }
4350 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4351 /// while executing the actual API request.
4352 ///
4353 /// ````text
4354 /// It should be used to handle progress information, and to implement a certain level of resilience.
4355 /// ````
4356 ///
4357 /// Sets the *delegate* property to the given value.
4358 pub fn delegate(
4359 mut self,
4360 new_value: &'a mut dyn common::Delegate,
4361 ) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
4362 self._delegate = Some(new_value);
4363 self
4364 }
4365
4366 /// Set any additional parameter of the query string used in the request.
4367 /// It should be used to set parameters which are not yet available through their own
4368 /// setters.
4369 ///
4370 /// Please note that this method must not be used to set any of the known parameters
4371 /// which have their own setter method. If done anyway, the request will fail.
4372 ///
4373 /// # Additional Parameters
4374 ///
4375 /// * *$.xgafv* (query-string) - V1 error format.
4376 /// * *access_token* (query-string) - OAuth access token.
4377 /// * *alt* (query-string) - Data format for response.
4378 /// * *callback* (query-string) - JSONP
4379 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4380 /// * *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.
4381 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4382 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4383 /// * *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.
4384 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4385 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4386 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
4387 where
4388 T: AsRef<str>,
4389 {
4390 self._additional_params
4391 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4392 self
4393 }
4394
4395 /// Identifies the authorization scope for the method you are building.
4396 ///
4397 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4398 /// [`Scope::CloudPlatform`].
4399 ///
4400 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4401 /// tokens for more than one scope.
4402 ///
4403 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4404 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4405 /// sufficient, a read-write scope will do as well.
4406 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
4407 where
4408 St: AsRef<str>,
4409 {
4410 self._scopes.insert(String::from(scope.as_ref()));
4411 self
4412 }
4413 /// Identifies the authorization scope(s) for the method you are building.
4414 ///
4415 /// See [`Self::add_scope()`] for details.
4416 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C>
4417 where
4418 I: IntoIterator<Item = St>,
4419 St: AsRef<str>,
4420 {
4421 self._scopes
4422 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4423 self
4424 }
4425
4426 /// Removes all scopes, and no default scope will be used either.
4427 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4428 /// for details).
4429 pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigSetIamPolicyCall<'a, C> {
4430 self._scopes.clear();
4431 self
4432 }
4433}
4434
4435/// 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.
4436///
4437/// A builder for the *locations.ekmConfig.testIamPermissions* method supported by a *project* resource.
4438/// It is not used directly, but through a [`ProjectMethods`] instance.
4439///
4440/// # Example
4441///
4442/// Instantiate a resource method builder
4443///
4444/// ```test_harness,no_run
4445/// # extern crate hyper;
4446/// # extern crate hyper_rustls;
4447/// # extern crate google_cloudkms1 as cloudkms1;
4448/// use cloudkms1::api::TestIamPermissionsRequest;
4449/// # async fn dox() {
4450/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4451///
4452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4454/// # secret,
4455/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4456/// # ).build().await.unwrap();
4457///
4458/// # let client = hyper_util::client::legacy::Client::builder(
4459/// # hyper_util::rt::TokioExecutor::new()
4460/// # )
4461/// # .build(
4462/// # hyper_rustls::HttpsConnectorBuilder::new()
4463/// # .with_native_roots()
4464/// # .unwrap()
4465/// # .https_or_http()
4466/// # .enable_http1()
4467/// # .build()
4468/// # );
4469/// # let mut hub = CloudKMS::new(client, auth);
4470/// // As the method needs a request, you would usually fill it with the desired information
4471/// // into the respective structure. Some of the parts shown here might not be applicable !
4472/// // Values shown here are possibly random and not representative !
4473/// let mut req = TestIamPermissionsRequest::default();
4474///
4475/// // You can configure optional parameters by calling the respective setters at will, and
4476/// // execute the final call using `doit()`.
4477/// // Values shown here are possibly random and not representative !
4478/// let result = hub.projects().locations_ekm_config_test_iam_permissions(req, "resource")
4479/// .doit().await;
4480/// # }
4481/// ```
4482pub struct ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
4483where
4484 C: 'a,
4485{
4486 hub: &'a CloudKMS<C>,
4487 _request: TestIamPermissionsRequest,
4488 _resource: String,
4489 _delegate: Option<&'a mut dyn common::Delegate>,
4490 _additional_params: HashMap<String, String>,
4491 _scopes: BTreeSet<String>,
4492}
4493
4494impl<'a, C> common::CallBuilder for ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {}
4495
4496impl<'a, C> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
4497where
4498 C: common::Connector,
4499{
4500 /// Perform the operation you have build so far.
4501 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4502 use std::borrow::Cow;
4503 use std::io::{Read, Seek};
4504
4505 use common::{url::Params, ToParts};
4506 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4507
4508 let mut dd = common::DefaultDelegate;
4509 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4510 dlg.begin(common::MethodInfo {
4511 id: "cloudkms.projects.locations.ekmConfig.testIamPermissions",
4512 http_method: hyper::Method::POST,
4513 });
4514
4515 for &field in ["alt", "resource"].iter() {
4516 if self._additional_params.contains_key(field) {
4517 dlg.finished(false);
4518 return Err(common::Error::FieldClash(field));
4519 }
4520 }
4521
4522 let mut params = Params::with_capacity(4 + self._additional_params.len());
4523 params.push("resource", self._resource);
4524
4525 params.extend(self._additional_params.iter());
4526
4527 params.push("alt", "json");
4528 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
4529 if self._scopes.is_empty() {
4530 self._scopes
4531 .insert(Scope::CloudPlatform.as_ref().to_string());
4532 }
4533
4534 #[allow(clippy::single_element_loop)]
4535 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4536 url = params.uri_replacement(url, param_name, find_this, true);
4537 }
4538 {
4539 let to_remove = ["resource"];
4540 params.remove_params(&to_remove);
4541 }
4542
4543 let url = params.parse_with_url(&url);
4544
4545 let mut json_mime_type = mime::APPLICATION_JSON;
4546 let mut request_value_reader = {
4547 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4548 common::remove_json_null_values(&mut value);
4549 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4550 serde_json::to_writer(&mut dst, &value).unwrap();
4551 dst
4552 };
4553 let request_size = request_value_reader
4554 .seek(std::io::SeekFrom::End(0))
4555 .unwrap();
4556 request_value_reader
4557 .seek(std::io::SeekFrom::Start(0))
4558 .unwrap();
4559
4560 loop {
4561 let token = match self
4562 .hub
4563 .auth
4564 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4565 .await
4566 {
4567 Ok(token) => token,
4568 Err(e) => match dlg.token(e) {
4569 Ok(token) => token,
4570 Err(e) => {
4571 dlg.finished(false);
4572 return Err(common::Error::MissingToken(e));
4573 }
4574 },
4575 };
4576 request_value_reader
4577 .seek(std::io::SeekFrom::Start(0))
4578 .unwrap();
4579 let mut req_result = {
4580 let client = &self.hub.client;
4581 dlg.pre_request();
4582 let mut req_builder = hyper::Request::builder()
4583 .method(hyper::Method::POST)
4584 .uri(url.as_str())
4585 .header(USER_AGENT, self.hub._user_agent.clone());
4586
4587 if let Some(token) = token.as_ref() {
4588 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4589 }
4590
4591 let request = req_builder
4592 .header(CONTENT_TYPE, json_mime_type.to_string())
4593 .header(CONTENT_LENGTH, request_size as u64)
4594 .body(common::to_body(
4595 request_value_reader.get_ref().clone().into(),
4596 ));
4597
4598 client.request(request.unwrap()).await
4599 };
4600
4601 match req_result {
4602 Err(err) => {
4603 if let common::Retry::After(d) = dlg.http_error(&err) {
4604 sleep(d).await;
4605 continue;
4606 }
4607 dlg.finished(false);
4608 return Err(common::Error::HttpError(err));
4609 }
4610 Ok(res) => {
4611 let (mut parts, body) = res.into_parts();
4612 let mut body = common::Body::new(body);
4613 if !parts.status.is_success() {
4614 let bytes = common::to_bytes(body).await.unwrap_or_default();
4615 let error = serde_json::from_str(&common::to_string(&bytes));
4616 let response = common::to_response(parts, bytes.into());
4617
4618 if let common::Retry::After(d) =
4619 dlg.http_failure(&response, error.as_ref().ok())
4620 {
4621 sleep(d).await;
4622 continue;
4623 }
4624
4625 dlg.finished(false);
4626
4627 return Err(match error {
4628 Ok(value) => common::Error::BadRequest(value),
4629 _ => common::Error::Failure(response),
4630 });
4631 }
4632 let response = {
4633 let bytes = common::to_bytes(body).await.unwrap_or_default();
4634 let encoded = common::to_string(&bytes);
4635 match serde_json::from_str(&encoded) {
4636 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4637 Err(error) => {
4638 dlg.response_json_decode_error(&encoded, &error);
4639 return Err(common::Error::JsonDecodeError(
4640 encoded.to_string(),
4641 error,
4642 ));
4643 }
4644 }
4645 };
4646
4647 dlg.finished(true);
4648 return Ok(response);
4649 }
4650 }
4651 }
4652 }
4653
4654 ///
4655 /// Sets the *request* property to the given value.
4656 ///
4657 /// Even though the property as already been set when instantiating this call,
4658 /// we provide this method for API completeness.
4659 pub fn request(
4660 mut self,
4661 new_value: TestIamPermissionsRequest,
4662 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
4663 self._request = new_value;
4664 self
4665 }
4666 /// 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.
4667 ///
4668 /// Sets the *resource* path property to the given value.
4669 ///
4670 /// Even though the property as already been set when instantiating this call,
4671 /// we provide this method for API completeness.
4672 pub fn resource(
4673 mut self,
4674 new_value: &str,
4675 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
4676 self._resource = new_value.to_string();
4677 self
4678 }
4679 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4680 /// while executing the actual API request.
4681 ///
4682 /// ````text
4683 /// It should be used to handle progress information, and to implement a certain level of resilience.
4684 /// ````
4685 ///
4686 /// Sets the *delegate* property to the given value.
4687 pub fn delegate(
4688 mut self,
4689 new_value: &'a mut dyn common::Delegate,
4690 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
4691 self._delegate = Some(new_value);
4692 self
4693 }
4694
4695 /// Set any additional parameter of the query string used in the request.
4696 /// It should be used to set parameters which are not yet available through their own
4697 /// setters.
4698 ///
4699 /// Please note that this method must not be used to set any of the known parameters
4700 /// which have their own setter method. If done anyway, the request will fail.
4701 ///
4702 /// # Additional Parameters
4703 ///
4704 /// * *$.xgafv* (query-string) - V1 error format.
4705 /// * *access_token* (query-string) - OAuth access token.
4706 /// * *alt* (query-string) - Data format for response.
4707 /// * *callback* (query-string) - JSONP
4708 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4709 /// * *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.
4710 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4711 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4712 /// * *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.
4713 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4714 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4715 pub fn param<T>(
4716 mut self,
4717 name: T,
4718 value: T,
4719 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
4720 where
4721 T: AsRef<str>,
4722 {
4723 self._additional_params
4724 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4725 self
4726 }
4727
4728 /// Identifies the authorization scope for the method you are building.
4729 ///
4730 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4731 /// [`Scope::CloudPlatform`].
4732 ///
4733 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4734 /// tokens for more than one scope.
4735 ///
4736 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4737 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4738 /// sufficient, a read-write scope will do as well.
4739 pub fn add_scope<St>(
4740 mut self,
4741 scope: St,
4742 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
4743 where
4744 St: AsRef<str>,
4745 {
4746 self._scopes.insert(String::from(scope.as_ref()));
4747 self
4748 }
4749 /// Identifies the authorization scope(s) for the method you are building.
4750 ///
4751 /// See [`Self::add_scope()`] for details.
4752 pub fn add_scopes<I, St>(
4753 mut self,
4754 scopes: I,
4755 ) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C>
4756 where
4757 I: IntoIterator<Item = St>,
4758 St: AsRef<str>,
4759 {
4760 self._scopes
4761 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4762 self
4763 }
4764
4765 /// Removes all scopes, and no default scope will be used either.
4766 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4767 /// for details).
4768 pub fn clear_scopes(mut self) -> ProjectLocationEkmConfigTestIamPermissionCall<'a, C> {
4769 self._scopes.clear();
4770 self
4771 }
4772}
4773
4774/// Creates a new EkmConnection in a given Project and Location.
4775///
4776/// A builder for the *locations.ekmConnections.create* method supported by a *project* resource.
4777/// It is not used directly, but through a [`ProjectMethods`] instance.
4778///
4779/// # Example
4780///
4781/// Instantiate a resource method builder
4782///
4783/// ```test_harness,no_run
4784/// # extern crate hyper;
4785/// # extern crate hyper_rustls;
4786/// # extern crate google_cloudkms1 as cloudkms1;
4787/// use cloudkms1::api::EkmConnection;
4788/// # async fn dox() {
4789/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4790///
4791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4792/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4793/// # secret,
4794/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4795/// # ).build().await.unwrap();
4796///
4797/// # let client = hyper_util::client::legacy::Client::builder(
4798/// # hyper_util::rt::TokioExecutor::new()
4799/// # )
4800/// # .build(
4801/// # hyper_rustls::HttpsConnectorBuilder::new()
4802/// # .with_native_roots()
4803/// # .unwrap()
4804/// # .https_or_http()
4805/// # .enable_http1()
4806/// # .build()
4807/// # );
4808/// # let mut hub = CloudKMS::new(client, auth);
4809/// // As the method needs a request, you would usually fill it with the desired information
4810/// // into the respective structure. Some of the parts shown here might not be applicable !
4811/// // Values shown here are possibly random and not representative !
4812/// let mut req = EkmConnection::default();
4813///
4814/// // You can configure optional parameters by calling the respective setters at will, and
4815/// // execute the final call using `doit()`.
4816/// // Values shown here are possibly random and not representative !
4817/// let result = hub.projects().locations_ekm_connections_create(req, "parent")
4818/// .ekm_connection_id("gubergren")
4819/// .doit().await;
4820/// # }
4821/// ```
4822pub struct ProjectLocationEkmConnectionCreateCall<'a, C>
4823where
4824 C: 'a,
4825{
4826 hub: &'a CloudKMS<C>,
4827 _request: EkmConnection,
4828 _parent: String,
4829 _ekm_connection_id: Option<String>,
4830 _delegate: Option<&'a mut dyn common::Delegate>,
4831 _additional_params: HashMap<String, String>,
4832 _scopes: BTreeSet<String>,
4833}
4834
4835impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionCreateCall<'a, C> {}
4836
4837impl<'a, C> ProjectLocationEkmConnectionCreateCall<'a, C>
4838where
4839 C: common::Connector,
4840{
4841 /// Perform the operation you have build so far.
4842 pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
4843 use std::borrow::Cow;
4844 use std::io::{Read, Seek};
4845
4846 use common::{url::Params, ToParts};
4847 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4848
4849 let mut dd = common::DefaultDelegate;
4850 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4851 dlg.begin(common::MethodInfo {
4852 id: "cloudkms.projects.locations.ekmConnections.create",
4853 http_method: hyper::Method::POST,
4854 });
4855
4856 for &field in ["alt", "parent", "ekmConnectionId"].iter() {
4857 if self._additional_params.contains_key(field) {
4858 dlg.finished(false);
4859 return Err(common::Error::FieldClash(field));
4860 }
4861 }
4862
4863 let mut params = Params::with_capacity(5 + self._additional_params.len());
4864 params.push("parent", self._parent);
4865 if let Some(value) = self._ekm_connection_id.as_ref() {
4866 params.push("ekmConnectionId", value);
4867 }
4868
4869 params.extend(self._additional_params.iter());
4870
4871 params.push("alt", "json");
4872 let mut url = self.hub._base_url.clone() + "v1/{+parent}/ekmConnections";
4873 if self._scopes.is_empty() {
4874 self._scopes
4875 .insert(Scope::CloudPlatform.as_ref().to_string());
4876 }
4877
4878 #[allow(clippy::single_element_loop)]
4879 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4880 url = params.uri_replacement(url, param_name, find_this, true);
4881 }
4882 {
4883 let to_remove = ["parent"];
4884 params.remove_params(&to_remove);
4885 }
4886
4887 let url = params.parse_with_url(&url);
4888
4889 let mut json_mime_type = mime::APPLICATION_JSON;
4890 let mut request_value_reader = {
4891 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4892 common::remove_json_null_values(&mut value);
4893 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4894 serde_json::to_writer(&mut dst, &value).unwrap();
4895 dst
4896 };
4897 let request_size = request_value_reader
4898 .seek(std::io::SeekFrom::End(0))
4899 .unwrap();
4900 request_value_reader
4901 .seek(std::io::SeekFrom::Start(0))
4902 .unwrap();
4903
4904 loop {
4905 let token = match self
4906 .hub
4907 .auth
4908 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4909 .await
4910 {
4911 Ok(token) => token,
4912 Err(e) => match dlg.token(e) {
4913 Ok(token) => token,
4914 Err(e) => {
4915 dlg.finished(false);
4916 return Err(common::Error::MissingToken(e));
4917 }
4918 },
4919 };
4920 request_value_reader
4921 .seek(std::io::SeekFrom::Start(0))
4922 .unwrap();
4923 let mut req_result = {
4924 let client = &self.hub.client;
4925 dlg.pre_request();
4926 let mut req_builder = hyper::Request::builder()
4927 .method(hyper::Method::POST)
4928 .uri(url.as_str())
4929 .header(USER_AGENT, self.hub._user_agent.clone());
4930
4931 if let Some(token) = token.as_ref() {
4932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4933 }
4934
4935 let request = req_builder
4936 .header(CONTENT_TYPE, json_mime_type.to_string())
4937 .header(CONTENT_LENGTH, request_size as u64)
4938 .body(common::to_body(
4939 request_value_reader.get_ref().clone().into(),
4940 ));
4941
4942 client.request(request.unwrap()).await
4943 };
4944
4945 match req_result {
4946 Err(err) => {
4947 if let common::Retry::After(d) = dlg.http_error(&err) {
4948 sleep(d).await;
4949 continue;
4950 }
4951 dlg.finished(false);
4952 return Err(common::Error::HttpError(err));
4953 }
4954 Ok(res) => {
4955 let (mut parts, body) = res.into_parts();
4956 let mut body = common::Body::new(body);
4957 if !parts.status.is_success() {
4958 let bytes = common::to_bytes(body).await.unwrap_or_default();
4959 let error = serde_json::from_str(&common::to_string(&bytes));
4960 let response = common::to_response(parts, bytes.into());
4961
4962 if let common::Retry::After(d) =
4963 dlg.http_failure(&response, error.as_ref().ok())
4964 {
4965 sleep(d).await;
4966 continue;
4967 }
4968
4969 dlg.finished(false);
4970
4971 return Err(match error {
4972 Ok(value) => common::Error::BadRequest(value),
4973 _ => common::Error::Failure(response),
4974 });
4975 }
4976 let response = {
4977 let bytes = common::to_bytes(body).await.unwrap_or_default();
4978 let encoded = common::to_string(&bytes);
4979 match serde_json::from_str(&encoded) {
4980 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4981 Err(error) => {
4982 dlg.response_json_decode_error(&encoded, &error);
4983 return Err(common::Error::JsonDecodeError(
4984 encoded.to_string(),
4985 error,
4986 ));
4987 }
4988 }
4989 };
4990
4991 dlg.finished(true);
4992 return Ok(response);
4993 }
4994 }
4995 }
4996 }
4997
4998 ///
4999 /// Sets the *request* property to the given value.
5000 ///
5001 /// Even though the property as already been set when instantiating this call,
5002 /// we provide this method for API completeness.
5003 pub fn request(
5004 mut self,
5005 new_value: EkmConnection,
5006 ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
5007 self._request = new_value;
5008 self
5009 }
5010 /// Required. The resource name of the location associated with the EkmConnection, in the format `projects/*/locations/*`.
5011 ///
5012 /// Sets the *parent* path property to the given value.
5013 ///
5014 /// Even though the property as already been set when instantiating this call,
5015 /// we provide this method for API completeness.
5016 pub fn parent(mut self, new_value: &str) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
5017 self._parent = new_value.to_string();
5018 self
5019 }
5020 /// Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`.
5021 ///
5022 /// Sets the *ekm connection id* query property to the given value.
5023 pub fn ekm_connection_id(
5024 mut self,
5025 new_value: &str,
5026 ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
5027 self._ekm_connection_id = Some(new_value.to_string());
5028 self
5029 }
5030 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5031 /// while executing the actual API request.
5032 ///
5033 /// ````text
5034 /// It should be used to handle progress information, and to implement a certain level of resilience.
5035 /// ````
5036 ///
5037 /// Sets the *delegate* property to the given value.
5038 pub fn delegate(
5039 mut self,
5040 new_value: &'a mut dyn common::Delegate,
5041 ) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
5042 self._delegate = Some(new_value);
5043 self
5044 }
5045
5046 /// Set any additional parameter of the query string used in the request.
5047 /// It should be used to set parameters which are not yet available through their own
5048 /// setters.
5049 ///
5050 /// Please note that this method must not be used to set any of the known parameters
5051 /// which have their own setter method. If done anyway, the request will fail.
5052 ///
5053 /// # Additional Parameters
5054 ///
5055 /// * *$.xgafv* (query-string) - V1 error format.
5056 /// * *access_token* (query-string) - OAuth access token.
5057 /// * *alt* (query-string) - Data format for response.
5058 /// * *callback* (query-string) - JSONP
5059 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5060 /// * *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.
5061 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5062 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5063 /// * *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.
5064 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5065 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5066 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionCreateCall<'a, C>
5067 where
5068 T: AsRef<str>,
5069 {
5070 self._additional_params
5071 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5072 self
5073 }
5074
5075 /// Identifies the authorization scope for the method you are building.
5076 ///
5077 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5078 /// [`Scope::CloudPlatform`].
5079 ///
5080 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5081 /// tokens for more than one scope.
5082 ///
5083 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5084 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5085 /// sufficient, a read-write scope will do as well.
5086 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionCreateCall<'a, C>
5087 where
5088 St: AsRef<str>,
5089 {
5090 self._scopes.insert(String::from(scope.as_ref()));
5091 self
5092 }
5093 /// Identifies the authorization scope(s) for the method you are building.
5094 ///
5095 /// See [`Self::add_scope()`] for details.
5096 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionCreateCall<'a, C>
5097 where
5098 I: IntoIterator<Item = St>,
5099 St: AsRef<str>,
5100 {
5101 self._scopes
5102 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5103 self
5104 }
5105
5106 /// Removes all scopes, and no default scope will be used either.
5107 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5108 /// for details).
5109 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionCreateCall<'a, C> {
5110 self._scopes.clear();
5111 self
5112 }
5113}
5114
5115/// Returns metadata for a given EkmConnection.
5116///
5117/// A builder for the *locations.ekmConnections.get* method supported by a *project* resource.
5118/// It is not used directly, but through a [`ProjectMethods`] instance.
5119///
5120/// # Example
5121///
5122/// Instantiate a resource method builder
5123///
5124/// ```test_harness,no_run
5125/// # extern crate hyper;
5126/// # extern crate hyper_rustls;
5127/// # extern crate google_cloudkms1 as cloudkms1;
5128/// # async fn dox() {
5129/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5130///
5131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5132/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5133/// # secret,
5134/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5135/// # ).build().await.unwrap();
5136///
5137/// # let client = hyper_util::client::legacy::Client::builder(
5138/// # hyper_util::rt::TokioExecutor::new()
5139/// # )
5140/// # .build(
5141/// # hyper_rustls::HttpsConnectorBuilder::new()
5142/// # .with_native_roots()
5143/// # .unwrap()
5144/// # .https_or_http()
5145/// # .enable_http1()
5146/// # .build()
5147/// # );
5148/// # let mut hub = CloudKMS::new(client, auth);
5149/// // You can configure optional parameters by calling the respective setters at will, and
5150/// // execute the final call using `doit()`.
5151/// // Values shown here are possibly random and not representative !
5152/// let result = hub.projects().locations_ekm_connections_get("name")
5153/// .doit().await;
5154/// # }
5155/// ```
5156pub struct ProjectLocationEkmConnectionGetCall<'a, C>
5157where
5158 C: 'a,
5159{
5160 hub: &'a CloudKMS<C>,
5161 _name: String,
5162 _delegate: Option<&'a mut dyn common::Delegate>,
5163 _additional_params: HashMap<String, String>,
5164 _scopes: BTreeSet<String>,
5165}
5166
5167impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionGetCall<'a, C> {}
5168
5169impl<'a, C> ProjectLocationEkmConnectionGetCall<'a, C>
5170where
5171 C: common::Connector,
5172{
5173 /// Perform the operation you have build so far.
5174 pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
5175 use std::borrow::Cow;
5176 use std::io::{Read, Seek};
5177
5178 use common::{url::Params, ToParts};
5179 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5180
5181 let mut dd = common::DefaultDelegate;
5182 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5183 dlg.begin(common::MethodInfo {
5184 id: "cloudkms.projects.locations.ekmConnections.get",
5185 http_method: hyper::Method::GET,
5186 });
5187
5188 for &field in ["alt", "name"].iter() {
5189 if self._additional_params.contains_key(field) {
5190 dlg.finished(false);
5191 return Err(common::Error::FieldClash(field));
5192 }
5193 }
5194
5195 let mut params = Params::with_capacity(3 + self._additional_params.len());
5196 params.push("name", self._name);
5197
5198 params.extend(self._additional_params.iter());
5199
5200 params.push("alt", "json");
5201 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5202 if self._scopes.is_empty() {
5203 self._scopes
5204 .insert(Scope::CloudPlatform.as_ref().to_string());
5205 }
5206
5207 #[allow(clippy::single_element_loop)]
5208 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5209 url = params.uri_replacement(url, param_name, find_this, true);
5210 }
5211 {
5212 let to_remove = ["name"];
5213 params.remove_params(&to_remove);
5214 }
5215
5216 let url = params.parse_with_url(&url);
5217
5218 loop {
5219 let token = match self
5220 .hub
5221 .auth
5222 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5223 .await
5224 {
5225 Ok(token) => token,
5226 Err(e) => match dlg.token(e) {
5227 Ok(token) => token,
5228 Err(e) => {
5229 dlg.finished(false);
5230 return Err(common::Error::MissingToken(e));
5231 }
5232 },
5233 };
5234 let mut req_result = {
5235 let client = &self.hub.client;
5236 dlg.pre_request();
5237 let mut req_builder = hyper::Request::builder()
5238 .method(hyper::Method::GET)
5239 .uri(url.as_str())
5240 .header(USER_AGENT, self.hub._user_agent.clone());
5241
5242 if let Some(token) = token.as_ref() {
5243 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5244 }
5245
5246 let request = req_builder
5247 .header(CONTENT_LENGTH, 0_u64)
5248 .body(common::to_body::<String>(None));
5249
5250 client.request(request.unwrap()).await
5251 };
5252
5253 match req_result {
5254 Err(err) => {
5255 if let common::Retry::After(d) = dlg.http_error(&err) {
5256 sleep(d).await;
5257 continue;
5258 }
5259 dlg.finished(false);
5260 return Err(common::Error::HttpError(err));
5261 }
5262 Ok(res) => {
5263 let (mut parts, body) = res.into_parts();
5264 let mut body = common::Body::new(body);
5265 if !parts.status.is_success() {
5266 let bytes = common::to_bytes(body).await.unwrap_or_default();
5267 let error = serde_json::from_str(&common::to_string(&bytes));
5268 let response = common::to_response(parts, bytes.into());
5269
5270 if let common::Retry::After(d) =
5271 dlg.http_failure(&response, error.as_ref().ok())
5272 {
5273 sleep(d).await;
5274 continue;
5275 }
5276
5277 dlg.finished(false);
5278
5279 return Err(match error {
5280 Ok(value) => common::Error::BadRequest(value),
5281 _ => common::Error::Failure(response),
5282 });
5283 }
5284 let response = {
5285 let bytes = common::to_bytes(body).await.unwrap_or_default();
5286 let encoded = common::to_string(&bytes);
5287 match serde_json::from_str(&encoded) {
5288 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5289 Err(error) => {
5290 dlg.response_json_decode_error(&encoded, &error);
5291 return Err(common::Error::JsonDecodeError(
5292 encoded.to_string(),
5293 error,
5294 ));
5295 }
5296 }
5297 };
5298
5299 dlg.finished(true);
5300 return Ok(response);
5301 }
5302 }
5303 }
5304 }
5305
5306 /// Required. The name of the EkmConnection to get.
5307 ///
5308 /// Sets the *name* path property to the given value.
5309 ///
5310 /// Even though the property as already been set when instantiating this call,
5311 /// we provide this method for API completeness.
5312 pub fn name(mut self, new_value: &str) -> ProjectLocationEkmConnectionGetCall<'a, C> {
5313 self._name = new_value.to_string();
5314 self
5315 }
5316 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5317 /// while executing the actual API request.
5318 ///
5319 /// ````text
5320 /// It should be used to handle progress information, and to implement a certain level of resilience.
5321 /// ````
5322 ///
5323 /// Sets the *delegate* property to the given value.
5324 pub fn delegate(
5325 mut self,
5326 new_value: &'a mut dyn common::Delegate,
5327 ) -> ProjectLocationEkmConnectionGetCall<'a, C> {
5328 self._delegate = Some(new_value);
5329 self
5330 }
5331
5332 /// Set any additional parameter of the query string used in the request.
5333 /// It should be used to set parameters which are not yet available through their own
5334 /// setters.
5335 ///
5336 /// Please note that this method must not be used to set any of the known parameters
5337 /// which have their own setter method. If done anyway, the request will fail.
5338 ///
5339 /// # Additional Parameters
5340 ///
5341 /// * *$.xgafv* (query-string) - V1 error format.
5342 /// * *access_token* (query-string) - OAuth access token.
5343 /// * *alt* (query-string) - Data format for response.
5344 /// * *callback* (query-string) - JSONP
5345 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5346 /// * *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.
5347 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5348 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5349 /// * *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.
5350 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5351 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5352 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionGetCall<'a, C>
5353 where
5354 T: AsRef<str>,
5355 {
5356 self._additional_params
5357 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5358 self
5359 }
5360
5361 /// Identifies the authorization scope for the method you are building.
5362 ///
5363 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5364 /// [`Scope::CloudPlatform`].
5365 ///
5366 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5367 /// tokens for more than one scope.
5368 ///
5369 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5370 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5371 /// sufficient, a read-write scope will do as well.
5372 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionGetCall<'a, C>
5373 where
5374 St: AsRef<str>,
5375 {
5376 self._scopes.insert(String::from(scope.as_ref()));
5377 self
5378 }
5379 /// Identifies the authorization scope(s) for the method you are building.
5380 ///
5381 /// See [`Self::add_scope()`] for details.
5382 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionGetCall<'a, C>
5383 where
5384 I: IntoIterator<Item = St>,
5385 St: AsRef<str>,
5386 {
5387 self._scopes
5388 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5389 self
5390 }
5391
5392 /// Removes all scopes, and no default scope will be used either.
5393 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5394 /// for details).
5395 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionGetCall<'a, C> {
5396 self._scopes.clear();
5397 self
5398 }
5399}
5400
5401/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
5402///
5403/// A builder for the *locations.ekmConnections.getIamPolicy* method supported by a *project* resource.
5404/// It is not used directly, but through a [`ProjectMethods`] instance.
5405///
5406/// # Example
5407///
5408/// Instantiate a resource method builder
5409///
5410/// ```test_harness,no_run
5411/// # extern crate hyper;
5412/// # extern crate hyper_rustls;
5413/// # extern crate google_cloudkms1 as cloudkms1;
5414/// # async fn dox() {
5415/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5416///
5417/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5418/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5419/// # secret,
5420/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5421/// # ).build().await.unwrap();
5422///
5423/// # let client = hyper_util::client::legacy::Client::builder(
5424/// # hyper_util::rt::TokioExecutor::new()
5425/// # )
5426/// # .build(
5427/// # hyper_rustls::HttpsConnectorBuilder::new()
5428/// # .with_native_roots()
5429/// # .unwrap()
5430/// # .https_or_http()
5431/// # .enable_http1()
5432/// # .build()
5433/// # );
5434/// # let mut hub = CloudKMS::new(client, auth);
5435/// // You can configure optional parameters by calling the respective setters at will, and
5436/// // execute the final call using `doit()`.
5437/// // Values shown here are possibly random and not representative !
5438/// let result = hub.projects().locations_ekm_connections_get_iam_policy("resource")
5439/// .options_requested_policy_version(-75)
5440/// .doit().await;
5441/// # }
5442/// ```
5443pub struct ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
5444where
5445 C: 'a,
5446{
5447 hub: &'a CloudKMS<C>,
5448 _resource: String,
5449 _options_requested_policy_version: Option<i32>,
5450 _delegate: Option<&'a mut dyn common::Delegate>,
5451 _additional_params: HashMap<String, String>,
5452 _scopes: BTreeSet<String>,
5453}
5454
5455impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {}
5456
5457impl<'a, C> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
5458where
5459 C: common::Connector,
5460{
5461 /// Perform the operation you have build so far.
5462 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5463 use std::borrow::Cow;
5464 use std::io::{Read, Seek};
5465
5466 use common::{url::Params, ToParts};
5467 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5468
5469 let mut dd = common::DefaultDelegate;
5470 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5471 dlg.begin(common::MethodInfo {
5472 id: "cloudkms.projects.locations.ekmConnections.getIamPolicy",
5473 http_method: hyper::Method::GET,
5474 });
5475
5476 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
5477 if self._additional_params.contains_key(field) {
5478 dlg.finished(false);
5479 return Err(common::Error::FieldClash(field));
5480 }
5481 }
5482
5483 let mut params = Params::with_capacity(4 + self._additional_params.len());
5484 params.push("resource", self._resource);
5485 if let Some(value) = self._options_requested_policy_version.as_ref() {
5486 params.push("options.requestedPolicyVersion", value.to_string());
5487 }
5488
5489 params.extend(self._additional_params.iter());
5490
5491 params.push("alt", "json");
5492 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
5493 if self._scopes.is_empty() {
5494 self._scopes
5495 .insert(Scope::CloudPlatform.as_ref().to_string());
5496 }
5497
5498 #[allow(clippy::single_element_loop)]
5499 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5500 url = params.uri_replacement(url, param_name, find_this, true);
5501 }
5502 {
5503 let to_remove = ["resource"];
5504 params.remove_params(&to_remove);
5505 }
5506
5507 let url = params.parse_with_url(&url);
5508
5509 loop {
5510 let token = match self
5511 .hub
5512 .auth
5513 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5514 .await
5515 {
5516 Ok(token) => token,
5517 Err(e) => match dlg.token(e) {
5518 Ok(token) => token,
5519 Err(e) => {
5520 dlg.finished(false);
5521 return Err(common::Error::MissingToken(e));
5522 }
5523 },
5524 };
5525 let mut req_result = {
5526 let client = &self.hub.client;
5527 dlg.pre_request();
5528 let mut req_builder = hyper::Request::builder()
5529 .method(hyper::Method::GET)
5530 .uri(url.as_str())
5531 .header(USER_AGENT, self.hub._user_agent.clone());
5532
5533 if let Some(token) = token.as_ref() {
5534 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5535 }
5536
5537 let request = req_builder
5538 .header(CONTENT_LENGTH, 0_u64)
5539 .body(common::to_body::<String>(None));
5540
5541 client.request(request.unwrap()).await
5542 };
5543
5544 match req_result {
5545 Err(err) => {
5546 if let common::Retry::After(d) = dlg.http_error(&err) {
5547 sleep(d).await;
5548 continue;
5549 }
5550 dlg.finished(false);
5551 return Err(common::Error::HttpError(err));
5552 }
5553 Ok(res) => {
5554 let (mut parts, body) = res.into_parts();
5555 let mut body = common::Body::new(body);
5556 if !parts.status.is_success() {
5557 let bytes = common::to_bytes(body).await.unwrap_or_default();
5558 let error = serde_json::from_str(&common::to_string(&bytes));
5559 let response = common::to_response(parts, bytes.into());
5560
5561 if let common::Retry::After(d) =
5562 dlg.http_failure(&response, error.as_ref().ok())
5563 {
5564 sleep(d).await;
5565 continue;
5566 }
5567
5568 dlg.finished(false);
5569
5570 return Err(match error {
5571 Ok(value) => common::Error::BadRequest(value),
5572 _ => common::Error::Failure(response),
5573 });
5574 }
5575 let response = {
5576 let bytes = common::to_bytes(body).await.unwrap_or_default();
5577 let encoded = common::to_string(&bytes);
5578 match serde_json::from_str(&encoded) {
5579 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5580 Err(error) => {
5581 dlg.response_json_decode_error(&encoded, &error);
5582 return Err(common::Error::JsonDecodeError(
5583 encoded.to_string(),
5584 error,
5585 ));
5586 }
5587 }
5588 };
5589
5590 dlg.finished(true);
5591 return Ok(response);
5592 }
5593 }
5594 }
5595 }
5596
5597 /// 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.
5598 ///
5599 /// Sets the *resource* path property to the given value.
5600 ///
5601 /// Even though the property as already been set when instantiating this call,
5602 /// we provide this method for API completeness.
5603 pub fn resource(
5604 mut self,
5605 new_value: &str,
5606 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
5607 self._resource = new_value.to_string();
5608 self
5609 }
5610 /// 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).
5611 ///
5612 /// Sets the *options.requested policy version* query property to the given value.
5613 pub fn options_requested_policy_version(
5614 mut self,
5615 new_value: i32,
5616 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
5617 self._options_requested_policy_version = Some(new_value);
5618 self
5619 }
5620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5621 /// while executing the actual API request.
5622 ///
5623 /// ````text
5624 /// It should be used to handle progress information, and to implement a certain level of resilience.
5625 /// ````
5626 ///
5627 /// Sets the *delegate* property to the given value.
5628 pub fn delegate(
5629 mut self,
5630 new_value: &'a mut dyn common::Delegate,
5631 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
5632 self._delegate = Some(new_value);
5633 self
5634 }
5635
5636 /// Set any additional parameter of the query string used in the request.
5637 /// It should be used to set parameters which are not yet available through their own
5638 /// setters.
5639 ///
5640 /// Please note that this method must not be used to set any of the known parameters
5641 /// which have their own setter method. If done anyway, the request will fail.
5642 ///
5643 /// # Additional Parameters
5644 ///
5645 /// * *$.xgafv* (query-string) - V1 error format.
5646 /// * *access_token* (query-string) - OAuth access token.
5647 /// * *alt* (query-string) - Data format for response.
5648 /// * *callback* (query-string) - JSONP
5649 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5650 /// * *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.
5651 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5652 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5653 /// * *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.
5654 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5655 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5656 pub fn param<T>(
5657 mut self,
5658 name: T,
5659 value: T,
5660 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
5661 where
5662 T: AsRef<str>,
5663 {
5664 self._additional_params
5665 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5666 self
5667 }
5668
5669 /// Identifies the authorization scope for the method you are building.
5670 ///
5671 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5672 /// [`Scope::CloudPlatform`].
5673 ///
5674 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5675 /// tokens for more than one scope.
5676 ///
5677 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5678 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5679 /// sufficient, a read-write scope will do as well.
5680 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
5681 where
5682 St: AsRef<str>,
5683 {
5684 self._scopes.insert(String::from(scope.as_ref()));
5685 self
5686 }
5687 /// Identifies the authorization scope(s) for the method you are building.
5688 ///
5689 /// See [`Self::add_scope()`] for details.
5690 pub fn add_scopes<I, St>(
5691 mut self,
5692 scopes: I,
5693 ) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C>
5694 where
5695 I: IntoIterator<Item = St>,
5696 St: AsRef<str>,
5697 {
5698 self._scopes
5699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5700 self
5701 }
5702
5703 /// Removes all scopes, and no default scope will be used either.
5704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5705 /// for details).
5706 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionGetIamPolicyCall<'a, C> {
5707 self._scopes.clear();
5708 self
5709 }
5710}
5711
5712/// Lists EkmConnections.
5713///
5714/// A builder for the *locations.ekmConnections.list* method supported by a *project* resource.
5715/// It is not used directly, but through a [`ProjectMethods`] instance.
5716///
5717/// # Example
5718///
5719/// Instantiate a resource method builder
5720///
5721/// ```test_harness,no_run
5722/// # extern crate hyper;
5723/// # extern crate hyper_rustls;
5724/// # extern crate google_cloudkms1 as cloudkms1;
5725/// # async fn dox() {
5726/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5727///
5728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5729/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5730/// # secret,
5731/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5732/// # ).build().await.unwrap();
5733///
5734/// # let client = hyper_util::client::legacy::Client::builder(
5735/// # hyper_util::rt::TokioExecutor::new()
5736/// # )
5737/// # .build(
5738/// # hyper_rustls::HttpsConnectorBuilder::new()
5739/// # .with_native_roots()
5740/// # .unwrap()
5741/// # .https_or_http()
5742/// # .enable_http1()
5743/// # .build()
5744/// # );
5745/// # let mut hub = CloudKMS::new(client, auth);
5746/// // You can configure optional parameters by calling the respective setters at will, and
5747/// // execute the final call using `doit()`.
5748/// // Values shown here are possibly random and not representative !
5749/// let result = hub.projects().locations_ekm_connections_list("parent")
5750/// .page_token("ea")
5751/// .page_size(-55)
5752/// .order_by("invidunt")
5753/// .filter("amet")
5754/// .doit().await;
5755/// # }
5756/// ```
5757pub struct ProjectLocationEkmConnectionListCall<'a, C>
5758where
5759 C: 'a,
5760{
5761 hub: &'a CloudKMS<C>,
5762 _parent: String,
5763 _page_token: Option<String>,
5764 _page_size: Option<i32>,
5765 _order_by: Option<String>,
5766 _filter: Option<String>,
5767 _delegate: Option<&'a mut dyn common::Delegate>,
5768 _additional_params: HashMap<String, String>,
5769 _scopes: BTreeSet<String>,
5770}
5771
5772impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionListCall<'a, C> {}
5773
5774impl<'a, C> ProjectLocationEkmConnectionListCall<'a, C>
5775where
5776 C: common::Connector,
5777{
5778 /// Perform the operation you have build so far.
5779 pub async fn doit(mut self) -> common::Result<(common::Response, ListEkmConnectionsResponse)> {
5780 use std::borrow::Cow;
5781 use std::io::{Read, Seek};
5782
5783 use common::{url::Params, ToParts};
5784 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5785
5786 let mut dd = common::DefaultDelegate;
5787 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5788 dlg.begin(common::MethodInfo {
5789 id: "cloudkms.projects.locations.ekmConnections.list",
5790 http_method: hyper::Method::GET,
5791 });
5792
5793 for &field in [
5794 "alt",
5795 "parent",
5796 "pageToken",
5797 "pageSize",
5798 "orderBy",
5799 "filter",
5800 ]
5801 .iter()
5802 {
5803 if self._additional_params.contains_key(field) {
5804 dlg.finished(false);
5805 return Err(common::Error::FieldClash(field));
5806 }
5807 }
5808
5809 let mut params = Params::with_capacity(7 + self._additional_params.len());
5810 params.push("parent", self._parent);
5811 if let Some(value) = self._page_token.as_ref() {
5812 params.push("pageToken", value);
5813 }
5814 if let Some(value) = self._page_size.as_ref() {
5815 params.push("pageSize", value.to_string());
5816 }
5817 if let Some(value) = self._order_by.as_ref() {
5818 params.push("orderBy", value);
5819 }
5820 if let Some(value) = self._filter.as_ref() {
5821 params.push("filter", value);
5822 }
5823
5824 params.extend(self._additional_params.iter());
5825
5826 params.push("alt", "json");
5827 let mut url = self.hub._base_url.clone() + "v1/{+parent}/ekmConnections";
5828 if self._scopes.is_empty() {
5829 self._scopes
5830 .insert(Scope::CloudPlatform.as_ref().to_string());
5831 }
5832
5833 #[allow(clippy::single_element_loop)]
5834 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5835 url = params.uri_replacement(url, param_name, find_this, true);
5836 }
5837 {
5838 let to_remove = ["parent"];
5839 params.remove_params(&to_remove);
5840 }
5841
5842 let url = params.parse_with_url(&url);
5843
5844 loop {
5845 let token = match self
5846 .hub
5847 .auth
5848 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5849 .await
5850 {
5851 Ok(token) => token,
5852 Err(e) => match dlg.token(e) {
5853 Ok(token) => token,
5854 Err(e) => {
5855 dlg.finished(false);
5856 return Err(common::Error::MissingToken(e));
5857 }
5858 },
5859 };
5860 let mut req_result = {
5861 let client = &self.hub.client;
5862 dlg.pre_request();
5863 let mut req_builder = hyper::Request::builder()
5864 .method(hyper::Method::GET)
5865 .uri(url.as_str())
5866 .header(USER_AGENT, self.hub._user_agent.clone());
5867
5868 if let Some(token) = token.as_ref() {
5869 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5870 }
5871
5872 let request = req_builder
5873 .header(CONTENT_LENGTH, 0_u64)
5874 .body(common::to_body::<String>(None));
5875
5876 client.request(request.unwrap()).await
5877 };
5878
5879 match req_result {
5880 Err(err) => {
5881 if let common::Retry::After(d) = dlg.http_error(&err) {
5882 sleep(d).await;
5883 continue;
5884 }
5885 dlg.finished(false);
5886 return Err(common::Error::HttpError(err));
5887 }
5888 Ok(res) => {
5889 let (mut parts, body) = res.into_parts();
5890 let mut body = common::Body::new(body);
5891 if !parts.status.is_success() {
5892 let bytes = common::to_bytes(body).await.unwrap_or_default();
5893 let error = serde_json::from_str(&common::to_string(&bytes));
5894 let response = common::to_response(parts, bytes.into());
5895
5896 if let common::Retry::After(d) =
5897 dlg.http_failure(&response, error.as_ref().ok())
5898 {
5899 sleep(d).await;
5900 continue;
5901 }
5902
5903 dlg.finished(false);
5904
5905 return Err(match error {
5906 Ok(value) => common::Error::BadRequest(value),
5907 _ => common::Error::Failure(response),
5908 });
5909 }
5910 let response = {
5911 let bytes = common::to_bytes(body).await.unwrap_or_default();
5912 let encoded = common::to_string(&bytes);
5913 match serde_json::from_str(&encoded) {
5914 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5915 Err(error) => {
5916 dlg.response_json_decode_error(&encoded, &error);
5917 return Err(common::Error::JsonDecodeError(
5918 encoded.to_string(),
5919 error,
5920 ));
5921 }
5922 }
5923 };
5924
5925 dlg.finished(true);
5926 return Ok(response);
5927 }
5928 }
5929 }
5930 }
5931
5932 /// Required. The resource name of the location associated with the EkmConnections to list, in the format `projects/*/locations/*`.
5933 ///
5934 /// Sets the *parent* path property to the given value.
5935 ///
5936 /// Even though the property as already been set when instantiating this call,
5937 /// we provide this method for API completeness.
5938 pub fn parent(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
5939 self._parent = new_value.to_string();
5940 self
5941 }
5942 /// Optional. Optional pagination token, returned earlier via ListEkmConnectionsResponse.next_page_token.
5943 ///
5944 /// Sets the *page token* query property to the given value.
5945 pub fn page_token(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
5946 self._page_token = Some(new_value.to_string());
5947 self
5948 }
5949 /// 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.
5950 ///
5951 /// Sets the *page size* query property to the given value.
5952 pub fn page_size(mut self, new_value: i32) -> ProjectLocationEkmConnectionListCall<'a, C> {
5953 self._page_size = Some(new_value);
5954 self
5955 }
5956 /// 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).
5957 ///
5958 /// Sets the *order by* query property to the given value.
5959 pub fn order_by(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
5960 self._order_by = Some(new_value.to_string());
5961 self
5962 }
5963 /// 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).
5964 ///
5965 /// Sets the *filter* query property to the given value.
5966 pub fn filter(mut self, new_value: &str) -> ProjectLocationEkmConnectionListCall<'a, C> {
5967 self._filter = Some(new_value.to_string());
5968 self
5969 }
5970 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5971 /// while executing the actual API request.
5972 ///
5973 /// ````text
5974 /// It should be used to handle progress information, and to implement a certain level of resilience.
5975 /// ````
5976 ///
5977 /// Sets the *delegate* property to the given value.
5978 pub fn delegate(
5979 mut self,
5980 new_value: &'a mut dyn common::Delegate,
5981 ) -> ProjectLocationEkmConnectionListCall<'a, C> {
5982 self._delegate = Some(new_value);
5983 self
5984 }
5985
5986 /// Set any additional parameter of the query string used in the request.
5987 /// It should be used to set parameters which are not yet available through their own
5988 /// setters.
5989 ///
5990 /// Please note that this method must not be used to set any of the known parameters
5991 /// which have their own setter method. If done anyway, the request will fail.
5992 ///
5993 /// # Additional Parameters
5994 ///
5995 /// * *$.xgafv* (query-string) - V1 error format.
5996 /// * *access_token* (query-string) - OAuth access token.
5997 /// * *alt* (query-string) - Data format for response.
5998 /// * *callback* (query-string) - JSONP
5999 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6000 /// * *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.
6001 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6002 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6003 /// * *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.
6004 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6005 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6006 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionListCall<'a, C>
6007 where
6008 T: AsRef<str>,
6009 {
6010 self._additional_params
6011 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6012 self
6013 }
6014
6015 /// Identifies the authorization scope for the method you are building.
6016 ///
6017 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6018 /// [`Scope::CloudPlatform`].
6019 ///
6020 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6021 /// tokens for more than one scope.
6022 ///
6023 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6024 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6025 /// sufficient, a read-write scope will do as well.
6026 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionListCall<'a, C>
6027 where
6028 St: AsRef<str>,
6029 {
6030 self._scopes.insert(String::from(scope.as_ref()));
6031 self
6032 }
6033 /// Identifies the authorization scope(s) for the method you are building.
6034 ///
6035 /// See [`Self::add_scope()`] for details.
6036 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionListCall<'a, C>
6037 where
6038 I: IntoIterator<Item = St>,
6039 St: AsRef<str>,
6040 {
6041 self._scopes
6042 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6043 self
6044 }
6045
6046 /// Removes all scopes, and no default scope will be used either.
6047 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6048 /// for details).
6049 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionListCall<'a, C> {
6050 self._scopes.clear();
6051 self
6052 }
6053}
6054
6055/// Updates an EkmConnection's metadata.
6056///
6057/// A builder for the *locations.ekmConnections.patch* method supported by a *project* resource.
6058/// It is not used directly, but through a [`ProjectMethods`] instance.
6059///
6060/// # Example
6061///
6062/// Instantiate a resource method builder
6063///
6064/// ```test_harness,no_run
6065/// # extern crate hyper;
6066/// # extern crate hyper_rustls;
6067/// # extern crate google_cloudkms1 as cloudkms1;
6068/// use cloudkms1::api::EkmConnection;
6069/// # async fn dox() {
6070/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6071///
6072/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6073/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6074/// # secret,
6075/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6076/// # ).build().await.unwrap();
6077///
6078/// # let client = hyper_util::client::legacy::Client::builder(
6079/// # hyper_util::rt::TokioExecutor::new()
6080/// # )
6081/// # .build(
6082/// # hyper_rustls::HttpsConnectorBuilder::new()
6083/// # .with_native_roots()
6084/// # .unwrap()
6085/// # .https_or_http()
6086/// # .enable_http1()
6087/// # .build()
6088/// # );
6089/// # let mut hub = CloudKMS::new(client, auth);
6090/// // As the method needs a request, you would usually fill it with the desired information
6091/// // into the respective structure. Some of the parts shown here might not be applicable !
6092/// // Values shown here are possibly random and not representative !
6093/// let mut req = EkmConnection::default();
6094///
6095/// // You can configure optional parameters by calling the respective setters at will, and
6096/// // execute the final call using `doit()`.
6097/// // Values shown here are possibly random and not representative !
6098/// let result = hub.projects().locations_ekm_connections_patch(req, "name")
6099/// .update_mask(FieldMask::new::<&str>(&[]))
6100/// .doit().await;
6101/// # }
6102/// ```
6103pub struct ProjectLocationEkmConnectionPatchCall<'a, C>
6104where
6105 C: 'a,
6106{
6107 hub: &'a CloudKMS<C>,
6108 _request: EkmConnection,
6109 _name: String,
6110 _update_mask: Option<common::FieldMask>,
6111 _delegate: Option<&'a mut dyn common::Delegate>,
6112 _additional_params: HashMap<String, String>,
6113 _scopes: BTreeSet<String>,
6114}
6115
6116impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionPatchCall<'a, C> {}
6117
6118impl<'a, C> ProjectLocationEkmConnectionPatchCall<'a, C>
6119where
6120 C: common::Connector,
6121{
6122 /// Perform the operation you have build so far.
6123 pub async fn doit(mut self) -> common::Result<(common::Response, EkmConnection)> {
6124 use std::borrow::Cow;
6125 use std::io::{Read, Seek};
6126
6127 use common::{url::Params, ToParts};
6128 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6129
6130 let mut dd = common::DefaultDelegate;
6131 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6132 dlg.begin(common::MethodInfo {
6133 id: "cloudkms.projects.locations.ekmConnections.patch",
6134 http_method: hyper::Method::PATCH,
6135 });
6136
6137 for &field in ["alt", "name", "updateMask"].iter() {
6138 if self._additional_params.contains_key(field) {
6139 dlg.finished(false);
6140 return Err(common::Error::FieldClash(field));
6141 }
6142 }
6143
6144 let mut params = Params::with_capacity(5 + self._additional_params.len());
6145 params.push("name", self._name);
6146 if let Some(value) = self._update_mask.as_ref() {
6147 params.push("updateMask", value.to_string());
6148 }
6149
6150 params.extend(self._additional_params.iter());
6151
6152 params.push("alt", "json");
6153 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6154 if self._scopes.is_empty() {
6155 self._scopes
6156 .insert(Scope::CloudPlatform.as_ref().to_string());
6157 }
6158
6159 #[allow(clippy::single_element_loop)]
6160 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6161 url = params.uri_replacement(url, param_name, find_this, true);
6162 }
6163 {
6164 let to_remove = ["name"];
6165 params.remove_params(&to_remove);
6166 }
6167
6168 let url = params.parse_with_url(&url);
6169
6170 let mut json_mime_type = mime::APPLICATION_JSON;
6171 let mut request_value_reader = {
6172 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6173 common::remove_json_null_values(&mut value);
6174 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6175 serde_json::to_writer(&mut dst, &value).unwrap();
6176 dst
6177 };
6178 let request_size = request_value_reader
6179 .seek(std::io::SeekFrom::End(0))
6180 .unwrap();
6181 request_value_reader
6182 .seek(std::io::SeekFrom::Start(0))
6183 .unwrap();
6184
6185 loop {
6186 let token = match self
6187 .hub
6188 .auth
6189 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6190 .await
6191 {
6192 Ok(token) => token,
6193 Err(e) => match dlg.token(e) {
6194 Ok(token) => token,
6195 Err(e) => {
6196 dlg.finished(false);
6197 return Err(common::Error::MissingToken(e));
6198 }
6199 },
6200 };
6201 request_value_reader
6202 .seek(std::io::SeekFrom::Start(0))
6203 .unwrap();
6204 let mut req_result = {
6205 let client = &self.hub.client;
6206 dlg.pre_request();
6207 let mut req_builder = hyper::Request::builder()
6208 .method(hyper::Method::PATCH)
6209 .uri(url.as_str())
6210 .header(USER_AGENT, self.hub._user_agent.clone());
6211
6212 if let Some(token) = token.as_ref() {
6213 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6214 }
6215
6216 let request = req_builder
6217 .header(CONTENT_TYPE, json_mime_type.to_string())
6218 .header(CONTENT_LENGTH, request_size as u64)
6219 .body(common::to_body(
6220 request_value_reader.get_ref().clone().into(),
6221 ));
6222
6223 client.request(request.unwrap()).await
6224 };
6225
6226 match req_result {
6227 Err(err) => {
6228 if let common::Retry::After(d) = dlg.http_error(&err) {
6229 sleep(d).await;
6230 continue;
6231 }
6232 dlg.finished(false);
6233 return Err(common::Error::HttpError(err));
6234 }
6235 Ok(res) => {
6236 let (mut parts, body) = res.into_parts();
6237 let mut body = common::Body::new(body);
6238 if !parts.status.is_success() {
6239 let bytes = common::to_bytes(body).await.unwrap_or_default();
6240 let error = serde_json::from_str(&common::to_string(&bytes));
6241 let response = common::to_response(parts, bytes.into());
6242
6243 if let common::Retry::After(d) =
6244 dlg.http_failure(&response, error.as_ref().ok())
6245 {
6246 sleep(d).await;
6247 continue;
6248 }
6249
6250 dlg.finished(false);
6251
6252 return Err(match error {
6253 Ok(value) => common::Error::BadRequest(value),
6254 _ => common::Error::Failure(response),
6255 });
6256 }
6257 let response = {
6258 let bytes = common::to_bytes(body).await.unwrap_or_default();
6259 let encoded = common::to_string(&bytes);
6260 match serde_json::from_str(&encoded) {
6261 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6262 Err(error) => {
6263 dlg.response_json_decode_error(&encoded, &error);
6264 return Err(common::Error::JsonDecodeError(
6265 encoded.to_string(),
6266 error,
6267 ));
6268 }
6269 }
6270 };
6271
6272 dlg.finished(true);
6273 return Ok(response);
6274 }
6275 }
6276 }
6277 }
6278
6279 ///
6280 /// Sets the *request* property to the given value.
6281 ///
6282 /// Even though the property as already been set when instantiating this call,
6283 /// we provide this method for API completeness.
6284 pub fn request(
6285 mut self,
6286 new_value: EkmConnection,
6287 ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
6288 self._request = new_value;
6289 self
6290 }
6291 /// Output only. The resource name for the EkmConnection in the format `projects/*/locations/*/ekmConnections/*`.
6292 ///
6293 /// Sets the *name* path property to the given value.
6294 ///
6295 /// Even though the property as already been set when instantiating this call,
6296 /// we provide this method for API completeness.
6297 pub fn name(mut self, new_value: &str) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
6298 self._name = new_value.to_string();
6299 self
6300 }
6301 /// Required. List of fields to be updated in this request.
6302 ///
6303 /// Sets the *update mask* query property to the given value.
6304 pub fn update_mask(
6305 mut self,
6306 new_value: common::FieldMask,
6307 ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
6308 self._update_mask = Some(new_value);
6309 self
6310 }
6311 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6312 /// while executing the actual API request.
6313 ///
6314 /// ````text
6315 /// It should be used to handle progress information, and to implement a certain level of resilience.
6316 /// ````
6317 ///
6318 /// Sets the *delegate* property to the given value.
6319 pub fn delegate(
6320 mut self,
6321 new_value: &'a mut dyn common::Delegate,
6322 ) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
6323 self._delegate = Some(new_value);
6324 self
6325 }
6326
6327 /// Set any additional parameter of the query string used in the request.
6328 /// It should be used to set parameters which are not yet available through their own
6329 /// setters.
6330 ///
6331 /// Please note that this method must not be used to set any of the known parameters
6332 /// which have their own setter method. If done anyway, the request will fail.
6333 ///
6334 /// # Additional Parameters
6335 ///
6336 /// * *$.xgafv* (query-string) - V1 error format.
6337 /// * *access_token* (query-string) - OAuth access token.
6338 /// * *alt* (query-string) - Data format for response.
6339 /// * *callback* (query-string) - JSONP
6340 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6341 /// * *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.
6342 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6343 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6344 /// * *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.
6345 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6346 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6347 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEkmConnectionPatchCall<'a, C>
6348 where
6349 T: AsRef<str>,
6350 {
6351 self._additional_params
6352 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6353 self
6354 }
6355
6356 /// Identifies the authorization scope for the method you are building.
6357 ///
6358 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6359 /// [`Scope::CloudPlatform`].
6360 ///
6361 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6362 /// tokens for more than one scope.
6363 ///
6364 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6365 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6366 /// sufficient, a read-write scope will do as well.
6367 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionPatchCall<'a, C>
6368 where
6369 St: AsRef<str>,
6370 {
6371 self._scopes.insert(String::from(scope.as_ref()));
6372 self
6373 }
6374 /// Identifies the authorization scope(s) for the method you are building.
6375 ///
6376 /// See [`Self::add_scope()`] for details.
6377 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEkmConnectionPatchCall<'a, C>
6378 where
6379 I: IntoIterator<Item = St>,
6380 St: AsRef<str>,
6381 {
6382 self._scopes
6383 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6384 self
6385 }
6386
6387 /// Removes all scopes, and no default scope will be used either.
6388 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6389 /// for details).
6390 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionPatchCall<'a, C> {
6391 self._scopes.clear();
6392 self
6393 }
6394}
6395
6396/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
6397///
6398/// A builder for the *locations.ekmConnections.setIamPolicy* method supported by a *project* resource.
6399/// It is not used directly, but through a [`ProjectMethods`] instance.
6400///
6401/// # Example
6402///
6403/// Instantiate a resource method builder
6404///
6405/// ```test_harness,no_run
6406/// # extern crate hyper;
6407/// # extern crate hyper_rustls;
6408/// # extern crate google_cloudkms1 as cloudkms1;
6409/// use cloudkms1::api::SetIamPolicyRequest;
6410/// # async fn dox() {
6411/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6412///
6413/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6415/// # secret,
6416/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6417/// # ).build().await.unwrap();
6418///
6419/// # let client = hyper_util::client::legacy::Client::builder(
6420/// # hyper_util::rt::TokioExecutor::new()
6421/// # )
6422/// # .build(
6423/// # hyper_rustls::HttpsConnectorBuilder::new()
6424/// # .with_native_roots()
6425/// # .unwrap()
6426/// # .https_or_http()
6427/// # .enable_http1()
6428/// # .build()
6429/// # );
6430/// # let mut hub = CloudKMS::new(client, auth);
6431/// // As the method needs a request, you would usually fill it with the desired information
6432/// // into the respective structure. Some of the parts shown here might not be applicable !
6433/// // Values shown here are possibly random and not representative !
6434/// let mut req = SetIamPolicyRequest::default();
6435///
6436/// // You can configure optional parameters by calling the respective setters at will, and
6437/// // execute the final call using `doit()`.
6438/// // Values shown here are possibly random and not representative !
6439/// let result = hub.projects().locations_ekm_connections_set_iam_policy(req, "resource")
6440/// .doit().await;
6441/// # }
6442/// ```
6443pub struct ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
6444where
6445 C: 'a,
6446{
6447 hub: &'a CloudKMS<C>,
6448 _request: SetIamPolicyRequest,
6449 _resource: String,
6450 _delegate: Option<&'a mut dyn common::Delegate>,
6451 _additional_params: HashMap<String, String>,
6452 _scopes: BTreeSet<String>,
6453}
6454
6455impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {}
6456
6457impl<'a, C> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
6458where
6459 C: common::Connector,
6460{
6461 /// Perform the operation you have build so far.
6462 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6463 use std::borrow::Cow;
6464 use std::io::{Read, Seek};
6465
6466 use common::{url::Params, ToParts};
6467 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6468
6469 let mut dd = common::DefaultDelegate;
6470 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6471 dlg.begin(common::MethodInfo {
6472 id: "cloudkms.projects.locations.ekmConnections.setIamPolicy",
6473 http_method: hyper::Method::POST,
6474 });
6475
6476 for &field in ["alt", "resource"].iter() {
6477 if self._additional_params.contains_key(field) {
6478 dlg.finished(false);
6479 return Err(common::Error::FieldClash(field));
6480 }
6481 }
6482
6483 let mut params = Params::with_capacity(4 + self._additional_params.len());
6484 params.push("resource", self._resource);
6485
6486 params.extend(self._additional_params.iter());
6487
6488 params.push("alt", "json");
6489 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
6490 if self._scopes.is_empty() {
6491 self._scopes
6492 .insert(Scope::CloudPlatform.as_ref().to_string());
6493 }
6494
6495 #[allow(clippy::single_element_loop)]
6496 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6497 url = params.uri_replacement(url, param_name, find_this, true);
6498 }
6499 {
6500 let to_remove = ["resource"];
6501 params.remove_params(&to_remove);
6502 }
6503
6504 let url = params.parse_with_url(&url);
6505
6506 let mut json_mime_type = mime::APPLICATION_JSON;
6507 let mut request_value_reader = {
6508 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6509 common::remove_json_null_values(&mut value);
6510 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6511 serde_json::to_writer(&mut dst, &value).unwrap();
6512 dst
6513 };
6514 let request_size = request_value_reader
6515 .seek(std::io::SeekFrom::End(0))
6516 .unwrap();
6517 request_value_reader
6518 .seek(std::io::SeekFrom::Start(0))
6519 .unwrap();
6520
6521 loop {
6522 let token = match self
6523 .hub
6524 .auth
6525 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6526 .await
6527 {
6528 Ok(token) => token,
6529 Err(e) => match dlg.token(e) {
6530 Ok(token) => token,
6531 Err(e) => {
6532 dlg.finished(false);
6533 return Err(common::Error::MissingToken(e));
6534 }
6535 },
6536 };
6537 request_value_reader
6538 .seek(std::io::SeekFrom::Start(0))
6539 .unwrap();
6540 let mut req_result = {
6541 let client = &self.hub.client;
6542 dlg.pre_request();
6543 let mut req_builder = hyper::Request::builder()
6544 .method(hyper::Method::POST)
6545 .uri(url.as_str())
6546 .header(USER_AGENT, self.hub._user_agent.clone());
6547
6548 if let Some(token) = token.as_ref() {
6549 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6550 }
6551
6552 let request = req_builder
6553 .header(CONTENT_TYPE, json_mime_type.to_string())
6554 .header(CONTENT_LENGTH, request_size as u64)
6555 .body(common::to_body(
6556 request_value_reader.get_ref().clone().into(),
6557 ));
6558
6559 client.request(request.unwrap()).await
6560 };
6561
6562 match req_result {
6563 Err(err) => {
6564 if let common::Retry::After(d) = dlg.http_error(&err) {
6565 sleep(d).await;
6566 continue;
6567 }
6568 dlg.finished(false);
6569 return Err(common::Error::HttpError(err));
6570 }
6571 Ok(res) => {
6572 let (mut parts, body) = res.into_parts();
6573 let mut body = common::Body::new(body);
6574 if !parts.status.is_success() {
6575 let bytes = common::to_bytes(body).await.unwrap_or_default();
6576 let error = serde_json::from_str(&common::to_string(&bytes));
6577 let response = common::to_response(parts, bytes.into());
6578
6579 if let common::Retry::After(d) =
6580 dlg.http_failure(&response, error.as_ref().ok())
6581 {
6582 sleep(d).await;
6583 continue;
6584 }
6585
6586 dlg.finished(false);
6587
6588 return Err(match error {
6589 Ok(value) => common::Error::BadRequest(value),
6590 _ => common::Error::Failure(response),
6591 });
6592 }
6593 let response = {
6594 let bytes = common::to_bytes(body).await.unwrap_or_default();
6595 let encoded = common::to_string(&bytes);
6596 match serde_json::from_str(&encoded) {
6597 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6598 Err(error) => {
6599 dlg.response_json_decode_error(&encoded, &error);
6600 return Err(common::Error::JsonDecodeError(
6601 encoded.to_string(),
6602 error,
6603 ));
6604 }
6605 }
6606 };
6607
6608 dlg.finished(true);
6609 return Ok(response);
6610 }
6611 }
6612 }
6613 }
6614
6615 ///
6616 /// Sets the *request* property to the given value.
6617 ///
6618 /// Even though the property as already been set when instantiating this call,
6619 /// we provide this method for API completeness.
6620 pub fn request(
6621 mut self,
6622 new_value: SetIamPolicyRequest,
6623 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
6624 self._request = new_value;
6625 self
6626 }
6627 /// 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.
6628 ///
6629 /// Sets the *resource* path property to the given value.
6630 ///
6631 /// Even though the property as already been set when instantiating this call,
6632 /// we provide this method for API completeness.
6633 pub fn resource(
6634 mut self,
6635 new_value: &str,
6636 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
6637 self._resource = new_value.to_string();
6638 self
6639 }
6640 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6641 /// while executing the actual API request.
6642 ///
6643 /// ````text
6644 /// It should be used to handle progress information, and to implement a certain level of resilience.
6645 /// ````
6646 ///
6647 /// Sets the *delegate* property to the given value.
6648 pub fn delegate(
6649 mut self,
6650 new_value: &'a mut dyn common::Delegate,
6651 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
6652 self._delegate = Some(new_value);
6653 self
6654 }
6655
6656 /// Set any additional parameter of the query string used in the request.
6657 /// It should be used to set parameters which are not yet available through their own
6658 /// setters.
6659 ///
6660 /// Please note that this method must not be used to set any of the known parameters
6661 /// which have their own setter method. If done anyway, the request will fail.
6662 ///
6663 /// # Additional Parameters
6664 ///
6665 /// * *$.xgafv* (query-string) - V1 error format.
6666 /// * *access_token* (query-string) - OAuth access token.
6667 /// * *alt* (query-string) - Data format for response.
6668 /// * *callback* (query-string) - JSONP
6669 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6670 /// * *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.
6671 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6672 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6673 /// * *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.
6674 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6675 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6676 pub fn param<T>(
6677 mut self,
6678 name: T,
6679 value: T,
6680 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
6681 where
6682 T: AsRef<str>,
6683 {
6684 self._additional_params
6685 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6686 self
6687 }
6688
6689 /// Identifies the authorization scope for the method you are building.
6690 ///
6691 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6692 /// [`Scope::CloudPlatform`].
6693 ///
6694 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6695 /// tokens for more than one scope.
6696 ///
6697 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6698 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6699 /// sufficient, a read-write scope will do as well.
6700 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
6701 where
6702 St: AsRef<str>,
6703 {
6704 self._scopes.insert(String::from(scope.as_ref()));
6705 self
6706 }
6707 /// Identifies the authorization scope(s) for the method you are building.
6708 ///
6709 /// See [`Self::add_scope()`] for details.
6710 pub fn add_scopes<I, St>(
6711 mut self,
6712 scopes: I,
6713 ) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C>
6714 where
6715 I: IntoIterator<Item = St>,
6716 St: AsRef<str>,
6717 {
6718 self._scopes
6719 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6720 self
6721 }
6722
6723 /// Removes all scopes, and no default scope will be used either.
6724 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6725 /// for details).
6726 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionSetIamPolicyCall<'a, C> {
6727 self._scopes.clear();
6728 self
6729 }
6730}
6731
6732/// 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.
6733///
6734/// A builder for the *locations.ekmConnections.testIamPermissions* method supported by a *project* resource.
6735/// It is not used directly, but through a [`ProjectMethods`] instance.
6736///
6737/// # Example
6738///
6739/// Instantiate a resource method builder
6740///
6741/// ```test_harness,no_run
6742/// # extern crate hyper;
6743/// # extern crate hyper_rustls;
6744/// # extern crate google_cloudkms1 as cloudkms1;
6745/// use cloudkms1::api::TestIamPermissionsRequest;
6746/// # async fn dox() {
6747/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6748///
6749/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6751/// # secret,
6752/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6753/// # ).build().await.unwrap();
6754///
6755/// # let client = hyper_util::client::legacy::Client::builder(
6756/// # hyper_util::rt::TokioExecutor::new()
6757/// # )
6758/// # .build(
6759/// # hyper_rustls::HttpsConnectorBuilder::new()
6760/// # .with_native_roots()
6761/// # .unwrap()
6762/// # .https_or_http()
6763/// # .enable_http1()
6764/// # .build()
6765/// # );
6766/// # let mut hub = CloudKMS::new(client, auth);
6767/// // As the method needs a request, you would usually fill it with the desired information
6768/// // into the respective structure. Some of the parts shown here might not be applicable !
6769/// // Values shown here are possibly random and not representative !
6770/// let mut req = TestIamPermissionsRequest::default();
6771///
6772/// // You can configure optional parameters by calling the respective setters at will, and
6773/// // execute the final call using `doit()`.
6774/// // Values shown here are possibly random and not representative !
6775/// let result = hub.projects().locations_ekm_connections_test_iam_permissions(req, "resource")
6776/// .doit().await;
6777/// # }
6778/// ```
6779pub struct ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
6780where
6781 C: 'a,
6782{
6783 hub: &'a CloudKMS<C>,
6784 _request: TestIamPermissionsRequest,
6785 _resource: String,
6786 _delegate: Option<&'a mut dyn common::Delegate>,
6787 _additional_params: HashMap<String, String>,
6788 _scopes: BTreeSet<String>,
6789}
6790
6791impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {}
6792
6793impl<'a, C> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
6794where
6795 C: common::Connector,
6796{
6797 /// Perform the operation you have build so far.
6798 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
6799 use std::borrow::Cow;
6800 use std::io::{Read, Seek};
6801
6802 use common::{url::Params, ToParts};
6803 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6804
6805 let mut dd = common::DefaultDelegate;
6806 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6807 dlg.begin(common::MethodInfo {
6808 id: "cloudkms.projects.locations.ekmConnections.testIamPermissions",
6809 http_method: hyper::Method::POST,
6810 });
6811
6812 for &field in ["alt", "resource"].iter() {
6813 if self._additional_params.contains_key(field) {
6814 dlg.finished(false);
6815 return Err(common::Error::FieldClash(field));
6816 }
6817 }
6818
6819 let mut params = Params::with_capacity(4 + self._additional_params.len());
6820 params.push("resource", self._resource);
6821
6822 params.extend(self._additional_params.iter());
6823
6824 params.push("alt", "json");
6825 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
6826 if self._scopes.is_empty() {
6827 self._scopes
6828 .insert(Scope::CloudPlatform.as_ref().to_string());
6829 }
6830
6831 #[allow(clippy::single_element_loop)]
6832 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6833 url = params.uri_replacement(url, param_name, find_this, true);
6834 }
6835 {
6836 let to_remove = ["resource"];
6837 params.remove_params(&to_remove);
6838 }
6839
6840 let url = params.parse_with_url(&url);
6841
6842 let mut json_mime_type = mime::APPLICATION_JSON;
6843 let mut request_value_reader = {
6844 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6845 common::remove_json_null_values(&mut value);
6846 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6847 serde_json::to_writer(&mut dst, &value).unwrap();
6848 dst
6849 };
6850 let request_size = request_value_reader
6851 .seek(std::io::SeekFrom::End(0))
6852 .unwrap();
6853 request_value_reader
6854 .seek(std::io::SeekFrom::Start(0))
6855 .unwrap();
6856
6857 loop {
6858 let token = match self
6859 .hub
6860 .auth
6861 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6862 .await
6863 {
6864 Ok(token) => token,
6865 Err(e) => match dlg.token(e) {
6866 Ok(token) => token,
6867 Err(e) => {
6868 dlg.finished(false);
6869 return Err(common::Error::MissingToken(e));
6870 }
6871 },
6872 };
6873 request_value_reader
6874 .seek(std::io::SeekFrom::Start(0))
6875 .unwrap();
6876 let mut req_result = {
6877 let client = &self.hub.client;
6878 dlg.pre_request();
6879 let mut req_builder = hyper::Request::builder()
6880 .method(hyper::Method::POST)
6881 .uri(url.as_str())
6882 .header(USER_AGENT, self.hub._user_agent.clone());
6883
6884 if let Some(token) = token.as_ref() {
6885 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6886 }
6887
6888 let request = req_builder
6889 .header(CONTENT_TYPE, json_mime_type.to_string())
6890 .header(CONTENT_LENGTH, request_size as u64)
6891 .body(common::to_body(
6892 request_value_reader.get_ref().clone().into(),
6893 ));
6894
6895 client.request(request.unwrap()).await
6896 };
6897
6898 match req_result {
6899 Err(err) => {
6900 if let common::Retry::After(d) = dlg.http_error(&err) {
6901 sleep(d).await;
6902 continue;
6903 }
6904 dlg.finished(false);
6905 return Err(common::Error::HttpError(err));
6906 }
6907 Ok(res) => {
6908 let (mut parts, body) = res.into_parts();
6909 let mut body = common::Body::new(body);
6910 if !parts.status.is_success() {
6911 let bytes = common::to_bytes(body).await.unwrap_or_default();
6912 let error = serde_json::from_str(&common::to_string(&bytes));
6913 let response = common::to_response(parts, bytes.into());
6914
6915 if let common::Retry::After(d) =
6916 dlg.http_failure(&response, error.as_ref().ok())
6917 {
6918 sleep(d).await;
6919 continue;
6920 }
6921
6922 dlg.finished(false);
6923
6924 return Err(match error {
6925 Ok(value) => common::Error::BadRequest(value),
6926 _ => common::Error::Failure(response),
6927 });
6928 }
6929 let response = {
6930 let bytes = common::to_bytes(body).await.unwrap_or_default();
6931 let encoded = common::to_string(&bytes);
6932 match serde_json::from_str(&encoded) {
6933 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6934 Err(error) => {
6935 dlg.response_json_decode_error(&encoded, &error);
6936 return Err(common::Error::JsonDecodeError(
6937 encoded.to_string(),
6938 error,
6939 ));
6940 }
6941 }
6942 };
6943
6944 dlg.finished(true);
6945 return Ok(response);
6946 }
6947 }
6948 }
6949 }
6950
6951 ///
6952 /// Sets the *request* property to the given value.
6953 ///
6954 /// Even though the property as already been set when instantiating this call,
6955 /// we provide this method for API completeness.
6956 pub fn request(
6957 mut self,
6958 new_value: TestIamPermissionsRequest,
6959 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
6960 self._request = new_value;
6961 self
6962 }
6963 /// 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.
6964 ///
6965 /// Sets the *resource* path property to the given value.
6966 ///
6967 /// Even though the property as already been set when instantiating this call,
6968 /// we provide this method for API completeness.
6969 pub fn resource(
6970 mut self,
6971 new_value: &str,
6972 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
6973 self._resource = new_value.to_string();
6974 self
6975 }
6976 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6977 /// while executing the actual API request.
6978 ///
6979 /// ````text
6980 /// It should be used to handle progress information, and to implement a certain level of resilience.
6981 /// ````
6982 ///
6983 /// Sets the *delegate* property to the given value.
6984 pub fn delegate(
6985 mut self,
6986 new_value: &'a mut dyn common::Delegate,
6987 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
6988 self._delegate = Some(new_value);
6989 self
6990 }
6991
6992 /// Set any additional parameter of the query string used in the request.
6993 /// It should be used to set parameters which are not yet available through their own
6994 /// setters.
6995 ///
6996 /// Please note that this method must not be used to set any of the known parameters
6997 /// which have their own setter method. If done anyway, the request will fail.
6998 ///
6999 /// # Additional Parameters
7000 ///
7001 /// * *$.xgafv* (query-string) - V1 error format.
7002 /// * *access_token* (query-string) - OAuth access token.
7003 /// * *alt* (query-string) - Data format for response.
7004 /// * *callback* (query-string) - JSONP
7005 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7006 /// * *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.
7007 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7008 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7009 /// * *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.
7010 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7011 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7012 pub fn param<T>(
7013 mut self,
7014 name: T,
7015 value: T,
7016 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
7017 where
7018 T: AsRef<str>,
7019 {
7020 self._additional_params
7021 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7022 self
7023 }
7024
7025 /// Identifies the authorization scope for the method you are building.
7026 ///
7027 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7028 /// [`Scope::CloudPlatform`].
7029 ///
7030 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7031 /// tokens for more than one scope.
7032 ///
7033 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7034 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7035 /// sufficient, a read-write scope will do as well.
7036 pub fn add_scope<St>(
7037 mut self,
7038 scope: St,
7039 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
7040 where
7041 St: AsRef<str>,
7042 {
7043 self._scopes.insert(String::from(scope.as_ref()));
7044 self
7045 }
7046 /// Identifies the authorization scope(s) for the method you are building.
7047 ///
7048 /// See [`Self::add_scope()`] for details.
7049 pub fn add_scopes<I, St>(
7050 mut self,
7051 scopes: I,
7052 ) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C>
7053 where
7054 I: IntoIterator<Item = St>,
7055 St: AsRef<str>,
7056 {
7057 self._scopes
7058 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7059 self
7060 }
7061
7062 /// Removes all scopes, and no default scope will be used either.
7063 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7064 /// for details).
7065 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionTestIamPermissionCall<'a, C> {
7066 self._scopes.clear();
7067 self
7068 }
7069}
7070
7071/// 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.
7072///
7073/// A builder for the *locations.ekmConnections.verifyConnectivity* method supported by a *project* resource.
7074/// It is not used directly, but through a [`ProjectMethods`] instance.
7075///
7076/// # Example
7077///
7078/// Instantiate a resource method builder
7079///
7080/// ```test_harness,no_run
7081/// # extern crate hyper;
7082/// # extern crate hyper_rustls;
7083/// # extern crate google_cloudkms1 as cloudkms1;
7084/// # async fn dox() {
7085/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7086///
7087/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7088/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7089/// # secret,
7090/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7091/// # ).build().await.unwrap();
7092///
7093/// # let client = hyper_util::client::legacy::Client::builder(
7094/// # hyper_util::rt::TokioExecutor::new()
7095/// # )
7096/// # .build(
7097/// # hyper_rustls::HttpsConnectorBuilder::new()
7098/// # .with_native_roots()
7099/// # .unwrap()
7100/// # .https_or_http()
7101/// # .enable_http1()
7102/// # .build()
7103/// # );
7104/// # let mut hub = CloudKMS::new(client, auth);
7105/// // You can configure optional parameters by calling the respective setters at will, and
7106/// // execute the final call using `doit()`.
7107/// // Values shown here are possibly random and not representative !
7108/// let result = hub.projects().locations_ekm_connections_verify_connectivity("name")
7109/// .doit().await;
7110/// # }
7111/// ```
7112pub struct ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
7113where
7114 C: 'a,
7115{
7116 hub: &'a CloudKMS<C>,
7117 _name: String,
7118 _delegate: Option<&'a mut dyn common::Delegate>,
7119 _additional_params: HashMap<String, String>,
7120 _scopes: BTreeSet<String>,
7121}
7122
7123impl<'a, C> common::CallBuilder for ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {}
7124
7125impl<'a, C> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
7126where
7127 C: common::Connector,
7128{
7129 /// Perform the operation you have build so far.
7130 pub async fn doit(mut self) -> common::Result<(common::Response, VerifyConnectivityResponse)> {
7131 use std::borrow::Cow;
7132 use std::io::{Read, Seek};
7133
7134 use common::{url::Params, ToParts};
7135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7136
7137 let mut dd = common::DefaultDelegate;
7138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7139 dlg.begin(common::MethodInfo {
7140 id: "cloudkms.projects.locations.ekmConnections.verifyConnectivity",
7141 http_method: hyper::Method::GET,
7142 });
7143
7144 for &field in ["alt", "name"].iter() {
7145 if self._additional_params.contains_key(field) {
7146 dlg.finished(false);
7147 return Err(common::Error::FieldClash(field));
7148 }
7149 }
7150
7151 let mut params = Params::with_capacity(3 + self._additional_params.len());
7152 params.push("name", self._name);
7153
7154 params.extend(self._additional_params.iter());
7155
7156 params.push("alt", "json");
7157 let mut url = self.hub._base_url.clone() + "v1/{+name}:verifyConnectivity";
7158 if self._scopes.is_empty() {
7159 self._scopes
7160 .insert(Scope::CloudPlatform.as_ref().to_string());
7161 }
7162
7163 #[allow(clippy::single_element_loop)]
7164 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7165 url = params.uri_replacement(url, param_name, find_this, true);
7166 }
7167 {
7168 let to_remove = ["name"];
7169 params.remove_params(&to_remove);
7170 }
7171
7172 let url = params.parse_with_url(&url);
7173
7174 loop {
7175 let token = match self
7176 .hub
7177 .auth
7178 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7179 .await
7180 {
7181 Ok(token) => token,
7182 Err(e) => match dlg.token(e) {
7183 Ok(token) => token,
7184 Err(e) => {
7185 dlg.finished(false);
7186 return Err(common::Error::MissingToken(e));
7187 }
7188 },
7189 };
7190 let mut req_result = {
7191 let client = &self.hub.client;
7192 dlg.pre_request();
7193 let mut req_builder = hyper::Request::builder()
7194 .method(hyper::Method::GET)
7195 .uri(url.as_str())
7196 .header(USER_AGENT, self.hub._user_agent.clone());
7197
7198 if let Some(token) = token.as_ref() {
7199 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7200 }
7201
7202 let request = req_builder
7203 .header(CONTENT_LENGTH, 0_u64)
7204 .body(common::to_body::<String>(None));
7205
7206 client.request(request.unwrap()).await
7207 };
7208
7209 match req_result {
7210 Err(err) => {
7211 if let common::Retry::After(d) = dlg.http_error(&err) {
7212 sleep(d).await;
7213 continue;
7214 }
7215 dlg.finished(false);
7216 return Err(common::Error::HttpError(err));
7217 }
7218 Ok(res) => {
7219 let (mut parts, body) = res.into_parts();
7220 let mut body = common::Body::new(body);
7221 if !parts.status.is_success() {
7222 let bytes = common::to_bytes(body).await.unwrap_or_default();
7223 let error = serde_json::from_str(&common::to_string(&bytes));
7224 let response = common::to_response(parts, bytes.into());
7225
7226 if let common::Retry::After(d) =
7227 dlg.http_failure(&response, error.as_ref().ok())
7228 {
7229 sleep(d).await;
7230 continue;
7231 }
7232
7233 dlg.finished(false);
7234
7235 return Err(match error {
7236 Ok(value) => common::Error::BadRequest(value),
7237 _ => common::Error::Failure(response),
7238 });
7239 }
7240 let response = {
7241 let bytes = common::to_bytes(body).await.unwrap_or_default();
7242 let encoded = common::to_string(&bytes);
7243 match serde_json::from_str(&encoded) {
7244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7245 Err(error) => {
7246 dlg.response_json_decode_error(&encoded, &error);
7247 return Err(common::Error::JsonDecodeError(
7248 encoded.to_string(),
7249 error,
7250 ));
7251 }
7252 }
7253 };
7254
7255 dlg.finished(true);
7256 return Ok(response);
7257 }
7258 }
7259 }
7260 }
7261
7262 /// Required. The name of the EkmConnection to verify.
7263 ///
7264 /// Sets the *name* path property to the given value.
7265 ///
7266 /// Even though the property as already been set when instantiating this call,
7267 /// we provide this method for API completeness.
7268 pub fn name(
7269 mut self,
7270 new_value: &str,
7271 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
7272 self._name = new_value.to_string();
7273 self
7274 }
7275 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7276 /// while executing the actual API request.
7277 ///
7278 /// ````text
7279 /// It should be used to handle progress information, and to implement a certain level of resilience.
7280 /// ````
7281 ///
7282 /// Sets the *delegate* property to the given value.
7283 pub fn delegate(
7284 mut self,
7285 new_value: &'a mut dyn common::Delegate,
7286 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
7287 self._delegate = Some(new_value);
7288 self
7289 }
7290
7291 /// Set any additional parameter of the query string used in the request.
7292 /// It should be used to set parameters which are not yet available through their own
7293 /// setters.
7294 ///
7295 /// Please note that this method must not be used to set any of the known parameters
7296 /// which have their own setter method. If done anyway, the request will fail.
7297 ///
7298 /// # Additional Parameters
7299 ///
7300 /// * *$.xgafv* (query-string) - V1 error format.
7301 /// * *access_token* (query-string) - OAuth access token.
7302 /// * *alt* (query-string) - Data format for response.
7303 /// * *callback* (query-string) - JSONP
7304 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7305 /// * *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.
7306 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7307 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7308 /// * *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.
7309 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7310 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7311 pub fn param<T>(
7312 mut self,
7313 name: T,
7314 value: T,
7315 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
7316 where
7317 T: AsRef<str>,
7318 {
7319 self._additional_params
7320 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7321 self
7322 }
7323
7324 /// Identifies the authorization scope for the method you are building.
7325 ///
7326 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7327 /// [`Scope::CloudPlatform`].
7328 ///
7329 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7330 /// tokens for more than one scope.
7331 ///
7332 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7333 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7334 /// sufficient, a read-write scope will do as well.
7335 pub fn add_scope<St>(
7336 mut self,
7337 scope: St,
7338 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
7339 where
7340 St: AsRef<str>,
7341 {
7342 self._scopes.insert(String::from(scope.as_ref()));
7343 self
7344 }
7345 /// Identifies the authorization scope(s) for the method you are building.
7346 ///
7347 /// See [`Self::add_scope()`] for details.
7348 pub fn add_scopes<I, St>(
7349 mut self,
7350 scopes: I,
7351 ) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C>
7352 where
7353 I: IntoIterator<Item = St>,
7354 St: AsRef<str>,
7355 {
7356 self._scopes
7357 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7358 self
7359 }
7360
7361 /// Removes all scopes, and no default scope will be used either.
7362 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7363 /// for details).
7364 pub fn clear_scopes(mut self) -> ProjectLocationEkmConnectionVerifyConnectivityCall<'a, C> {
7365 self._scopes.clear();
7366 self
7367 }
7368}
7369
7370/// 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.
7371///
7372/// A builder for the *locations.keyHandles.create* method supported by a *project* resource.
7373/// It is not used directly, but through a [`ProjectMethods`] instance.
7374///
7375/// # Example
7376///
7377/// Instantiate a resource method builder
7378///
7379/// ```test_harness,no_run
7380/// # extern crate hyper;
7381/// # extern crate hyper_rustls;
7382/// # extern crate google_cloudkms1 as cloudkms1;
7383/// use cloudkms1::api::KeyHandle;
7384/// # async fn dox() {
7385/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7386///
7387/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7388/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7389/// # secret,
7390/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7391/// # ).build().await.unwrap();
7392///
7393/// # let client = hyper_util::client::legacy::Client::builder(
7394/// # hyper_util::rt::TokioExecutor::new()
7395/// # )
7396/// # .build(
7397/// # hyper_rustls::HttpsConnectorBuilder::new()
7398/// # .with_native_roots()
7399/// # .unwrap()
7400/// # .https_or_http()
7401/// # .enable_http1()
7402/// # .build()
7403/// # );
7404/// # let mut hub = CloudKMS::new(client, auth);
7405/// // As the method needs a request, you would usually fill it with the desired information
7406/// // into the respective structure. Some of the parts shown here might not be applicable !
7407/// // Values shown here are possibly random and not representative !
7408/// let mut req = KeyHandle::default();
7409///
7410/// // You can configure optional parameters by calling the respective setters at will, and
7411/// // execute the final call using `doit()`.
7412/// // Values shown here are possibly random and not representative !
7413/// let result = hub.projects().locations_key_handles_create(req, "parent")
7414/// .key_handle_id("rebum.")
7415/// .doit().await;
7416/// # }
7417/// ```
7418pub struct ProjectLocationKeyHandleCreateCall<'a, C>
7419where
7420 C: 'a,
7421{
7422 hub: &'a CloudKMS<C>,
7423 _request: KeyHandle,
7424 _parent: String,
7425 _key_handle_id: Option<String>,
7426 _delegate: Option<&'a mut dyn common::Delegate>,
7427 _additional_params: HashMap<String, String>,
7428 _scopes: BTreeSet<String>,
7429}
7430
7431impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleCreateCall<'a, C> {}
7432
7433impl<'a, C> ProjectLocationKeyHandleCreateCall<'a, C>
7434where
7435 C: common::Connector,
7436{
7437 /// Perform the operation you have build so far.
7438 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7439 use std::borrow::Cow;
7440 use std::io::{Read, Seek};
7441
7442 use common::{url::Params, ToParts};
7443 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7444
7445 let mut dd = common::DefaultDelegate;
7446 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7447 dlg.begin(common::MethodInfo {
7448 id: "cloudkms.projects.locations.keyHandles.create",
7449 http_method: hyper::Method::POST,
7450 });
7451
7452 for &field in ["alt", "parent", "keyHandleId"].iter() {
7453 if self._additional_params.contains_key(field) {
7454 dlg.finished(false);
7455 return Err(common::Error::FieldClash(field));
7456 }
7457 }
7458
7459 let mut params = Params::with_capacity(5 + self._additional_params.len());
7460 params.push("parent", self._parent);
7461 if let Some(value) = self._key_handle_id.as_ref() {
7462 params.push("keyHandleId", value);
7463 }
7464
7465 params.extend(self._additional_params.iter());
7466
7467 params.push("alt", "json");
7468 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyHandles";
7469 if self._scopes.is_empty() {
7470 self._scopes
7471 .insert(Scope::CloudPlatform.as_ref().to_string());
7472 }
7473
7474 #[allow(clippy::single_element_loop)]
7475 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7476 url = params.uri_replacement(url, param_name, find_this, true);
7477 }
7478 {
7479 let to_remove = ["parent"];
7480 params.remove_params(&to_remove);
7481 }
7482
7483 let url = params.parse_with_url(&url);
7484
7485 let mut json_mime_type = mime::APPLICATION_JSON;
7486 let mut request_value_reader = {
7487 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7488 common::remove_json_null_values(&mut value);
7489 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7490 serde_json::to_writer(&mut dst, &value).unwrap();
7491 dst
7492 };
7493 let request_size = request_value_reader
7494 .seek(std::io::SeekFrom::End(0))
7495 .unwrap();
7496 request_value_reader
7497 .seek(std::io::SeekFrom::Start(0))
7498 .unwrap();
7499
7500 loop {
7501 let token = match self
7502 .hub
7503 .auth
7504 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7505 .await
7506 {
7507 Ok(token) => token,
7508 Err(e) => match dlg.token(e) {
7509 Ok(token) => token,
7510 Err(e) => {
7511 dlg.finished(false);
7512 return Err(common::Error::MissingToken(e));
7513 }
7514 },
7515 };
7516 request_value_reader
7517 .seek(std::io::SeekFrom::Start(0))
7518 .unwrap();
7519 let mut req_result = {
7520 let client = &self.hub.client;
7521 dlg.pre_request();
7522 let mut req_builder = hyper::Request::builder()
7523 .method(hyper::Method::POST)
7524 .uri(url.as_str())
7525 .header(USER_AGENT, self.hub._user_agent.clone());
7526
7527 if let Some(token) = token.as_ref() {
7528 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7529 }
7530
7531 let request = req_builder
7532 .header(CONTENT_TYPE, json_mime_type.to_string())
7533 .header(CONTENT_LENGTH, request_size as u64)
7534 .body(common::to_body(
7535 request_value_reader.get_ref().clone().into(),
7536 ));
7537
7538 client.request(request.unwrap()).await
7539 };
7540
7541 match req_result {
7542 Err(err) => {
7543 if let common::Retry::After(d) = dlg.http_error(&err) {
7544 sleep(d).await;
7545 continue;
7546 }
7547 dlg.finished(false);
7548 return Err(common::Error::HttpError(err));
7549 }
7550 Ok(res) => {
7551 let (mut parts, body) = res.into_parts();
7552 let mut body = common::Body::new(body);
7553 if !parts.status.is_success() {
7554 let bytes = common::to_bytes(body).await.unwrap_or_default();
7555 let error = serde_json::from_str(&common::to_string(&bytes));
7556 let response = common::to_response(parts, bytes.into());
7557
7558 if let common::Retry::After(d) =
7559 dlg.http_failure(&response, error.as_ref().ok())
7560 {
7561 sleep(d).await;
7562 continue;
7563 }
7564
7565 dlg.finished(false);
7566
7567 return Err(match error {
7568 Ok(value) => common::Error::BadRequest(value),
7569 _ => common::Error::Failure(response),
7570 });
7571 }
7572 let response = {
7573 let bytes = common::to_bytes(body).await.unwrap_or_default();
7574 let encoded = common::to_string(&bytes);
7575 match serde_json::from_str(&encoded) {
7576 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7577 Err(error) => {
7578 dlg.response_json_decode_error(&encoded, &error);
7579 return Err(common::Error::JsonDecodeError(
7580 encoded.to_string(),
7581 error,
7582 ));
7583 }
7584 }
7585 };
7586
7587 dlg.finished(true);
7588 return Ok(response);
7589 }
7590 }
7591 }
7592 }
7593
7594 ///
7595 /// Sets the *request* property to the given value.
7596 ///
7597 /// Even though the property as already been set when instantiating this call,
7598 /// we provide this method for API completeness.
7599 pub fn request(mut self, new_value: KeyHandle) -> ProjectLocationKeyHandleCreateCall<'a, C> {
7600 self._request = new_value;
7601 self
7602 }
7603 /// Required. Name of the resource project and location to create the KeyHandle in, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
7604 ///
7605 /// Sets the *parent* path property to the given value.
7606 ///
7607 /// Even though the property as already been set when instantiating this call,
7608 /// we provide this method for API completeness.
7609 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyHandleCreateCall<'a, C> {
7610 self._parent = new_value.to_string();
7611 self
7612 }
7613 /// 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.
7614 ///
7615 /// Sets the *key handle id* query property to the given value.
7616 pub fn key_handle_id(mut self, new_value: &str) -> ProjectLocationKeyHandleCreateCall<'a, C> {
7617 self._key_handle_id = Some(new_value.to_string());
7618 self
7619 }
7620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7621 /// while executing the actual API request.
7622 ///
7623 /// ````text
7624 /// It should be used to handle progress information, and to implement a certain level of resilience.
7625 /// ````
7626 ///
7627 /// Sets the *delegate* property to the given value.
7628 pub fn delegate(
7629 mut self,
7630 new_value: &'a mut dyn common::Delegate,
7631 ) -> ProjectLocationKeyHandleCreateCall<'a, C> {
7632 self._delegate = Some(new_value);
7633 self
7634 }
7635
7636 /// Set any additional parameter of the query string used in the request.
7637 /// It should be used to set parameters which are not yet available through their own
7638 /// setters.
7639 ///
7640 /// Please note that this method must not be used to set any of the known parameters
7641 /// which have their own setter method. If done anyway, the request will fail.
7642 ///
7643 /// # Additional Parameters
7644 ///
7645 /// * *$.xgafv* (query-string) - V1 error format.
7646 /// * *access_token* (query-string) - OAuth access token.
7647 /// * *alt* (query-string) - Data format for response.
7648 /// * *callback* (query-string) - JSONP
7649 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7650 /// * *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.
7651 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7652 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7653 /// * *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.
7654 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7655 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7656 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleCreateCall<'a, C>
7657 where
7658 T: AsRef<str>,
7659 {
7660 self._additional_params
7661 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7662 self
7663 }
7664
7665 /// Identifies the authorization scope for the method you are building.
7666 ///
7667 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7668 /// [`Scope::CloudPlatform`].
7669 ///
7670 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7671 /// tokens for more than one scope.
7672 ///
7673 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7674 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7675 /// sufficient, a read-write scope will do as well.
7676 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleCreateCall<'a, C>
7677 where
7678 St: AsRef<str>,
7679 {
7680 self._scopes.insert(String::from(scope.as_ref()));
7681 self
7682 }
7683 /// Identifies the authorization scope(s) for the method you are building.
7684 ///
7685 /// See [`Self::add_scope()`] for details.
7686 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleCreateCall<'a, C>
7687 where
7688 I: IntoIterator<Item = St>,
7689 St: AsRef<str>,
7690 {
7691 self._scopes
7692 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7693 self
7694 }
7695
7696 /// Removes all scopes, and no default scope will be used either.
7697 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7698 /// for details).
7699 pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleCreateCall<'a, C> {
7700 self._scopes.clear();
7701 self
7702 }
7703}
7704
7705/// Returns the KeyHandle.
7706///
7707/// A builder for the *locations.keyHandles.get* method supported by a *project* resource.
7708/// It is not used directly, but through a [`ProjectMethods`] instance.
7709///
7710/// # Example
7711///
7712/// Instantiate a resource method builder
7713///
7714/// ```test_harness,no_run
7715/// # extern crate hyper;
7716/// # extern crate hyper_rustls;
7717/// # extern crate google_cloudkms1 as cloudkms1;
7718/// # async fn dox() {
7719/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7720///
7721/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7722/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7723/// # secret,
7724/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7725/// # ).build().await.unwrap();
7726///
7727/// # let client = hyper_util::client::legacy::Client::builder(
7728/// # hyper_util::rt::TokioExecutor::new()
7729/// # )
7730/// # .build(
7731/// # hyper_rustls::HttpsConnectorBuilder::new()
7732/// # .with_native_roots()
7733/// # .unwrap()
7734/// # .https_or_http()
7735/// # .enable_http1()
7736/// # .build()
7737/// # );
7738/// # let mut hub = CloudKMS::new(client, auth);
7739/// // You can configure optional parameters by calling the respective setters at will, and
7740/// // execute the final call using `doit()`.
7741/// // Values shown here are possibly random and not representative !
7742/// let result = hub.projects().locations_key_handles_get("name")
7743/// .doit().await;
7744/// # }
7745/// ```
7746pub struct ProjectLocationKeyHandleGetCall<'a, C>
7747where
7748 C: 'a,
7749{
7750 hub: &'a CloudKMS<C>,
7751 _name: String,
7752 _delegate: Option<&'a mut dyn common::Delegate>,
7753 _additional_params: HashMap<String, String>,
7754 _scopes: BTreeSet<String>,
7755}
7756
7757impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleGetCall<'a, C> {}
7758
7759impl<'a, C> ProjectLocationKeyHandleGetCall<'a, C>
7760where
7761 C: common::Connector,
7762{
7763 /// Perform the operation you have build so far.
7764 pub async fn doit(mut self) -> common::Result<(common::Response, KeyHandle)> {
7765 use std::borrow::Cow;
7766 use std::io::{Read, Seek};
7767
7768 use common::{url::Params, ToParts};
7769 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7770
7771 let mut dd = common::DefaultDelegate;
7772 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7773 dlg.begin(common::MethodInfo {
7774 id: "cloudkms.projects.locations.keyHandles.get",
7775 http_method: hyper::Method::GET,
7776 });
7777
7778 for &field in ["alt", "name"].iter() {
7779 if self._additional_params.contains_key(field) {
7780 dlg.finished(false);
7781 return Err(common::Error::FieldClash(field));
7782 }
7783 }
7784
7785 let mut params = Params::with_capacity(3 + self._additional_params.len());
7786 params.push("name", self._name);
7787
7788 params.extend(self._additional_params.iter());
7789
7790 params.push("alt", "json");
7791 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7792 if self._scopes.is_empty() {
7793 self._scopes
7794 .insert(Scope::CloudPlatform.as_ref().to_string());
7795 }
7796
7797 #[allow(clippy::single_element_loop)]
7798 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7799 url = params.uri_replacement(url, param_name, find_this, true);
7800 }
7801 {
7802 let to_remove = ["name"];
7803 params.remove_params(&to_remove);
7804 }
7805
7806 let url = params.parse_with_url(&url);
7807
7808 loop {
7809 let token = match self
7810 .hub
7811 .auth
7812 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7813 .await
7814 {
7815 Ok(token) => token,
7816 Err(e) => match dlg.token(e) {
7817 Ok(token) => token,
7818 Err(e) => {
7819 dlg.finished(false);
7820 return Err(common::Error::MissingToken(e));
7821 }
7822 },
7823 };
7824 let mut req_result = {
7825 let client = &self.hub.client;
7826 dlg.pre_request();
7827 let mut req_builder = hyper::Request::builder()
7828 .method(hyper::Method::GET)
7829 .uri(url.as_str())
7830 .header(USER_AGENT, self.hub._user_agent.clone());
7831
7832 if let Some(token) = token.as_ref() {
7833 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7834 }
7835
7836 let request = req_builder
7837 .header(CONTENT_LENGTH, 0_u64)
7838 .body(common::to_body::<String>(None));
7839
7840 client.request(request.unwrap()).await
7841 };
7842
7843 match req_result {
7844 Err(err) => {
7845 if let common::Retry::After(d) = dlg.http_error(&err) {
7846 sleep(d).await;
7847 continue;
7848 }
7849 dlg.finished(false);
7850 return Err(common::Error::HttpError(err));
7851 }
7852 Ok(res) => {
7853 let (mut parts, body) = res.into_parts();
7854 let mut body = common::Body::new(body);
7855 if !parts.status.is_success() {
7856 let bytes = common::to_bytes(body).await.unwrap_or_default();
7857 let error = serde_json::from_str(&common::to_string(&bytes));
7858 let response = common::to_response(parts, bytes.into());
7859
7860 if let common::Retry::After(d) =
7861 dlg.http_failure(&response, error.as_ref().ok())
7862 {
7863 sleep(d).await;
7864 continue;
7865 }
7866
7867 dlg.finished(false);
7868
7869 return Err(match error {
7870 Ok(value) => common::Error::BadRequest(value),
7871 _ => common::Error::Failure(response),
7872 });
7873 }
7874 let response = {
7875 let bytes = common::to_bytes(body).await.unwrap_or_default();
7876 let encoded = common::to_string(&bytes);
7877 match serde_json::from_str(&encoded) {
7878 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7879 Err(error) => {
7880 dlg.response_json_decode_error(&encoded, &error);
7881 return Err(common::Error::JsonDecodeError(
7882 encoded.to_string(),
7883 error,
7884 ));
7885 }
7886 }
7887 };
7888
7889 dlg.finished(true);
7890 return Ok(response);
7891 }
7892 }
7893 }
7894 }
7895
7896 /// Required. Name of the KeyHandle resource, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}`.
7897 ///
7898 /// Sets the *name* path property to the given value.
7899 ///
7900 /// Even though the property as already been set when instantiating this call,
7901 /// we provide this method for API completeness.
7902 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyHandleGetCall<'a, C> {
7903 self._name = new_value.to_string();
7904 self
7905 }
7906 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7907 /// while executing the actual API request.
7908 ///
7909 /// ````text
7910 /// It should be used to handle progress information, and to implement a certain level of resilience.
7911 /// ````
7912 ///
7913 /// Sets the *delegate* property to the given value.
7914 pub fn delegate(
7915 mut self,
7916 new_value: &'a mut dyn common::Delegate,
7917 ) -> ProjectLocationKeyHandleGetCall<'a, C> {
7918 self._delegate = Some(new_value);
7919 self
7920 }
7921
7922 /// Set any additional parameter of the query string used in the request.
7923 /// It should be used to set parameters which are not yet available through their own
7924 /// setters.
7925 ///
7926 /// Please note that this method must not be used to set any of the known parameters
7927 /// which have their own setter method. If done anyway, the request will fail.
7928 ///
7929 /// # Additional Parameters
7930 ///
7931 /// * *$.xgafv* (query-string) - V1 error format.
7932 /// * *access_token* (query-string) - OAuth access token.
7933 /// * *alt* (query-string) - Data format for response.
7934 /// * *callback* (query-string) - JSONP
7935 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7936 /// * *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.
7937 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7938 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7939 /// * *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.
7940 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7941 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7942 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleGetCall<'a, C>
7943 where
7944 T: AsRef<str>,
7945 {
7946 self._additional_params
7947 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7948 self
7949 }
7950
7951 /// Identifies the authorization scope for the method you are building.
7952 ///
7953 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7954 /// [`Scope::CloudPlatform`].
7955 ///
7956 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7957 /// tokens for more than one scope.
7958 ///
7959 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7960 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7961 /// sufficient, a read-write scope will do as well.
7962 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleGetCall<'a, C>
7963 where
7964 St: AsRef<str>,
7965 {
7966 self._scopes.insert(String::from(scope.as_ref()));
7967 self
7968 }
7969 /// Identifies the authorization scope(s) for the method you are building.
7970 ///
7971 /// See [`Self::add_scope()`] for details.
7972 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleGetCall<'a, C>
7973 where
7974 I: IntoIterator<Item = St>,
7975 St: AsRef<str>,
7976 {
7977 self._scopes
7978 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7979 self
7980 }
7981
7982 /// Removes all scopes, and no default scope will be used either.
7983 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7984 /// for details).
7985 pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleGetCall<'a, C> {
7986 self._scopes.clear();
7987 self
7988 }
7989}
7990
7991/// Lists KeyHandles.
7992///
7993/// A builder for the *locations.keyHandles.list* method supported by a *project* resource.
7994/// It is not used directly, but through a [`ProjectMethods`] instance.
7995///
7996/// # Example
7997///
7998/// Instantiate a resource method builder
7999///
8000/// ```test_harness,no_run
8001/// # extern crate hyper;
8002/// # extern crate hyper_rustls;
8003/// # extern crate google_cloudkms1 as cloudkms1;
8004/// # async fn dox() {
8005/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8006///
8007/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8008/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8009/// # secret,
8010/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8011/// # ).build().await.unwrap();
8012///
8013/// # let client = hyper_util::client::legacy::Client::builder(
8014/// # hyper_util::rt::TokioExecutor::new()
8015/// # )
8016/// # .build(
8017/// # hyper_rustls::HttpsConnectorBuilder::new()
8018/// # .with_native_roots()
8019/// # .unwrap()
8020/// # .https_or_http()
8021/// # .enable_http1()
8022/// # .build()
8023/// # );
8024/// # let mut hub = CloudKMS::new(client, auth);
8025/// // You can configure optional parameters by calling the respective setters at will, and
8026/// // execute the final call using `doit()`.
8027/// // Values shown here are possibly random and not representative !
8028/// let result = hub.projects().locations_key_handles_list("parent")
8029/// .filter("ipsum")
8030/// .doit().await;
8031/// # }
8032/// ```
8033pub struct ProjectLocationKeyHandleListCall<'a, C>
8034where
8035 C: 'a,
8036{
8037 hub: &'a CloudKMS<C>,
8038 _parent: String,
8039 _filter: Option<String>,
8040 _delegate: Option<&'a mut dyn common::Delegate>,
8041 _additional_params: HashMap<String, String>,
8042 _scopes: BTreeSet<String>,
8043}
8044
8045impl<'a, C> common::CallBuilder for ProjectLocationKeyHandleListCall<'a, C> {}
8046
8047impl<'a, C> ProjectLocationKeyHandleListCall<'a, C>
8048where
8049 C: common::Connector,
8050{
8051 /// Perform the operation you have build so far.
8052 pub async fn doit(mut self) -> common::Result<(common::Response, ListKeyHandlesResponse)> {
8053 use std::borrow::Cow;
8054 use std::io::{Read, Seek};
8055
8056 use common::{url::Params, ToParts};
8057 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8058
8059 let mut dd = common::DefaultDelegate;
8060 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8061 dlg.begin(common::MethodInfo {
8062 id: "cloudkms.projects.locations.keyHandles.list",
8063 http_method: hyper::Method::GET,
8064 });
8065
8066 for &field in ["alt", "parent", "filter"].iter() {
8067 if self._additional_params.contains_key(field) {
8068 dlg.finished(false);
8069 return Err(common::Error::FieldClash(field));
8070 }
8071 }
8072
8073 let mut params = Params::with_capacity(4 + self._additional_params.len());
8074 params.push("parent", self._parent);
8075 if let Some(value) = self._filter.as_ref() {
8076 params.push("filter", value);
8077 }
8078
8079 params.extend(self._additional_params.iter());
8080
8081 params.push("alt", "json");
8082 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyHandles";
8083 if self._scopes.is_empty() {
8084 self._scopes
8085 .insert(Scope::CloudPlatform.as_ref().to_string());
8086 }
8087
8088 #[allow(clippy::single_element_loop)]
8089 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8090 url = params.uri_replacement(url, param_name, find_this, true);
8091 }
8092 {
8093 let to_remove = ["parent"];
8094 params.remove_params(&to_remove);
8095 }
8096
8097 let url = params.parse_with_url(&url);
8098
8099 loop {
8100 let token = match self
8101 .hub
8102 .auth
8103 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8104 .await
8105 {
8106 Ok(token) => token,
8107 Err(e) => match dlg.token(e) {
8108 Ok(token) => token,
8109 Err(e) => {
8110 dlg.finished(false);
8111 return Err(common::Error::MissingToken(e));
8112 }
8113 },
8114 };
8115 let mut req_result = {
8116 let client = &self.hub.client;
8117 dlg.pre_request();
8118 let mut req_builder = hyper::Request::builder()
8119 .method(hyper::Method::GET)
8120 .uri(url.as_str())
8121 .header(USER_AGENT, self.hub._user_agent.clone());
8122
8123 if let Some(token) = token.as_ref() {
8124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8125 }
8126
8127 let request = req_builder
8128 .header(CONTENT_LENGTH, 0_u64)
8129 .body(common::to_body::<String>(None));
8130
8131 client.request(request.unwrap()).await
8132 };
8133
8134 match req_result {
8135 Err(err) => {
8136 if let common::Retry::After(d) = dlg.http_error(&err) {
8137 sleep(d).await;
8138 continue;
8139 }
8140 dlg.finished(false);
8141 return Err(common::Error::HttpError(err));
8142 }
8143 Ok(res) => {
8144 let (mut parts, body) = res.into_parts();
8145 let mut body = common::Body::new(body);
8146 if !parts.status.is_success() {
8147 let bytes = common::to_bytes(body).await.unwrap_or_default();
8148 let error = serde_json::from_str(&common::to_string(&bytes));
8149 let response = common::to_response(parts, bytes.into());
8150
8151 if let common::Retry::After(d) =
8152 dlg.http_failure(&response, error.as_ref().ok())
8153 {
8154 sleep(d).await;
8155 continue;
8156 }
8157
8158 dlg.finished(false);
8159
8160 return Err(match error {
8161 Ok(value) => common::Error::BadRequest(value),
8162 _ => common::Error::Failure(response),
8163 });
8164 }
8165 let response = {
8166 let bytes = common::to_bytes(body).await.unwrap_or_default();
8167 let encoded = common::to_string(&bytes);
8168 match serde_json::from_str(&encoded) {
8169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8170 Err(error) => {
8171 dlg.response_json_decode_error(&encoded, &error);
8172 return Err(common::Error::JsonDecodeError(
8173 encoded.to_string(),
8174 error,
8175 ));
8176 }
8177 }
8178 };
8179
8180 dlg.finished(true);
8181 return Ok(response);
8182 }
8183 }
8184 }
8185 }
8186
8187 /// Required. Name of the resource project and location from which to list KeyHandles, e.g. `projects/{PROJECT_ID}/locations/{LOCATION}`.
8188 ///
8189 /// Sets the *parent* path property to the given value.
8190 ///
8191 /// Even though the property as already been set when instantiating this call,
8192 /// we provide this method for API completeness.
8193 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyHandleListCall<'a, C> {
8194 self._parent = new_value.to_string();
8195 self
8196 }
8197 /// Optional. Filter to apply when listing KeyHandles, e.g. `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`.
8198 ///
8199 /// Sets the *filter* query property to the given value.
8200 pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyHandleListCall<'a, C> {
8201 self._filter = Some(new_value.to_string());
8202 self
8203 }
8204 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8205 /// while executing the actual API request.
8206 ///
8207 /// ````text
8208 /// It should be used to handle progress information, and to implement a certain level of resilience.
8209 /// ````
8210 ///
8211 /// Sets the *delegate* property to the given value.
8212 pub fn delegate(
8213 mut self,
8214 new_value: &'a mut dyn common::Delegate,
8215 ) -> ProjectLocationKeyHandleListCall<'a, C> {
8216 self._delegate = Some(new_value);
8217 self
8218 }
8219
8220 /// Set any additional parameter of the query string used in the request.
8221 /// It should be used to set parameters which are not yet available through their own
8222 /// setters.
8223 ///
8224 /// Please note that this method must not be used to set any of the known parameters
8225 /// which have their own setter method. If done anyway, the request will fail.
8226 ///
8227 /// # Additional Parameters
8228 ///
8229 /// * *$.xgafv* (query-string) - V1 error format.
8230 /// * *access_token* (query-string) - OAuth access token.
8231 /// * *alt* (query-string) - Data format for response.
8232 /// * *callback* (query-string) - JSONP
8233 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8234 /// * *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.
8235 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8236 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8237 /// * *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.
8238 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8239 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8240 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyHandleListCall<'a, C>
8241 where
8242 T: AsRef<str>,
8243 {
8244 self._additional_params
8245 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8246 self
8247 }
8248
8249 /// Identifies the authorization scope for the method you are building.
8250 ///
8251 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8252 /// [`Scope::CloudPlatform`].
8253 ///
8254 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8255 /// tokens for more than one scope.
8256 ///
8257 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8258 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8259 /// sufficient, a read-write scope will do as well.
8260 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyHandleListCall<'a, C>
8261 where
8262 St: AsRef<str>,
8263 {
8264 self._scopes.insert(String::from(scope.as_ref()));
8265 self
8266 }
8267 /// Identifies the authorization scope(s) for the method you are building.
8268 ///
8269 /// See [`Self::add_scope()`] for details.
8270 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyHandleListCall<'a, C>
8271 where
8272 I: IntoIterator<Item = St>,
8273 St: AsRef<str>,
8274 {
8275 self._scopes
8276 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8277 self
8278 }
8279
8280 /// Removes all scopes, and no default scope will be used either.
8281 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8282 /// for details).
8283 pub fn clear_scopes(mut self) -> ProjectLocationKeyHandleListCall<'a, C> {
8284 self._scopes.clear();
8285 self
8286 }
8287}
8288
8289/// Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.
8290///
8291/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricDecrypt* method supported by a *project* resource.
8292/// It is not used directly, but through a [`ProjectMethods`] instance.
8293///
8294/// # Example
8295///
8296/// Instantiate a resource method builder
8297///
8298/// ```test_harness,no_run
8299/// # extern crate hyper;
8300/// # extern crate hyper_rustls;
8301/// # extern crate google_cloudkms1 as cloudkms1;
8302/// use cloudkms1::api::AsymmetricDecryptRequest;
8303/// # async fn dox() {
8304/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8305///
8306/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8307/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8308/// # secret,
8309/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
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_http1()
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 = AsymmetricDecryptRequest::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_key_rings_crypto_keys_crypto_key_versions_asymmetric_decrypt(req, "name")
8333/// .doit().await;
8334/// # }
8335/// ```
8336pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8337where
8338 C: 'a,
8339{
8340 hub: &'a CloudKMS<C>,
8341 _request: AsymmetricDecryptRequest,
8342 _name: 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
8349 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8350{
8351}
8352
8353impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8354where
8355 C: common::Connector,
8356{
8357 /// Perform the operation you have build so far.
8358 pub async fn doit(mut self) -> common::Result<(common::Response, AsymmetricDecryptResponse)> {
8359 use std::borrow::Cow;
8360 use std::io::{Read, Seek};
8361
8362 use common::{url::Params, ToParts};
8363 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8364
8365 let mut dd = common::DefaultDelegate;
8366 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8367 dlg.begin(common::MethodInfo { id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricDecrypt",
8368 http_method: hyper::Method::POST });
8369
8370 for &field in ["alt", "name"].iter() {
8371 if self._additional_params.contains_key(field) {
8372 dlg.finished(false);
8373 return Err(common::Error::FieldClash(field));
8374 }
8375 }
8376
8377 let mut params = Params::with_capacity(4 + self._additional_params.len());
8378 params.push("name", self._name);
8379
8380 params.extend(self._additional_params.iter());
8381
8382 params.push("alt", "json");
8383 let mut url = self.hub._base_url.clone() + "v1/{+name}:asymmetricDecrypt";
8384 if self._scopes.is_empty() {
8385 self._scopes
8386 .insert(Scope::CloudPlatform.as_ref().to_string());
8387 }
8388
8389 #[allow(clippy::single_element_loop)]
8390 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8391 url = params.uri_replacement(url, param_name, find_this, true);
8392 }
8393 {
8394 let to_remove = ["name"];
8395 params.remove_params(&to_remove);
8396 }
8397
8398 let url = params.parse_with_url(&url);
8399
8400 let mut json_mime_type = mime::APPLICATION_JSON;
8401 let mut request_value_reader = {
8402 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8403 common::remove_json_null_values(&mut value);
8404 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8405 serde_json::to_writer(&mut dst, &value).unwrap();
8406 dst
8407 };
8408 let request_size = request_value_reader
8409 .seek(std::io::SeekFrom::End(0))
8410 .unwrap();
8411 request_value_reader
8412 .seek(std::io::SeekFrom::Start(0))
8413 .unwrap();
8414
8415 loop {
8416 let token = match self
8417 .hub
8418 .auth
8419 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8420 .await
8421 {
8422 Ok(token) => token,
8423 Err(e) => match dlg.token(e) {
8424 Ok(token) => token,
8425 Err(e) => {
8426 dlg.finished(false);
8427 return Err(common::Error::MissingToken(e));
8428 }
8429 },
8430 };
8431 request_value_reader
8432 .seek(std::io::SeekFrom::Start(0))
8433 .unwrap();
8434 let mut req_result = {
8435 let client = &self.hub.client;
8436 dlg.pre_request();
8437 let mut req_builder = hyper::Request::builder()
8438 .method(hyper::Method::POST)
8439 .uri(url.as_str())
8440 .header(USER_AGENT, self.hub._user_agent.clone());
8441
8442 if let Some(token) = token.as_ref() {
8443 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8444 }
8445
8446 let request = req_builder
8447 .header(CONTENT_TYPE, json_mime_type.to_string())
8448 .header(CONTENT_LENGTH, request_size as u64)
8449 .body(common::to_body(
8450 request_value_reader.get_ref().clone().into(),
8451 ));
8452
8453 client.request(request.unwrap()).await
8454 };
8455
8456 match req_result {
8457 Err(err) => {
8458 if let common::Retry::After(d) = dlg.http_error(&err) {
8459 sleep(d).await;
8460 continue;
8461 }
8462 dlg.finished(false);
8463 return Err(common::Error::HttpError(err));
8464 }
8465 Ok(res) => {
8466 let (mut parts, body) = res.into_parts();
8467 let mut body = common::Body::new(body);
8468 if !parts.status.is_success() {
8469 let bytes = common::to_bytes(body).await.unwrap_or_default();
8470 let error = serde_json::from_str(&common::to_string(&bytes));
8471 let response = common::to_response(parts, bytes.into());
8472
8473 if let common::Retry::After(d) =
8474 dlg.http_failure(&response, error.as_ref().ok())
8475 {
8476 sleep(d).await;
8477 continue;
8478 }
8479
8480 dlg.finished(false);
8481
8482 return Err(match error {
8483 Ok(value) => common::Error::BadRequest(value),
8484 _ => common::Error::Failure(response),
8485 });
8486 }
8487 let response = {
8488 let bytes = common::to_bytes(body).await.unwrap_or_default();
8489 let encoded = common::to_string(&bytes);
8490 match serde_json::from_str(&encoded) {
8491 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8492 Err(error) => {
8493 dlg.response_json_decode_error(&encoded, &error);
8494 return Err(common::Error::JsonDecodeError(
8495 encoded.to_string(),
8496 error,
8497 ));
8498 }
8499 }
8500 };
8501
8502 dlg.finished(true);
8503 return Ok(response);
8504 }
8505 }
8506 }
8507 }
8508
8509 ///
8510 /// Sets the *request* property to the given value.
8511 ///
8512 /// Even though the property as already been set when instantiating this call,
8513 /// we provide this method for API completeness.
8514 pub fn request(
8515 mut self,
8516 new_value: AsymmetricDecryptRequest,
8517 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
8518 self._request = new_value;
8519 self
8520 }
8521 /// Required. The resource name of the CryptoKeyVersion to use for decryption.
8522 ///
8523 /// Sets the *name* path property to the given value.
8524 ///
8525 /// Even though the property as already been set when instantiating this call,
8526 /// we provide this method for API completeness.
8527 pub fn name(
8528 mut self,
8529 new_value: &str,
8530 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
8531 self._name = new_value.to_string();
8532 self
8533 }
8534 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8535 /// while executing the actual API request.
8536 ///
8537 /// ````text
8538 /// It should be used to handle progress information, and to implement a certain level of resilience.
8539 /// ````
8540 ///
8541 /// Sets the *delegate* property to the given value.
8542 pub fn delegate(
8543 mut self,
8544 new_value: &'a mut dyn common::Delegate,
8545 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
8546 self._delegate = Some(new_value);
8547 self
8548 }
8549
8550 /// Set any additional parameter of the query string used in the request.
8551 /// It should be used to set parameters which are not yet available through their own
8552 /// setters.
8553 ///
8554 /// Please note that this method must not be used to set any of the known parameters
8555 /// which have their own setter method. If done anyway, the request will fail.
8556 ///
8557 /// # Additional Parameters
8558 ///
8559 /// * *$.xgafv* (query-string) - V1 error format.
8560 /// * *access_token* (query-string) - OAuth access token.
8561 /// * *alt* (query-string) - Data format for response.
8562 /// * *callback* (query-string) - JSONP
8563 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8564 /// * *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.
8565 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8566 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8567 /// * *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.
8568 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8569 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8570 pub fn param<T>(
8571 mut self,
8572 name: T,
8573 value: T,
8574 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8575 where
8576 T: AsRef<str>,
8577 {
8578 self._additional_params
8579 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8580 self
8581 }
8582
8583 /// Identifies the authorization scope for the method you are building.
8584 ///
8585 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8586 /// [`Scope::CloudPlatform`].
8587 ///
8588 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8589 /// tokens for more than one scope.
8590 ///
8591 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8592 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8593 /// sufficient, a read-write scope will do as well.
8594 pub fn add_scope<St>(
8595 mut self,
8596 scope: St,
8597 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8598 where
8599 St: AsRef<str>,
8600 {
8601 self._scopes.insert(String::from(scope.as_ref()));
8602 self
8603 }
8604 /// Identifies the authorization scope(s) for the method you are building.
8605 ///
8606 /// See [`Self::add_scope()`] for details.
8607 pub fn add_scopes<I, St>(
8608 mut self,
8609 scopes: I,
8610 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C>
8611 where
8612 I: IntoIterator<Item = St>,
8613 St: AsRef<str>,
8614 {
8615 self._scopes
8616 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8617 self
8618 }
8619
8620 /// Removes all scopes, and no default scope will be used either.
8621 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8622 /// for details).
8623 pub fn clear_scopes(
8624 mut self,
8625 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricDecryptCall<'a, C> {
8626 self._scopes.clear();
8627 self
8628 }
8629}
8630
8631/// Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.
8632///
8633/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricSign* method supported by a *project* resource.
8634/// It is not used directly, but through a [`ProjectMethods`] instance.
8635///
8636/// # Example
8637///
8638/// Instantiate a resource method builder
8639///
8640/// ```test_harness,no_run
8641/// # extern crate hyper;
8642/// # extern crate hyper_rustls;
8643/// # extern crate google_cloudkms1 as cloudkms1;
8644/// use cloudkms1::api::AsymmetricSignRequest;
8645/// # async fn dox() {
8646/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8647///
8648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8650/// # secret,
8651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8652/// # ).build().await.unwrap();
8653///
8654/// # let client = hyper_util::client::legacy::Client::builder(
8655/// # hyper_util::rt::TokioExecutor::new()
8656/// # )
8657/// # .build(
8658/// # hyper_rustls::HttpsConnectorBuilder::new()
8659/// # .with_native_roots()
8660/// # .unwrap()
8661/// # .https_or_http()
8662/// # .enable_http1()
8663/// # .build()
8664/// # );
8665/// # let mut hub = CloudKMS::new(client, auth);
8666/// // As the method needs a request, you would usually fill it with the desired information
8667/// // into the respective structure. Some of the parts shown here might not be applicable !
8668/// // Values shown here are possibly random and not representative !
8669/// let mut req = AsymmetricSignRequest::default();
8670///
8671/// // You can configure optional parameters by calling the respective setters at will, and
8672/// // execute the final call using `doit()`.
8673/// // Values shown here are possibly random and not representative !
8674/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_asymmetric_sign(req, "name")
8675/// .doit().await;
8676/// # }
8677/// ```
8678pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8679where
8680 C: 'a,
8681{
8682 hub: &'a CloudKMS<C>,
8683 _request: AsymmetricSignRequest,
8684 _name: String,
8685 _delegate: Option<&'a mut dyn common::Delegate>,
8686 _additional_params: HashMap<String, String>,
8687 _scopes: BTreeSet<String>,
8688}
8689
8690impl<'a, C> common::CallBuilder
8691 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8692{
8693}
8694
8695impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8696where
8697 C: common::Connector,
8698{
8699 /// Perform the operation you have build so far.
8700 pub async fn doit(mut self) -> common::Result<(common::Response, AsymmetricSignResponse)> {
8701 use std::borrow::Cow;
8702 use std::io::{Read, Seek};
8703
8704 use common::{url::Params, ToParts};
8705 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8706
8707 let mut dd = common::DefaultDelegate;
8708 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8709 dlg.begin(common::MethodInfo {
8710 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.asymmetricSign",
8711 http_method: hyper::Method::POST,
8712 });
8713
8714 for &field in ["alt", "name"].iter() {
8715 if self._additional_params.contains_key(field) {
8716 dlg.finished(false);
8717 return Err(common::Error::FieldClash(field));
8718 }
8719 }
8720
8721 let mut params = Params::with_capacity(4 + self._additional_params.len());
8722 params.push("name", self._name);
8723
8724 params.extend(self._additional_params.iter());
8725
8726 params.push("alt", "json");
8727 let mut url = self.hub._base_url.clone() + "v1/{+name}:asymmetricSign";
8728 if self._scopes.is_empty() {
8729 self._scopes
8730 .insert(Scope::CloudPlatform.as_ref().to_string());
8731 }
8732
8733 #[allow(clippy::single_element_loop)]
8734 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8735 url = params.uri_replacement(url, param_name, find_this, true);
8736 }
8737 {
8738 let to_remove = ["name"];
8739 params.remove_params(&to_remove);
8740 }
8741
8742 let url = params.parse_with_url(&url);
8743
8744 let mut json_mime_type = mime::APPLICATION_JSON;
8745 let mut request_value_reader = {
8746 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8747 common::remove_json_null_values(&mut value);
8748 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8749 serde_json::to_writer(&mut dst, &value).unwrap();
8750 dst
8751 };
8752 let request_size = request_value_reader
8753 .seek(std::io::SeekFrom::End(0))
8754 .unwrap();
8755 request_value_reader
8756 .seek(std::io::SeekFrom::Start(0))
8757 .unwrap();
8758
8759 loop {
8760 let token = match self
8761 .hub
8762 .auth
8763 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8764 .await
8765 {
8766 Ok(token) => token,
8767 Err(e) => match dlg.token(e) {
8768 Ok(token) => token,
8769 Err(e) => {
8770 dlg.finished(false);
8771 return Err(common::Error::MissingToken(e));
8772 }
8773 },
8774 };
8775 request_value_reader
8776 .seek(std::io::SeekFrom::Start(0))
8777 .unwrap();
8778 let mut req_result = {
8779 let client = &self.hub.client;
8780 dlg.pre_request();
8781 let mut req_builder = hyper::Request::builder()
8782 .method(hyper::Method::POST)
8783 .uri(url.as_str())
8784 .header(USER_AGENT, self.hub._user_agent.clone());
8785
8786 if let Some(token) = token.as_ref() {
8787 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8788 }
8789
8790 let request = req_builder
8791 .header(CONTENT_TYPE, json_mime_type.to_string())
8792 .header(CONTENT_LENGTH, request_size as u64)
8793 .body(common::to_body(
8794 request_value_reader.get_ref().clone().into(),
8795 ));
8796
8797 client.request(request.unwrap()).await
8798 };
8799
8800 match req_result {
8801 Err(err) => {
8802 if let common::Retry::After(d) = dlg.http_error(&err) {
8803 sleep(d).await;
8804 continue;
8805 }
8806 dlg.finished(false);
8807 return Err(common::Error::HttpError(err));
8808 }
8809 Ok(res) => {
8810 let (mut parts, body) = res.into_parts();
8811 let mut body = common::Body::new(body);
8812 if !parts.status.is_success() {
8813 let bytes = common::to_bytes(body).await.unwrap_or_default();
8814 let error = serde_json::from_str(&common::to_string(&bytes));
8815 let response = common::to_response(parts, bytes.into());
8816
8817 if let common::Retry::After(d) =
8818 dlg.http_failure(&response, error.as_ref().ok())
8819 {
8820 sleep(d).await;
8821 continue;
8822 }
8823
8824 dlg.finished(false);
8825
8826 return Err(match error {
8827 Ok(value) => common::Error::BadRequest(value),
8828 _ => common::Error::Failure(response),
8829 });
8830 }
8831 let response = {
8832 let bytes = common::to_bytes(body).await.unwrap_or_default();
8833 let encoded = common::to_string(&bytes);
8834 match serde_json::from_str(&encoded) {
8835 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8836 Err(error) => {
8837 dlg.response_json_decode_error(&encoded, &error);
8838 return Err(common::Error::JsonDecodeError(
8839 encoded.to_string(),
8840 error,
8841 ));
8842 }
8843 }
8844 };
8845
8846 dlg.finished(true);
8847 return Ok(response);
8848 }
8849 }
8850 }
8851 }
8852
8853 ///
8854 /// Sets the *request* property to the given value.
8855 ///
8856 /// Even though the property as already been set when instantiating this call,
8857 /// we provide this method for API completeness.
8858 pub fn request(
8859 mut self,
8860 new_value: AsymmetricSignRequest,
8861 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
8862 self._request = new_value;
8863 self
8864 }
8865 /// Required. The resource name of the CryptoKeyVersion to use for signing.
8866 ///
8867 /// Sets the *name* path property to the given value.
8868 ///
8869 /// Even though the property as already been set when instantiating this call,
8870 /// we provide this method for API completeness.
8871 pub fn name(
8872 mut self,
8873 new_value: &str,
8874 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
8875 self._name = new_value.to_string();
8876 self
8877 }
8878 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8879 /// while executing the actual API request.
8880 ///
8881 /// ````text
8882 /// It should be used to handle progress information, and to implement a certain level of resilience.
8883 /// ````
8884 ///
8885 /// Sets the *delegate* property to the given value.
8886 pub fn delegate(
8887 mut self,
8888 new_value: &'a mut dyn common::Delegate,
8889 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
8890 self._delegate = Some(new_value);
8891 self
8892 }
8893
8894 /// Set any additional parameter of the query string used in the request.
8895 /// It should be used to set parameters which are not yet available through their own
8896 /// setters.
8897 ///
8898 /// Please note that this method must not be used to set any of the known parameters
8899 /// which have their own setter method. If done anyway, the request will fail.
8900 ///
8901 /// # Additional Parameters
8902 ///
8903 /// * *$.xgafv* (query-string) - V1 error format.
8904 /// * *access_token* (query-string) - OAuth access token.
8905 /// * *alt* (query-string) - Data format for response.
8906 /// * *callback* (query-string) - JSONP
8907 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8908 /// * *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.
8909 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8910 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8911 /// * *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.
8912 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8913 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8914 pub fn param<T>(
8915 mut self,
8916 name: T,
8917 value: T,
8918 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8919 where
8920 T: AsRef<str>,
8921 {
8922 self._additional_params
8923 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8924 self
8925 }
8926
8927 /// Identifies the authorization scope for the method you are building.
8928 ///
8929 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8930 /// [`Scope::CloudPlatform`].
8931 ///
8932 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8933 /// tokens for more than one scope.
8934 ///
8935 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8936 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8937 /// sufficient, a read-write scope will do as well.
8938 pub fn add_scope<St>(
8939 mut self,
8940 scope: St,
8941 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8942 where
8943 St: AsRef<str>,
8944 {
8945 self._scopes.insert(String::from(scope.as_ref()));
8946 self
8947 }
8948 /// Identifies the authorization scope(s) for the method you are building.
8949 ///
8950 /// See [`Self::add_scope()`] for details.
8951 pub fn add_scopes<I, St>(
8952 mut self,
8953 scopes: I,
8954 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C>
8955 where
8956 I: IntoIterator<Item = St>,
8957 St: AsRef<str>,
8958 {
8959 self._scopes
8960 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8961 self
8962 }
8963
8964 /// Removes all scopes, and no default scope will be used either.
8965 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8966 /// for details).
8967 pub fn clear_scopes(
8968 mut self,
8969 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionAsymmetricSignCall<'a, C> {
8970 self._scopes.clear();
8971 self
8972 }
8973}
8974
8975/// Create a new CryptoKeyVersion in a CryptoKey. The server will assign the next sequential id. If unset, state will be set to ENABLED.
8976///
8977/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.create* 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/// use cloudkms1::api::CryptoKeyVersion;
8989/// # async fn dox() {
8990/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8991///
8992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8993/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8994/// # secret,
8995/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8996/// # ).build().await.unwrap();
8997///
8998/// # let client = hyper_util::client::legacy::Client::builder(
8999/// # hyper_util::rt::TokioExecutor::new()
9000/// # )
9001/// # .build(
9002/// # hyper_rustls::HttpsConnectorBuilder::new()
9003/// # .with_native_roots()
9004/// # .unwrap()
9005/// # .https_or_http()
9006/// # .enable_http1()
9007/// # .build()
9008/// # );
9009/// # let mut hub = CloudKMS::new(client, auth);
9010/// // As the method needs a request, you would usually fill it with the desired information
9011/// // into the respective structure. Some of the parts shown here might not be applicable !
9012/// // Values shown here are possibly random and not representative !
9013/// let mut req = CryptoKeyVersion::default();
9014///
9015/// // You can configure optional parameters by calling the respective setters at will, and
9016/// // execute the final call using `doit()`.
9017/// // Values shown here are possibly random and not representative !
9018/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_create(req, "parent")
9019/// .doit().await;
9020/// # }
9021/// ```
9022pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9023where
9024 C: 'a,
9025{
9026 hub: &'a CloudKMS<C>,
9027 _request: CryptoKeyVersion,
9028 _parent: String,
9029 _delegate: Option<&'a mut dyn common::Delegate>,
9030 _additional_params: HashMap<String, String>,
9031 _scopes: BTreeSet<String>,
9032}
9033
9034impl<'a, C> common::CallBuilder
9035 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9036{
9037}
9038
9039impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9040where
9041 C: common::Connector,
9042{
9043 /// Perform the operation you have build so far.
9044 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
9045 use std::borrow::Cow;
9046 use std::io::{Read, Seek};
9047
9048 use common::{url::Params, ToParts};
9049 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9050
9051 let mut dd = common::DefaultDelegate;
9052 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9053 dlg.begin(common::MethodInfo {
9054 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create",
9055 http_method: hyper::Method::POST,
9056 });
9057
9058 for &field in ["alt", "parent"].iter() {
9059 if self._additional_params.contains_key(field) {
9060 dlg.finished(false);
9061 return Err(common::Error::FieldClash(field));
9062 }
9063 }
9064
9065 let mut params = Params::with_capacity(4 + self._additional_params.len());
9066 params.push("parent", self._parent);
9067
9068 params.extend(self._additional_params.iter());
9069
9070 params.push("alt", "json");
9071 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions";
9072 if self._scopes.is_empty() {
9073 self._scopes
9074 .insert(Scope::CloudPlatform.as_ref().to_string());
9075 }
9076
9077 #[allow(clippy::single_element_loop)]
9078 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9079 url = params.uri_replacement(url, param_name, find_this, true);
9080 }
9081 {
9082 let to_remove = ["parent"];
9083 params.remove_params(&to_remove);
9084 }
9085
9086 let url = params.parse_with_url(&url);
9087
9088 let mut json_mime_type = mime::APPLICATION_JSON;
9089 let mut request_value_reader = {
9090 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9091 common::remove_json_null_values(&mut value);
9092 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9093 serde_json::to_writer(&mut dst, &value).unwrap();
9094 dst
9095 };
9096 let request_size = request_value_reader
9097 .seek(std::io::SeekFrom::End(0))
9098 .unwrap();
9099 request_value_reader
9100 .seek(std::io::SeekFrom::Start(0))
9101 .unwrap();
9102
9103 loop {
9104 let token = match self
9105 .hub
9106 .auth
9107 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9108 .await
9109 {
9110 Ok(token) => token,
9111 Err(e) => match dlg.token(e) {
9112 Ok(token) => token,
9113 Err(e) => {
9114 dlg.finished(false);
9115 return Err(common::Error::MissingToken(e));
9116 }
9117 },
9118 };
9119 request_value_reader
9120 .seek(std::io::SeekFrom::Start(0))
9121 .unwrap();
9122 let mut req_result = {
9123 let client = &self.hub.client;
9124 dlg.pre_request();
9125 let mut req_builder = hyper::Request::builder()
9126 .method(hyper::Method::POST)
9127 .uri(url.as_str())
9128 .header(USER_AGENT, self.hub._user_agent.clone());
9129
9130 if let Some(token) = token.as_ref() {
9131 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9132 }
9133
9134 let request = req_builder
9135 .header(CONTENT_TYPE, json_mime_type.to_string())
9136 .header(CONTENT_LENGTH, request_size as u64)
9137 .body(common::to_body(
9138 request_value_reader.get_ref().clone().into(),
9139 ));
9140
9141 client.request(request.unwrap()).await
9142 };
9143
9144 match req_result {
9145 Err(err) => {
9146 if let common::Retry::After(d) = dlg.http_error(&err) {
9147 sleep(d).await;
9148 continue;
9149 }
9150 dlg.finished(false);
9151 return Err(common::Error::HttpError(err));
9152 }
9153 Ok(res) => {
9154 let (mut parts, body) = res.into_parts();
9155 let mut body = common::Body::new(body);
9156 if !parts.status.is_success() {
9157 let bytes = common::to_bytes(body).await.unwrap_or_default();
9158 let error = serde_json::from_str(&common::to_string(&bytes));
9159 let response = common::to_response(parts, bytes.into());
9160
9161 if let common::Retry::After(d) =
9162 dlg.http_failure(&response, error.as_ref().ok())
9163 {
9164 sleep(d).await;
9165 continue;
9166 }
9167
9168 dlg.finished(false);
9169
9170 return Err(match error {
9171 Ok(value) => common::Error::BadRequest(value),
9172 _ => common::Error::Failure(response),
9173 });
9174 }
9175 let response = {
9176 let bytes = common::to_bytes(body).await.unwrap_or_default();
9177 let encoded = common::to_string(&bytes);
9178 match serde_json::from_str(&encoded) {
9179 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9180 Err(error) => {
9181 dlg.response_json_decode_error(&encoded, &error);
9182 return Err(common::Error::JsonDecodeError(
9183 encoded.to_string(),
9184 error,
9185 ));
9186 }
9187 }
9188 };
9189
9190 dlg.finished(true);
9191 return Ok(response);
9192 }
9193 }
9194 }
9195 }
9196
9197 ///
9198 /// Sets the *request* property to the given value.
9199 ///
9200 /// Even though the property as already been set when instantiating this call,
9201 /// we provide this method for API completeness.
9202 pub fn request(
9203 mut self,
9204 new_value: CryptoKeyVersion,
9205 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
9206 self._request = new_value;
9207 self
9208 }
9209 /// Required. The name of the CryptoKey associated with the CryptoKeyVersions.
9210 ///
9211 /// Sets the *parent* path property to the given value.
9212 ///
9213 /// Even though the property as already been set when instantiating this call,
9214 /// we provide this method for API completeness.
9215 pub fn parent(
9216 mut self,
9217 new_value: &str,
9218 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
9219 self._parent = new_value.to_string();
9220 self
9221 }
9222 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9223 /// while executing the actual API request.
9224 ///
9225 /// ````text
9226 /// It should be used to handle progress information, and to implement a certain level of resilience.
9227 /// ````
9228 ///
9229 /// Sets the *delegate* property to the given value.
9230 pub fn delegate(
9231 mut self,
9232 new_value: &'a mut dyn common::Delegate,
9233 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
9234 self._delegate = Some(new_value);
9235 self
9236 }
9237
9238 /// Set any additional parameter of the query string used in the request.
9239 /// It should be used to set parameters which are not yet available through their own
9240 /// setters.
9241 ///
9242 /// Please note that this method must not be used to set any of the known parameters
9243 /// which have their own setter method. If done anyway, the request will fail.
9244 ///
9245 /// # Additional Parameters
9246 ///
9247 /// * *$.xgafv* (query-string) - V1 error format.
9248 /// * *access_token* (query-string) - OAuth access token.
9249 /// * *alt* (query-string) - Data format for response.
9250 /// * *callback* (query-string) - JSONP
9251 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9252 /// * *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.
9253 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9254 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9255 /// * *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.
9256 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9257 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9258 pub fn param<T>(
9259 mut self,
9260 name: T,
9261 value: T,
9262 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9263 where
9264 T: AsRef<str>,
9265 {
9266 self._additional_params
9267 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9268 self
9269 }
9270
9271 /// Identifies the authorization scope for the method you are building.
9272 ///
9273 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9274 /// [`Scope::CloudPlatform`].
9275 ///
9276 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9277 /// tokens for more than one scope.
9278 ///
9279 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9280 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9281 /// sufficient, a read-write scope will do as well.
9282 pub fn add_scope<St>(
9283 mut self,
9284 scope: St,
9285 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9286 where
9287 St: AsRef<str>,
9288 {
9289 self._scopes.insert(String::from(scope.as_ref()));
9290 self
9291 }
9292 /// Identifies the authorization scope(s) for the method you are building.
9293 ///
9294 /// See [`Self::add_scope()`] for details.
9295 pub fn add_scopes<I, St>(
9296 mut self,
9297 scopes: I,
9298 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
9299 where
9300 I: IntoIterator<Item = St>,
9301 St: AsRef<str>,
9302 {
9303 self._scopes
9304 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9305 self
9306 }
9307
9308 /// Removes all scopes, and no default scope will be used either.
9309 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9310 /// for details).
9311 pub fn clear_scopes(
9312 mut self,
9313 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
9314 self._scopes.clear();
9315 self
9316 }
9317}
9318
9319/// 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.
9320///
9321/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy* method supported by a *project* resource.
9322/// It is not used directly, but through a [`ProjectMethods`] instance.
9323///
9324/// # Example
9325///
9326/// Instantiate a resource method builder
9327///
9328/// ```test_harness,no_run
9329/// # extern crate hyper;
9330/// # extern crate hyper_rustls;
9331/// # extern crate google_cloudkms1 as cloudkms1;
9332/// use cloudkms1::api::DestroyCryptoKeyVersionRequest;
9333/// # async fn dox() {
9334/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9335///
9336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9338/// # secret,
9339/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9340/// # ).build().await.unwrap();
9341///
9342/// # let client = hyper_util::client::legacy::Client::builder(
9343/// # hyper_util::rt::TokioExecutor::new()
9344/// # )
9345/// # .build(
9346/// # hyper_rustls::HttpsConnectorBuilder::new()
9347/// # .with_native_roots()
9348/// # .unwrap()
9349/// # .https_or_http()
9350/// # .enable_http1()
9351/// # .build()
9352/// # );
9353/// # let mut hub = CloudKMS::new(client, auth);
9354/// // As the method needs a request, you would usually fill it with the desired information
9355/// // into the respective structure. Some of the parts shown here might not be applicable !
9356/// // Values shown here are possibly random and not representative !
9357/// let mut req = DestroyCryptoKeyVersionRequest::default();
9358///
9359/// // You can configure optional parameters by calling the respective setters at will, and
9360/// // execute the final call using `doit()`.
9361/// // Values shown here are possibly random and not representative !
9362/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_destroy(req, "name")
9363/// .doit().await;
9364/// # }
9365/// ```
9366pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9367where
9368 C: 'a,
9369{
9370 hub: &'a CloudKMS<C>,
9371 _request: DestroyCryptoKeyVersionRequest,
9372 _name: String,
9373 _delegate: Option<&'a mut dyn common::Delegate>,
9374 _additional_params: HashMap<String, String>,
9375 _scopes: BTreeSet<String>,
9376}
9377
9378impl<'a, C> common::CallBuilder
9379 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9380{
9381}
9382
9383impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9384where
9385 C: common::Connector,
9386{
9387 /// Perform the operation you have build so far.
9388 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
9389 use std::borrow::Cow;
9390 use std::io::{Read, Seek};
9391
9392 use common::{url::Params, ToParts};
9393 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9394
9395 let mut dd = common::DefaultDelegate;
9396 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9397 dlg.begin(common::MethodInfo {
9398 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy",
9399 http_method: hyper::Method::POST,
9400 });
9401
9402 for &field in ["alt", "name"].iter() {
9403 if self._additional_params.contains_key(field) {
9404 dlg.finished(false);
9405 return Err(common::Error::FieldClash(field));
9406 }
9407 }
9408
9409 let mut params = Params::with_capacity(4 + self._additional_params.len());
9410 params.push("name", self._name);
9411
9412 params.extend(self._additional_params.iter());
9413
9414 params.push("alt", "json");
9415 let mut url = self.hub._base_url.clone() + "v1/{+name}:destroy";
9416 if self._scopes.is_empty() {
9417 self._scopes
9418 .insert(Scope::CloudPlatform.as_ref().to_string());
9419 }
9420
9421 #[allow(clippy::single_element_loop)]
9422 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9423 url = params.uri_replacement(url, param_name, find_this, true);
9424 }
9425 {
9426 let to_remove = ["name"];
9427 params.remove_params(&to_remove);
9428 }
9429
9430 let url = params.parse_with_url(&url);
9431
9432 let mut json_mime_type = mime::APPLICATION_JSON;
9433 let mut request_value_reader = {
9434 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9435 common::remove_json_null_values(&mut value);
9436 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9437 serde_json::to_writer(&mut dst, &value).unwrap();
9438 dst
9439 };
9440 let request_size = request_value_reader
9441 .seek(std::io::SeekFrom::End(0))
9442 .unwrap();
9443 request_value_reader
9444 .seek(std::io::SeekFrom::Start(0))
9445 .unwrap();
9446
9447 loop {
9448 let token = match self
9449 .hub
9450 .auth
9451 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9452 .await
9453 {
9454 Ok(token) => token,
9455 Err(e) => match dlg.token(e) {
9456 Ok(token) => token,
9457 Err(e) => {
9458 dlg.finished(false);
9459 return Err(common::Error::MissingToken(e));
9460 }
9461 },
9462 };
9463 request_value_reader
9464 .seek(std::io::SeekFrom::Start(0))
9465 .unwrap();
9466 let mut req_result = {
9467 let client = &self.hub.client;
9468 dlg.pre_request();
9469 let mut req_builder = hyper::Request::builder()
9470 .method(hyper::Method::POST)
9471 .uri(url.as_str())
9472 .header(USER_AGENT, self.hub._user_agent.clone());
9473
9474 if let Some(token) = token.as_ref() {
9475 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9476 }
9477
9478 let request = req_builder
9479 .header(CONTENT_TYPE, json_mime_type.to_string())
9480 .header(CONTENT_LENGTH, request_size as u64)
9481 .body(common::to_body(
9482 request_value_reader.get_ref().clone().into(),
9483 ));
9484
9485 client.request(request.unwrap()).await
9486 };
9487
9488 match req_result {
9489 Err(err) => {
9490 if let common::Retry::After(d) = dlg.http_error(&err) {
9491 sleep(d).await;
9492 continue;
9493 }
9494 dlg.finished(false);
9495 return Err(common::Error::HttpError(err));
9496 }
9497 Ok(res) => {
9498 let (mut parts, body) = res.into_parts();
9499 let mut body = common::Body::new(body);
9500 if !parts.status.is_success() {
9501 let bytes = common::to_bytes(body).await.unwrap_or_default();
9502 let error = serde_json::from_str(&common::to_string(&bytes));
9503 let response = common::to_response(parts, bytes.into());
9504
9505 if let common::Retry::After(d) =
9506 dlg.http_failure(&response, error.as_ref().ok())
9507 {
9508 sleep(d).await;
9509 continue;
9510 }
9511
9512 dlg.finished(false);
9513
9514 return Err(match error {
9515 Ok(value) => common::Error::BadRequest(value),
9516 _ => common::Error::Failure(response),
9517 });
9518 }
9519 let response = {
9520 let bytes = common::to_bytes(body).await.unwrap_or_default();
9521 let encoded = common::to_string(&bytes);
9522 match serde_json::from_str(&encoded) {
9523 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9524 Err(error) => {
9525 dlg.response_json_decode_error(&encoded, &error);
9526 return Err(common::Error::JsonDecodeError(
9527 encoded.to_string(),
9528 error,
9529 ));
9530 }
9531 }
9532 };
9533
9534 dlg.finished(true);
9535 return Ok(response);
9536 }
9537 }
9538 }
9539 }
9540
9541 ///
9542 /// Sets the *request* property to the given value.
9543 ///
9544 /// Even though the property as already been set when instantiating this call,
9545 /// we provide this method for API completeness.
9546 pub fn request(
9547 mut self,
9548 new_value: DestroyCryptoKeyVersionRequest,
9549 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
9550 self._request = new_value;
9551 self
9552 }
9553 /// Required. The resource name of the CryptoKeyVersion to destroy.
9554 ///
9555 /// Sets the *name* path property to the given value.
9556 ///
9557 /// Even though the property as already been set when instantiating this call,
9558 /// we provide this method for API completeness.
9559 pub fn name(
9560 mut self,
9561 new_value: &str,
9562 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
9563 self._name = new_value.to_string();
9564 self
9565 }
9566 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9567 /// while executing the actual API request.
9568 ///
9569 /// ````text
9570 /// It should be used to handle progress information, and to implement a certain level of resilience.
9571 /// ````
9572 ///
9573 /// Sets the *delegate* property to the given value.
9574 pub fn delegate(
9575 mut self,
9576 new_value: &'a mut dyn common::Delegate,
9577 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
9578 self._delegate = Some(new_value);
9579 self
9580 }
9581
9582 /// Set any additional parameter of the query string used in the request.
9583 /// It should be used to set parameters which are not yet available through their own
9584 /// setters.
9585 ///
9586 /// Please note that this method must not be used to set any of the known parameters
9587 /// which have their own setter method. If done anyway, the request will fail.
9588 ///
9589 /// # Additional Parameters
9590 ///
9591 /// * *$.xgafv* (query-string) - V1 error format.
9592 /// * *access_token* (query-string) - OAuth access token.
9593 /// * *alt* (query-string) - Data format for response.
9594 /// * *callback* (query-string) - JSONP
9595 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9596 /// * *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.
9597 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9598 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9599 /// * *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.
9600 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9601 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9602 pub fn param<T>(
9603 mut self,
9604 name: T,
9605 value: T,
9606 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9607 where
9608 T: AsRef<str>,
9609 {
9610 self._additional_params
9611 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9612 self
9613 }
9614
9615 /// Identifies the authorization scope for the method you are building.
9616 ///
9617 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9618 /// [`Scope::CloudPlatform`].
9619 ///
9620 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9621 /// tokens for more than one scope.
9622 ///
9623 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9624 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9625 /// sufficient, a read-write scope will do as well.
9626 pub fn add_scope<St>(
9627 mut self,
9628 scope: St,
9629 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9630 where
9631 St: AsRef<str>,
9632 {
9633 self._scopes.insert(String::from(scope.as_ref()));
9634 self
9635 }
9636 /// Identifies the authorization scope(s) for the method you are building.
9637 ///
9638 /// See [`Self::add_scope()`] for details.
9639 pub fn add_scopes<I, St>(
9640 mut self,
9641 scopes: I,
9642 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
9643 where
9644 I: IntoIterator<Item = St>,
9645 St: AsRef<str>,
9646 {
9647 self._scopes
9648 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9649 self
9650 }
9651
9652 /// Removes all scopes, and no default scope will be used either.
9653 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9654 /// for details).
9655 pub fn clear_scopes(
9656 mut self,
9657 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
9658 self._scopes.clear();
9659 self
9660 }
9661}
9662
9663/// Returns metadata for a given CryptoKeyVersion.
9664///
9665/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.get* method supported by a *project* resource.
9666/// It is not used directly, but through a [`ProjectMethods`] instance.
9667///
9668/// # Example
9669///
9670/// Instantiate a resource method builder
9671///
9672/// ```test_harness,no_run
9673/// # extern crate hyper;
9674/// # extern crate hyper_rustls;
9675/// # extern crate google_cloudkms1 as cloudkms1;
9676/// # async fn dox() {
9677/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9678///
9679/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9680/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9681/// # secret,
9682/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9683/// # ).build().await.unwrap();
9684///
9685/// # let client = hyper_util::client::legacy::Client::builder(
9686/// # hyper_util::rt::TokioExecutor::new()
9687/// # )
9688/// # .build(
9689/// # hyper_rustls::HttpsConnectorBuilder::new()
9690/// # .with_native_roots()
9691/// # .unwrap()
9692/// # .https_or_http()
9693/// # .enable_http1()
9694/// # .build()
9695/// # );
9696/// # let mut hub = CloudKMS::new(client, auth);
9697/// // You can configure optional parameters by calling the respective setters at will, and
9698/// // execute the final call using `doit()`.
9699/// // Values shown here are possibly random and not representative !
9700/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get("name")
9701/// .doit().await;
9702/// # }
9703/// ```
9704pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
9705where
9706 C: 'a,
9707{
9708 hub: &'a CloudKMS<C>,
9709 _name: String,
9710 _delegate: Option<&'a mut dyn common::Delegate>,
9711 _additional_params: HashMap<String, String>,
9712 _scopes: BTreeSet<String>,
9713}
9714
9715impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {}
9716
9717impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
9718where
9719 C: common::Connector,
9720{
9721 /// Perform the operation you have build so far.
9722 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
9723 use std::borrow::Cow;
9724 use std::io::{Read, Seek};
9725
9726 use common::{url::Params, ToParts};
9727 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9728
9729 let mut dd = common::DefaultDelegate;
9730 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9731 dlg.begin(common::MethodInfo {
9732 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get",
9733 http_method: hyper::Method::GET,
9734 });
9735
9736 for &field in ["alt", "name"].iter() {
9737 if self._additional_params.contains_key(field) {
9738 dlg.finished(false);
9739 return Err(common::Error::FieldClash(field));
9740 }
9741 }
9742
9743 let mut params = Params::with_capacity(3 + self._additional_params.len());
9744 params.push("name", self._name);
9745
9746 params.extend(self._additional_params.iter());
9747
9748 params.push("alt", "json");
9749 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9750 if self._scopes.is_empty() {
9751 self._scopes
9752 .insert(Scope::CloudPlatform.as_ref().to_string());
9753 }
9754
9755 #[allow(clippy::single_element_loop)]
9756 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9757 url = params.uri_replacement(url, param_name, find_this, true);
9758 }
9759 {
9760 let to_remove = ["name"];
9761 params.remove_params(&to_remove);
9762 }
9763
9764 let url = params.parse_with_url(&url);
9765
9766 loop {
9767 let token = match self
9768 .hub
9769 .auth
9770 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9771 .await
9772 {
9773 Ok(token) => token,
9774 Err(e) => match dlg.token(e) {
9775 Ok(token) => token,
9776 Err(e) => {
9777 dlg.finished(false);
9778 return Err(common::Error::MissingToken(e));
9779 }
9780 },
9781 };
9782 let mut req_result = {
9783 let client = &self.hub.client;
9784 dlg.pre_request();
9785 let mut req_builder = hyper::Request::builder()
9786 .method(hyper::Method::GET)
9787 .uri(url.as_str())
9788 .header(USER_AGENT, self.hub._user_agent.clone());
9789
9790 if let Some(token) = token.as_ref() {
9791 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9792 }
9793
9794 let request = req_builder
9795 .header(CONTENT_LENGTH, 0_u64)
9796 .body(common::to_body::<String>(None));
9797
9798 client.request(request.unwrap()).await
9799 };
9800
9801 match req_result {
9802 Err(err) => {
9803 if let common::Retry::After(d) = dlg.http_error(&err) {
9804 sleep(d).await;
9805 continue;
9806 }
9807 dlg.finished(false);
9808 return Err(common::Error::HttpError(err));
9809 }
9810 Ok(res) => {
9811 let (mut parts, body) = res.into_parts();
9812 let mut body = common::Body::new(body);
9813 if !parts.status.is_success() {
9814 let bytes = common::to_bytes(body).await.unwrap_or_default();
9815 let error = serde_json::from_str(&common::to_string(&bytes));
9816 let response = common::to_response(parts, bytes.into());
9817
9818 if let common::Retry::After(d) =
9819 dlg.http_failure(&response, error.as_ref().ok())
9820 {
9821 sleep(d).await;
9822 continue;
9823 }
9824
9825 dlg.finished(false);
9826
9827 return Err(match error {
9828 Ok(value) => common::Error::BadRequest(value),
9829 _ => common::Error::Failure(response),
9830 });
9831 }
9832 let response = {
9833 let bytes = common::to_bytes(body).await.unwrap_or_default();
9834 let encoded = common::to_string(&bytes);
9835 match serde_json::from_str(&encoded) {
9836 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9837 Err(error) => {
9838 dlg.response_json_decode_error(&encoded, &error);
9839 return Err(common::Error::JsonDecodeError(
9840 encoded.to_string(),
9841 error,
9842 ));
9843 }
9844 }
9845 };
9846
9847 dlg.finished(true);
9848 return Ok(response);
9849 }
9850 }
9851 }
9852 }
9853
9854 /// Required. The name of the CryptoKeyVersion to get.
9855 ///
9856 /// Sets the *name* path property to the given value.
9857 ///
9858 /// Even though the property as already been set when instantiating this call,
9859 /// we provide this method for API completeness.
9860 pub fn name(
9861 mut self,
9862 new_value: &str,
9863 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
9864 self._name = new_value.to_string();
9865 self
9866 }
9867 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9868 /// while executing the actual API request.
9869 ///
9870 /// ````text
9871 /// It should be used to handle progress information, and to implement a certain level of resilience.
9872 /// ````
9873 ///
9874 /// Sets the *delegate* property to the given value.
9875 pub fn delegate(
9876 mut self,
9877 new_value: &'a mut dyn common::Delegate,
9878 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
9879 self._delegate = Some(new_value);
9880 self
9881 }
9882
9883 /// Set any additional parameter of the query string used in the request.
9884 /// It should be used to set parameters which are not yet available through their own
9885 /// setters.
9886 ///
9887 /// Please note that this method must not be used to set any of the known parameters
9888 /// which have their own setter method. If done anyway, the request will fail.
9889 ///
9890 /// # Additional Parameters
9891 ///
9892 /// * *$.xgafv* (query-string) - V1 error format.
9893 /// * *access_token* (query-string) - OAuth access token.
9894 /// * *alt* (query-string) - Data format for response.
9895 /// * *callback* (query-string) - JSONP
9896 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9897 /// * *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.
9898 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9899 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9900 /// * *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.
9901 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9902 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9903 pub fn param<T>(
9904 mut self,
9905 name: T,
9906 value: T,
9907 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
9908 where
9909 T: AsRef<str>,
9910 {
9911 self._additional_params
9912 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9913 self
9914 }
9915
9916 /// Identifies the authorization scope for the method you are building.
9917 ///
9918 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9919 /// [`Scope::CloudPlatform`].
9920 ///
9921 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9922 /// tokens for more than one scope.
9923 ///
9924 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9925 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9926 /// sufficient, a read-write scope will do as well.
9927 pub fn add_scope<St>(
9928 mut self,
9929 scope: St,
9930 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
9931 where
9932 St: AsRef<str>,
9933 {
9934 self._scopes.insert(String::from(scope.as_ref()));
9935 self
9936 }
9937 /// Identifies the authorization scope(s) for the method you are building.
9938 ///
9939 /// See [`Self::add_scope()`] for details.
9940 pub fn add_scopes<I, St>(
9941 mut self,
9942 scopes: I,
9943 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
9944 where
9945 I: IntoIterator<Item = St>,
9946 St: AsRef<str>,
9947 {
9948 self._scopes
9949 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9950 self
9951 }
9952
9953 /// Removes all scopes, and no default scope will be used either.
9954 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9955 /// for details).
9956 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
9957 self._scopes.clear();
9958 self
9959 }
9960}
9961
9962/// Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.
9963///
9964/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.getPublicKey* method supported by a *project* resource.
9965/// It is not used directly, but through a [`ProjectMethods`] instance.
9966///
9967/// # Example
9968///
9969/// Instantiate a resource method builder
9970///
9971/// ```test_harness,no_run
9972/// # extern crate hyper;
9973/// # extern crate hyper_rustls;
9974/// # extern crate google_cloudkms1 as cloudkms1;
9975/// # async fn dox() {
9976/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9977///
9978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9979/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9980/// # secret,
9981/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9982/// # ).build().await.unwrap();
9983///
9984/// # let client = hyper_util::client::legacy::Client::builder(
9985/// # hyper_util::rt::TokioExecutor::new()
9986/// # )
9987/// # .build(
9988/// # hyper_rustls::HttpsConnectorBuilder::new()
9989/// # .with_native_roots()
9990/// # .unwrap()
9991/// # .https_or_http()
9992/// # .enable_http1()
9993/// # .build()
9994/// # );
9995/// # let mut hub = CloudKMS::new(client, auth);
9996/// // You can configure optional parameters by calling the respective setters at will, and
9997/// // execute the final call using `doit()`.
9998/// // Values shown here are possibly random and not representative !
9999/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get_public_key("name")
10000/// .doit().await;
10001/// # }
10002/// ```
10003pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
10004where
10005 C: 'a,
10006{
10007 hub: &'a CloudKMS<C>,
10008 _name: String,
10009 _delegate: Option<&'a mut dyn common::Delegate>,
10010 _additional_params: HashMap<String, String>,
10011 _scopes: BTreeSet<String>,
10012}
10013
10014impl<'a, C> common::CallBuilder
10015 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
10016{
10017}
10018
10019impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
10020where
10021 C: common::Connector,
10022{
10023 /// Perform the operation you have build so far.
10024 pub async fn doit(mut self) -> common::Result<(common::Response, PublicKey)> {
10025 use std::borrow::Cow;
10026 use std::io::{Read, Seek};
10027
10028 use common::{url::Params, ToParts};
10029 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10030
10031 let mut dd = common::DefaultDelegate;
10032 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10033 dlg.begin(common::MethodInfo {
10034 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.getPublicKey",
10035 http_method: hyper::Method::GET,
10036 });
10037
10038 for &field in ["alt", "name"].iter() {
10039 if self._additional_params.contains_key(field) {
10040 dlg.finished(false);
10041 return Err(common::Error::FieldClash(field));
10042 }
10043 }
10044
10045 let mut params = Params::with_capacity(3 + self._additional_params.len());
10046 params.push("name", self._name);
10047
10048 params.extend(self._additional_params.iter());
10049
10050 params.push("alt", "json");
10051 let mut url = self.hub._base_url.clone() + "v1/{+name}/publicKey";
10052 if self._scopes.is_empty() {
10053 self._scopes
10054 .insert(Scope::CloudPlatform.as_ref().to_string());
10055 }
10056
10057 #[allow(clippy::single_element_loop)]
10058 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10059 url = params.uri_replacement(url, param_name, find_this, true);
10060 }
10061 {
10062 let to_remove = ["name"];
10063 params.remove_params(&to_remove);
10064 }
10065
10066 let url = params.parse_with_url(&url);
10067
10068 loop {
10069 let token = match self
10070 .hub
10071 .auth
10072 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10073 .await
10074 {
10075 Ok(token) => token,
10076 Err(e) => match dlg.token(e) {
10077 Ok(token) => token,
10078 Err(e) => {
10079 dlg.finished(false);
10080 return Err(common::Error::MissingToken(e));
10081 }
10082 },
10083 };
10084 let mut req_result = {
10085 let client = &self.hub.client;
10086 dlg.pre_request();
10087 let mut req_builder = hyper::Request::builder()
10088 .method(hyper::Method::GET)
10089 .uri(url.as_str())
10090 .header(USER_AGENT, self.hub._user_agent.clone());
10091
10092 if let Some(token) = token.as_ref() {
10093 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10094 }
10095
10096 let request = req_builder
10097 .header(CONTENT_LENGTH, 0_u64)
10098 .body(common::to_body::<String>(None));
10099
10100 client.request(request.unwrap()).await
10101 };
10102
10103 match req_result {
10104 Err(err) => {
10105 if let common::Retry::After(d) = dlg.http_error(&err) {
10106 sleep(d).await;
10107 continue;
10108 }
10109 dlg.finished(false);
10110 return Err(common::Error::HttpError(err));
10111 }
10112 Ok(res) => {
10113 let (mut parts, body) = res.into_parts();
10114 let mut body = common::Body::new(body);
10115 if !parts.status.is_success() {
10116 let bytes = common::to_bytes(body).await.unwrap_or_default();
10117 let error = serde_json::from_str(&common::to_string(&bytes));
10118 let response = common::to_response(parts, bytes.into());
10119
10120 if let common::Retry::After(d) =
10121 dlg.http_failure(&response, error.as_ref().ok())
10122 {
10123 sleep(d).await;
10124 continue;
10125 }
10126
10127 dlg.finished(false);
10128
10129 return Err(match error {
10130 Ok(value) => common::Error::BadRequest(value),
10131 _ => common::Error::Failure(response),
10132 });
10133 }
10134 let response = {
10135 let bytes = common::to_bytes(body).await.unwrap_or_default();
10136 let encoded = common::to_string(&bytes);
10137 match serde_json::from_str(&encoded) {
10138 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10139 Err(error) => {
10140 dlg.response_json_decode_error(&encoded, &error);
10141 return Err(common::Error::JsonDecodeError(
10142 encoded.to_string(),
10143 error,
10144 ));
10145 }
10146 }
10147 };
10148
10149 dlg.finished(true);
10150 return Ok(response);
10151 }
10152 }
10153 }
10154 }
10155
10156 /// Required. The name of the CryptoKeyVersion public key to get.
10157 ///
10158 /// Sets the *name* path property to the given value.
10159 ///
10160 /// Even though the property as already been set when instantiating this call,
10161 /// we provide this method for API completeness.
10162 pub fn name(
10163 mut self,
10164 new_value: &str,
10165 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
10166 self._name = new_value.to_string();
10167 self
10168 }
10169 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10170 /// while executing the actual API request.
10171 ///
10172 /// ````text
10173 /// It should be used to handle progress information, and to implement a certain level of resilience.
10174 /// ````
10175 ///
10176 /// Sets the *delegate* property to the given value.
10177 pub fn delegate(
10178 mut self,
10179 new_value: &'a mut dyn common::Delegate,
10180 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
10181 self._delegate = Some(new_value);
10182 self
10183 }
10184
10185 /// Set any additional parameter of the query string used in the request.
10186 /// It should be used to set parameters which are not yet available through their own
10187 /// setters.
10188 ///
10189 /// Please note that this method must not be used to set any of the known parameters
10190 /// which have their own setter method. If done anyway, the request will fail.
10191 ///
10192 /// # Additional Parameters
10193 ///
10194 /// * *$.xgafv* (query-string) - V1 error format.
10195 /// * *access_token* (query-string) - OAuth access token.
10196 /// * *alt* (query-string) - Data format for response.
10197 /// * *callback* (query-string) - JSONP
10198 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10199 /// * *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.
10200 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10201 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10202 /// * *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.
10203 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10204 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10205 pub fn param<T>(
10206 mut self,
10207 name: T,
10208 value: T,
10209 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
10210 where
10211 T: AsRef<str>,
10212 {
10213 self._additional_params
10214 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10215 self
10216 }
10217
10218 /// Identifies the authorization scope for the method you are building.
10219 ///
10220 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10221 /// [`Scope::CloudPlatform`].
10222 ///
10223 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10224 /// tokens for more than one scope.
10225 ///
10226 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10227 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10228 /// sufficient, a read-write scope will do as well.
10229 pub fn add_scope<St>(
10230 mut self,
10231 scope: St,
10232 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'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>(
10243 mut self,
10244 scopes: I,
10245 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C>
10246 where
10247 I: IntoIterator<Item = St>,
10248 St: AsRef<str>,
10249 {
10250 self._scopes
10251 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10252 self
10253 }
10254
10255 /// Removes all scopes, and no default scope will be used either.
10256 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10257 /// for details).
10258 pub fn clear_scopes(
10259 mut self,
10260 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetPublicKeyCall<'a, C> {
10261 self._scopes.clear();
10262 self
10263 }
10264}
10265
10266/// 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.
10267///
10268/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.import* method supported by a *project* resource.
10269/// It is not used directly, but through a [`ProjectMethods`] instance.
10270///
10271/// # Example
10272///
10273/// Instantiate a resource method builder
10274///
10275/// ```test_harness,no_run
10276/// # extern crate hyper;
10277/// # extern crate hyper_rustls;
10278/// # extern crate google_cloudkms1 as cloudkms1;
10279/// use cloudkms1::api::ImportCryptoKeyVersionRequest;
10280/// # async fn dox() {
10281/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10282///
10283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10284/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10285/// # secret,
10286/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10287/// # ).build().await.unwrap();
10288///
10289/// # let client = hyper_util::client::legacy::Client::builder(
10290/// # hyper_util::rt::TokioExecutor::new()
10291/// # )
10292/// # .build(
10293/// # hyper_rustls::HttpsConnectorBuilder::new()
10294/// # .with_native_roots()
10295/// # .unwrap()
10296/// # .https_or_http()
10297/// # .enable_http1()
10298/// # .build()
10299/// # );
10300/// # let mut hub = CloudKMS::new(client, auth);
10301/// // As the method needs a request, you would usually fill it with the desired information
10302/// // into the respective structure. Some of the parts shown here might not be applicable !
10303/// // Values shown here are possibly random and not representative !
10304/// let mut req = ImportCryptoKeyVersionRequest::default();
10305///
10306/// // You can configure optional parameters by calling the respective setters at will, and
10307/// // execute the final call using `doit()`.
10308/// // Values shown here are possibly random and not representative !
10309/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_import(req, "parent")
10310/// .doit().await;
10311/// # }
10312/// ```
10313pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10314where
10315 C: 'a,
10316{
10317 hub: &'a CloudKMS<C>,
10318 _request: ImportCryptoKeyVersionRequest,
10319 _parent: String,
10320 _delegate: Option<&'a mut dyn common::Delegate>,
10321 _additional_params: HashMap<String, String>,
10322 _scopes: BTreeSet<String>,
10323}
10324
10325impl<'a, C> common::CallBuilder
10326 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10327{
10328}
10329
10330impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10331where
10332 C: common::Connector,
10333{
10334 /// Perform the operation you have build so far.
10335 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
10336 use std::borrow::Cow;
10337 use std::io::{Read, Seek};
10338
10339 use common::{url::Params, ToParts};
10340 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10341
10342 let mut dd = common::DefaultDelegate;
10343 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10344 dlg.begin(common::MethodInfo {
10345 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.import",
10346 http_method: hyper::Method::POST,
10347 });
10348
10349 for &field in ["alt", "parent"].iter() {
10350 if self._additional_params.contains_key(field) {
10351 dlg.finished(false);
10352 return Err(common::Error::FieldClash(field));
10353 }
10354 }
10355
10356 let mut params = Params::with_capacity(4 + self._additional_params.len());
10357 params.push("parent", self._parent);
10358
10359 params.extend(self._additional_params.iter());
10360
10361 params.push("alt", "json");
10362 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions:import";
10363 if self._scopes.is_empty() {
10364 self._scopes
10365 .insert(Scope::CloudPlatform.as_ref().to_string());
10366 }
10367
10368 #[allow(clippy::single_element_loop)]
10369 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10370 url = params.uri_replacement(url, param_name, find_this, true);
10371 }
10372 {
10373 let to_remove = ["parent"];
10374 params.remove_params(&to_remove);
10375 }
10376
10377 let url = params.parse_with_url(&url);
10378
10379 let mut json_mime_type = mime::APPLICATION_JSON;
10380 let mut request_value_reader = {
10381 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10382 common::remove_json_null_values(&mut value);
10383 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10384 serde_json::to_writer(&mut dst, &value).unwrap();
10385 dst
10386 };
10387 let request_size = request_value_reader
10388 .seek(std::io::SeekFrom::End(0))
10389 .unwrap();
10390 request_value_reader
10391 .seek(std::io::SeekFrom::Start(0))
10392 .unwrap();
10393
10394 loop {
10395 let token = match self
10396 .hub
10397 .auth
10398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10399 .await
10400 {
10401 Ok(token) => token,
10402 Err(e) => match dlg.token(e) {
10403 Ok(token) => token,
10404 Err(e) => {
10405 dlg.finished(false);
10406 return Err(common::Error::MissingToken(e));
10407 }
10408 },
10409 };
10410 request_value_reader
10411 .seek(std::io::SeekFrom::Start(0))
10412 .unwrap();
10413 let mut req_result = {
10414 let client = &self.hub.client;
10415 dlg.pre_request();
10416 let mut req_builder = hyper::Request::builder()
10417 .method(hyper::Method::POST)
10418 .uri(url.as_str())
10419 .header(USER_AGENT, self.hub._user_agent.clone());
10420
10421 if let Some(token) = token.as_ref() {
10422 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10423 }
10424
10425 let request = req_builder
10426 .header(CONTENT_TYPE, json_mime_type.to_string())
10427 .header(CONTENT_LENGTH, request_size as u64)
10428 .body(common::to_body(
10429 request_value_reader.get_ref().clone().into(),
10430 ));
10431
10432 client.request(request.unwrap()).await
10433 };
10434
10435 match req_result {
10436 Err(err) => {
10437 if let common::Retry::After(d) = dlg.http_error(&err) {
10438 sleep(d).await;
10439 continue;
10440 }
10441 dlg.finished(false);
10442 return Err(common::Error::HttpError(err));
10443 }
10444 Ok(res) => {
10445 let (mut parts, body) = res.into_parts();
10446 let mut body = common::Body::new(body);
10447 if !parts.status.is_success() {
10448 let bytes = common::to_bytes(body).await.unwrap_or_default();
10449 let error = serde_json::from_str(&common::to_string(&bytes));
10450 let response = common::to_response(parts, bytes.into());
10451
10452 if let common::Retry::After(d) =
10453 dlg.http_failure(&response, error.as_ref().ok())
10454 {
10455 sleep(d).await;
10456 continue;
10457 }
10458
10459 dlg.finished(false);
10460
10461 return Err(match error {
10462 Ok(value) => common::Error::BadRequest(value),
10463 _ => common::Error::Failure(response),
10464 });
10465 }
10466 let response = {
10467 let bytes = common::to_bytes(body).await.unwrap_or_default();
10468 let encoded = common::to_string(&bytes);
10469 match serde_json::from_str(&encoded) {
10470 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10471 Err(error) => {
10472 dlg.response_json_decode_error(&encoded, &error);
10473 return Err(common::Error::JsonDecodeError(
10474 encoded.to_string(),
10475 error,
10476 ));
10477 }
10478 }
10479 };
10480
10481 dlg.finished(true);
10482 return Ok(response);
10483 }
10484 }
10485 }
10486 }
10487
10488 ///
10489 /// Sets the *request* property to the given value.
10490 ///
10491 /// Even though the property as already been set when instantiating this call,
10492 /// we provide this method for API completeness.
10493 pub fn request(
10494 mut self,
10495 new_value: ImportCryptoKeyVersionRequest,
10496 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
10497 self._request = new_value;
10498 self
10499 }
10500 /// Required. The name of the CryptoKey to be imported into. The create permission is only required on this key when creating a new CryptoKeyVersion.
10501 ///
10502 /// Sets the *parent* path property to the given value.
10503 ///
10504 /// Even though the property as already been set when instantiating this call,
10505 /// we provide this method for API completeness.
10506 pub fn parent(
10507 mut self,
10508 new_value: &str,
10509 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
10510 self._parent = new_value.to_string();
10511 self
10512 }
10513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10514 /// while executing the actual API request.
10515 ///
10516 /// ````text
10517 /// It should be used to handle progress information, and to implement a certain level of resilience.
10518 /// ````
10519 ///
10520 /// Sets the *delegate* property to the given value.
10521 pub fn delegate(
10522 mut self,
10523 new_value: &'a mut dyn common::Delegate,
10524 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
10525 self._delegate = Some(new_value);
10526 self
10527 }
10528
10529 /// Set any additional parameter of the query string used in the request.
10530 /// It should be used to set parameters which are not yet available through their own
10531 /// setters.
10532 ///
10533 /// Please note that this method must not be used to set any of the known parameters
10534 /// which have their own setter method. If done anyway, the request will fail.
10535 ///
10536 /// # Additional Parameters
10537 ///
10538 /// * *$.xgafv* (query-string) - V1 error format.
10539 /// * *access_token* (query-string) - OAuth access token.
10540 /// * *alt* (query-string) - Data format for response.
10541 /// * *callback* (query-string) - JSONP
10542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10543 /// * *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.
10544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10546 /// * *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.
10547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10549 pub fn param<T>(
10550 mut self,
10551 name: T,
10552 value: T,
10553 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10554 where
10555 T: AsRef<str>,
10556 {
10557 self._additional_params
10558 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10559 self
10560 }
10561
10562 /// Identifies the authorization scope for the method you are building.
10563 ///
10564 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10565 /// [`Scope::CloudPlatform`].
10566 ///
10567 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10568 /// tokens for more than one scope.
10569 ///
10570 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10571 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10572 /// sufficient, a read-write scope will do as well.
10573 pub fn add_scope<St>(
10574 mut self,
10575 scope: St,
10576 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10577 where
10578 St: AsRef<str>,
10579 {
10580 self._scopes.insert(String::from(scope.as_ref()));
10581 self
10582 }
10583 /// Identifies the authorization scope(s) for the method you are building.
10584 ///
10585 /// See [`Self::add_scope()`] for details.
10586 pub fn add_scopes<I, St>(
10587 mut self,
10588 scopes: I,
10589 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C>
10590 where
10591 I: IntoIterator<Item = St>,
10592 St: AsRef<str>,
10593 {
10594 self._scopes
10595 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10596 self
10597 }
10598
10599 /// Removes all scopes, and no default scope will be used either.
10600 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10601 /// for details).
10602 pub fn clear_scopes(
10603 mut self,
10604 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionImportCall<'a, C> {
10605 self._scopes.clear();
10606 self
10607 }
10608}
10609
10610/// Lists CryptoKeyVersions.
10611///
10612/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.list* method supported by a *project* resource.
10613/// It is not used directly, but through a [`ProjectMethods`] instance.
10614///
10615/// # Example
10616///
10617/// Instantiate a resource method builder
10618///
10619/// ```test_harness,no_run
10620/// # extern crate hyper;
10621/// # extern crate hyper_rustls;
10622/// # extern crate google_cloudkms1 as cloudkms1;
10623/// # async fn dox() {
10624/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10625///
10626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10628/// # secret,
10629/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10630/// # ).build().await.unwrap();
10631///
10632/// # let client = hyper_util::client::legacy::Client::builder(
10633/// # hyper_util::rt::TokioExecutor::new()
10634/// # )
10635/// # .build(
10636/// # hyper_rustls::HttpsConnectorBuilder::new()
10637/// # .with_native_roots()
10638/// # .unwrap()
10639/// # .https_or_http()
10640/// # .enable_http1()
10641/// # .build()
10642/// # );
10643/// # let mut hub = CloudKMS::new(client, auth);
10644/// // You can configure optional parameters by calling the respective setters at will, and
10645/// // execute the final call using `doit()`.
10646/// // Values shown here are possibly random and not representative !
10647/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_list("parent")
10648/// .view("duo")
10649/// .page_token("sed")
10650/// .page_size(-61)
10651/// .order_by("Stet")
10652/// .filter("kasd")
10653/// .doit().await;
10654/// # }
10655/// ```
10656pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
10657where
10658 C: 'a,
10659{
10660 hub: &'a CloudKMS<C>,
10661 _parent: String,
10662 _view: Option<String>,
10663 _page_token: Option<String>,
10664 _page_size: Option<i32>,
10665 _order_by: Option<String>,
10666 _filter: Option<String>,
10667 _delegate: Option<&'a mut dyn common::Delegate>,
10668 _additional_params: HashMap<String, String>,
10669 _scopes: BTreeSet<String>,
10670}
10671
10672impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {}
10673
10674impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
10675where
10676 C: common::Connector,
10677{
10678 /// Perform the operation you have build so far.
10679 pub async fn doit(
10680 mut self,
10681 ) -> common::Result<(common::Response, ListCryptoKeyVersionsResponse)> {
10682 use std::borrow::Cow;
10683 use std::io::{Read, Seek};
10684
10685 use common::{url::Params, ToParts};
10686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10687
10688 let mut dd = common::DefaultDelegate;
10689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10690 dlg.begin(common::MethodInfo {
10691 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list",
10692 http_method: hyper::Method::GET,
10693 });
10694
10695 for &field in [
10696 "alt",
10697 "parent",
10698 "view",
10699 "pageToken",
10700 "pageSize",
10701 "orderBy",
10702 "filter",
10703 ]
10704 .iter()
10705 {
10706 if self._additional_params.contains_key(field) {
10707 dlg.finished(false);
10708 return Err(common::Error::FieldClash(field));
10709 }
10710 }
10711
10712 let mut params = Params::with_capacity(8 + self._additional_params.len());
10713 params.push("parent", self._parent);
10714 if let Some(value) = self._view.as_ref() {
10715 params.push("view", value);
10716 }
10717 if let Some(value) = self._page_token.as_ref() {
10718 params.push("pageToken", value);
10719 }
10720 if let Some(value) = self._page_size.as_ref() {
10721 params.push("pageSize", value.to_string());
10722 }
10723 if let Some(value) = self._order_by.as_ref() {
10724 params.push("orderBy", value);
10725 }
10726 if let Some(value) = self._filter.as_ref() {
10727 params.push("filter", value);
10728 }
10729
10730 params.extend(self._additional_params.iter());
10731
10732 params.push("alt", "json");
10733 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions";
10734 if self._scopes.is_empty() {
10735 self._scopes
10736 .insert(Scope::CloudPlatform.as_ref().to_string());
10737 }
10738
10739 #[allow(clippy::single_element_loop)]
10740 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10741 url = params.uri_replacement(url, param_name, find_this, true);
10742 }
10743 {
10744 let to_remove = ["parent"];
10745 params.remove_params(&to_remove);
10746 }
10747
10748 let url = params.parse_with_url(&url);
10749
10750 loop {
10751 let token = match self
10752 .hub
10753 .auth
10754 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10755 .await
10756 {
10757 Ok(token) => token,
10758 Err(e) => match dlg.token(e) {
10759 Ok(token) => token,
10760 Err(e) => {
10761 dlg.finished(false);
10762 return Err(common::Error::MissingToken(e));
10763 }
10764 },
10765 };
10766 let mut req_result = {
10767 let client = &self.hub.client;
10768 dlg.pre_request();
10769 let mut req_builder = hyper::Request::builder()
10770 .method(hyper::Method::GET)
10771 .uri(url.as_str())
10772 .header(USER_AGENT, self.hub._user_agent.clone());
10773
10774 if let Some(token) = token.as_ref() {
10775 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10776 }
10777
10778 let request = req_builder
10779 .header(CONTENT_LENGTH, 0_u64)
10780 .body(common::to_body::<String>(None));
10781
10782 client.request(request.unwrap()).await
10783 };
10784
10785 match req_result {
10786 Err(err) => {
10787 if let common::Retry::After(d) = dlg.http_error(&err) {
10788 sleep(d).await;
10789 continue;
10790 }
10791 dlg.finished(false);
10792 return Err(common::Error::HttpError(err));
10793 }
10794 Ok(res) => {
10795 let (mut parts, body) = res.into_parts();
10796 let mut body = common::Body::new(body);
10797 if !parts.status.is_success() {
10798 let bytes = common::to_bytes(body).await.unwrap_or_default();
10799 let error = serde_json::from_str(&common::to_string(&bytes));
10800 let response = common::to_response(parts, bytes.into());
10801
10802 if let common::Retry::After(d) =
10803 dlg.http_failure(&response, error.as_ref().ok())
10804 {
10805 sleep(d).await;
10806 continue;
10807 }
10808
10809 dlg.finished(false);
10810
10811 return Err(match error {
10812 Ok(value) => common::Error::BadRequest(value),
10813 _ => common::Error::Failure(response),
10814 });
10815 }
10816 let response = {
10817 let bytes = common::to_bytes(body).await.unwrap_or_default();
10818 let encoded = common::to_string(&bytes);
10819 match serde_json::from_str(&encoded) {
10820 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10821 Err(error) => {
10822 dlg.response_json_decode_error(&encoded, &error);
10823 return Err(common::Error::JsonDecodeError(
10824 encoded.to_string(),
10825 error,
10826 ));
10827 }
10828 }
10829 };
10830
10831 dlg.finished(true);
10832 return Ok(response);
10833 }
10834 }
10835 }
10836 }
10837
10838 /// Required. The resource name of the CryptoKey to list, in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
10839 ///
10840 /// Sets the *parent* path property to the given value.
10841 ///
10842 /// Even though the property as already been set when instantiating this call,
10843 /// we provide this method for API completeness.
10844 pub fn parent(
10845 mut self,
10846 new_value: &str,
10847 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10848 self._parent = new_value.to_string();
10849 self
10850 }
10851 /// The fields to include in the response.
10852 ///
10853 /// Sets the *view* query property to the given value.
10854 pub fn view(
10855 mut self,
10856 new_value: &str,
10857 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10858 self._view = Some(new_value.to_string());
10859 self
10860 }
10861 /// Optional. Optional pagination token, returned earlier via ListCryptoKeyVersionsResponse.next_page_token.
10862 ///
10863 /// Sets the *page token* query property to the given value.
10864 pub fn page_token(
10865 mut self,
10866 new_value: &str,
10867 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10868 self._page_token = Some(new_value.to_string());
10869 self
10870 }
10871 /// 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.
10872 ///
10873 /// Sets the *page size* query property to the given value.
10874 pub fn page_size(
10875 mut self,
10876 new_value: i32,
10877 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10878 self._page_size = Some(new_value);
10879 self
10880 }
10881 /// 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).
10882 ///
10883 /// Sets the *order by* query property to the given value.
10884 pub fn order_by(
10885 mut self,
10886 new_value: &str,
10887 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10888 self._order_by = Some(new_value.to_string());
10889 self
10890 }
10891 /// 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).
10892 ///
10893 /// Sets the *filter* query property to the given value.
10894 pub fn filter(
10895 mut self,
10896 new_value: &str,
10897 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10898 self._filter = Some(new_value.to_string());
10899 self
10900 }
10901 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10902 /// while executing the actual API request.
10903 ///
10904 /// ````text
10905 /// It should be used to handle progress information, and to implement a certain level of resilience.
10906 /// ````
10907 ///
10908 /// Sets the *delegate* property to the given value.
10909 pub fn delegate(
10910 mut self,
10911 new_value: &'a mut dyn common::Delegate,
10912 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10913 self._delegate = Some(new_value);
10914 self
10915 }
10916
10917 /// Set any additional parameter of the query string used in the request.
10918 /// It should be used to set parameters which are not yet available through their own
10919 /// setters.
10920 ///
10921 /// Please note that this method must not be used to set any of the known parameters
10922 /// which have their own setter method. If done anyway, the request will fail.
10923 ///
10924 /// # Additional Parameters
10925 ///
10926 /// * *$.xgafv* (query-string) - V1 error format.
10927 /// * *access_token* (query-string) - OAuth access token.
10928 /// * *alt* (query-string) - Data format for response.
10929 /// * *callback* (query-string) - JSONP
10930 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10931 /// * *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.
10932 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10933 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10934 /// * *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.
10935 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10936 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10937 pub fn param<T>(
10938 mut self,
10939 name: T,
10940 value: T,
10941 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
10942 where
10943 T: AsRef<str>,
10944 {
10945 self._additional_params
10946 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10947 self
10948 }
10949
10950 /// Identifies the authorization scope for the method you are building.
10951 ///
10952 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10953 /// [`Scope::CloudPlatform`].
10954 ///
10955 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10956 /// tokens for more than one scope.
10957 ///
10958 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10959 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10960 /// sufficient, a read-write scope will do as well.
10961 pub fn add_scope<St>(
10962 mut self,
10963 scope: St,
10964 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
10965 where
10966 St: AsRef<str>,
10967 {
10968 self._scopes.insert(String::from(scope.as_ref()));
10969 self
10970 }
10971 /// Identifies the authorization scope(s) for the method you are building.
10972 ///
10973 /// See [`Self::add_scope()`] for details.
10974 pub fn add_scopes<I, St>(
10975 mut self,
10976 scopes: I,
10977 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
10978 where
10979 I: IntoIterator<Item = St>,
10980 St: AsRef<str>,
10981 {
10982 self._scopes
10983 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10984 self
10985 }
10986
10987 /// Removes all scopes, and no default scope will be used either.
10988 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10989 /// for details).
10990 pub fn clear_scopes(
10991 mut self,
10992 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
10993 self._scopes.clear();
10994 self
10995 }
10996}
10997
10998/// Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key.
10999///
11000/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.macSign* method supported by a *project* resource.
11001/// It is not used directly, but through a [`ProjectMethods`] instance.
11002///
11003/// # Example
11004///
11005/// Instantiate a resource method builder
11006///
11007/// ```test_harness,no_run
11008/// # extern crate hyper;
11009/// # extern crate hyper_rustls;
11010/// # extern crate google_cloudkms1 as cloudkms1;
11011/// use cloudkms1::api::MacSignRequest;
11012/// # async fn dox() {
11013/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11014///
11015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11016/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11017/// # secret,
11018/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11019/// # ).build().await.unwrap();
11020///
11021/// # let client = hyper_util::client::legacy::Client::builder(
11022/// # hyper_util::rt::TokioExecutor::new()
11023/// # )
11024/// # .build(
11025/// # hyper_rustls::HttpsConnectorBuilder::new()
11026/// # .with_native_roots()
11027/// # .unwrap()
11028/// # .https_or_http()
11029/// # .enable_http1()
11030/// # .build()
11031/// # );
11032/// # let mut hub = CloudKMS::new(client, auth);
11033/// // As the method needs a request, you would usually fill it with the desired information
11034/// // into the respective structure. Some of the parts shown here might not be applicable !
11035/// // Values shown here are possibly random and not representative !
11036/// let mut req = MacSignRequest::default();
11037///
11038/// // You can configure optional parameters by calling the respective setters at will, and
11039/// // execute the final call using `doit()`.
11040/// // Values shown here are possibly random and not representative !
11041/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_mac_sign(req, "name")
11042/// .doit().await;
11043/// # }
11044/// ```
11045pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11046where
11047 C: 'a,
11048{
11049 hub: &'a CloudKMS<C>,
11050 _request: MacSignRequest,
11051 _name: String,
11052 _delegate: Option<&'a mut dyn common::Delegate>,
11053 _additional_params: HashMap<String, String>,
11054 _scopes: BTreeSet<String>,
11055}
11056
11057impl<'a, C> common::CallBuilder
11058 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11059{
11060}
11061
11062impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11063where
11064 C: common::Connector,
11065{
11066 /// Perform the operation you have build so far.
11067 pub async fn doit(mut self) -> common::Result<(common::Response, MacSignResponse)> {
11068 use std::borrow::Cow;
11069 use std::io::{Read, Seek};
11070
11071 use common::{url::Params, ToParts};
11072 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11073
11074 let mut dd = common::DefaultDelegate;
11075 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11076 dlg.begin(common::MethodInfo {
11077 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.macSign",
11078 http_method: hyper::Method::POST,
11079 });
11080
11081 for &field in ["alt", "name"].iter() {
11082 if self._additional_params.contains_key(field) {
11083 dlg.finished(false);
11084 return Err(common::Error::FieldClash(field));
11085 }
11086 }
11087
11088 let mut params = Params::with_capacity(4 + self._additional_params.len());
11089 params.push("name", self._name);
11090
11091 params.extend(self._additional_params.iter());
11092
11093 params.push("alt", "json");
11094 let mut url = self.hub._base_url.clone() + "v1/{+name}:macSign";
11095 if self._scopes.is_empty() {
11096 self._scopes
11097 .insert(Scope::CloudPlatform.as_ref().to_string());
11098 }
11099
11100 #[allow(clippy::single_element_loop)]
11101 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11102 url = params.uri_replacement(url, param_name, find_this, true);
11103 }
11104 {
11105 let to_remove = ["name"];
11106 params.remove_params(&to_remove);
11107 }
11108
11109 let url = params.parse_with_url(&url);
11110
11111 let mut json_mime_type = mime::APPLICATION_JSON;
11112 let mut request_value_reader = {
11113 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11114 common::remove_json_null_values(&mut value);
11115 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11116 serde_json::to_writer(&mut dst, &value).unwrap();
11117 dst
11118 };
11119 let request_size = request_value_reader
11120 .seek(std::io::SeekFrom::End(0))
11121 .unwrap();
11122 request_value_reader
11123 .seek(std::io::SeekFrom::Start(0))
11124 .unwrap();
11125
11126 loop {
11127 let token = match self
11128 .hub
11129 .auth
11130 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11131 .await
11132 {
11133 Ok(token) => token,
11134 Err(e) => match dlg.token(e) {
11135 Ok(token) => token,
11136 Err(e) => {
11137 dlg.finished(false);
11138 return Err(common::Error::MissingToken(e));
11139 }
11140 },
11141 };
11142 request_value_reader
11143 .seek(std::io::SeekFrom::Start(0))
11144 .unwrap();
11145 let mut req_result = {
11146 let client = &self.hub.client;
11147 dlg.pre_request();
11148 let mut req_builder = hyper::Request::builder()
11149 .method(hyper::Method::POST)
11150 .uri(url.as_str())
11151 .header(USER_AGENT, self.hub._user_agent.clone());
11152
11153 if let Some(token) = token.as_ref() {
11154 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11155 }
11156
11157 let request = req_builder
11158 .header(CONTENT_TYPE, json_mime_type.to_string())
11159 .header(CONTENT_LENGTH, request_size as u64)
11160 .body(common::to_body(
11161 request_value_reader.get_ref().clone().into(),
11162 ));
11163
11164 client.request(request.unwrap()).await
11165 };
11166
11167 match req_result {
11168 Err(err) => {
11169 if let common::Retry::After(d) = dlg.http_error(&err) {
11170 sleep(d).await;
11171 continue;
11172 }
11173 dlg.finished(false);
11174 return Err(common::Error::HttpError(err));
11175 }
11176 Ok(res) => {
11177 let (mut parts, body) = res.into_parts();
11178 let mut body = common::Body::new(body);
11179 if !parts.status.is_success() {
11180 let bytes = common::to_bytes(body).await.unwrap_or_default();
11181 let error = serde_json::from_str(&common::to_string(&bytes));
11182 let response = common::to_response(parts, bytes.into());
11183
11184 if let common::Retry::After(d) =
11185 dlg.http_failure(&response, error.as_ref().ok())
11186 {
11187 sleep(d).await;
11188 continue;
11189 }
11190
11191 dlg.finished(false);
11192
11193 return Err(match error {
11194 Ok(value) => common::Error::BadRequest(value),
11195 _ => common::Error::Failure(response),
11196 });
11197 }
11198 let response = {
11199 let bytes = common::to_bytes(body).await.unwrap_or_default();
11200 let encoded = common::to_string(&bytes);
11201 match serde_json::from_str(&encoded) {
11202 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11203 Err(error) => {
11204 dlg.response_json_decode_error(&encoded, &error);
11205 return Err(common::Error::JsonDecodeError(
11206 encoded.to_string(),
11207 error,
11208 ));
11209 }
11210 }
11211 };
11212
11213 dlg.finished(true);
11214 return Ok(response);
11215 }
11216 }
11217 }
11218 }
11219
11220 ///
11221 /// Sets the *request* property to the given value.
11222 ///
11223 /// Even though the property as already been set when instantiating this call,
11224 /// we provide this method for API completeness.
11225 pub fn request(
11226 mut self,
11227 new_value: MacSignRequest,
11228 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
11229 self._request = new_value;
11230 self
11231 }
11232 /// Required. The resource name of the CryptoKeyVersion to use for signing.
11233 ///
11234 /// Sets the *name* path property to the given value.
11235 ///
11236 /// Even though the property as already been set when instantiating this call,
11237 /// we provide this method for API completeness.
11238 pub fn name(
11239 mut self,
11240 new_value: &str,
11241 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
11242 self._name = new_value.to_string();
11243 self
11244 }
11245 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11246 /// while executing the actual API request.
11247 ///
11248 /// ````text
11249 /// It should be used to handle progress information, and to implement a certain level of resilience.
11250 /// ````
11251 ///
11252 /// Sets the *delegate* property to the given value.
11253 pub fn delegate(
11254 mut self,
11255 new_value: &'a mut dyn common::Delegate,
11256 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
11257 self._delegate = Some(new_value);
11258 self
11259 }
11260
11261 /// Set any additional parameter of the query string used in the request.
11262 /// It should be used to set parameters which are not yet available through their own
11263 /// setters.
11264 ///
11265 /// Please note that this method must not be used to set any of the known parameters
11266 /// which have their own setter method. If done anyway, the request will fail.
11267 ///
11268 /// # Additional Parameters
11269 ///
11270 /// * *$.xgafv* (query-string) - V1 error format.
11271 /// * *access_token* (query-string) - OAuth access token.
11272 /// * *alt* (query-string) - Data format for response.
11273 /// * *callback* (query-string) - JSONP
11274 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11275 /// * *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.
11276 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11277 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11278 /// * *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.
11279 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11280 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11281 pub fn param<T>(
11282 mut self,
11283 name: T,
11284 value: T,
11285 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11286 where
11287 T: AsRef<str>,
11288 {
11289 self._additional_params
11290 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11291 self
11292 }
11293
11294 /// Identifies the authorization scope for the method you are building.
11295 ///
11296 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11297 /// [`Scope::CloudPlatform`].
11298 ///
11299 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11300 /// tokens for more than one scope.
11301 ///
11302 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11303 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11304 /// sufficient, a read-write scope will do as well.
11305 pub fn add_scope<St>(
11306 mut self,
11307 scope: St,
11308 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11309 where
11310 St: AsRef<str>,
11311 {
11312 self._scopes.insert(String::from(scope.as_ref()));
11313 self
11314 }
11315 /// Identifies the authorization scope(s) for the method you are building.
11316 ///
11317 /// See [`Self::add_scope()`] for details.
11318 pub fn add_scopes<I, St>(
11319 mut self,
11320 scopes: I,
11321 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C>
11322 where
11323 I: IntoIterator<Item = St>,
11324 St: AsRef<str>,
11325 {
11326 self._scopes
11327 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11328 self
11329 }
11330
11331 /// Removes all scopes, and no default scope will be used either.
11332 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11333 /// for details).
11334 pub fn clear_scopes(
11335 mut self,
11336 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacSignCall<'a, C> {
11337 self._scopes.clear();
11338 self
11339 }
11340}
11341
11342/// Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful.
11343///
11344/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.macVerify* method supported by a *project* resource.
11345/// It is not used directly, but through a [`ProjectMethods`] instance.
11346///
11347/// # Example
11348///
11349/// Instantiate a resource method builder
11350///
11351/// ```test_harness,no_run
11352/// # extern crate hyper;
11353/// # extern crate hyper_rustls;
11354/// # extern crate google_cloudkms1 as cloudkms1;
11355/// use cloudkms1::api::MacVerifyRequest;
11356/// # async fn dox() {
11357/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11358///
11359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11360/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11361/// # secret,
11362/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11363/// # ).build().await.unwrap();
11364///
11365/// # let client = hyper_util::client::legacy::Client::builder(
11366/// # hyper_util::rt::TokioExecutor::new()
11367/// # )
11368/// # .build(
11369/// # hyper_rustls::HttpsConnectorBuilder::new()
11370/// # .with_native_roots()
11371/// # .unwrap()
11372/// # .https_or_http()
11373/// # .enable_http1()
11374/// # .build()
11375/// # );
11376/// # let mut hub = CloudKMS::new(client, auth);
11377/// // As the method needs a request, you would usually fill it with the desired information
11378/// // into the respective structure. Some of the parts shown here might not be applicable !
11379/// // Values shown here are possibly random and not representative !
11380/// let mut req = MacVerifyRequest::default();
11381///
11382/// // You can configure optional parameters by calling the respective setters at will, and
11383/// // execute the final call using `doit()`.
11384/// // Values shown here are possibly random and not representative !
11385/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_mac_verify(req, "name")
11386/// .doit().await;
11387/// # }
11388/// ```
11389pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11390where
11391 C: 'a,
11392{
11393 hub: &'a CloudKMS<C>,
11394 _request: MacVerifyRequest,
11395 _name: String,
11396 _delegate: Option<&'a mut dyn common::Delegate>,
11397 _additional_params: HashMap<String, String>,
11398 _scopes: BTreeSet<String>,
11399}
11400
11401impl<'a, C> common::CallBuilder
11402 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11403{
11404}
11405
11406impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11407where
11408 C: common::Connector,
11409{
11410 /// Perform the operation you have build so far.
11411 pub async fn doit(mut self) -> common::Result<(common::Response, MacVerifyResponse)> {
11412 use std::borrow::Cow;
11413 use std::io::{Read, Seek};
11414
11415 use common::{url::Params, ToParts};
11416 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11417
11418 let mut dd = common::DefaultDelegate;
11419 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11420 dlg.begin(common::MethodInfo {
11421 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.macVerify",
11422 http_method: hyper::Method::POST,
11423 });
11424
11425 for &field in ["alt", "name"].iter() {
11426 if self._additional_params.contains_key(field) {
11427 dlg.finished(false);
11428 return Err(common::Error::FieldClash(field));
11429 }
11430 }
11431
11432 let mut params = Params::with_capacity(4 + self._additional_params.len());
11433 params.push("name", self._name);
11434
11435 params.extend(self._additional_params.iter());
11436
11437 params.push("alt", "json");
11438 let mut url = self.hub._base_url.clone() + "v1/{+name}:macVerify";
11439 if self._scopes.is_empty() {
11440 self._scopes
11441 .insert(Scope::CloudPlatform.as_ref().to_string());
11442 }
11443
11444 #[allow(clippy::single_element_loop)]
11445 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11446 url = params.uri_replacement(url, param_name, find_this, true);
11447 }
11448 {
11449 let to_remove = ["name"];
11450 params.remove_params(&to_remove);
11451 }
11452
11453 let url = params.parse_with_url(&url);
11454
11455 let mut json_mime_type = mime::APPLICATION_JSON;
11456 let mut request_value_reader = {
11457 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11458 common::remove_json_null_values(&mut value);
11459 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11460 serde_json::to_writer(&mut dst, &value).unwrap();
11461 dst
11462 };
11463 let request_size = request_value_reader
11464 .seek(std::io::SeekFrom::End(0))
11465 .unwrap();
11466 request_value_reader
11467 .seek(std::io::SeekFrom::Start(0))
11468 .unwrap();
11469
11470 loop {
11471 let token = match self
11472 .hub
11473 .auth
11474 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11475 .await
11476 {
11477 Ok(token) => token,
11478 Err(e) => match dlg.token(e) {
11479 Ok(token) => token,
11480 Err(e) => {
11481 dlg.finished(false);
11482 return Err(common::Error::MissingToken(e));
11483 }
11484 },
11485 };
11486 request_value_reader
11487 .seek(std::io::SeekFrom::Start(0))
11488 .unwrap();
11489 let mut req_result = {
11490 let client = &self.hub.client;
11491 dlg.pre_request();
11492 let mut req_builder = hyper::Request::builder()
11493 .method(hyper::Method::POST)
11494 .uri(url.as_str())
11495 .header(USER_AGENT, self.hub._user_agent.clone());
11496
11497 if let Some(token) = token.as_ref() {
11498 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11499 }
11500
11501 let request = req_builder
11502 .header(CONTENT_TYPE, json_mime_type.to_string())
11503 .header(CONTENT_LENGTH, request_size as u64)
11504 .body(common::to_body(
11505 request_value_reader.get_ref().clone().into(),
11506 ));
11507
11508 client.request(request.unwrap()).await
11509 };
11510
11511 match req_result {
11512 Err(err) => {
11513 if let common::Retry::After(d) = dlg.http_error(&err) {
11514 sleep(d).await;
11515 continue;
11516 }
11517 dlg.finished(false);
11518 return Err(common::Error::HttpError(err));
11519 }
11520 Ok(res) => {
11521 let (mut parts, body) = res.into_parts();
11522 let mut body = common::Body::new(body);
11523 if !parts.status.is_success() {
11524 let bytes = common::to_bytes(body).await.unwrap_or_default();
11525 let error = serde_json::from_str(&common::to_string(&bytes));
11526 let response = common::to_response(parts, bytes.into());
11527
11528 if let common::Retry::After(d) =
11529 dlg.http_failure(&response, error.as_ref().ok())
11530 {
11531 sleep(d).await;
11532 continue;
11533 }
11534
11535 dlg.finished(false);
11536
11537 return Err(match error {
11538 Ok(value) => common::Error::BadRequest(value),
11539 _ => common::Error::Failure(response),
11540 });
11541 }
11542 let response = {
11543 let bytes = common::to_bytes(body).await.unwrap_or_default();
11544 let encoded = common::to_string(&bytes);
11545 match serde_json::from_str(&encoded) {
11546 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11547 Err(error) => {
11548 dlg.response_json_decode_error(&encoded, &error);
11549 return Err(common::Error::JsonDecodeError(
11550 encoded.to_string(),
11551 error,
11552 ));
11553 }
11554 }
11555 };
11556
11557 dlg.finished(true);
11558 return Ok(response);
11559 }
11560 }
11561 }
11562 }
11563
11564 ///
11565 /// Sets the *request* property to the given value.
11566 ///
11567 /// Even though the property as already been set when instantiating this call,
11568 /// we provide this method for API completeness.
11569 pub fn request(
11570 mut self,
11571 new_value: MacVerifyRequest,
11572 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
11573 self._request = new_value;
11574 self
11575 }
11576 /// Required. The resource name of the CryptoKeyVersion to use for verification.
11577 ///
11578 /// Sets the *name* path property to the given value.
11579 ///
11580 /// Even though the property as already been set when instantiating this call,
11581 /// we provide this method for API completeness.
11582 pub fn name(
11583 mut self,
11584 new_value: &str,
11585 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
11586 self._name = new_value.to_string();
11587 self
11588 }
11589 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11590 /// while executing the actual API request.
11591 ///
11592 /// ````text
11593 /// It should be used to handle progress information, and to implement a certain level of resilience.
11594 /// ````
11595 ///
11596 /// Sets the *delegate* property to the given value.
11597 pub fn delegate(
11598 mut self,
11599 new_value: &'a mut dyn common::Delegate,
11600 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
11601 self._delegate = Some(new_value);
11602 self
11603 }
11604
11605 /// Set any additional parameter of the query string used in the request.
11606 /// It should be used to set parameters which are not yet available through their own
11607 /// setters.
11608 ///
11609 /// Please note that this method must not be used to set any of the known parameters
11610 /// which have their own setter method. If done anyway, the request will fail.
11611 ///
11612 /// # Additional Parameters
11613 ///
11614 /// * *$.xgafv* (query-string) - V1 error format.
11615 /// * *access_token* (query-string) - OAuth access token.
11616 /// * *alt* (query-string) - Data format for response.
11617 /// * *callback* (query-string) - JSONP
11618 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11619 /// * *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.
11620 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11621 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11622 /// * *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.
11623 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11624 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11625 pub fn param<T>(
11626 mut self,
11627 name: T,
11628 value: T,
11629 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11630 where
11631 T: AsRef<str>,
11632 {
11633 self._additional_params
11634 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11635 self
11636 }
11637
11638 /// Identifies the authorization scope for the method you are building.
11639 ///
11640 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11641 /// [`Scope::CloudPlatform`].
11642 ///
11643 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11644 /// tokens for more than one scope.
11645 ///
11646 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11647 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11648 /// sufficient, a read-write scope will do as well.
11649 pub fn add_scope<St>(
11650 mut self,
11651 scope: St,
11652 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11653 where
11654 St: AsRef<str>,
11655 {
11656 self._scopes.insert(String::from(scope.as_ref()));
11657 self
11658 }
11659 /// Identifies the authorization scope(s) for the method you are building.
11660 ///
11661 /// See [`Self::add_scope()`] for details.
11662 pub fn add_scopes<I, St>(
11663 mut self,
11664 scopes: I,
11665 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C>
11666 where
11667 I: IntoIterator<Item = St>,
11668 St: AsRef<str>,
11669 {
11670 self._scopes
11671 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11672 self
11673 }
11674
11675 /// Removes all scopes, and no default scope will be used either.
11676 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11677 /// for details).
11678 pub fn clear_scopes(
11679 mut self,
11680 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionMacVerifyCall<'a, C> {
11681 self._scopes.clear();
11682 self
11683 }
11684}
11685
11686/// 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.
11687///
11688/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.patch* method supported by a *project* resource.
11689/// It is not used directly, but through a [`ProjectMethods`] instance.
11690///
11691/// # Example
11692///
11693/// Instantiate a resource method builder
11694///
11695/// ```test_harness,no_run
11696/// # extern crate hyper;
11697/// # extern crate hyper_rustls;
11698/// # extern crate google_cloudkms1 as cloudkms1;
11699/// use cloudkms1::api::CryptoKeyVersion;
11700/// # async fn dox() {
11701/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11702///
11703/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11705/// # secret,
11706/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11707/// # ).build().await.unwrap();
11708///
11709/// # let client = hyper_util::client::legacy::Client::builder(
11710/// # hyper_util::rt::TokioExecutor::new()
11711/// # )
11712/// # .build(
11713/// # hyper_rustls::HttpsConnectorBuilder::new()
11714/// # .with_native_roots()
11715/// # .unwrap()
11716/// # .https_or_http()
11717/// # .enable_http1()
11718/// # .build()
11719/// # );
11720/// # let mut hub = CloudKMS::new(client, auth);
11721/// // As the method needs a request, you would usually fill it with the desired information
11722/// // into the respective structure. Some of the parts shown here might not be applicable !
11723/// // Values shown here are possibly random and not representative !
11724/// let mut req = CryptoKeyVersion::default();
11725///
11726/// // You can configure optional parameters by calling the respective setters at will, and
11727/// // execute the final call using `doit()`.
11728/// // Values shown here are possibly random and not representative !
11729/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
11730/// .update_mask(FieldMask::new::<&str>(&[]))
11731/// .doit().await;
11732/// # }
11733/// ```
11734pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
11735where
11736 C: 'a,
11737{
11738 hub: &'a CloudKMS<C>,
11739 _request: CryptoKeyVersion,
11740 _name: String,
11741 _update_mask: Option<common::FieldMask>,
11742 _delegate: Option<&'a mut dyn common::Delegate>,
11743 _additional_params: HashMap<String, String>,
11744 _scopes: BTreeSet<String>,
11745}
11746
11747impl<'a, C> common::CallBuilder
11748 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
11749{
11750}
11751
11752impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
11753where
11754 C: common::Connector,
11755{
11756 /// Perform the operation you have build so far.
11757 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
11758 use std::borrow::Cow;
11759 use std::io::{Read, Seek};
11760
11761 use common::{url::Params, ToParts};
11762 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11763
11764 let mut dd = common::DefaultDelegate;
11765 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11766 dlg.begin(common::MethodInfo {
11767 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch",
11768 http_method: hyper::Method::PATCH,
11769 });
11770
11771 for &field in ["alt", "name", "updateMask"].iter() {
11772 if self._additional_params.contains_key(field) {
11773 dlg.finished(false);
11774 return Err(common::Error::FieldClash(field));
11775 }
11776 }
11777
11778 let mut params = Params::with_capacity(5 + self._additional_params.len());
11779 params.push("name", self._name);
11780 if let Some(value) = self._update_mask.as_ref() {
11781 params.push("updateMask", value.to_string());
11782 }
11783
11784 params.extend(self._additional_params.iter());
11785
11786 params.push("alt", "json");
11787 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11788 if self._scopes.is_empty() {
11789 self._scopes
11790 .insert(Scope::CloudPlatform.as_ref().to_string());
11791 }
11792
11793 #[allow(clippy::single_element_loop)]
11794 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11795 url = params.uri_replacement(url, param_name, find_this, true);
11796 }
11797 {
11798 let to_remove = ["name"];
11799 params.remove_params(&to_remove);
11800 }
11801
11802 let url = params.parse_with_url(&url);
11803
11804 let mut json_mime_type = mime::APPLICATION_JSON;
11805 let mut request_value_reader = {
11806 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11807 common::remove_json_null_values(&mut value);
11808 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11809 serde_json::to_writer(&mut dst, &value).unwrap();
11810 dst
11811 };
11812 let request_size = request_value_reader
11813 .seek(std::io::SeekFrom::End(0))
11814 .unwrap();
11815 request_value_reader
11816 .seek(std::io::SeekFrom::Start(0))
11817 .unwrap();
11818
11819 loop {
11820 let token = match self
11821 .hub
11822 .auth
11823 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11824 .await
11825 {
11826 Ok(token) => token,
11827 Err(e) => match dlg.token(e) {
11828 Ok(token) => token,
11829 Err(e) => {
11830 dlg.finished(false);
11831 return Err(common::Error::MissingToken(e));
11832 }
11833 },
11834 };
11835 request_value_reader
11836 .seek(std::io::SeekFrom::Start(0))
11837 .unwrap();
11838 let mut req_result = {
11839 let client = &self.hub.client;
11840 dlg.pre_request();
11841 let mut req_builder = hyper::Request::builder()
11842 .method(hyper::Method::PATCH)
11843 .uri(url.as_str())
11844 .header(USER_AGENT, self.hub._user_agent.clone());
11845
11846 if let Some(token) = token.as_ref() {
11847 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11848 }
11849
11850 let request = req_builder
11851 .header(CONTENT_TYPE, json_mime_type.to_string())
11852 .header(CONTENT_LENGTH, request_size as u64)
11853 .body(common::to_body(
11854 request_value_reader.get_ref().clone().into(),
11855 ));
11856
11857 client.request(request.unwrap()).await
11858 };
11859
11860 match req_result {
11861 Err(err) => {
11862 if let common::Retry::After(d) = dlg.http_error(&err) {
11863 sleep(d).await;
11864 continue;
11865 }
11866 dlg.finished(false);
11867 return Err(common::Error::HttpError(err));
11868 }
11869 Ok(res) => {
11870 let (mut parts, body) = res.into_parts();
11871 let mut body = common::Body::new(body);
11872 if !parts.status.is_success() {
11873 let bytes = common::to_bytes(body).await.unwrap_or_default();
11874 let error = serde_json::from_str(&common::to_string(&bytes));
11875 let response = common::to_response(parts, bytes.into());
11876
11877 if let common::Retry::After(d) =
11878 dlg.http_failure(&response, error.as_ref().ok())
11879 {
11880 sleep(d).await;
11881 continue;
11882 }
11883
11884 dlg.finished(false);
11885
11886 return Err(match error {
11887 Ok(value) => common::Error::BadRequest(value),
11888 _ => common::Error::Failure(response),
11889 });
11890 }
11891 let response = {
11892 let bytes = common::to_bytes(body).await.unwrap_or_default();
11893 let encoded = common::to_string(&bytes);
11894 match serde_json::from_str(&encoded) {
11895 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11896 Err(error) => {
11897 dlg.response_json_decode_error(&encoded, &error);
11898 return Err(common::Error::JsonDecodeError(
11899 encoded.to_string(),
11900 error,
11901 ));
11902 }
11903 }
11904 };
11905
11906 dlg.finished(true);
11907 return Ok(response);
11908 }
11909 }
11910 }
11911 }
11912
11913 ///
11914 /// Sets the *request* property to the given value.
11915 ///
11916 /// Even though the property as already been set when instantiating this call,
11917 /// we provide this method for API completeness.
11918 pub fn request(
11919 mut self,
11920 new_value: CryptoKeyVersion,
11921 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
11922 self._request = new_value;
11923 self
11924 }
11925 /// Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
11926 ///
11927 /// Sets the *name* path property to the given value.
11928 ///
11929 /// Even though the property as already been set when instantiating this call,
11930 /// we provide this method for API completeness.
11931 pub fn name(
11932 mut self,
11933 new_value: &str,
11934 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
11935 self._name = new_value.to_string();
11936 self
11937 }
11938 /// Required. List of fields to be updated in this request.
11939 ///
11940 /// Sets the *update mask* query property to the given value.
11941 pub fn update_mask(
11942 mut self,
11943 new_value: common::FieldMask,
11944 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
11945 self._update_mask = Some(new_value);
11946 self
11947 }
11948 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11949 /// while executing the actual API request.
11950 ///
11951 /// ````text
11952 /// It should be used to handle progress information, and to implement a certain level of resilience.
11953 /// ````
11954 ///
11955 /// Sets the *delegate* property to the given value.
11956 pub fn delegate(
11957 mut self,
11958 new_value: &'a mut dyn common::Delegate,
11959 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
11960 self._delegate = Some(new_value);
11961 self
11962 }
11963
11964 /// Set any additional parameter of the query string used in the request.
11965 /// It should be used to set parameters which are not yet available through their own
11966 /// setters.
11967 ///
11968 /// Please note that this method must not be used to set any of the known parameters
11969 /// which have their own setter method. If done anyway, the request will fail.
11970 ///
11971 /// # Additional Parameters
11972 ///
11973 /// * *$.xgafv* (query-string) - V1 error format.
11974 /// * *access_token* (query-string) - OAuth access token.
11975 /// * *alt* (query-string) - Data format for response.
11976 /// * *callback* (query-string) - JSONP
11977 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11978 /// * *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.
11979 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11980 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11981 /// * *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.
11982 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11983 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11984 pub fn param<T>(
11985 mut self,
11986 name: T,
11987 value: T,
11988 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
11989 where
11990 T: AsRef<str>,
11991 {
11992 self._additional_params
11993 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11994 self
11995 }
11996
11997 /// Identifies the authorization scope for the method you are building.
11998 ///
11999 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12000 /// [`Scope::CloudPlatform`].
12001 ///
12002 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12003 /// tokens for more than one scope.
12004 ///
12005 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12006 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12007 /// sufficient, a read-write scope will do as well.
12008 pub fn add_scope<St>(
12009 mut self,
12010 scope: St,
12011 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
12012 where
12013 St: AsRef<str>,
12014 {
12015 self._scopes.insert(String::from(scope.as_ref()));
12016 self
12017 }
12018 /// Identifies the authorization scope(s) for the method you are building.
12019 ///
12020 /// See [`Self::add_scope()`] for details.
12021 pub fn add_scopes<I, St>(
12022 mut self,
12023 scopes: I,
12024 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
12025 where
12026 I: IntoIterator<Item = St>,
12027 St: AsRef<str>,
12028 {
12029 self._scopes
12030 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12031 self
12032 }
12033
12034 /// Removes all scopes, and no default scope will be used either.
12035 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12036 /// for details).
12037 pub fn clear_scopes(
12038 mut self,
12039 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
12040 self._scopes.clear();
12041 self
12042 }
12043}
12044
12045/// Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.
12046///
12047/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.rawDecrypt* method supported by a *project* resource.
12048/// It is not used directly, but through a [`ProjectMethods`] instance.
12049///
12050/// # Example
12051///
12052/// Instantiate a resource method builder
12053///
12054/// ```test_harness,no_run
12055/// # extern crate hyper;
12056/// # extern crate hyper_rustls;
12057/// # extern crate google_cloudkms1 as cloudkms1;
12058/// use cloudkms1::api::RawDecryptRequest;
12059/// # async fn dox() {
12060/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12061///
12062/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12063/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12064/// # secret,
12065/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12066/// # ).build().await.unwrap();
12067///
12068/// # let client = hyper_util::client::legacy::Client::builder(
12069/// # hyper_util::rt::TokioExecutor::new()
12070/// # )
12071/// # .build(
12072/// # hyper_rustls::HttpsConnectorBuilder::new()
12073/// # .with_native_roots()
12074/// # .unwrap()
12075/// # .https_or_http()
12076/// # .enable_http1()
12077/// # .build()
12078/// # );
12079/// # let mut hub = CloudKMS::new(client, auth);
12080/// // As the method needs a request, you would usually fill it with the desired information
12081/// // into the respective structure. Some of the parts shown here might not be applicable !
12082/// // Values shown here are possibly random and not representative !
12083/// let mut req = RawDecryptRequest::default();
12084///
12085/// // You can configure optional parameters by calling the respective setters at will, and
12086/// // execute the final call using `doit()`.
12087/// // Values shown here are possibly random and not representative !
12088/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_raw_decrypt(req, "name")
12089/// .doit().await;
12090/// # }
12091/// ```
12092pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12093where
12094 C: 'a,
12095{
12096 hub: &'a CloudKMS<C>,
12097 _request: RawDecryptRequest,
12098 _name: String,
12099 _delegate: Option<&'a mut dyn common::Delegate>,
12100 _additional_params: HashMap<String, String>,
12101 _scopes: BTreeSet<String>,
12102}
12103
12104impl<'a, C> common::CallBuilder
12105 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12106{
12107}
12108
12109impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12110where
12111 C: common::Connector,
12112{
12113 /// Perform the operation you have build so far.
12114 pub async fn doit(mut self) -> common::Result<(common::Response, RawDecryptResponse)> {
12115 use std::borrow::Cow;
12116 use std::io::{Read, Seek};
12117
12118 use common::{url::Params, ToParts};
12119 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12120
12121 let mut dd = common::DefaultDelegate;
12122 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12123 dlg.begin(common::MethodInfo {
12124 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.rawDecrypt",
12125 http_method: hyper::Method::POST,
12126 });
12127
12128 for &field in ["alt", "name"].iter() {
12129 if self._additional_params.contains_key(field) {
12130 dlg.finished(false);
12131 return Err(common::Error::FieldClash(field));
12132 }
12133 }
12134
12135 let mut params = Params::with_capacity(4 + self._additional_params.len());
12136 params.push("name", self._name);
12137
12138 params.extend(self._additional_params.iter());
12139
12140 params.push("alt", "json");
12141 let mut url = self.hub._base_url.clone() + "v1/{+name}:rawDecrypt";
12142 if self._scopes.is_empty() {
12143 self._scopes
12144 .insert(Scope::CloudPlatform.as_ref().to_string());
12145 }
12146
12147 #[allow(clippy::single_element_loop)]
12148 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12149 url = params.uri_replacement(url, param_name, find_this, true);
12150 }
12151 {
12152 let to_remove = ["name"];
12153 params.remove_params(&to_remove);
12154 }
12155
12156 let url = params.parse_with_url(&url);
12157
12158 let mut json_mime_type = mime::APPLICATION_JSON;
12159 let mut request_value_reader = {
12160 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12161 common::remove_json_null_values(&mut value);
12162 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12163 serde_json::to_writer(&mut dst, &value).unwrap();
12164 dst
12165 };
12166 let request_size = request_value_reader
12167 .seek(std::io::SeekFrom::End(0))
12168 .unwrap();
12169 request_value_reader
12170 .seek(std::io::SeekFrom::Start(0))
12171 .unwrap();
12172
12173 loop {
12174 let token = match self
12175 .hub
12176 .auth
12177 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12178 .await
12179 {
12180 Ok(token) => token,
12181 Err(e) => match dlg.token(e) {
12182 Ok(token) => token,
12183 Err(e) => {
12184 dlg.finished(false);
12185 return Err(common::Error::MissingToken(e));
12186 }
12187 },
12188 };
12189 request_value_reader
12190 .seek(std::io::SeekFrom::Start(0))
12191 .unwrap();
12192 let mut req_result = {
12193 let client = &self.hub.client;
12194 dlg.pre_request();
12195 let mut req_builder = hyper::Request::builder()
12196 .method(hyper::Method::POST)
12197 .uri(url.as_str())
12198 .header(USER_AGENT, self.hub._user_agent.clone());
12199
12200 if let Some(token) = token.as_ref() {
12201 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12202 }
12203
12204 let request = req_builder
12205 .header(CONTENT_TYPE, json_mime_type.to_string())
12206 .header(CONTENT_LENGTH, request_size as u64)
12207 .body(common::to_body(
12208 request_value_reader.get_ref().clone().into(),
12209 ));
12210
12211 client.request(request.unwrap()).await
12212 };
12213
12214 match req_result {
12215 Err(err) => {
12216 if let common::Retry::After(d) = dlg.http_error(&err) {
12217 sleep(d).await;
12218 continue;
12219 }
12220 dlg.finished(false);
12221 return Err(common::Error::HttpError(err));
12222 }
12223 Ok(res) => {
12224 let (mut parts, body) = res.into_parts();
12225 let mut body = common::Body::new(body);
12226 if !parts.status.is_success() {
12227 let bytes = common::to_bytes(body).await.unwrap_or_default();
12228 let error = serde_json::from_str(&common::to_string(&bytes));
12229 let response = common::to_response(parts, bytes.into());
12230
12231 if let common::Retry::After(d) =
12232 dlg.http_failure(&response, error.as_ref().ok())
12233 {
12234 sleep(d).await;
12235 continue;
12236 }
12237
12238 dlg.finished(false);
12239
12240 return Err(match error {
12241 Ok(value) => common::Error::BadRequest(value),
12242 _ => common::Error::Failure(response),
12243 });
12244 }
12245 let response = {
12246 let bytes = common::to_bytes(body).await.unwrap_or_default();
12247 let encoded = common::to_string(&bytes);
12248 match serde_json::from_str(&encoded) {
12249 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12250 Err(error) => {
12251 dlg.response_json_decode_error(&encoded, &error);
12252 return Err(common::Error::JsonDecodeError(
12253 encoded.to_string(),
12254 error,
12255 ));
12256 }
12257 }
12258 };
12259
12260 dlg.finished(true);
12261 return Ok(response);
12262 }
12263 }
12264 }
12265 }
12266
12267 ///
12268 /// Sets the *request* property to the given value.
12269 ///
12270 /// Even though the property as already been set when instantiating this call,
12271 /// we provide this method for API completeness.
12272 pub fn request(
12273 mut self,
12274 new_value: RawDecryptRequest,
12275 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
12276 self._request = new_value;
12277 self
12278 }
12279 /// Required. The resource name of the CryptoKeyVersion to use for decryption.
12280 ///
12281 /// Sets the *name* path property to the given value.
12282 ///
12283 /// Even though the property as already been set when instantiating this call,
12284 /// we provide this method for API completeness.
12285 pub fn name(
12286 mut self,
12287 new_value: &str,
12288 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
12289 self._name = new_value.to_string();
12290 self
12291 }
12292 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12293 /// while executing the actual API request.
12294 ///
12295 /// ````text
12296 /// It should be used to handle progress information, and to implement a certain level of resilience.
12297 /// ````
12298 ///
12299 /// Sets the *delegate* property to the given value.
12300 pub fn delegate(
12301 mut self,
12302 new_value: &'a mut dyn common::Delegate,
12303 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
12304 self._delegate = Some(new_value);
12305 self
12306 }
12307
12308 /// Set any additional parameter of the query string used in the request.
12309 /// It should be used to set parameters which are not yet available through their own
12310 /// setters.
12311 ///
12312 /// Please note that this method must not be used to set any of the known parameters
12313 /// which have their own setter method. If done anyway, the request will fail.
12314 ///
12315 /// # Additional Parameters
12316 ///
12317 /// * *$.xgafv* (query-string) - V1 error format.
12318 /// * *access_token* (query-string) - OAuth access token.
12319 /// * *alt* (query-string) - Data format for response.
12320 /// * *callback* (query-string) - JSONP
12321 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12322 /// * *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.
12323 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12324 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12325 /// * *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.
12326 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12327 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12328 pub fn param<T>(
12329 mut self,
12330 name: T,
12331 value: T,
12332 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12333 where
12334 T: AsRef<str>,
12335 {
12336 self._additional_params
12337 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12338 self
12339 }
12340
12341 /// Identifies the authorization scope for the method you are building.
12342 ///
12343 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12344 /// [`Scope::CloudPlatform`].
12345 ///
12346 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12347 /// tokens for more than one scope.
12348 ///
12349 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12350 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12351 /// sufficient, a read-write scope will do as well.
12352 pub fn add_scope<St>(
12353 mut self,
12354 scope: St,
12355 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12356 where
12357 St: AsRef<str>,
12358 {
12359 self._scopes.insert(String::from(scope.as_ref()));
12360 self
12361 }
12362 /// Identifies the authorization scope(s) for the method you are building.
12363 ///
12364 /// See [`Self::add_scope()`] for details.
12365 pub fn add_scopes<I, St>(
12366 mut self,
12367 scopes: I,
12368 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C>
12369 where
12370 I: IntoIterator<Item = St>,
12371 St: AsRef<str>,
12372 {
12373 self._scopes
12374 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12375 self
12376 }
12377
12378 /// Removes all scopes, and no default scope will be used either.
12379 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12380 /// for details).
12381 pub fn clear_scopes(
12382 mut self,
12383 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawDecryptCall<'a, C> {
12384 self._scopes.clear();
12385 self
12386 }
12387}
12388
12389/// 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.
12390///
12391/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.rawEncrypt* method supported by a *project* resource.
12392/// It is not used directly, but through a [`ProjectMethods`] instance.
12393///
12394/// # Example
12395///
12396/// Instantiate a resource method builder
12397///
12398/// ```test_harness,no_run
12399/// # extern crate hyper;
12400/// # extern crate hyper_rustls;
12401/// # extern crate google_cloudkms1 as cloudkms1;
12402/// use cloudkms1::api::RawEncryptRequest;
12403/// # async fn dox() {
12404/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12405///
12406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12408/// # secret,
12409/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12410/// # ).build().await.unwrap();
12411///
12412/// # let client = hyper_util::client::legacy::Client::builder(
12413/// # hyper_util::rt::TokioExecutor::new()
12414/// # )
12415/// # .build(
12416/// # hyper_rustls::HttpsConnectorBuilder::new()
12417/// # .with_native_roots()
12418/// # .unwrap()
12419/// # .https_or_http()
12420/// # .enable_http1()
12421/// # .build()
12422/// # );
12423/// # let mut hub = CloudKMS::new(client, auth);
12424/// // As the method needs a request, you would usually fill it with the desired information
12425/// // into the respective structure. Some of the parts shown here might not be applicable !
12426/// // Values shown here are possibly random and not representative !
12427/// let mut req = RawEncryptRequest::default();
12428///
12429/// // You can configure optional parameters by calling the respective setters at will, and
12430/// // execute the final call using `doit()`.
12431/// // Values shown here are possibly random and not representative !
12432/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_raw_encrypt(req, "name")
12433/// .doit().await;
12434/// # }
12435/// ```
12436pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12437where
12438 C: 'a,
12439{
12440 hub: &'a CloudKMS<C>,
12441 _request: RawEncryptRequest,
12442 _name: String,
12443 _delegate: Option<&'a mut dyn common::Delegate>,
12444 _additional_params: HashMap<String, String>,
12445 _scopes: BTreeSet<String>,
12446}
12447
12448impl<'a, C> common::CallBuilder
12449 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12450{
12451}
12452
12453impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12454where
12455 C: common::Connector,
12456{
12457 /// Perform the operation you have build so far.
12458 pub async fn doit(mut self) -> common::Result<(common::Response, RawEncryptResponse)> {
12459 use std::borrow::Cow;
12460 use std::io::{Read, Seek};
12461
12462 use common::{url::Params, ToParts};
12463 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12464
12465 let mut dd = common::DefaultDelegate;
12466 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12467 dlg.begin(common::MethodInfo {
12468 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.rawEncrypt",
12469 http_method: hyper::Method::POST,
12470 });
12471
12472 for &field in ["alt", "name"].iter() {
12473 if self._additional_params.contains_key(field) {
12474 dlg.finished(false);
12475 return Err(common::Error::FieldClash(field));
12476 }
12477 }
12478
12479 let mut params = Params::with_capacity(4 + self._additional_params.len());
12480 params.push("name", self._name);
12481
12482 params.extend(self._additional_params.iter());
12483
12484 params.push("alt", "json");
12485 let mut url = self.hub._base_url.clone() + "v1/{+name}:rawEncrypt";
12486 if self._scopes.is_empty() {
12487 self._scopes
12488 .insert(Scope::CloudPlatform.as_ref().to_string());
12489 }
12490
12491 #[allow(clippy::single_element_loop)]
12492 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12493 url = params.uri_replacement(url, param_name, find_this, true);
12494 }
12495 {
12496 let to_remove = ["name"];
12497 params.remove_params(&to_remove);
12498 }
12499
12500 let url = params.parse_with_url(&url);
12501
12502 let mut json_mime_type = mime::APPLICATION_JSON;
12503 let mut request_value_reader = {
12504 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12505 common::remove_json_null_values(&mut value);
12506 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12507 serde_json::to_writer(&mut dst, &value).unwrap();
12508 dst
12509 };
12510 let request_size = request_value_reader
12511 .seek(std::io::SeekFrom::End(0))
12512 .unwrap();
12513 request_value_reader
12514 .seek(std::io::SeekFrom::Start(0))
12515 .unwrap();
12516
12517 loop {
12518 let token = match self
12519 .hub
12520 .auth
12521 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12522 .await
12523 {
12524 Ok(token) => token,
12525 Err(e) => match dlg.token(e) {
12526 Ok(token) => token,
12527 Err(e) => {
12528 dlg.finished(false);
12529 return Err(common::Error::MissingToken(e));
12530 }
12531 },
12532 };
12533 request_value_reader
12534 .seek(std::io::SeekFrom::Start(0))
12535 .unwrap();
12536 let mut req_result = {
12537 let client = &self.hub.client;
12538 dlg.pre_request();
12539 let mut req_builder = hyper::Request::builder()
12540 .method(hyper::Method::POST)
12541 .uri(url.as_str())
12542 .header(USER_AGENT, self.hub._user_agent.clone());
12543
12544 if let Some(token) = token.as_ref() {
12545 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12546 }
12547
12548 let request = req_builder
12549 .header(CONTENT_TYPE, json_mime_type.to_string())
12550 .header(CONTENT_LENGTH, request_size as u64)
12551 .body(common::to_body(
12552 request_value_reader.get_ref().clone().into(),
12553 ));
12554
12555 client.request(request.unwrap()).await
12556 };
12557
12558 match req_result {
12559 Err(err) => {
12560 if let common::Retry::After(d) = dlg.http_error(&err) {
12561 sleep(d).await;
12562 continue;
12563 }
12564 dlg.finished(false);
12565 return Err(common::Error::HttpError(err));
12566 }
12567 Ok(res) => {
12568 let (mut parts, body) = res.into_parts();
12569 let mut body = common::Body::new(body);
12570 if !parts.status.is_success() {
12571 let bytes = common::to_bytes(body).await.unwrap_or_default();
12572 let error = serde_json::from_str(&common::to_string(&bytes));
12573 let response = common::to_response(parts, bytes.into());
12574
12575 if let common::Retry::After(d) =
12576 dlg.http_failure(&response, error.as_ref().ok())
12577 {
12578 sleep(d).await;
12579 continue;
12580 }
12581
12582 dlg.finished(false);
12583
12584 return Err(match error {
12585 Ok(value) => common::Error::BadRequest(value),
12586 _ => common::Error::Failure(response),
12587 });
12588 }
12589 let response = {
12590 let bytes = common::to_bytes(body).await.unwrap_or_default();
12591 let encoded = common::to_string(&bytes);
12592 match serde_json::from_str(&encoded) {
12593 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12594 Err(error) => {
12595 dlg.response_json_decode_error(&encoded, &error);
12596 return Err(common::Error::JsonDecodeError(
12597 encoded.to_string(),
12598 error,
12599 ));
12600 }
12601 }
12602 };
12603
12604 dlg.finished(true);
12605 return Ok(response);
12606 }
12607 }
12608 }
12609 }
12610
12611 ///
12612 /// Sets the *request* property to the given value.
12613 ///
12614 /// Even though the property as already been set when instantiating this call,
12615 /// we provide this method for API completeness.
12616 pub fn request(
12617 mut self,
12618 new_value: RawEncryptRequest,
12619 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
12620 self._request = new_value;
12621 self
12622 }
12623 /// Required. The resource name of the CryptoKeyVersion to use for encryption.
12624 ///
12625 /// Sets the *name* path property to the given value.
12626 ///
12627 /// Even though the property as already been set when instantiating this call,
12628 /// we provide this method for API completeness.
12629 pub fn name(
12630 mut self,
12631 new_value: &str,
12632 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
12633 self._name = new_value.to_string();
12634 self
12635 }
12636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12637 /// while executing the actual API request.
12638 ///
12639 /// ````text
12640 /// It should be used to handle progress information, and to implement a certain level of resilience.
12641 /// ````
12642 ///
12643 /// Sets the *delegate* property to the given value.
12644 pub fn delegate(
12645 mut self,
12646 new_value: &'a mut dyn common::Delegate,
12647 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
12648 self._delegate = Some(new_value);
12649 self
12650 }
12651
12652 /// Set any additional parameter of the query string used in the request.
12653 /// It should be used to set parameters which are not yet available through their own
12654 /// setters.
12655 ///
12656 /// Please note that this method must not be used to set any of the known parameters
12657 /// which have their own setter method. If done anyway, the request will fail.
12658 ///
12659 /// # Additional Parameters
12660 ///
12661 /// * *$.xgafv* (query-string) - V1 error format.
12662 /// * *access_token* (query-string) - OAuth access token.
12663 /// * *alt* (query-string) - Data format for response.
12664 /// * *callback* (query-string) - JSONP
12665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12666 /// * *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.
12667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12669 /// * *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.
12670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12672 pub fn param<T>(
12673 mut self,
12674 name: T,
12675 value: T,
12676 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12677 where
12678 T: AsRef<str>,
12679 {
12680 self._additional_params
12681 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12682 self
12683 }
12684
12685 /// Identifies the authorization scope for the method you are building.
12686 ///
12687 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12688 /// [`Scope::CloudPlatform`].
12689 ///
12690 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12691 /// tokens for more than one scope.
12692 ///
12693 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12694 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12695 /// sufficient, a read-write scope will do as well.
12696 pub fn add_scope<St>(
12697 mut self,
12698 scope: St,
12699 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12700 where
12701 St: AsRef<str>,
12702 {
12703 self._scopes.insert(String::from(scope.as_ref()));
12704 self
12705 }
12706 /// Identifies the authorization scope(s) for the method you are building.
12707 ///
12708 /// See [`Self::add_scope()`] for details.
12709 pub fn add_scopes<I, St>(
12710 mut self,
12711 scopes: I,
12712 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C>
12713 where
12714 I: IntoIterator<Item = St>,
12715 St: AsRef<str>,
12716 {
12717 self._scopes
12718 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12719 self
12720 }
12721
12722 /// Removes all scopes, and no default scope will be used either.
12723 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12724 /// for details).
12725 pub fn clear_scopes(
12726 mut self,
12727 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRawEncryptCall<'a, C> {
12728 self._scopes.clear();
12729 self
12730 }
12731}
12732
12733/// 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.
12734///
12735/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.restore* method supported by a *project* resource.
12736/// It is not used directly, but through a [`ProjectMethods`] instance.
12737///
12738/// # Example
12739///
12740/// Instantiate a resource method builder
12741///
12742/// ```test_harness,no_run
12743/// # extern crate hyper;
12744/// # extern crate hyper_rustls;
12745/// # extern crate google_cloudkms1 as cloudkms1;
12746/// use cloudkms1::api::RestoreCryptoKeyVersionRequest;
12747/// # async fn dox() {
12748/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12749///
12750/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12751/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12752/// # secret,
12753/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12754/// # ).build().await.unwrap();
12755///
12756/// # let client = hyper_util::client::legacy::Client::builder(
12757/// # hyper_util::rt::TokioExecutor::new()
12758/// # )
12759/// # .build(
12760/// # hyper_rustls::HttpsConnectorBuilder::new()
12761/// # .with_native_roots()
12762/// # .unwrap()
12763/// # .https_or_http()
12764/// # .enable_http1()
12765/// # .build()
12766/// # );
12767/// # let mut hub = CloudKMS::new(client, auth);
12768/// // As the method needs a request, you would usually fill it with the desired information
12769/// // into the respective structure. Some of the parts shown here might not be applicable !
12770/// // Values shown here are possibly random and not representative !
12771/// let mut req = RestoreCryptoKeyVersionRequest::default();
12772///
12773/// // You can configure optional parameters by calling the respective setters at will, and
12774/// // execute the final call using `doit()`.
12775/// // Values shown here are possibly random and not representative !
12776/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_restore(req, "name")
12777/// .doit().await;
12778/// # }
12779/// ```
12780pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
12781where
12782 C: 'a,
12783{
12784 hub: &'a CloudKMS<C>,
12785 _request: RestoreCryptoKeyVersionRequest,
12786 _name: String,
12787 _delegate: Option<&'a mut dyn common::Delegate>,
12788 _additional_params: HashMap<String, String>,
12789 _scopes: BTreeSet<String>,
12790}
12791
12792impl<'a, C> common::CallBuilder
12793 for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
12794{
12795}
12796
12797impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
12798where
12799 C: common::Connector,
12800{
12801 /// Perform the operation you have build so far.
12802 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
12803 use std::borrow::Cow;
12804 use std::io::{Read, Seek};
12805
12806 use common::{url::Params, ToParts};
12807 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12808
12809 let mut dd = common::DefaultDelegate;
12810 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12811 dlg.begin(common::MethodInfo {
12812 id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore",
12813 http_method: hyper::Method::POST,
12814 });
12815
12816 for &field in ["alt", "name"].iter() {
12817 if self._additional_params.contains_key(field) {
12818 dlg.finished(false);
12819 return Err(common::Error::FieldClash(field));
12820 }
12821 }
12822
12823 let mut params = Params::with_capacity(4 + self._additional_params.len());
12824 params.push("name", self._name);
12825
12826 params.extend(self._additional_params.iter());
12827
12828 params.push("alt", "json");
12829 let mut url = self.hub._base_url.clone() + "v1/{+name}:restore";
12830 if self._scopes.is_empty() {
12831 self._scopes
12832 .insert(Scope::CloudPlatform.as_ref().to_string());
12833 }
12834
12835 #[allow(clippy::single_element_loop)]
12836 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12837 url = params.uri_replacement(url, param_name, find_this, true);
12838 }
12839 {
12840 let to_remove = ["name"];
12841 params.remove_params(&to_remove);
12842 }
12843
12844 let url = params.parse_with_url(&url);
12845
12846 let mut json_mime_type = mime::APPLICATION_JSON;
12847 let mut request_value_reader = {
12848 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12849 common::remove_json_null_values(&mut value);
12850 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12851 serde_json::to_writer(&mut dst, &value).unwrap();
12852 dst
12853 };
12854 let request_size = request_value_reader
12855 .seek(std::io::SeekFrom::End(0))
12856 .unwrap();
12857 request_value_reader
12858 .seek(std::io::SeekFrom::Start(0))
12859 .unwrap();
12860
12861 loop {
12862 let token = match self
12863 .hub
12864 .auth
12865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12866 .await
12867 {
12868 Ok(token) => token,
12869 Err(e) => match dlg.token(e) {
12870 Ok(token) => token,
12871 Err(e) => {
12872 dlg.finished(false);
12873 return Err(common::Error::MissingToken(e));
12874 }
12875 },
12876 };
12877 request_value_reader
12878 .seek(std::io::SeekFrom::Start(0))
12879 .unwrap();
12880 let mut req_result = {
12881 let client = &self.hub.client;
12882 dlg.pre_request();
12883 let mut req_builder = hyper::Request::builder()
12884 .method(hyper::Method::POST)
12885 .uri(url.as_str())
12886 .header(USER_AGENT, self.hub._user_agent.clone());
12887
12888 if let Some(token) = token.as_ref() {
12889 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12890 }
12891
12892 let request = req_builder
12893 .header(CONTENT_TYPE, json_mime_type.to_string())
12894 .header(CONTENT_LENGTH, request_size as u64)
12895 .body(common::to_body(
12896 request_value_reader.get_ref().clone().into(),
12897 ));
12898
12899 client.request(request.unwrap()).await
12900 };
12901
12902 match req_result {
12903 Err(err) => {
12904 if let common::Retry::After(d) = dlg.http_error(&err) {
12905 sleep(d).await;
12906 continue;
12907 }
12908 dlg.finished(false);
12909 return Err(common::Error::HttpError(err));
12910 }
12911 Ok(res) => {
12912 let (mut parts, body) = res.into_parts();
12913 let mut body = common::Body::new(body);
12914 if !parts.status.is_success() {
12915 let bytes = common::to_bytes(body).await.unwrap_or_default();
12916 let error = serde_json::from_str(&common::to_string(&bytes));
12917 let response = common::to_response(parts, bytes.into());
12918
12919 if let common::Retry::After(d) =
12920 dlg.http_failure(&response, error.as_ref().ok())
12921 {
12922 sleep(d).await;
12923 continue;
12924 }
12925
12926 dlg.finished(false);
12927
12928 return Err(match error {
12929 Ok(value) => common::Error::BadRequest(value),
12930 _ => common::Error::Failure(response),
12931 });
12932 }
12933 let response = {
12934 let bytes = common::to_bytes(body).await.unwrap_or_default();
12935 let encoded = common::to_string(&bytes);
12936 match serde_json::from_str(&encoded) {
12937 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12938 Err(error) => {
12939 dlg.response_json_decode_error(&encoded, &error);
12940 return Err(common::Error::JsonDecodeError(
12941 encoded.to_string(),
12942 error,
12943 ));
12944 }
12945 }
12946 };
12947
12948 dlg.finished(true);
12949 return Ok(response);
12950 }
12951 }
12952 }
12953 }
12954
12955 ///
12956 /// Sets the *request* property to the given value.
12957 ///
12958 /// Even though the property as already been set when instantiating this call,
12959 /// we provide this method for API completeness.
12960 pub fn request(
12961 mut self,
12962 new_value: RestoreCryptoKeyVersionRequest,
12963 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
12964 self._request = new_value;
12965 self
12966 }
12967 /// Required. The resource name of the CryptoKeyVersion to restore.
12968 ///
12969 /// Sets the *name* path property to the given value.
12970 ///
12971 /// Even though the property as already been set when instantiating this call,
12972 /// we provide this method for API completeness.
12973 pub fn name(
12974 mut self,
12975 new_value: &str,
12976 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
12977 self._name = new_value.to_string();
12978 self
12979 }
12980 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12981 /// while executing the actual API request.
12982 ///
12983 /// ````text
12984 /// It should be used to handle progress information, and to implement a certain level of resilience.
12985 /// ````
12986 ///
12987 /// Sets the *delegate* property to the given value.
12988 pub fn delegate(
12989 mut self,
12990 new_value: &'a mut dyn common::Delegate,
12991 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
12992 self._delegate = Some(new_value);
12993 self
12994 }
12995
12996 /// Set any additional parameter of the query string used in the request.
12997 /// It should be used to set parameters which are not yet available through their own
12998 /// setters.
12999 ///
13000 /// Please note that this method must not be used to set any of the known parameters
13001 /// which have their own setter method. If done anyway, the request will fail.
13002 ///
13003 /// # Additional Parameters
13004 ///
13005 /// * *$.xgafv* (query-string) - V1 error format.
13006 /// * *access_token* (query-string) - OAuth access token.
13007 /// * *alt* (query-string) - Data format for response.
13008 /// * *callback* (query-string) - JSONP
13009 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13010 /// * *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.
13011 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13012 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13013 /// * *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.
13014 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13015 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13016 pub fn param<T>(
13017 mut self,
13018 name: T,
13019 value: T,
13020 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
13021 where
13022 T: AsRef<str>,
13023 {
13024 self._additional_params
13025 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13026 self
13027 }
13028
13029 /// Identifies the authorization scope for the method you are building.
13030 ///
13031 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13032 /// [`Scope::CloudPlatform`].
13033 ///
13034 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13035 /// tokens for more than one scope.
13036 ///
13037 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13038 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13039 /// sufficient, a read-write scope will do as well.
13040 pub fn add_scope<St>(
13041 mut self,
13042 scope: St,
13043 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
13044 where
13045 St: AsRef<str>,
13046 {
13047 self._scopes.insert(String::from(scope.as_ref()));
13048 self
13049 }
13050 /// Identifies the authorization scope(s) for the method you are building.
13051 ///
13052 /// See [`Self::add_scope()`] for details.
13053 pub fn add_scopes<I, St>(
13054 mut self,
13055 scopes: I,
13056 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
13057 where
13058 I: IntoIterator<Item = St>,
13059 St: AsRef<str>,
13060 {
13061 self._scopes
13062 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13063 self
13064 }
13065
13066 /// Removes all scopes, and no default scope will be used either.
13067 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13068 /// for details).
13069 pub fn clear_scopes(
13070 mut self,
13071 ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
13072 self._scopes.clear();
13073 self
13074 }
13075}
13076
13077/// Create a new CryptoKey within a KeyRing. CryptoKey.purpose and CryptoKey.version_template.algorithm are required.
13078///
13079/// A builder for the *locations.keyRings.cryptoKeys.create* method supported by a *project* resource.
13080/// It is not used directly, but through a [`ProjectMethods`] instance.
13081///
13082/// # Example
13083///
13084/// Instantiate a resource method builder
13085///
13086/// ```test_harness,no_run
13087/// # extern crate hyper;
13088/// # extern crate hyper_rustls;
13089/// # extern crate google_cloudkms1 as cloudkms1;
13090/// use cloudkms1::api::CryptoKey;
13091/// # async fn dox() {
13092/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13093///
13094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13096/// # secret,
13097/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13098/// # ).build().await.unwrap();
13099///
13100/// # let client = hyper_util::client::legacy::Client::builder(
13101/// # hyper_util::rt::TokioExecutor::new()
13102/// # )
13103/// # .build(
13104/// # hyper_rustls::HttpsConnectorBuilder::new()
13105/// # .with_native_roots()
13106/// # .unwrap()
13107/// # .https_or_http()
13108/// # .enable_http1()
13109/// # .build()
13110/// # );
13111/// # let mut hub = CloudKMS::new(client, auth);
13112/// // As the method needs a request, you would usually fill it with the desired information
13113/// // into the respective structure. Some of the parts shown here might not be applicable !
13114/// // Values shown here are possibly random and not representative !
13115/// let mut req = CryptoKey::default();
13116///
13117/// // You can configure optional parameters by calling the respective setters at will, and
13118/// // execute the final call using `doit()`.
13119/// // Values shown here are possibly random and not representative !
13120/// let result = hub.projects().locations_key_rings_crypto_keys_create(req, "parent")
13121/// .skip_initial_version_creation(false)
13122/// .crypto_key_id("diam")
13123/// .doit().await;
13124/// # }
13125/// ```
13126pub struct ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
13127where
13128 C: 'a,
13129{
13130 hub: &'a CloudKMS<C>,
13131 _request: CryptoKey,
13132 _parent: String,
13133 _skip_initial_version_creation: Option<bool>,
13134 _crypto_key_id: Option<String>,
13135 _delegate: Option<&'a mut dyn common::Delegate>,
13136 _additional_params: HashMap<String, String>,
13137 _scopes: BTreeSet<String>,
13138}
13139
13140impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {}
13141
13142impl<'a, C> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
13143where
13144 C: common::Connector,
13145{
13146 /// Perform the operation you have build so far.
13147 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
13148 use std::borrow::Cow;
13149 use std::io::{Read, Seek};
13150
13151 use common::{url::Params, ToParts};
13152 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13153
13154 let mut dd = common::DefaultDelegate;
13155 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13156 dlg.begin(common::MethodInfo {
13157 id: "cloudkms.projects.locations.keyRings.cryptoKeys.create",
13158 http_method: hyper::Method::POST,
13159 });
13160
13161 for &field in ["alt", "parent", "skipInitialVersionCreation", "cryptoKeyId"].iter() {
13162 if self._additional_params.contains_key(field) {
13163 dlg.finished(false);
13164 return Err(common::Error::FieldClash(field));
13165 }
13166 }
13167
13168 let mut params = Params::with_capacity(6 + self._additional_params.len());
13169 params.push("parent", self._parent);
13170 if let Some(value) = self._skip_initial_version_creation.as_ref() {
13171 params.push("skipInitialVersionCreation", value.to_string());
13172 }
13173 if let Some(value) = self._crypto_key_id.as_ref() {
13174 params.push("cryptoKeyId", value);
13175 }
13176
13177 params.extend(self._additional_params.iter());
13178
13179 params.push("alt", "json");
13180 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeys";
13181 if self._scopes.is_empty() {
13182 self._scopes
13183 .insert(Scope::CloudPlatform.as_ref().to_string());
13184 }
13185
13186 #[allow(clippy::single_element_loop)]
13187 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13188 url = params.uri_replacement(url, param_name, find_this, true);
13189 }
13190 {
13191 let to_remove = ["parent"];
13192 params.remove_params(&to_remove);
13193 }
13194
13195 let url = params.parse_with_url(&url);
13196
13197 let mut json_mime_type = mime::APPLICATION_JSON;
13198 let mut request_value_reader = {
13199 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13200 common::remove_json_null_values(&mut value);
13201 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13202 serde_json::to_writer(&mut dst, &value).unwrap();
13203 dst
13204 };
13205 let request_size = request_value_reader
13206 .seek(std::io::SeekFrom::End(0))
13207 .unwrap();
13208 request_value_reader
13209 .seek(std::io::SeekFrom::Start(0))
13210 .unwrap();
13211
13212 loop {
13213 let token = match self
13214 .hub
13215 .auth
13216 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13217 .await
13218 {
13219 Ok(token) => token,
13220 Err(e) => match dlg.token(e) {
13221 Ok(token) => token,
13222 Err(e) => {
13223 dlg.finished(false);
13224 return Err(common::Error::MissingToken(e));
13225 }
13226 },
13227 };
13228 request_value_reader
13229 .seek(std::io::SeekFrom::Start(0))
13230 .unwrap();
13231 let mut req_result = {
13232 let client = &self.hub.client;
13233 dlg.pre_request();
13234 let mut req_builder = hyper::Request::builder()
13235 .method(hyper::Method::POST)
13236 .uri(url.as_str())
13237 .header(USER_AGENT, self.hub._user_agent.clone());
13238
13239 if let Some(token) = token.as_ref() {
13240 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13241 }
13242
13243 let request = req_builder
13244 .header(CONTENT_TYPE, json_mime_type.to_string())
13245 .header(CONTENT_LENGTH, request_size as u64)
13246 .body(common::to_body(
13247 request_value_reader.get_ref().clone().into(),
13248 ));
13249
13250 client.request(request.unwrap()).await
13251 };
13252
13253 match req_result {
13254 Err(err) => {
13255 if let common::Retry::After(d) = dlg.http_error(&err) {
13256 sleep(d).await;
13257 continue;
13258 }
13259 dlg.finished(false);
13260 return Err(common::Error::HttpError(err));
13261 }
13262 Ok(res) => {
13263 let (mut parts, body) = res.into_parts();
13264 let mut body = common::Body::new(body);
13265 if !parts.status.is_success() {
13266 let bytes = common::to_bytes(body).await.unwrap_or_default();
13267 let error = serde_json::from_str(&common::to_string(&bytes));
13268 let response = common::to_response(parts, bytes.into());
13269
13270 if let common::Retry::After(d) =
13271 dlg.http_failure(&response, error.as_ref().ok())
13272 {
13273 sleep(d).await;
13274 continue;
13275 }
13276
13277 dlg.finished(false);
13278
13279 return Err(match error {
13280 Ok(value) => common::Error::BadRequest(value),
13281 _ => common::Error::Failure(response),
13282 });
13283 }
13284 let response = {
13285 let bytes = common::to_bytes(body).await.unwrap_or_default();
13286 let encoded = common::to_string(&bytes);
13287 match serde_json::from_str(&encoded) {
13288 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13289 Err(error) => {
13290 dlg.response_json_decode_error(&encoded, &error);
13291 return Err(common::Error::JsonDecodeError(
13292 encoded.to_string(),
13293 error,
13294 ));
13295 }
13296 }
13297 };
13298
13299 dlg.finished(true);
13300 return Ok(response);
13301 }
13302 }
13303 }
13304 }
13305
13306 ///
13307 /// Sets the *request* property to the given value.
13308 ///
13309 /// Even though the property as already been set when instantiating this call,
13310 /// we provide this method for API completeness.
13311 pub fn request(
13312 mut self,
13313 new_value: CryptoKey,
13314 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13315 self._request = new_value;
13316 self
13317 }
13318 /// Required. The name of the KeyRing associated with the CryptoKeys.
13319 ///
13320 /// Sets the *parent* path property to the given value.
13321 ///
13322 /// Even though the property as already been set when instantiating this call,
13323 /// we provide this method for API completeness.
13324 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13325 self._parent = new_value.to_string();
13326 self
13327 }
13328 /// 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.
13329 ///
13330 /// Sets the *skip initial version creation* query property to the given value.
13331 pub fn skip_initial_version_creation(
13332 mut self,
13333 new_value: bool,
13334 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13335 self._skip_initial_version_creation = Some(new_value);
13336 self
13337 }
13338 /// Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`
13339 ///
13340 /// Sets the *crypto key id* query property to the given value.
13341 pub fn crypto_key_id(
13342 mut self,
13343 new_value: &str,
13344 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13345 self._crypto_key_id = Some(new_value.to_string());
13346 self
13347 }
13348 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13349 /// while executing the actual API request.
13350 ///
13351 /// ````text
13352 /// It should be used to handle progress information, and to implement a certain level of resilience.
13353 /// ````
13354 ///
13355 /// Sets the *delegate* property to the given value.
13356 pub fn delegate(
13357 mut self,
13358 new_value: &'a mut dyn common::Delegate,
13359 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13360 self._delegate = Some(new_value);
13361 self
13362 }
13363
13364 /// Set any additional parameter of the query string used in the request.
13365 /// It should be used to set parameters which are not yet available through their own
13366 /// setters.
13367 ///
13368 /// Please note that this method must not be used to set any of the known parameters
13369 /// which have their own setter method. If done anyway, the request will fail.
13370 ///
13371 /// # Additional Parameters
13372 ///
13373 /// * *$.xgafv* (query-string) - V1 error format.
13374 /// * *access_token* (query-string) - OAuth access token.
13375 /// * *alt* (query-string) - Data format for response.
13376 /// * *callback* (query-string) - JSONP
13377 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13378 /// * *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.
13379 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13380 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13381 /// * *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.
13382 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13383 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13384 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
13385 where
13386 T: AsRef<str>,
13387 {
13388 self._additional_params
13389 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13390 self
13391 }
13392
13393 /// Identifies the authorization scope for the method you are building.
13394 ///
13395 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13396 /// [`Scope::CloudPlatform`].
13397 ///
13398 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13399 /// tokens for more than one scope.
13400 ///
13401 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13402 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13403 /// sufficient, a read-write scope will do as well.
13404 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
13405 where
13406 St: AsRef<str>,
13407 {
13408 self._scopes.insert(String::from(scope.as_ref()));
13409 self
13410 }
13411 /// Identifies the authorization scope(s) for the method you are building.
13412 ///
13413 /// See [`Self::add_scope()`] for details.
13414 pub fn add_scopes<I, St>(
13415 mut self,
13416 scopes: I,
13417 ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
13418 where
13419 I: IntoIterator<Item = St>,
13420 St: AsRef<str>,
13421 {
13422 self._scopes
13423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13424 self
13425 }
13426
13427 /// Removes all scopes, and no default scope will be used either.
13428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13429 /// for details).
13430 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
13431 self._scopes.clear();
13432 self
13433 }
13434}
13435
13436/// Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
13437///
13438/// A builder for the *locations.keyRings.cryptoKeys.decrypt* method supported by a *project* resource.
13439/// It is not used directly, but through a [`ProjectMethods`] instance.
13440///
13441/// # Example
13442///
13443/// Instantiate a resource method builder
13444///
13445/// ```test_harness,no_run
13446/// # extern crate hyper;
13447/// # extern crate hyper_rustls;
13448/// # extern crate google_cloudkms1 as cloudkms1;
13449/// use cloudkms1::api::DecryptRequest;
13450/// # async fn dox() {
13451/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13452///
13453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13455/// # secret,
13456/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13457/// # ).build().await.unwrap();
13458///
13459/// # let client = hyper_util::client::legacy::Client::builder(
13460/// # hyper_util::rt::TokioExecutor::new()
13461/// # )
13462/// # .build(
13463/// # hyper_rustls::HttpsConnectorBuilder::new()
13464/// # .with_native_roots()
13465/// # .unwrap()
13466/// # .https_or_http()
13467/// # .enable_http1()
13468/// # .build()
13469/// # );
13470/// # let mut hub = CloudKMS::new(client, auth);
13471/// // As the method needs a request, you would usually fill it with the desired information
13472/// // into the respective structure. Some of the parts shown here might not be applicable !
13473/// // Values shown here are possibly random and not representative !
13474/// let mut req = DecryptRequest::default();
13475///
13476/// // You can configure optional parameters by calling the respective setters at will, and
13477/// // execute the final call using `doit()`.
13478/// // Values shown here are possibly random and not representative !
13479/// let result = hub.projects().locations_key_rings_crypto_keys_decrypt(req, "name")
13480/// .doit().await;
13481/// # }
13482/// ```
13483pub struct ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
13484where
13485 C: 'a,
13486{
13487 hub: &'a CloudKMS<C>,
13488 _request: DecryptRequest,
13489 _name: String,
13490 _delegate: Option<&'a mut dyn common::Delegate>,
13491 _additional_params: HashMap<String, String>,
13492 _scopes: BTreeSet<String>,
13493}
13494
13495impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {}
13496
13497impl<'a, C> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
13498where
13499 C: common::Connector,
13500{
13501 /// Perform the operation you have build so far.
13502 pub async fn doit(mut self) -> common::Result<(common::Response, DecryptResponse)> {
13503 use std::borrow::Cow;
13504 use std::io::{Read, Seek};
13505
13506 use common::{url::Params, ToParts};
13507 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13508
13509 let mut dd = common::DefaultDelegate;
13510 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13511 dlg.begin(common::MethodInfo {
13512 id: "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt",
13513 http_method: hyper::Method::POST,
13514 });
13515
13516 for &field in ["alt", "name"].iter() {
13517 if self._additional_params.contains_key(field) {
13518 dlg.finished(false);
13519 return Err(common::Error::FieldClash(field));
13520 }
13521 }
13522
13523 let mut params = Params::with_capacity(4 + self._additional_params.len());
13524 params.push("name", self._name);
13525
13526 params.extend(self._additional_params.iter());
13527
13528 params.push("alt", "json");
13529 let mut url = self.hub._base_url.clone() + "v1/{+name}:decrypt";
13530 if self._scopes.is_empty() {
13531 self._scopes
13532 .insert(Scope::CloudPlatform.as_ref().to_string());
13533 }
13534
13535 #[allow(clippy::single_element_loop)]
13536 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13537 url = params.uri_replacement(url, param_name, find_this, true);
13538 }
13539 {
13540 let to_remove = ["name"];
13541 params.remove_params(&to_remove);
13542 }
13543
13544 let url = params.parse_with_url(&url);
13545
13546 let mut json_mime_type = mime::APPLICATION_JSON;
13547 let mut request_value_reader = {
13548 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13549 common::remove_json_null_values(&mut value);
13550 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13551 serde_json::to_writer(&mut dst, &value).unwrap();
13552 dst
13553 };
13554 let request_size = request_value_reader
13555 .seek(std::io::SeekFrom::End(0))
13556 .unwrap();
13557 request_value_reader
13558 .seek(std::io::SeekFrom::Start(0))
13559 .unwrap();
13560
13561 loop {
13562 let token = match self
13563 .hub
13564 .auth
13565 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13566 .await
13567 {
13568 Ok(token) => token,
13569 Err(e) => match dlg.token(e) {
13570 Ok(token) => token,
13571 Err(e) => {
13572 dlg.finished(false);
13573 return Err(common::Error::MissingToken(e));
13574 }
13575 },
13576 };
13577 request_value_reader
13578 .seek(std::io::SeekFrom::Start(0))
13579 .unwrap();
13580 let mut req_result = {
13581 let client = &self.hub.client;
13582 dlg.pre_request();
13583 let mut req_builder = hyper::Request::builder()
13584 .method(hyper::Method::POST)
13585 .uri(url.as_str())
13586 .header(USER_AGENT, self.hub._user_agent.clone());
13587
13588 if let Some(token) = token.as_ref() {
13589 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13590 }
13591
13592 let request = req_builder
13593 .header(CONTENT_TYPE, json_mime_type.to_string())
13594 .header(CONTENT_LENGTH, request_size as u64)
13595 .body(common::to_body(
13596 request_value_reader.get_ref().clone().into(),
13597 ));
13598
13599 client.request(request.unwrap()).await
13600 };
13601
13602 match req_result {
13603 Err(err) => {
13604 if let common::Retry::After(d) = dlg.http_error(&err) {
13605 sleep(d).await;
13606 continue;
13607 }
13608 dlg.finished(false);
13609 return Err(common::Error::HttpError(err));
13610 }
13611 Ok(res) => {
13612 let (mut parts, body) = res.into_parts();
13613 let mut body = common::Body::new(body);
13614 if !parts.status.is_success() {
13615 let bytes = common::to_bytes(body).await.unwrap_or_default();
13616 let error = serde_json::from_str(&common::to_string(&bytes));
13617 let response = common::to_response(parts, bytes.into());
13618
13619 if let common::Retry::After(d) =
13620 dlg.http_failure(&response, error.as_ref().ok())
13621 {
13622 sleep(d).await;
13623 continue;
13624 }
13625
13626 dlg.finished(false);
13627
13628 return Err(match error {
13629 Ok(value) => common::Error::BadRequest(value),
13630 _ => common::Error::Failure(response),
13631 });
13632 }
13633 let response = {
13634 let bytes = common::to_bytes(body).await.unwrap_or_default();
13635 let encoded = common::to_string(&bytes);
13636 match serde_json::from_str(&encoded) {
13637 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13638 Err(error) => {
13639 dlg.response_json_decode_error(&encoded, &error);
13640 return Err(common::Error::JsonDecodeError(
13641 encoded.to_string(),
13642 error,
13643 ));
13644 }
13645 }
13646 };
13647
13648 dlg.finished(true);
13649 return Ok(response);
13650 }
13651 }
13652 }
13653 }
13654
13655 ///
13656 /// Sets the *request* property to the given value.
13657 ///
13658 /// Even though the property as already been set when instantiating this call,
13659 /// we provide this method for API completeness.
13660 pub fn request(
13661 mut self,
13662 new_value: DecryptRequest,
13663 ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
13664 self._request = new_value;
13665 self
13666 }
13667 /// Required. The resource name of the CryptoKey to use for decryption. The server will choose the appropriate version.
13668 ///
13669 /// Sets the *name* path property to the given value.
13670 ///
13671 /// Even though the property as already been set when instantiating this call,
13672 /// we provide this method for API completeness.
13673 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
13674 self._name = new_value.to_string();
13675 self
13676 }
13677 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13678 /// while executing the actual API request.
13679 ///
13680 /// ````text
13681 /// It should be used to handle progress information, and to implement a certain level of resilience.
13682 /// ````
13683 ///
13684 /// Sets the *delegate* property to the given value.
13685 pub fn delegate(
13686 mut self,
13687 new_value: &'a mut dyn common::Delegate,
13688 ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
13689 self._delegate = Some(new_value);
13690 self
13691 }
13692
13693 /// Set any additional parameter of the query string used in the request.
13694 /// It should be used to set parameters which are not yet available through their own
13695 /// setters.
13696 ///
13697 /// Please note that this method must not be used to set any of the known parameters
13698 /// which have their own setter method. If done anyway, the request will fail.
13699 ///
13700 /// # Additional Parameters
13701 ///
13702 /// * *$.xgafv* (query-string) - V1 error format.
13703 /// * *access_token* (query-string) - OAuth access token.
13704 /// * *alt* (query-string) - Data format for response.
13705 /// * *callback* (query-string) - JSONP
13706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13707 /// * *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.
13708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13710 /// * *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.
13711 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13712 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13713 pub fn param<T>(
13714 mut self,
13715 name: T,
13716 value: T,
13717 ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
13718 where
13719 T: AsRef<str>,
13720 {
13721 self._additional_params
13722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13723 self
13724 }
13725
13726 /// Identifies the authorization scope for the method you are building.
13727 ///
13728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13729 /// [`Scope::CloudPlatform`].
13730 ///
13731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13732 /// tokens for more than one scope.
13733 ///
13734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13736 /// sufficient, a read-write scope will do as well.
13737 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
13738 where
13739 St: AsRef<str>,
13740 {
13741 self._scopes.insert(String::from(scope.as_ref()));
13742 self
13743 }
13744 /// Identifies the authorization scope(s) for the method you are building.
13745 ///
13746 /// See [`Self::add_scope()`] for details.
13747 pub fn add_scopes<I, St>(
13748 mut self,
13749 scopes: I,
13750 ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
13751 where
13752 I: IntoIterator<Item = St>,
13753 St: AsRef<str>,
13754 {
13755 self._scopes
13756 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13757 self
13758 }
13759
13760 /// Removes all scopes, and no default scope will be used either.
13761 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13762 /// for details).
13763 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
13764 self._scopes.clear();
13765 self
13766 }
13767}
13768
13769/// Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.
13770///
13771/// A builder for the *locations.keyRings.cryptoKeys.encrypt* method supported by a *project* resource.
13772/// It is not used directly, but through a [`ProjectMethods`] instance.
13773///
13774/// # Example
13775///
13776/// Instantiate a resource method builder
13777///
13778/// ```test_harness,no_run
13779/// # extern crate hyper;
13780/// # extern crate hyper_rustls;
13781/// # extern crate google_cloudkms1 as cloudkms1;
13782/// use cloudkms1::api::EncryptRequest;
13783/// # async fn dox() {
13784/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13785///
13786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13787/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13788/// # secret,
13789/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13790/// # ).build().await.unwrap();
13791///
13792/// # let client = hyper_util::client::legacy::Client::builder(
13793/// # hyper_util::rt::TokioExecutor::new()
13794/// # )
13795/// # .build(
13796/// # hyper_rustls::HttpsConnectorBuilder::new()
13797/// # .with_native_roots()
13798/// # .unwrap()
13799/// # .https_or_http()
13800/// # .enable_http1()
13801/// # .build()
13802/// # );
13803/// # let mut hub = CloudKMS::new(client, auth);
13804/// // As the method needs a request, you would usually fill it with the desired information
13805/// // into the respective structure. Some of the parts shown here might not be applicable !
13806/// // Values shown here are possibly random and not representative !
13807/// let mut req = EncryptRequest::default();
13808///
13809/// // You can configure optional parameters by calling the respective setters at will, and
13810/// // execute the final call using `doit()`.
13811/// // Values shown here are possibly random and not representative !
13812/// let result = hub.projects().locations_key_rings_crypto_keys_encrypt(req, "name")
13813/// .doit().await;
13814/// # }
13815/// ```
13816pub struct ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
13817where
13818 C: 'a,
13819{
13820 hub: &'a CloudKMS<C>,
13821 _request: EncryptRequest,
13822 _name: String,
13823 _delegate: Option<&'a mut dyn common::Delegate>,
13824 _additional_params: HashMap<String, String>,
13825 _scopes: BTreeSet<String>,
13826}
13827
13828impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {}
13829
13830impl<'a, C> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
13831where
13832 C: common::Connector,
13833{
13834 /// Perform the operation you have build so far.
13835 pub async fn doit(mut self) -> common::Result<(common::Response, EncryptResponse)> {
13836 use std::borrow::Cow;
13837 use std::io::{Read, Seek};
13838
13839 use common::{url::Params, ToParts};
13840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13841
13842 let mut dd = common::DefaultDelegate;
13843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13844 dlg.begin(common::MethodInfo {
13845 id: "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt",
13846 http_method: hyper::Method::POST,
13847 });
13848
13849 for &field in ["alt", "name"].iter() {
13850 if self._additional_params.contains_key(field) {
13851 dlg.finished(false);
13852 return Err(common::Error::FieldClash(field));
13853 }
13854 }
13855
13856 let mut params = Params::with_capacity(4 + self._additional_params.len());
13857 params.push("name", self._name);
13858
13859 params.extend(self._additional_params.iter());
13860
13861 params.push("alt", "json");
13862 let mut url = self.hub._base_url.clone() + "v1/{+name}:encrypt";
13863 if self._scopes.is_empty() {
13864 self._scopes
13865 .insert(Scope::CloudPlatform.as_ref().to_string());
13866 }
13867
13868 #[allow(clippy::single_element_loop)]
13869 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13870 url = params.uri_replacement(url, param_name, find_this, true);
13871 }
13872 {
13873 let to_remove = ["name"];
13874 params.remove_params(&to_remove);
13875 }
13876
13877 let url = params.parse_with_url(&url);
13878
13879 let mut json_mime_type = mime::APPLICATION_JSON;
13880 let mut request_value_reader = {
13881 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13882 common::remove_json_null_values(&mut value);
13883 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13884 serde_json::to_writer(&mut dst, &value).unwrap();
13885 dst
13886 };
13887 let request_size = request_value_reader
13888 .seek(std::io::SeekFrom::End(0))
13889 .unwrap();
13890 request_value_reader
13891 .seek(std::io::SeekFrom::Start(0))
13892 .unwrap();
13893
13894 loop {
13895 let token = match self
13896 .hub
13897 .auth
13898 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13899 .await
13900 {
13901 Ok(token) => token,
13902 Err(e) => match dlg.token(e) {
13903 Ok(token) => token,
13904 Err(e) => {
13905 dlg.finished(false);
13906 return Err(common::Error::MissingToken(e));
13907 }
13908 },
13909 };
13910 request_value_reader
13911 .seek(std::io::SeekFrom::Start(0))
13912 .unwrap();
13913 let mut req_result = {
13914 let client = &self.hub.client;
13915 dlg.pre_request();
13916 let mut req_builder = hyper::Request::builder()
13917 .method(hyper::Method::POST)
13918 .uri(url.as_str())
13919 .header(USER_AGENT, self.hub._user_agent.clone());
13920
13921 if let Some(token) = token.as_ref() {
13922 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13923 }
13924
13925 let request = req_builder
13926 .header(CONTENT_TYPE, json_mime_type.to_string())
13927 .header(CONTENT_LENGTH, request_size as u64)
13928 .body(common::to_body(
13929 request_value_reader.get_ref().clone().into(),
13930 ));
13931
13932 client.request(request.unwrap()).await
13933 };
13934
13935 match req_result {
13936 Err(err) => {
13937 if let common::Retry::After(d) = dlg.http_error(&err) {
13938 sleep(d).await;
13939 continue;
13940 }
13941 dlg.finished(false);
13942 return Err(common::Error::HttpError(err));
13943 }
13944 Ok(res) => {
13945 let (mut parts, body) = res.into_parts();
13946 let mut body = common::Body::new(body);
13947 if !parts.status.is_success() {
13948 let bytes = common::to_bytes(body).await.unwrap_or_default();
13949 let error = serde_json::from_str(&common::to_string(&bytes));
13950 let response = common::to_response(parts, bytes.into());
13951
13952 if let common::Retry::After(d) =
13953 dlg.http_failure(&response, error.as_ref().ok())
13954 {
13955 sleep(d).await;
13956 continue;
13957 }
13958
13959 dlg.finished(false);
13960
13961 return Err(match error {
13962 Ok(value) => common::Error::BadRequest(value),
13963 _ => common::Error::Failure(response),
13964 });
13965 }
13966 let response = {
13967 let bytes = common::to_bytes(body).await.unwrap_or_default();
13968 let encoded = common::to_string(&bytes);
13969 match serde_json::from_str(&encoded) {
13970 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13971 Err(error) => {
13972 dlg.response_json_decode_error(&encoded, &error);
13973 return Err(common::Error::JsonDecodeError(
13974 encoded.to_string(),
13975 error,
13976 ));
13977 }
13978 }
13979 };
13980
13981 dlg.finished(true);
13982 return Ok(response);
13983 }
13984 }
13985 }
13986 }
13987
13988 ///
13989 /// Sets the *request* property to the given value.
13990 ///
13991 /// Even though the property as already been set when instantiating this call,
13992 /// we provide this method for API completeness.
13993 pub fn request(
13994 mut self,
13995 new_value: EncryptRequest,
13996 ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
13997 self._request = new_value;
13998 self
13999 }
14000 /// 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.
14001 ///
14002 /// Sets the *name* path property to the given value.
14003 ///
14004 /// Even though the property as already been set when instantiating this call,
14005 /// we provide this method for API completeness.
14006 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
14007 self._name = new_value.to_string();
14008 self
14009 }
14010 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14011 /// while executing the actual API request.
14012 ///
14013 /// ````text
14014 /// It should be used to handle progress information, and to implement a certain level of resilience.
14015 /// ````
14016 ///
14017 /// Sets the *delegate* property to the given value.
14018 pub fn delegate(
14019 mut self,
14020 new_value: &'a mut dyn common::Delegate,
14021 ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
14022 self._delegate = Some(new_value);
14023 self
14024 }
14025
14026 /// Set any additional parameter of the query string used in the request.
14027 /// It should be used to set parameters which are not yet available through their own
14028 /// setters.
14029 ///
14030 /// Please note that this method must not be used to set any of the known parameters
14031 /// which have their own setter method. If done anyway, the request will fail.
14032 ///
14033 /// # Additional Parameters
14034 ///
14035 /// * *$.xgafv* (query-string) - V1 error format.
14036 /// * *access_token* (query-string) - OAuth access token.
14037 /// * *alt* (query-string) - Data format for response.
14038 /// * *callback* (query-string) - JSONP
14039 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14040 /// * *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.
14041 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14042 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14043 /// * *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.
14044 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14045 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14046 pub fn param<T>(
14047 mut self,
14048 name: T,
14049 value: T,
14050 ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
14051 where
14052 T: AsRef<str>,
14053 {
14054 self._additional_params
14055 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14056 self
14057 }
14058
14059 /// Identifies the authorization scope for the method you are building.
14060 ///
14061 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14062 /// [`Scope::CloudPlatform`].
14063 ///
14064 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14065 /// tokens for more than one scope.
14066 ///
14067 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14068 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14069 /// sufficient, a read-write scope will do as well.
14070 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
14071 where
14072 St: AsRef<str>,
14073 {
14074 self._scopes.insert(String::from(scope.as_ref()));
14075 self
14076 }
14077 /// Identifies the authorization scope(s) for the method you are building.
14078 ///
14079 /// See [`Self::add_scope()`] for details.
14080 pub fn add_scopes<I, St>(
14081 mut self,
14082 scopes: I,
14083 ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
14084 where
14085 I: IntoIterator<Item = St>,
14086 St: AsRef<str>,
14087 {
14088 self._scopes
14089 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14090 self
14091 }
14092
14093 /// Removes all scopes, and no default scope will be used either.
14094 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14095 /// for details).
14096 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
14097 self._scopes.clear();
14098 self
14099 }
14100}
14101
14102/// Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.
14103///
14104/// A builder for the *locations.keyRings.cryptoKeys.get* method supported by a *project* resource.
14105/// It is not used directly, but through a [`ProjectMethods`] instance.
14106///
14107/// # Example
14108///
14109/// Instantiate a resource method builder
14110///
14111/// ```test_harness,no_run
14112/// # extern crate hyper;
14113/// # extern crate hyper_rustls;
14114/// # extern crate google_cloudkms1 as cloudkms1;
14115/// # async fn dox() {
14116/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14117///
14118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14120/// # secret,
14121/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14122/// # ).build().await.unwrap();
14123///
14124/// # let client = hyper_util::client::legacy::Client::builder(
14125/// # hyper_util::rt::TokioExecutor::new()
14126/// # )
14127/// # .build(
14128/// # hyper_rustls::HttpsConnectorBuilder::new()
14129/// # .with_native_roots()
14130/// # .unwrap()
14131/// # .https_or_http()
14132/// # .enable_http1()
14133/// # .build()
14134/// # );
14135/// # let mut hub = CloudKMS::new(client, auth);
14136/// // You can configure optional parameters by calling the respective setters at will, and
14137/// // execute the final call using `doit()`.
14138/// // Values shown here are possibly random and not representative !
14139/// let result = hub.projects().locations_key_rings_crypto_keys_get("name")
14140/// .doit().await;
14141/// # }
14142/// ```
14143pub struct ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
14144where
14145 C: 'a,
14146{
14147 hub: &'a CloudKMS<C>,
14148 _name: String,
14149 _delegate: Option<&'a mut dyn common::Delegate>,
14150 _additional_params: HashMap<String, String>,
14151 _scopes: BTreeSet<String>,
14152}
14153
14154impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {}
14155
14156impl<'a, C> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
14157where
14158 C: common::Connector,
14159{
14160 /// Perform the operation you have build so far.
14161 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
14162 use std::borrow::Cow;
14163 use std::io::{Read, Seek};
14164
14165 use common::{url::Params, ToParts};
14166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14167
14168 let mut dd = common::DefaultDelegate;
14169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14170 dlg.begin(common::MethodInfo {
14171 id: "cloudkms.projects.locations.keyRings.cryptoKeys.get",
14172 http_method: hyper::Method::GET,
14173 });
14174
14175 for &field in ["alt", "name"].iter() {
14176 if self._additional_params.contains_key(field) {
14177 dlg.finished(false);
14178 return Err(common::Error::FieldClash(field));
14179 }
14180 }
14181
14182 let mut params = Params::with_capacity(3 + self._additional_params.len());
14183 params.push("name", self._name);
14184
14185 params.extend(self._additional_params.iter());
14186
14187 params.push("alt", "json");
14188 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14189 if self._scopes.is_empty() {
14190 self._scopes
14191 .insert(Scope::CloudPlatform.as_ref().to_string());
14192 }
14193
14194 #[allow(clippy::single_element_loop)]
14195 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14196 url = params.uri_replacement(url, param_name, find_this, true);
14197 }
14198 {
14199 let to_remove = ["name"];
14200 params.remove_params(&to_remove);
14201 }
14202
14203 let url = params.parse_with_url(&url);
14204
14205 loop {
14206 let token = match self
14207 .hub
14208 .auth
14209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14210 .await
14211 {
14212 Ok(token) => token,
14213 Err(e) => match dlg.token(e) {
14214 Ok(token) => token,
14215 Err(e) => {
14216 dlg.finished(false);
14217 return Err(common::Error::MissingToken(e));
14218 }
14219 },
14220 };
14221 let mut req_result = {
14222 let client = &self.hub.client;
14223 dlg.pre_request();
14224 let mut req_builder = hyper::Request::builder()
14225 .method(hyper::Method::GET)
14226 .uri(url.as_str())
14227 .header(USER_AGENT, self.hub._user_agent.clone());
14228
14229 if let Some(token) = token.as_ref() {
14230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14231 }
14232
14233 let request = req_builder
14234 .header(CONTENT_LENGTH, 0_u64)
14235 .body(common::to_body::<String>(None));
14236
14237 client.request(request.unwrap()).await
14238 };
14239
14240 match req_result {
14241 Err(err) => {
14242 if let common::Retry::After(d) = dlg.http_error(&err) {
14243 sleep(d).await;
14244 continue;
14245 }
14246 dlg.finished(false);
14247 return Err(common::Error::HttpError(err));
14248 }
14249 Ok(res) => {
14250 let (mut parts, body) = res.into_parts();
14251 let mut body = common::Body::new(body);
14252 if !parts.status.is_success() {
14253 let bytes = common::to_bytes(body).await.unwrap_or_default();
14254 let error = serde_json::from_str(&common::to_string(&bytes));
14255 let response = common::to_response(parts, bytes.into());
14256
14257 if let common::Retry::After(d) =
14258 dlg.http_failure(&response, error.as_ref().ok())
14259 {
14260 sleep(d).await;
14261 continue;
14262 }
14263
14264 dlg.finished(false);
14265
14266 return Err(match error {
14267 Ok(value) => common::Error::BadRequest(value),
14268 _ => common::Error::Failure(response),
14269 });
14270 }
14271 let response = {
14272 let bytes = common::to_bytes(body).await.unwrap_or_default();
14273 let encoded = common::to_string(&bytes);
14274 match serde_json::from_str(&encoded) {
14275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14276 Err(error) => {
14277 dlg.response_json_decode_error(&encoded, &error);
14278 return Err(common::Error::JsonDecodeError(
14279 encoded.to_string(),
14280 error,
14281 ));
14282 }
14283 }
14284 };
14285
14286 dlg.finished(true);
14287 return Ok(response);
14288 }
14289 }
14290 }
14291 }
14292
14293 /// Required. The name of the CryptoKey to get.
14294 ///
14295 /// Sets the *name* path property to the given value.
14296 ///
14297 /// Even though the property as already been set when instantiating this call,
14298 /// we provide this method for API completeness.
14299 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
14300 self._name = new_value.to_string();
14301 self
14302 }
14303 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14304 /// while executing the actual API request.
14305 ///
14306 /// ````text
14307 /// It should be used to handle progress information, and to implement a certain level of resilience.
14308 /// ````
14309 ///
14310 /// Sets the *delegate* property to the given value.
14311 pub fn delegate(
14312 mut self,
14313 new_value: &'a mut dyn common::Delegate,
14314 ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
14315 self._delegate = Some(new_value);
14316 self
14317 }
14318
14319 /// Set any additional parameter of the query string used in the request.
14320 /// It should be used to set parameters which are not yet available through their own
14321 /// setters.
14322 ///
14323 /// Please note that this method must not be used to set any of the known parameters
14324 /// which have their own setter method. If done anyway, the request will fail.
14325 ///
14326 /// # Additional Parameters
14327 ///
14328 /// * *$.xgafv* (query-string) - V1 error format.
14329 /// * *access_token* (query-string) - OAuth access token.
14330 /// * *alt* (query-string) - Data format for response.
14331 /// * *callback* (query-string) - JSONP
14332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14333 /// * *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.
14334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14336 /// * *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.
14337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14339 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
14340 where
14341 T: AsRef<str>,
14342 {
14343 self._additional_params
14344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14345 self
14346 }
14347
14348 /// Identifies the authorization scope for the method you are building.
14349 ///
14350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14351 /// [`Scope::CloudPlatform`].
14352 ///
14353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14354 /// tokens for more than one scope.
14355 ///
14356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14358 /// sufficient, a read-write scope will do as well.
14359 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
14360 where
14361 St: AsRef<str>,
14362 {
14363 self._scopes.insert(String::from(scope.as_ref()));
14364 self
14365 }
14366 /// Identifies the authorization scope(s) for the method you are building.
14367 ///
14368 /// See [`Self::add_scope()`] for details.
14369 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
14370 where
14371 I: IntoIterator<Item = St>,
14372 St: AsRef<str>,
14373 {
14374 self._scopes
14375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14376 self
14377 }
14378
14379 /// Removes all scopes, and no default scope will be used either.
14380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14381 /// for details).
14382 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
14383 self._scopes.clear();
14384 self
14385 }
14386}
14387
14388/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
14389///
14390/// A builder for the *locations.keyRings.cryptoKeys.getIamPolicy* method supported by a *project* resource.
14391/// It is not used directly, but through a [`ProjectMethods`] instance.
14392///
14393/// # Example
14394///
14395/// Instantiate a resource method builder
14396///
14397/// ```test_harness,no_run
14398/// # extern crate hyper;
14399/// # extern crate hyper_rustls;
14400/// # extern crate google_cloudkms1 as cloudkms1;
14401/// # async fn dox() {
14402/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14403///
14404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14405/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14406/// # secret,
14407/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14408/// # ).build().await.unwrap();
14409///
14410/// # let client = hyper_util::client::legacy::Client::builder(
14411/// # hyper_util::rt::TokioExecutor::new()
14412/// # )
14413/// # .build(
14414/// # hyper_rustls::HttpsConnectorBuilder::new()
14415/// # .with_native_roots()
14416/// # .unwrap()
14417/// # .https_or_http()
14418/// # .enable_http1()
14419/// # .build()
14420/// # );
14421/// # let mut hub = CloudKMS::new(client, auth);
14422/// // You can configure optional parameters by calling the respective setters at will, and
14423/// // execute the final call using `doit()`.
14424/// // Values shown here are possibly random and not representative !
14425/// let result = hub.projects().locations_key_rings_crypto_keys_get_iam_policy("resource")
14426/// .options_requested_policy_version(-15)
14427/// .doit().await;
14428/// # }
14429/// ```
14430pub struct ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
14431where
14432 C: 'a,
14433{
14434 hub: &'a CloudKMS<C>,
14435 _resource: String,
14436 _options_requested_policy_version: Option<i32>,
14437 _delegate: Option<&'a mut dyn common::Delegate>,
14438 _additional_params: HashMap<String, String>,
14439 _scopes: BTreeSet<String>,
14440}
14441
14442impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {}
14443
14444impl<'a, C> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
14445where
14446 C: common::Connector,
14447{
14448 /// Perform the operation you have build so far.
14449 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
14450 use std::borrow::Cow;
14451 use std::io::{Read, Seek};
14452
14453 use common::{url::Params, ToParts};
14454 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14455
14456 let mut dd = common::DefaultDelegate;
14457 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14458 dlg.begin(common::MethodInfo {
14459 id: "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy",
14460 http_method: hyper::Method::GET,
14461 });
14462
14463 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
14464 if self._additional_params.contains_key(field) {
14465 dlg.finished(false);
14466 return Err(common::Error::FieldClash(field));
14467 }
14468 }
14469
14470 let mut params = Params::with_capacity(4 + self._additional_params.len());
14471 params.push("resource", self._resource);
14472 if let Some(value) = self._options_requested_policy_version.as_ref() {
14473 params.push("options.requestedPolicyVersion", value.to_string());
14474 }
14475
14476 params.extend(self._additional_params.iter());
14477
14478 params.push("alt", "json");
14479 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
14480 if self._scopes.is_empty() {
14481 self._scopes
14482 .insert(Scope::CloudPlatform.as_ref().to_string());
14483 }
14484
14485 #[allow(clippy::single_element_loop)]
14486 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14487 url = params.uri_replacement(url, param_name, find_this, true);
14488 }
14489 {
14490 let to_remove = ["resource"];
14491 params.remove_params(&to_remove);
14492 }
14493
14494 let url = params.parse_with_url(&url);
14495
14496 loop {
14497 let token = match self
14498 .hub
14499 .auth
14500 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14501 .await
14502 {
14503 Ok(token) => token,
14504 Err(e) => match dlg.token(e) {
14505 Ok(token) => token,
14506 Err(e) => {
14507 dlg.finished(false);
14508 return Err(common::Error::MissingToken(e));
14509 }
14510 },
14511 };
14512 let mut req_result = {
14513 let client = &self.hub.client;
14514 dlg.pre_request();
14515 let mut req_builder = hyper::Request::builder()
14516 .method(hyper::Method::GET)
14517 .uri(url.as_str())
14518 .header(USER_AGENT, self.hub._user_agent.clone());
14519
14520 if let Some(token) = token.as_ref() {
14521 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14522 }
14523
14524 let request = req_builder
14525 .header(CONTENT_LENGTH, 0_u64)
14526 .body(common::to_body::<String>(None));
14527
14528 client.request(request.unwrap()).await
14529 };
14530
14531 match req_result {
14532 Err(err) => {
14533 if let common::Retry::After(d) = dlg.http_error(&err) {
14534 sleep(d).await;
14535 continue;
14536 }
14537 dlg.finished(false);
14538 return Err(common::Error::HttpError(err));
14539 }
14540 Ok(res) => {
14541 let (mut parts, body) = res.into_parts();
14542 let mut body = common::Body::new(body);
14543 if !parts.status.is_success() {
14544 let bytes = common::to_bytes(body).await.unwrap_or_default();
14545 let error = serde_json::from_str(&common::to_string(&bytes));
14546 let response = common::to_response(parts, bytes.into());
14547
14548 if let common::Retry::After(d) =
14549 dlg.http_failure(&response, error.as_ref().ok())
14550 {
14551 sleep(d).await;
14552 continue;
14553 }
14554
14555 dlg.finished(false);
14556
14557 return Err(match error {
14558 Ok(value) => common::Error::BadRequest(value),
14559 _ => common::Error::Failure(response),
14560 });
14561 }
14562 let response = {
14563 let bytes = common::to_bytes(body).await.unwrap_or_default();
14564 let encoded = common::to_string(&bytes);
14565 match serde_json::from_str(&encoded) {
14566 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14567 Err(error) => {
14568 dlg.response_json_decode_error(&encoded, &error);
14569 return Err(common::Error::JsonDecodeError(
14570 encoded.to_string(),
14571 error,
14572 ));
14573 }
14574 }
14575 };
14576
14577 dlg.finished(true);
14578 return Ok(response);
14579 }
14580 }
14581 }
14582 }
14583
14584 /// 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.
14585 ///
14586 /// Sets the *resource* path property to the given value.
14587 ///
14588 /// Even though the property as already been set when instantiating this call,
14589 /// we provide this method for API completeness.
14590 pub fn resource(
14591 mut self,
14592 new_value: &str,
14593 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
14594 self._resource = new_value.to_string();
14595 self
14596 }
14597 /// 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).
14598 ///
14599 /// Sets the *options.requested policy version* query property to the given value.
14600 pub fn options_requested_policy_version(
14601 mut self,
14602 new_value: i32,
14603 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
14604 self._options_requested_policy_version = Some(new_value);
14605 self
14606 }
14607 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14608 /// while executing the actual API request.
14609 ///
14610 /// ````text
14611 /// It should be used to handle progress information, and to implement a certain level of resilience.
14612 /// ````
14613 ///
14614 /// Sets the *delegate* property to the given value.
14615 pub fn delegate(
14616 mut self,
14617 new_value: &'a mut dyn common::Delegate,
14618 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
14619 self._delegate = Some(new_value);
14620 self
14621 }
14622
14623 /// Set any additional parameter of the query string used in the request.
14624 /// It should be used to set parameters which are not yet available through their own
14625 /// setters.
14626 ///
14627 /// Please note that this method must not be used to set any of the known parameters
14628 /// which have their own setter method. If done anyway, the request will fail.
14629 ///
14630 /// # Additional Parameters
14631 ///
14632 /// * *$.xgafv* (query-string) - V1 error format.
14633 /// * *access_token* (query-string) - OAuth access token.
14634 /// * *alt* (query-string) - Data format for response.
14635 /// * *callback* (query-string) - JSONP
14636 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14637 /// * *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.
14638 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14639 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14640 /// * *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.
14641 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14642 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14643 pub fn param<T>(
14644 mut self,
14645 name: T,
14646 value: T,
14647 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
14648 where
14649 T: AsRef<str>,
14650 {
14651 self._additional_params
14652 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14653 self
14654 }
14655
14656 /// Identifies the authorization scope for the method you are building.
14657 ///
14658 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14659 /// [`Scope::CloudPlatform`].
14660 ///
14661 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14662 /// tokens for more than one scope.
14663 ///
14664 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14665 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14666 /// sufficient, a read-write scope will do as well.
14667 pub fn add_scope<St>(
14668 mut self,
14669 scope: St,
14670 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
14671 where
14672 St: AsRef<str>,
14673 {
14674 self._scopes.insert(String::from(scope.as_ref()));
14675 self
14676 }
14677 /// Identifies the authorization scope(s) for the method you are building.
14678 ///
14679 /// See [`Self::add_scope()`] for details.
14680 pub fn add_scopes<I, St>(
14681 mut self,
14682 scopes: I,
14683 ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
14684 where
14685 I: IntoIterator<Item = St>,
14686 St: AsRef<str>,
14687 {
14688 self._scopes
14689 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14690 self
14691 }
14692
14693 /// Removes all scopes, and no default scope will be used either.
14694 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14695 /// for details).
14696 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
14697 self._scopes.clear();
14698 self
14699 }
14700}
14701
14702/// Lists CryptoKeys.
14703///
14704/// A builder for the *locations.keyRings.cryptoKeys.list* method supported by a *project* resource.
14705/// It is not used directly, but through a [`ProjectMethods`] instance.
14706///
14707/// # Example
14708///
14709/// Instantiate a resource method builder
14710///
14711/// ```test_harness,no_run
14712/// # extern crate hyper;
14713/// # extern crate hyper_rustls;
14714/// # extern crate google_cloudkms1 as cloudkms1;
14715/// # async fn dox() {
14716/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14717///
14718/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14720/// # secret,
14721/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14722/// # ).build().await.unwrap();
14723///
14724/// # let client = hyper_util::client::legacy::Client::builder(
14725/// # hyper_util::rt::TokioExecutor::new()
14726/// # )
14727/// # .build(
14728/// # hyper_rustls::HttpsConnectorBuilder::new()
14729/// # .with_native_roots()
14730/// # .unwrap()
14731/// # .https_or_http()
14732/// # .enable_http1()
14733/// # .build()
14734/// # );
14735/// # let mut hub = CloudKMS::new(client, auth);
14736/// // You can configure optional parameters by calling the respective setters at will, and
14737/// // execute the final call using `doit()`.
14738/// // Values shown here are possibly random and not representative !
14739/// let result = hub.projects().locations_key_rings_crypto_keys_list("parent")
14740/// .version_view("duo")
14741/// .page_token("vero")
14742/// .page_size(-76)
14743/// .order_by("invidunt")
14744/// .filter("Stet")
14745/// .doit().await;
14746/// # }
14747/// ```
14748pub struct ProjectLocationKeyRingCryptoKeyListCall<'a, C>
14749where
14750 C: 'a,
14751{
14752 hub: &'a CloudKMS<C>,
14753 _parent: String,
14754 _version_view: Option<String>,
14755 _page_token: Option<String>,
14756 _page_size: Option<i32>,
14757 _order_by: Option<String>,
14758 _filter: Option<String>,
14759 _delegate: Option<&'a mut dyn common::Delegate>,
14760 _additional_params: HashMap<String, String>,
14761 _scopes: BTreeSet<String>,
14762}
14763
14764impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyListCall<'a, C> {}
14765
14766impl<'a, C> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
14767where
14768 C: common::Connector,
14769{
14770 /// Perform the operation you have build so far.
14771 pub async fn doit(mut self) -> common::Result<(common::Response, ListCryptoKeysResponse)> {
14772 use std::borrow::Cow;
14773 use std::io::{Read, Seek};
14774
14775 use common::{url::Params, ToParts};
14776 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14777
14778 let mut dd = common::DefaultDelegate;
14779 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14780 dlg.begin(common::MethodInfo {
14781 id: "cloudkms.projects.locations.keyRings.cryptoKeys.list",
14782 http_method: hyper::Method::GET,
14783 });
14784
14785 for &field in [
14786 "alt",
14787 "parent",
14788 "versionView",
14789 "pageToken",
14790 "pageSize",
14791 "orderBy",
14792 "filter",
14793 ]
14794 .iter()
14795 {
14796 if self._additional_params.contains_key(field) {
14797 dlg.finished(false);
14798 return Err(common::Error::FieldClash(field));
14799 }
14800 }
14801
14802 let mut params = Params::with_capacity(8 + self._additional_params.len());
14803 params.push("parent", self._parent);
14804 if let Some(value) = self._version_view.as_ref() {
14805 params.push("versionView", value);
14806 }
14807 if let Some(value) = self._page_token.as_ref() {
14808 params.push("pageToken", value);
14809 }
14810 if let Some(value) = self._page_size.as_ref() {
14811 params.push("pageSize", value.to_string());
14812 }
14813 if let Some(value) = self._order_by.as_ref() {
14814 params.push("orderBy", value);
14815 }
14816 if let Some(value) = self._filter.as_ref() {
14817 params.push("filter", value);
14818 }
14819
14820 params.extend(self._additional_params.iter());
14821
14822 params.push("alt", "json");
14823 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeys";
14824 if self._scopes.is_empty() {
14825 self._scopes
14826 .insert(Scope::CloudPlatform.as_ref().to_string());
14827 }
14828
14829 #[allow(clippy::single_element_loop)]
14830 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14831 url = params.uri_replacement(url, param_name, find_this, true);
14832 }
14833 {
14834 let to_remove = ["parent"];
14835 params.remove_params(&to_remove);
14836 }
14837
14838 let url = params.parse_with_url(&url);
14839
14840 loop {
14841 let token = match self
14842 .hub
14843 .auth
14844 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14845 .await
14846 {
14847 Ok(token) => token,
14848 Err(e) => match dlg.token(e) {
14849 Ok(token) => token,
14850 Err(e) => {
14851 dlg.finished(false);
14852 return Err(common::Error::MissingToken(e));
14853 }
14854 },
14855 };
14856 let mut req_result = {
14857 let client = &self.hub.client;
14858 dlg.pre_request();
14859 let mut req_builder = hyper::Request::builder()
14860 .method(hyper::Method::GET)
14861 .uri(url.as_str())
14862 .header(USER_AGENT, self.hub._user_agent.clone());
14863
14864 if let Some(token) = token.as_ref() {
14865 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14866 }
14867
14868 let request = req_builder
14869 .header(CONTENT_LENGTH, 0_u64)
14870 .body(common::to_body::<String>(None));
14871
14872 client.request(request.unwrap()).await
14873 };
14874
14875 match req_result {
14876 Err(err) => {
14877 if let common::Retry::After(d) = dlg.http_error(&err) {
14878 sleep(d).await;
14879 continue;
14880 }
14881 dlg.finished(false);
14882 return Err(common::Error::HttpError(err));
14883 }
14884 Ok(res) => {
14885 let (mut parts, body) = res.into_parts();
14886 let mut body = common::Body::new(body);
14887 if !parts.status.is_success() {
14888 let bytes = common::to_bytes(body).await.unwrap_or_default();
14889 let error = serde_json::from_str(&common::to_string(&bytes));
14890 let response = common::to_response(parts, bytes.into());
14891
14892 if let common::Retry::After(d) =
14893 dlg.http_failure(&response, error.as_ref().ok())
14894 {
14895 sleep(d).await;
14896 continue;
14897 }
14898
14899 dlg.finished(false);
14900
14901 return Err(match error {
14902 Ok(value) => common::Error::BadRequest(value),
14903 _ => common::Error::Failure(response),
14904 });
14905 }
14906 let response = {
14907 let bytes = common::to_bytes(body).await.unwrap_or_default();
14908 let encoded = common::to_string(&bytes);
14909 match serde_json::from_str(&encoded) {
14910 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14911 Err(error) => {
14912 dlg.response_json_decode_error(&encoded, &error);
14913 return Err(common::Error::JsonDecodeError(
14914 encoded.to_string(),
14915 error,
14916 ));
14917 }
14918 }
14919 };
14920
14921 dlg.finished(true);
14922 return Ok(response);
14923 }
14924 }
14925 }
14926 }
14927
14928 /// Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
14929 ///
14930 /// Sets the *parent* path property to the given value.
14931 ///
14932 /// Even though the property as already been set when instantiating this call,
14933 /// we provide this method for API completeness.
14934 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14935 self._parent = new_value.to_string();
14936 self
14937 }
14938 /// The fields of the primary version to include in the response.
14939 ///
14940 /// Sets the *version view* query property to the given value.
14941 pub fn version_view(
14942 mut self,
14943 new_value: &str,
14944 ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14945 self._version_view = Some(new_value.to_string());
14946 self
14947 }
14948 /// Optional. Optional pagination token, returned earlier via ListCryptoKeysResponse.next_page_token.
14949 ///
14950 /// Sets the *page token* query property to the given value.
14951 pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14952 self._page_token = Some(new_value.to_string());
14953 self
14954 }
14955 /// 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.
14956 ///
14957 /// Sets the *page size* query property to the given value.
14958 pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14959 self._page_size = Some(new_value);
14960 self
14961 }
14962 /// 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).
14963 ///
14964 /// Sets the *order by* query property to the given value.
14965 pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14966 self._order_by = Some(new_value.to_string());
14967 self
14968 }
14969 /// 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).
14970 ///
14971 /// Sets the *filter* query property to the given value.
14972 pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14973 self._filter = Some(new_value.to_string());
14974 self
14975 }
14976 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14977 /// while executing the actual API request.
14978 ///
14979 /// ````text
14980 /// It should be used to handle progress information, and to implement a certain level of resilience.
14981 /// ````
14982 ///
14983 /// Sets the *delegate* property to the given value.
14984 pub fn delegate(
14985 mut self,
14986 new_value: &'a mut dyn common::Delegate,
14987 ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
14988 self._delegate = Some(new_value);
14989 self
14990 }
14991
14992 /// Set any additional parameter of the query string used in the request.
14993 /// It should be used to set parameters which are not yet available through their own
14994 /// setters.
14995 ///
14996 /// Please note that this method must not be used to set any of the known parameters
14997 /// which have their own setter method. If done anyway, the request will fail.
14998 ///
14999 /// # Additional Parameters
15000 ///
15001 /// * *$.xgafv* (query-string) - V1 error format.
15002 /// * *access_token* (query-string) - OAuth access token.
15003 /// * *alt* (query-string) - Data format for response.
15004 /// * *callback* (query-string) - JSONP
15005 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15006 /// * *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.
15007 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15008 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15009 /// * *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.
15010 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15011 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15012 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
15013 where
15014 T: AsRef<str>,
15015 {
15016 self._additional_params
15017 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15018 self
15019 }
15020
15021 /// Identifies the authorization scope for the method you are building.
15022 ///
15023 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15024 /// [`Scope::CloudPlatform`].
15025 ///
15026 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15027 /// tokens for more than one scope.
15028 ///
15029 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15030 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15031 /// sufficient, a read-write scope will do as well.
15032 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
15033 where
15034 St: AsRef<str>,
15035 {
15036 self._scopes.insert(String::from(scope.as_ref()));
15037 self
15038 }
15039 /// Identifies the authorization scope(s) for the method you are building.
15040 ///
15041 /// See [`Self::add_scope()`] for details.
15042 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
15043 where
15044 I: IntoIterator<Item = St>,
15045 St: AsRef<str>,
15046 {
15047 self._scopes
15048 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15049 self
15050 }
15051
15052 /// Removes all scopes, and no default scope will be used either.
15053 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15054 /// for details).
15055 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
15056 self._scopes.clear();
15057 self
15058 }
15059}
15060
15061/// Update a CryptoKey.
15062///
15063/// A builder for the *locations.keyRings.cryptoKeys.patch* method supported by a *project* resource.
15064/// It is not used directly, but through a [`ProjectMethods`] instance.
15065///
15066/// # Example
15067///
15068/// Instantiate a resource method builder
15069///
15070/// ```test_harness,no_run
15071/// # extern crate hyper;
15072/// # extern crate hyper_rustls;
15073/// # extern crate google_cloudkms1 as cloudkms1;
15074/// use cloudkms1::api::CryptoKey;
15075/// # async fn dox() {
15076/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15077///
15078/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15079/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15080/// # secret,
15081/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15082/// # ).build().await.unwrap();
15083///
15084/// # let client = hyper_util::client::legacy::Client::builder(
15085/// # hyper_util::rt::TokioExecutor::new()
15086/// # )
15087/// # .build(
15088/// # hyper_rustls::HttpsConnectorBuilder::new()
15089/// # .with_native_roots()
15090/// # .unwrap()
15091/// # .https_or_http()
15092/// # .enable_http1()
15093/// # .build()
15094/// # );
15095/// # let mut hub = CloudKMS::new(client, auth);
15096/// // As the method needs a request, you would usually fill it with the desired information
15097/// // into the respective structure. Some of the parts shown here might not be applicable !
15098/// // Values shown here are possibly random and not representative !
15099/// let mut req = CryptoKey::default();
15100///
15101/// // You can configure optional parameters by calling the respective setters at will, and
15102/// // execute the final call using `doit()`.
15103/// // Values shown here are possibly random and not representative !
15104/// let result = hub.projects().locations_key_rings_crypto_keys_patch(req, "name")
15105/// .update_mask(FieldMask::new::<&str>(&[]))
15106/// .doit().await;
15107/// # }
15108/// ```
15109pub struct ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
15110where
15111 C: 'a,
15112{
15113 hub: &'a CloudKMS<C>,
15114 _request: CryptoKey,
15115 _name: String,
15116 _update_mask: Option<common::FieldMask>,
15117 _delegate: Option<&'a mut dyn common::Delegate>,
15118 _additional_params: HashMap<String, String>,
15119 _scopes: BTreeSet<String>,
15120}
15121
15122impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {}
15123
15124impl<'a, C> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
15125where
15126 C: common::Connector,
15127{
15128 /// Perform the operation you have build so far.
15129 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
15130 use std::borrow::Cow;
15131 use std::io::{Read, Seek};
15132
15133 use common::{url::Params, ToParts};
15134 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15135
15136 let mut dd = common::DefaultDelegate;
15137 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15138 dlg.begin(common::MethodInfo {
15139 id: "cloudkms.projects.locations.keyRings.cryptoKeys.patch",
15140 http_method: hyper::Method::PATCH,
15141 });
15142
15143 for &field in ["alt", "name", "updateMask"].iter() {
15144 if self._additional_params.contains_key(field) {
15145 dlg.finished(false);
15146 return Err(common::Error::FieldClash(field));
15147 }
15148 }
15149
15150 let mut params = Params::with_capacity(5 + self._additional_params.len());
15151 params.push("name", self._name);
15152 if let Some(value) = self._update_mask.as_ref() {
15153 params.push("updateMask", value.to_string());
15154 }
15155
15156 params.extend(self._additional_params.iter());
15157
15158 params.push("alt", "json");
15159 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15160 if self._scopes.is_empty() {
15161 self._scopes
15162 .insert(Scope::CloudPlatform.as_ref().to_string());
15163 }
15164
15165 #[allow(clippy::single_element_loop)]
15166 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15167 url = params.uri_replacement(url, param_name, find_this, true);
15168 }
15169 {
15170 let to_remove = ["name"];
15171 params.remove_params(&to_remove);
15172 }
15173
15174 let url = params.parse_with_url(&url);
15175
15176 let mut json_mime_type = mime::APPLICATION_JSON;
15177 let mut request_value_reader = {
15178 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15179 common::remove_json_null_values(&mut value);
15180 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15181 serde_json::to_writer(&mut dst, &value).unwrap();
15182 dst
15183 };
15184 let request_size = request_value_reader
15185 .seek(std::io::SeekFrom::End(0))
15186 .unwrap();
15187 request_value_reader
15188 .seek(std::io::SeekFrom::Start(0))
15189 .unwrap();
15190
15191 loop {
15192 let token = match self
15193 .hub
15194 .auth
15195 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15196 .await
15197 {
15198 Ok(token) => token,
15199 Err(e) => match dlg.token(e) {
15200 Ok(token) => token,
15201 Err(e) => {
15202 dlg.finished(false);
15203 return Err(common::Error::MissingToken(e));
15204 }
15205 },
15206 };
15207 request_value_reader
15208 .seek(std::io::SeekFrom::Start(0))
15209 .unwrap();
15210 let mut req_result = {
15211 let client = &self.hub.client;
15212 dlg.pre_request();
15213 let mut req_builder = hyper::Request::builder()
15214 .method(hyper::Method::PATCH)
15215 .uri(url.as_str())
15216 .header(USER_AGENT, self.hub._user_agent.clone());
15217
15218 if let Some(token) = token.as_ref() {
15219 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15220 }
15221
15222 let request = req_builder
15223 .header(CONTENT_TYPE, json_mime_type.to_string())
15224 .header(CONTENT_LENGTH, request_size as u64)
15225 .body(common::to_body(
15226 request_value_reader.get_ref().clone().into(),
15227 ));
15228
15229 client.request(request.unwrap()).await
15230 };
15231
15232 match req_result {
15233 Err(err) => {
15234 if let common::Retry::After(d) = dlg.http_error(&err) {
15235 sleep(d).await;
15236 continue;
15237 }
15238 dlg.finished(false);
15239 return Err(common::Error::HttpError(err));
15240 }
15241 Ok(res) => {
15242 let (mut parts, body) = res.into_parts();
15243 let mut body = common::Body::new(body);
15244 if !parts.status.is_success() {
15245 let bytes = common::to_bytes(body).await.unwrap_or_default();
15246 let error = serde_json::from_str(&common::to_string(&bytes));
15247 let response = common::to_response(parts, bytes.into());
15248
15249 if let common::Retry::After(d) =
15250 dlg.http_failure(&response, error.as_ref().ok())
15251 {
15252 sleep(d).await;
15253 continue;
15254 }
15255
15256 dlg.finished(false);
15257
15258 return Err(match error {
15259 Ok(value) => common::Error::BadRequest(value),
15260 _ => common::Error::Failure(response),
15261 });
15262 }
15263 let response = {
15264 let bytes = common::to_bytes(body).await.unwrap_or_default();
15265 let encoded = common::to_string(&bytes);
15266 match serde_json::from_str(&encoded) {
15267 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15268 Err(error) => {
15269 dlg.response_json_decode_error(&encoded, &error);
15270 return Err(common::Error::JsonDecodeError(
15271 encoded.to_string(),
15272 error,
15273 ));
15274 }
15275 }
15276 };
15277
15278 dlg.finished(true);
15279 return Ok(response);
15280 }
15281 }
15282 }
15283 }
15284
15285 ///
15286 /// Sets the *request* property to the given value.
15287 ///
15288 /// Even though the property as already been set when instantiating this call,
15289 /// we provide this method for API completeness.
15290 pub fn request(
15291 mut self,
15292 new_value: CryptoKey,
15293 ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
15294 self._request = new_value;
15295 self
15296 }
15297 /// Output only. The resource name for this CryptoKey in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
15298 ///
15299 /// Sets the *name* path property to the given value.
15300 ///
15301 /// Even though the property as already been set when instantiating this call,
15302 /// we provide this method for API completeness.
15303 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
15304 self._name = new_value.to_string();
15305 self
15306 }
15307 /// Required. List of fields to be updated in this request.
15308 ///
15309 /// Sets the *update mask* query property to the given value.
15310 pub fn update_mask(
15311 mut self,
15312 new_value: common::FieldMask,
15313 ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
15314 self._update_mask = Some(new_value);
15315 self
15316 }
15317 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15318 /// while executing the actual API request.
15319 ///
15320 /// ````text
15321 /// It should be used to handle progress information, and to implement a certain level of resilience.
15322 /// ````
15323 ///
15324 /// Sets the *delegate* property to the given value.
15325 pub fn delegate(
15326 mut self,
15327 new_value: &'a mut dyn common::Delegate,
15328 ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
15329 self._delegate = Some(new_value);
15330 self
15331 }
15332
15333 /// Set any additional parameter of the query string used in the request.
15334 /// It should be used to set parameters which are not yet available through their own
15335 /// setters.
15336 ///
15337 /// Please note that this method must not be used to set any of the known parameters
15338 /// which have their own setter method. If done anyway, the request will fail.
15339 ///
15340 /// # Additional Parameters
15341 ///
15342 /// * *$.xgafv* (query-string) - V1 error format.
15343 /// * *access_token* (query-string) - OAuth access token.
15344 /// * *alt* (query-string) - Data format for response.
15345 /// * *callback* (query-string) - JSONP
15346 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15347 /// * *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.
15348 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15349 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15350 /// * *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.
15351 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15352 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15353 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
15354 where
15355 T: AsRef<str>,
15356 {
15357 self._additional_params
15358 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15359 self
15360 }
15361
15362 /// Identifies the authorization scope for the method you are building.
15363 ///
15364 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15365 /// [`Scope::CloudPlatform`].
15366 ///
15367 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15368 /// tokens for more than one scope.
15369 ///
15370 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15371 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15372 /// sufficient, a read-write scope will do as well.
15373 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
15374 where
15375 St: AsRef<str>,
15376 {
15377 self._scopes.insert(String::from(scope.as_ref()));
15378 self
15379 }
15380 /// Identifies the authorization scope(s) for the method you are building.
15381 ///
15382 /// See [`Self::add_scope()`] for details.
15383 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
15384 where
15385 I: IntoIterator<Item = St>,
15386 St: AsRef<str>,
15387 {
15388 self._scopes
15389 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15390 self
15391 }
15392
15393 /// Removes all scopes, and no default scope will be used either.
15394 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15395 /// for details).
15396 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
15397 self._scopes.clear();
15398 self
15399 }
15400}
15401
15402/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
15403///
15404/// A builder for the *locations.keyRings.cryptoKeys.setIamPolicy* method supported by a *project* resource.
15405/// It is not used directly, but through a [`ProjectMethods`] instance.
15406///
15407/// # Example
15408///
15409/// Instantiate a resource method builder
15410///
15411/// ```test_harness,no_run
15412/// # extern crate hyper;
15413/// # extern crate hyper_rustls;
15414/// # extern crate google_cloudkms1 as cloudkms1;
15415/// use cloudkms1::api::SetIamPolicyRequest;
15416/// # async fn dox() {
15417/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15418///
15419/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15421/// # secret,
15422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15423/// # ).build().await.unwrap();
15424///
15425/// # let client = hyper_util::client::legacy::Client::builder(
15426/// # hyper_util::rt::TokioExecutor::new()
15427/// # )
15428/// # .build(
15429/// # hyper_rustls::HttpsConnectorBuilder::new()
15430/// # .with_native_roots()
15431/// # .unwrap()
15432/// # .https_or_http()
15433/// # .enable_http1()
15434/// # .build()
15435/// # );
15436/// # let mut hub = CloudKMS::new(client, auth);
15437/// // As the method needs a request, you would usually fill it with the desired information
15438/// // into the respective structure. Some of the parts shown here might not be applicable !
15439/// // Values shown here are possibly random and not representative !
15440/// let mut req = SetIamPolicyRequest::default();
15441///
15442/// // You can configure optional parameters by calling the respective setters at will, and
15443/// // execute the final call using `doit()`.
15444/// // Values shown here are possibly random and not representative !
15445/// let result = hub.projects().locations_key_rings_crypto_keys_set_iam_policy(req, "resource")
15446/// .doit().await;
15447/// # }
15448/// ```
15449pub struct ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
15450where
15451 C: 'a,
15452{
15453 hub: &'a CloudKMS<C>,
15454 _request: SetIamPolicyRequest,
15455 _resource: String,
15456 _delegate: Option<&'a mut dyn common::Delegate>,
15457 _additional_params: HashMap<String, String>,
15458 _scopes: BTreeSet<String>,
15459}
15460
15461impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {}
15462
15463impl<'a, C> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
15464where
15465 C: common::Connector,
15466{
15467 /// Perform the operation you have build so far.
15468 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
15469 use std::borrow::Cow;
15470 use std::io::{Read, Seek};
15471
15472 use common::{url::Params, ToParts};
15473 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15474
15475 let mut dd = common::DefaultDelegate;
15476 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15477 dlg.begin(common::MethodInfo {
15478 id: "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy",
15479 http_method: hyper::Method::POST,
15480 });
15481
15482 for &field in ["alt", "resource"].iter() {
15483 if self._additional_params.contains_key(field) {
15484 dlg.finished(false);
15485 return Err(common::Error::FieldClash(field));
15486 }
15487 }
15488
15489 let mut params = Params::with_capacity(4 + self._additional_params.len());
15490 params.push("resource", self._resource);
15491
15492 params.extend(self._additional_params.iter());
15493
15494 params.push("alt", "json");
15495 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
15496 if self._scopes.is_empty() {
15497 self._scopes
15498 .insert(Scope::CloudPlatform.as_ref().to_string());
15499 }
15500
15501 #[allow(clippy::single_element_loop)]
15502 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
15503 url = params.uri_replacement(url, param_name, find_this, true);
15504 }
15505 {
15506 let to_remove = ["resource"];
15507 params.remove_params(&to_remove);
15508 }
15509
15510 let url = params.parse_with_url(&url);
15511
15512 let mut json_mime_type = mime::APPLICATION_JSON;
15513 let mut request_value_reader = {
15514 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15515 common::remove_json_null_values(&mut value);
15516 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15517 serde_json::to_writer(&mut dst, &value).unwrap();
15518 dst
15519 };
15520 let request_size = request_value_reader
15521 .seek(std::io::SeekFrom::End(0))
15522 .unwrap();
15523 request_value_reader
15524 .seek(std::io::SeekFrom::Start(0))
15525 .unwrap();
15526
15527 loop {
15528 let token = match self
15529 .hub
15530 .auth
15531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15532 .await
15533 {
15534 Ok(token) => token,
15535 Err(e) => match dlg.token(e) {
15536 Ok(token) => token,
15537 Err(e) => {
15538 dlg.finished(false);
15539 return Err(common::Error::MissingToken(e));
15540 }
15541 },
15542 };
15543 request_value_reader
15544 .seek(std::io::SeekFrom::Start(0))
15545 .unwrap();
15546 let mut req_result = {
15547 let client = &self.hub.client;
15548 dlg.pre_request();
15549 let mut req_builder = hyper::Request::builder()
15550 .method(hyper::Method::POST)
15551 .uri(url.as_str())
15552 .header(USER_AGENT, self.hub._user_agent.clone());
15553
15554 if let Some(token) = token.as_ref() {
15555 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15556 }
15557
15558 let request = req_builder
15559 .header(CONTENT_TYPE, json_mime_type.to_string())
15560 .header(CONTENT_LENGTH, request_size as u64)
15561 .body(common::to_body(
15562 request_value_reader.get_ref().clone().into(),
15563 ));
15564
15565 client.request(request.unwrap()).await
15566 };
15567
15568 match req_result {
15569 Err(err) => {
15570 if let common::Retry::After(d) = dlg.http_error(&err) {
15571 sleep(d).await;
15572 continue;
15573 }
15574 dlg.finished(false);
15575 return Err(common::Error::HttpError(err));
15576 }
15577 Ok(res) => {
15578 let (mut parts, body) = res.into_parts();
15579 let mut body = common::Body::new(body);
15580 if !parts.status.is_success() {
15581 let bytes = common::to_bytes(body).await.unwrap_or_default();
15582 let error = serde_json::from_str(&common::to_string(&bytes));
15583 let response = common::to_response(parts, bytes.into());
15584
15585 if let common::Retry::After(d) =
15586 dlg.http_failure(&response, error.as_ref().ok())
15587 {
15588 sleep(d).await;
15589 continue;
15590 }
15591
15592 dlg.finished(false);
15593
15594 return Err(match error {
15595 Ok(value) => common::Error::BadRequest(value),
15596 _ => common::Error::Failure(response),
15597 });
15598 }
15599 let response = {
15600 let bytes = common::to_bytes(body).await.unwrap_or_default();
15601 let encoded = common::to_string(&bytes);
15602 match serde_json::from_str(&encoded) {
15603 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15604 Err(error) => {
15605 dlg.response_json_decode_error(&encoded, &error);
15606 return Err(common::Error::JsonDecodeError(
15607 encoded.to_string(),
15608 error,
15609 ));
15610 }
15611 }
15612 };
15613
15614 dlg.finished(true);
15615 return Ok(response);
15616 }
15617 }
15618 }
15619 }
15620
15621 ///
15622 /// Sets the *request* property to the given value.
15623 ///
15624 /// Even though the property as already been set when instantiating this call,
15625 /// we provide this method for API completeness.
15626 pub fn request(
15627 mut self,
15628 new_value: SetIamPolicyRequest,
15629 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
15630 self._request = new_value;
15631 self
15632 }
15633 /// 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.
15634 ///
15635 /// Sets the *resource* path property to the given value.
15636 ///
15637 /// Even though the property as already been set when instantiating this call,
15638 /// we provide this method for API completeness.
15639 pub fn resource(
15640 mut self,
15641 new_value: &str,
15642 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
15643 self._resource = new_value.to_string();
15644 self
15645 }
15646 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15647 /// while executing the actual API request.
15648 ///
15649 /// ````text
15650 /// It should be used to handle progress information, and to implement a certain level of resilience.
15651 /// ````
15652 ///
15653 /// Sets the *delegate* property to the given value.
15654 pub fn delegate(
15655 mut self,
15656 new_value: &'a mut dyn common::Delegate,
15657 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
15658 self._delegate = Some(new_value);
15659 self
15660 }
15661
15662 /// Set any additional parameter of the query string used in the request.
15663 /// It should be used to set parameters which are not yet available through their own
15664 /// setters.
15665 ///
15666 /// Please note that this method must not be used to set any of the known parameters
15667 /// which have their own setter method. If done anyway, the request will fail.
15668 ///
15669 /// # Additional Parameters
15670 ///
15671 /// * *$.xgafv* (query-string) - V1 error format.
15672 /// * *access_token* (query-string) - OAuth access token.
15673 /// * *alt* (query-string) - Data format for response.
15674 /// * *callback* (query-string) - JSONP
15675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15676 /// * *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.
15677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15679 /// * *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.
15680 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15681 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15682 pub fn param<T>(
15683 mut self,
15684 name: T,
15685 value: T,
15686 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
15687 where
15688 T: AsRef<str>,
15689 {
15690 self._additional_params
15691 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15692 self
15693 }
15694
15695 /// Identifies the authorization scope for the method you are building.
15696 ///
15697 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15698 /// [`Scope::CloudPlatform`].
15699 ///
15700 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15701 /// tokens for more than one scope.
15702 ///
15703 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15704 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15705 /// sufficient, a read-write scope will do as well.
15706 pub fn add_scope<St>(
15707 mut self,
15708 scope: St,
15709 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
15710 where
15711 St: AsRef<str>,
15712 {
15713 self._scopes.insert(String::from(scope.as_ref()));
15714 self
15715 }
15716 /// Identifies the authorization scope(s) for the method you are building.
15717 ///
15718 /// See [`Self::add_scope()`] for details.
15719 pub fn add_scopes<I, St>(
15720 mut self,
15721 scopes: I,
15722 ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
15723 where
15724 I: IntoIterator<Item = St>,
15725 St: AsRef<str>,
15726 {
15727 self._scopes
15728 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15729 self
15730 }
15731
15732 /// Removes all scopes, and no default scope will be used either.
15733 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15734 /// for details).
15735 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
15736 self._scopes.clear();
15737 self
15738 }
15739}
15740
15741/// 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.
15742///
15743/// A builder for the *locations.keyRings.cryptoKeys.testIamPermissions* method supported by a *project* resource.
15744/// It is not used directly, but through a [`ProjectMethods`] instance.
15745///
15746/// # Example
15747///
15748/// Instantiate a resource method builder
15749///
15750/// ```test_harness,no_run
15751/// # extern crate hyper;
15752/// # extern crate hyper_rustls;
15753/// # extern crate google_cloudkms1 as cloudkms1;
15754/// use cloudkms1::api::TestIamPermissionsRequest;
15755/// # async fn dox() {
15756/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15757///
15758/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15760/// # secret,
15761/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15762/// # ).build().await.unwrap();
15763///
15764/// # let client = hyper_util::client::legacy::Client::builder(
15765/// # hyper_util::rt::TokioExecutor::new()
15766/// # )
15767/// # .build(
15768/// # hyper_rustls::HttpsConnectorBuilder::new()
15769/// # .with_native_roots()
15770/// # .unwrap()
15771/// # .https_or_http()
15772/// # .enable_http1()
15773/// # .build()
15774/// # );
15775/// # let mut hub = CloudKMS::new(client, auth);
15776/// // As the method needs a request, you would usually fill it with the desired information
15777/// // into the respective structure. Some of the parts shown here might not be applicable !
15778/// // Values shown here are possibly random and not representative !
15779/// let mut req = TestIamPermissionsRequest::default();
15780///
15781/// // You can configure optional parameters by calling the respective setters at will, and
15782/// // execute the final call using `doit()`.
15783/// // Values shown here are possibly random and not representative !
15784/// let result = hub.projects().locations_key_rings_crypto_keys_test_iam_permissions(req, "resource")
15785/// .doit().await;
15786/// # }
15787/// ```
15788pub struct ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
15789where
15790 C: 'a,
15791{
15792 hub: &'a CloudKMS<C>,
15793 _request: TestIamPermissionsRequest,
15794 _resource: String,
15795 _delegate: Option<&'a mut dyn common::Delegate>,
15796 _additional_params: HashMap<String, String>,
15797 _scopes: BTreeSet<String>,
15798}
15799
15800impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {}
15801
15802impl<'a, C> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
15803where
15804 C: common::Connector,
15805{
15806 /// Perform the operation you have build so far.
15807 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
15808 use std::borrow::Cow;
15809 use std::io::{Read, Seek};
15810
15811 use common::{url::Params, ToParts};
15812 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15813
15814 let mut dd = common::DefaultDelegate;
15815 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15816 dlg.begin(common::MethodInfo {
15817 id: "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions",
15818 http_method: hyper::Method::POST,
15819 });
15820
15821 for &field in ["alt", "resource"].iter() {
15822 if self._additional_params.contains_key(field) {
15823 dlg.finished(false);
15824 return Err(common::Error::FieldClash(field));
15825 }
15826 }
15827
15828 let mut params = Params::with_capacity(4 + self._additional_params.len());
15829 params.push("resource", self._resource);
15830
15831 params.extend(self._additional_params.iter());
15832
15833 params.push("alt", "json");
15834 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
15835 if self._scopes.is_empty() {
15836 self._scopes
15837 .insert(Scope::CloudPlatform.as_ref().to_string());
15838 }
15839
15840 #[allow(clippy::single_element_loop)]
15841 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
15842 url = params.uri_replacement(url, param_name, find_this, true);
15843 }
15844 {
15845 let to_remove = ["resource"];
15846 params.remove_params(&to_remove);
15847 }
15848
15849 let url = params.parse_with_url(&url);
15850
15851 let mut json_mime_type = mime::APPLICATION_JSON;
15852 let mut request_value_reader = {
15853 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15854 common::remove_json_null_values(&mut value);
15855 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15856 serde_json::to_writer(&mut dst, &value).unwrap();
15857 dst
15858 };
15859 let request_size = request_value_reader
15860 .seek(std::io::SeekFrom::End(0))
15861 .unwrap();
15862 request_value_reader
15863 .seek(std::io::SeekFrom::Start(0))
15864 .unwrap();
15865
15866 loop {
15867 let token = match self
15868 .hub
15869 .auth
15870 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15871 .await
15872 {
15873 Ok(token) => token,
15874 Err(e) => match dlg.token(e) {
15875 Ok(token) => token,
15876 Err(e) => {
15877 dlg.finished(false);
15878 return Err(common::Error::MissingToken(e));
15879 }
15880 },
15881 };
15882 request_value_reader
15883 .seek(std::io::SeekFrom::Start(0))
15884 .unwrap();
15885 let mut req_result = {
15886 let client = &self.hub.client;
15887 dlg.pre_request();
15888 let mut req_builder = hyper::Request::builder()
15889 .method(hyper::Method::POST)
15890 .uri(url.as_str())
15891 .header(USER_AGENT, self.hub._user_agent.clone());
15892
15893 if let Some(token) = token.as_ref() {
15894 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15895 }
15896
15897 let request = req_builder
15898 .header(CONTENT_TYPE, json_mime_type.to_string())
15899 .header(CONTENT_LENGTH, request_size as u64)
15900 .body(common::to_body(
15901 request_value_reader.get_ref().clone().into(),
15902 ));
15903
15904 client.request(request.unwrap()).await
15905 };
15906
15907 match req_result {
15908 Err(err) => {
15909 if let common::Retry::After(d) = dlg.http_error(&err) {
15910 sleep(d).await;
15911 continue;
15912 }
15913 dlg.finished(false);
15914 return Err(common::Error::HttpError(err));
15915 }
15916 Ok(res) => {
15917 let (mut parts, body) = res.into_parts();
15918 let mut body = common::Body::new(body);
15919 if !parts.status.is_success() {
15920 let bytes = common::to_bytes(body).await.unwrap_or_default();
15921 let error = serde_json::from_str(&common::to_string(&bytes));
15922 let response = common::to_response(parts, bytes.into());
15923
15924 if let common::Retry::After(d) =
15925 dlg.http_failure(&response, error.as_ref().ok())
15926 {
15927 sleep(d).await;
15928 continue;
15929 }
15930
15931 dlg.finished(false);
15932
15933 return Err(match error {
15934 Ok(value) => common::Error::BadRequest(value),
15935 _ => common::Error::Failure(response),
15936 });
15937 }
15938 let response = {
15939 let bytes = common::to_bytes(body).await.unwrap_or_default();
15940 let encoded = common::to_string(&bytes);
15941 match serde_json::from_str(&encoded) {
15942 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15943 Err(error) => {
15944 dlg.response_json_decode_error(&encoded, &error);
15945 return Err(common::Error::JsonDecodeError(
15946 encoded.to_string(),
15947 error,
15948 ));
15949 }
15950 }
15951 };
15952
15953 dlg.finished(true);
15954 return Ok(response);
15955 }
15956 }
15957 }
15958 }
15959
15960 ///
15961 /// Sets the *request* property to the given value.
15962 ///
15963 /// Even though the property as already been set when instantiating this call,
15964 /// we provide this method for API completeness.
15965 pub fn request(
15966 mut self,
15967 new_value: TestIamPermissionsRequest,
15968 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
15969 self._request = new_value;
15970 self
15971 }
15972 /// 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.
15973 ///
15974 /// Sets the *resource* path property to the given value.
15975 ///
15976 /// Even though the property as already been set when instantiating this call,
15977 /// we provide this method for API completeness.
15978 pub fn resource(
15979 mut self,
15980 new_value: &str,
15981 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
15982 self._resource = new_value.to_string();
15983 self
15984 }
15985 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15986 /// while executing the actual API request.
15987 ///
15988 /// ````text
15989 /// It should be used to handle progress information, and to implement a certain level of resilience.
15990 /// ````
15991 ///
15992 /// Sets the *delegate* property to the given value.
15993 pub fn delegate(
15994 mut self,
15995 new_value: &'a mut dyn common::Delegate,
15996 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
15997 self._delegate = Some(new_value);
15998 self
15999 }
16000
16001 /// Set any additional parameter of the query string used in the request.
16002 /// It should be used to set parameters which are not yet available through their own
16003 /// setters.
16004 ///
16005 /// Please note that this method must not be used to set any of the known parameters
16006 /// which have their own setter method. If done anyway, the request will fail.
16007 ///
16008 /// # Additional Parameters
16009 ///
16010 /// * *$.xgafv* (query-string) - V1 error format.
16011 /// * *access_token* (query-string) - OAuth access token.
16012 /// * *alt* (query-string) - Data format for response.
16013 /// * *callback* (query-string) - JSONP
16014 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16015 /// * *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.
16016 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16017 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16018 /// * *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.
16019 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16020 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16021 pub fn param<T>(
16022 mut self,
16023 name: T,
16024 value: T,
16025 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
16026 where
16027 T: AsRef<str>,
16028 {
16029 self._additional_params
16030 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16031 self
16032 }
16033
16034 /// Identifies the authorization scope for the method you are building.
16035 ///
16036 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16037 /// [`Scope::CloudPlatform`].
16038 ///
16039 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16040 /// tokens for more than one scope.
16041 ///
16042 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16043 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16044 /// sufficient, a read-write scope will do as well.
16045 pub fn add_scope<St>(
16046 mut self,
16047 scope: St,
16048 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
16049 where
16050 St: AsRef<str>,
16051 {
16052 self._scopes.insert(String::from(scope.as_ref()));
16053 self
16054 }
16055 /// Identifies the authorization scope(s) for the method you are building.
16056 ///
16057 /// See [`Self::add_scope()`] for details.
16058 pub fn add_scopes<I, St>(
16059 mut self,
16060 scopes: I,
16061 ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
16062 where
16063 I: IntoIterator<Item = St>,
16064 St: AsRef<str>,
16065 {
16066 self._scopes
16067 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16068 self
16069 }
16070
16071 /// Removes all scopes, and no default scope will be used either.
16072 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16073 /// for details).
16074 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
16075 self._scopes.clear();
16076 self
16077 }
16078}
16079
16080/// 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.
16081///
16082/// A builder for the *locations.keyRings.cryptoKeys.updatePrimaryVersion* method supported by a *project* resource.
16083/// It is not used directly, but through a [`ProjectMethods`] instance.
16084///
16085/// # Example
16086///
16087/// Instantiate a resource method builder
16088///
16089/// ```test_harness,no_run
16090/// # extern crate hyper;
16091/// # extern crate hyper_rustls;
16092/// # extern crate google_cloudkms1 as cloudkms1;
16093/// use cloudkms1::api::UpdateCryptoKeyPrimaryVersionRequest;
16094/// # async fn dox() {
16095/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16096///
16097/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16099/// # secret,
16100/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16101/// # ).build().await.unwrap();
16102///
16103/// # let client = hyper_util::client::legacy::Client::builder(
16104/// # hyper_util::rt::TokioExecutor::new()
16105/// # )
16106/// # .build(
16107/// # hyper_rustls::HttpsConnectorBuilder::new()
16108/// # .with_native_roots()
16109/// # .unwrap()
16110/// # .https_or_http()
16111/// # .enable_http1()
16112/// # .build()
16113/// # );
16114/// # let mut hub = CloudKMS::new(client, auth);
16115/// // As the method needs a request, you would usually fill it with the desired information
16116/// // into the respective structure. Some of the parts shown here might not be applicable !
16117/// // Values shown here are possibly random and not representative !
16118/// let mut req = UpdateCryptoKeyPrimaryVersionRequest::default();
16119///
16120/// // You can configure optional parameters by calling the respective setters at will, and
16121/// // execute the final call using `doit()`.
16122/// // Values shown here are possibly random and not representative !
16123/// let result = hub.projects().locations_key_rings_crypto_keys_update_primary_version(req, "name")
16124/// .doit().await;
16125/// # }
16126/// ```
16127pub struct ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
16128where
16129 C: 'a,
16130{
16131 hub: &'a CloudKMS<C>,
16132 _request: UpdateCryptoKeyPrimaryVersionRequest,
16133 _name: String,
16134 _delegate: Option<&'a mut dyn common::Delegate>,
16135 _additional_params: HashMap<String, String>,
16136 _scopes: BTreeSet<String>,
16137}
16138
16139impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {}
16140
16141impl<'a, C> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
16142where
16143 C: common::Connector,
16144{
16145 /// Perform the operation you have build so far.
16146 pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
16147 use std::borrow::Cow;
16148 use std::io::{Read, Seek};
16149
16150 use common::{url::Params, ToParts};
16151 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16152
16153 let mut dd = common::DefaultDelegate;
16154 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16155 dlg.begin(common::MethodInfo {
16156 id: "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion",
16157 http_method: hyper::Method::POST,
16158 });
16159
16160 for &field in ["alt", "name"].iter() {
16161 if self._additional_params.contains_key(field) {
16162 dlg.finished(false);
16163 return Err(common::Error::FieldClash(field));
16164 }
16165 }
16166
16167 let mut params = Params::with_capacity(4 + self._additional_params.len());
16168 params.push("name", self._name);
16169
16170 params.extend(self._additional_params.iter());
16171
16172 params.push("alt", "json");
16173 let mut url = self.hub._base_url.clone() + "v1/{+name}:updatePrimaryVersion";
16174 if self._scopes.is_empty() {
16175 self._scopes
16176 .insert(Scope::CloudPlatform.as_ref().to_string());
16177 }
16178
16179 #[allow(clippy::single_element_loop)]
16180 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16181 url = params.uri_replacement(url, param_name, find_this, true);
16182 }
16183 {
16184 let to_remove = ["name"];
16185 params.remove_params(&to_remove);
16186 }
16187
16188 let url = params.parse_with_url(&url);
16189
16190 let mut json_mime_type = mime::APPLICATION_JSON;
16191 let mut request_value_reader = {
16192 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16193 common::remove_json_null_values(&mut value);
16194 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16195 serde_json::to_writer(&mut dst, &value).unwrap();
16196 dst
16197 };
16198 let request_size = request_value_reader
16199 .seek(std::io::SeekFrom::End(0))
16200 .unwrap();
16201 request_value_reader
16202 .seek(std::io::SeekFrom::Start(0))
16203 .unwrap();
16204
16205 loop {
16206 let token = match self
16207 .hub
16208 .auth
16209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16210 .await
16211 {
16212 Ok(token) => token,
16213 Err(e) => match dlg.token(e) {
16214 Ok(token) => token,
16215 Err(e) => {
16216 dlg.finished(false);
16217 return Err(common::Error::MissingToken(e));
16218 }
16219 },
16220 };
16221 request_value_reader
16222 .seek(std::io::SeekFrom::Start(0))
16223 .unwrap();
16224 let mut req_result = {
16225 let client = &self.hub.client;
16226 dlg.pre_request();
16227 let mut req_builder = hyper::Request::builder()
16228 .method(hyper::Method::POST)
16229 .uri(url.as_str())
16230 .header(USER_AGENT, self.hub._user_agent.clone());
16231
16232 if let Some(token) = token.as_ref() {
16233 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16234 }
16235
16236 let request = req_builder
16237 .header(CONTENT_TYPE, json_mime_type.to_string())
16238 .header(CONTENT_LENGTH, request_size as u64)
16239 .body(common::to_body(
16240 request_value_reader.get_ref().clone().into(),
16241 ));
16242
16243 client.request(request.unwrap()).await
16244 };
16245
16246 match req_result {
16247 Err(err) => {
16248 if let common::Retry::After(d) = dlg.http_error(&err) {
16249 sleep(d).await;
16250 continue;
16251 }
16252 dlg.finished(false);
16253 return Err(common::Error::HttpError(err));
16254 }
16255 Ok(res) => {
16256 let (mut parts, body) = res.into_parts();
16257 let mut body = common::Body::new(body);
16258 if !parts.status.is_success() {
16259 let bytes = common::to_bytes(body).await.unwrap_or_default();
16260 let error = serde_json::from_str(&common::to_string(&bytes));
16261 let response = common::to_response(parts, bytes.into());
16262
16263 if let common::Retry::After(d) =
16264 dlg.http_failure(&response, error.as_ref().ok())
16265 {
16266 sleep(d).await;
16267 continue;
16268 }
16269
16270 dlg.finished(false);
16271
16272 return Err(match error {
16273 Ok(value) => common::Error::BadRequest(value),
16274 _ => common::Error::Failure(response),
16275 });
16276 }
16277 let response = {
16278 let bytes = common::to_bytes(body).await.unwrap_or_default();
16279 let encoded = common::to_string(&bytes);
16280 match serde_json::from_str(&encoded) {
16281 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16282 Err(error) => {
16283 dlg.response_json_decode_error(&encoded, &error);
16284 return Err(common::Error::JsonDecodeError(
16285 encoded.to_string(),
16286 error,
16287 ));
16288 }
16289 }
16290 };
16291
16292 dlg.finished(true);
16293 return Ok(response);
16294 }
16295 }
16296 }
16297 }
16298
16299 ///
16300 /// Sets the *request* property to the given value.
16301 ///
16302 /// Even though the property as already been set when instantiating this call,
16303 /// we provide this method for API completeness.
16304 pub fn request(
16305 mut self,
16306 new_value: UpdateCryptoKeyPrimaryVersionRequest,
16307 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
16308 self._request = new_value;
16309 self
16310 }
16311 /// Required. The resource name of the CryptoKey to update.
16312 ///
16313 /// Sets the *name* path property to the given value.
16314 ///
16315 /// Even though the property as already been set when instantiating this call,
16316 /// we provide this method for API completeness.
16317 pub fn name(
16318 mut self,
16319 new_value: &str,
16320 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
16321 self._name = new_value.to_string();
16322 self
16323 }
16324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16325 /// while executing the actual API request.
16326 ///
16327 /// ````text
16328 /// It should be used to handle progress information, and to implement a certain level of resilience.
16329 /// ````
16330 ///
16331 /// Sets the *delegate* property to the given value.
16332 pub fn delegate(
16333 mut self,
16334 new_value: &'a mut dyn common::Delegate,
16335 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
16336 self._delegate = Some(new_value);
16337 self
16338 }
16339
16340 /// Set any additional parameter of the query string used in the request.
16341 /// It should be used to set parameters which are not yet available through their own
16342 /// setters.
16343 ///
16344 /// Please note that this method must not be used to set any of the known parameters
16345 /// which have their own setter method. If done anyway, the request will fail.
16346 ///
16347 /// # Additional Parameters
16348 ///
16349 /// * *$.xgafv* (query-string) - V1 error format.
16350 /// * *access_token* (query-string) - OAuth access token.
16351 /// * *alt* (query-string) - Data format for response.
16352 /// * *callback* (query-string) - JSONP
16353 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16354 /// * *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.
16355 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16356 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16357 /// * *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.
16358 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16359 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16360 pub fn param<T>(
16361 mut self,
16362 name: T,
16363 value: T,
16364 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
16365 where
16366 T: AsRef<str>,
16367 {
16368 self._additional_params
16369 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16370 self
16371 }
16372
16373 /// Identifies the authorization scope for the method you are building.
16374 ///
16375 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16376 /// [`Scope::CloudPlatform`].
16377 ///
16378 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16379 /// tokens for more than one scope.
16380 ///
16381 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16382 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16383 /// sufficient, a read-write scope will do as well.
16384 pub fn add_scope<St>(
16385 mut self,
16386 scope: St,
16387 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
16388 where
16389 St: AsRef<str>,
16390 {
16391 self._scopes.insert(String::from(scope.as_ref()));
16392 self
16393 }
16394 /// Identifies the authorization scope(s) for the method you are building.
16395 ///
16396 /// See [`Self::add_scope()`] for details.
16397 pub fn add_scopes<I, St>(
16398 mut self,
16399 scopes: I,
16400 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
16401 where
16402 I: IntoIterator<Item = St>,
16403 St: AsRef<str>,
16404 {
16405 self._scopes
16406 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16407 self
16408 }
16409
16410 /// Removes all scopes, and no default scope will be used either.
16411 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16412 /// for details).
16413 pub fn clear_scopes(
16414 mut self,
16415 ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
16416 self._scopes.clear();
16417 self
16418 }
16419}
16420
16421/// Create a new ImportJob within a KeyRing. ImportJob.import_method is required.
16422///
16423/// A builder for the *locations.keyRings.importJobs.create* method supported by a *project* resource.
16424/// It is not used directly, but through a [`ProjectMethods`] instance.
16425///
16426/// # Example
16427///
16428/// Instantiate a resource method builder
16429///
16430/// ```test_harness,no_run
16431/// # extern crate hyper;
16432/// # extern crate hyper_rustls;
16433/// # extern crate google_cloudkms1 as cloudkms1;
16434/// use cloudkms1::api::ImportJob;
16435/// # async fn dox() {
16436/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16437///
16438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16440/// # secret,
16441/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16442/// # ).build().await.unwrap();
16443///
16444/// # let client = hyper_util::client::legacy::Client::builder(
16445/// # hyper_util::rt::TokioExecutor::new()
16446/// # )
16447/// # .build(
16448/// # hyper_rustls::HttpsConnectorBuilder::new()
16449/// # .with_native_roots()
16450/// # .unwrap()
16451/// # .https_or_http()
16452/// # .enable_http1()
16453/// # .build()
16454/// # );
16455/// # let mut hub = CloudKMS::new(client, auth);
16456/// // As the method needs a request, you would usually fill it with the desired information
16457/// // into the respective structure. Some of the parts shown here might not be applicable !
16458/// // Values shown here are possibly random and not representative !
16459/// let mut req = ImportJob::default();
16460///
16461/// // You can configure optional parameters by calling the respective setters at will, and
16462/// // execute the final call using `doit()`.
16463/// // Values shown here are possibly random and not representative !
16464/// let result = hub.projects().locations_key_rings_import_jobs_create(req, "parent")
16465/// .import_job_id("ipsum")
16466/// .doit().await;
16467/// # }
16468/// ```
16469pub struct ProjectLocationKeyRingImportJobCreateCall<'a, C>
16470where
16471 C: 'a,
16472{
16473 hub: &'a CloudKMS<C>,
16474 _request: ImportJob,
16475 _parent: String,
16476 _import_job_id: Option<String>,
16477 _delegate: Option<&'a mut dyn common::Delegate>,
16478 _additional_params: HashMap<String, String>,
16479 _scopes: BTreeSet<String>,
16480}
16481
16482impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobCreateCall<'a, C> {}
16483
16484impl<'a, C> ProjectLocationKeyRingImportJobCreateCall<'a, C>
16485where
16486 C: common::Connector,
16487{
16488 /// Perform the operation you have build so far.
16489 pub async fn doit(mut self) -> common::Result<(common::Response, ImportJob)> {
16490 use std::borrow::Cow;
16491 use std::io::{Read, Seek};
16492
16493 use common::{url::Params, ToParts};
16494 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16495
16496 let mut dd = common::DefaultDelegate;
16497 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16498 dlg.begin(common::MethodInfo {
16499 id: "cloudkms.projects.locations.keyRings.importJobs.create",
16500 http_method: hyper::Method::POST,
16501 });
16502
16503 for &field in ["alt", "parent", "importJobId"].iter() {
16504 if self._additional_params.contains_key(field) {
16505 dlg.finished(false);
16506 return Err(common::Error::FieldClash(field));
16507 }
16508 }
16509
16510 let mut params = Params::with_capacity(5 + self._additional_params.len());
16511 params.push("parent", self._parent);
16512 if let Some(value) = self._import_job_id.as_ref() {
16513 params.push("importJobId", value);
16514 }
16515
16516 params.extend(self._additional_params.iter());
16517
16518 params.push("alt", "json");
16519 let mut url = self.hub._base_url.clone() + "v1/{+parent}/importJobs";
16520 if self._scopes.is_empty() {
16521 self._scopes
16522 .insert(Scope::CloudPlatform.as_ref().to_string());
16523 }
16524
16525 #[allow(clippy::single_element_loop)]
16526 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16527 url = params.uri_replacement(url, param_name, find_this, true);
16528 }
16529 {
16530 let to_remove = ["parent"];
16531 params.remove_params(&to_remove);
16532 }
16533
16534 let url = params.parse_with_url(&url);
16535
16536 let mut json_mime_type = mime::APPLICATION_JSON;
16537 let mut request_value_reader = {
16538 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16539 common::remove_json_null_values(&mut value);
16540 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16541 serde_json::to_writer(&mut dst, &value).unwrap();
16542 dst
16543 };
16544 let request_size = request_value_reader
16545 .seek(std::io::SeekFrom::End(0))
16546 .unwrap();
16547 request_value_reader
16548 .seek(std::io::SeekFrom::Start(0))
16549 .unwrap();
16550
16551 loop {
16552 let token = match self
16553 .hub
16554 .auth
16555 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16556 .await
16557 {
16558 Ok(token) => token,
16559 Err(e) => match dlg.token(e) {
16560 Ok(token) => token,
16561 Err(e) => {
16562 dlg.finished(false);
16563 return Err(common::Error::MissingToken(e));
16564 }
16565 },
16566 };
16567 request_value_reader
16568 .seek(std::io::SeekFrom::Start(0))
16569 .unwrap();
16570 let mut req_result = {
16571 let client = &self.hub.client;
16572 dlg.pre_request();
16573 let mut req_builder = hyper::Request::builder()
16574 .method(hyper::Method::POST)
16575 .uri(url.as_str())
16576 .header(USER_AGENT, self.hub._user_agent.clone());
16577
16578 if let Some(token) = token.as_ref() {
16579 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16580 }
16581
16582 let request = req_builder
16583 .header(CONTENT_TYPE, json_mime_type.to_string())
16584 .header(CONTENT_LENGTH, request_size as u64)
16585 .body(common::to_body(
16586 request_value_reader.get_ref().clone().into(),
16587 ));
16588
16589 client.request(request.unwrap()).await
16590 };
16591
16592 match req_result {
16593 Err(err) => {
16594 if let common::Retry::After(d) = dlg.http_error(&err) {
16595 sleep(d).await;
16596 continue;
16597 }
16598 dlg.finished(false);
16599 return Err(common::Error::HttpError(err));
16600 }
16601 Ok(res) => {
16602 let (mut parts, body) = res.into_parts();
16603 let mut body = common::Body::new(body);
16604 if !parts.status.is_success() {
16605 let bytes = common::to_bytes(body).await.unwrap_or_default();
16606 let error = serde_json::from_str(&common::to_string(&bytes));
16607 let response = common::to_response(parts, bytes.into());
16608
16609 if let common::Retry::After(d) =
16610 dlg.http_failure(&response, error.as_ref().ok())
16611 {
16612 sleep(d).await;
16613 continue;
16614 }
16615
16616 dlg.finished(false);
16617
16618 return Err(match error {
16619 Ok(value) => common::Error::BadRequest(value),
16620 _ => common::Error::Failure(response),
16621 });
16622 }
16623 let response = {
16624 let bytes = common::to_bytes(body).await.unwrap_or_default();
16625 let encoded = common::to_string(&bytes);
16626 match serde_json::from_str(&encoded) {
16627 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16628 Err(error) => {
16629 dlg.response_json_decode_error(&encoded, &error);
16630 return Err(common::Error::JsonDecodeError(
16631 encoded.to_string(),
16632 error,
16633 ));
16634 }
16635 }
16636 };
16637
16638 dlg.finished(true);
16639 return Ok(response);
16640 }
16641 }
16642 }
16643 }
16644
16645 ///
16646 /// Sets the *request* property to the given value.
16647 ///
16648 /// Even though the property as already been set when instantiating this call,
16649 /// we provide this method for API completeness.
16650 pub fn request(
16651 mut self,
16652 new_value: ImportJob,
16653 ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
16654 self._request = new_value;
16655 self
16656 }
16657 /// Required. The name of the KeyRing associated with the ImportJobs.
16658 ///
16659 /// Sets the *parent* path property to the given value.
16660 ///
16661 /// Even though the property as already been set when instantiating this call,
16662 /// we provide this method for API completeness.
16663 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
16664 self._parent = new_value.to_string();
16665 self
16666 }
16667 /// Required. It must be unique within a KeyRing and match the regular expression `[a-zA-Z0-9_-]{1,63}`
16668 ///
16669 /// Sets the *import job id* query property to the given value.
16670 pub fn import_job_id(
16671 mut self,
16672 new_value: &str,
16673 ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
16674 self._import_job_id = Some(new_value.to_string());
16675 self
16676 }
16677 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16678 /// while executing the actual API request.
16679 ///
16680 /// ````text
16681 /// It should be used to handle progress information, and to implement a certain level of resilience.
16682 /// ````
16683 ///
16684 /// Sets the *delegate* property to the given value.
16685 pub fn delegate(
16686 mut self,
16687 new_value: &'a mut dyn common::Delegate,
16688 ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
16689 self._delegate = Some(new_value);
16690 self
16691 }
16692
16693 /// Set any additional parameter of the query string used in the request.
16694 /// It should be used to set parameters which are not yet available through their own
16695 /// setters.
16696 ///
16697 /// Please note that this method must not be used to set any of the known parameters
16698 /// which have their own setter method. If done anyway, the request will fail.
16699 ///
16700 /// # Additional Parameters
16701 ///
16702 /// * *$.xgafv* (query-string) - V1 error format.
16703 /// * *access_token* (query-string) - OAuth access token.
16704 /// * *alt* (query-string) - Data format for response.
16705 /// * *callback* (query-string) - JSONP
16706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16707 /// * *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.
16708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16710 /// * *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.
16711 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16712 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16713 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
16714 where
16715 T: AsRef<str>,
16716 {
16717 self._additional_params
16718 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16719 self
16720 }
16721
16722 /// Identifies the authorization scope for the method you are building.
16723 ///
16724 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16725 /// [`Scope::CloudPlatform`].
16726 ///
16727 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16728 /// tokens for more than one scope.
16729 ///
16730 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16731 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16732 /// sufficient, a read-write scope will do as well.
16733 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
16734 where
16735 St: AsRef<str>,
16736 {
16737 self._scopes.insert(String::from(scope.as_ref()));
16738 self
16739 }
16740 /// Identifies the authorization scope(s) for the method you are building.
16741 ///
16742 /// See [`Self::add_scope()`] for details.
16743 pub fn add_scopes<I, St>(
16744 mut self,
16745 scopes: I,
16746 ) -> ProjectLocationKeyRingImportJobCreateCall<'a, C>
16747 where
16748 I: IntoIterator<Item = St>,
16749 St: AsRef<str>,
16750 {
16751 self._scopes
16752 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16753 self
16754 }
16755
16756 /// Removes all scopes, and no default scope will be used either.
16757 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16758 /// for details).
16759 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobCreateCall<'a, C> {
16760 self._scopes.clear();
16761 self
16762 }
16763}
16764
16765/// Returns metadata for a given ImportJob.
16766///
16767/// A builder for the *locations.keyRings.importJobs.get* method supported by a *project* resource.
16768/// It is not used directly, but through a [`ProjectMethods`] instance.
16769///
16770/// # Example
16771///
16772/// Instantiate a resource method builder
16773///
16774/// ```test_harness,no_run
16775/// # extern crate hyper;
16776/// # extern crate hyper_rustls;
16777/// # extern crate google_cloudkms1 as cloudkms1;
16778/// # async fn dox() {
16779/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16780///
16781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16782/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16783/// # secret,
16784/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16785/// # ).build().await.unwrap();
16786///
16787/// # let client = hyper_util::client::legacy::Client::builder(
16788/// # hyper_util::rt::TokioExecutor::new()
16789/// # )
16790/// # .build(
16791/// # hyper_rustls::HttpsConnectorBuilder::new()
16792/// # .with_native_roots()
16793/// # .unwrap()
16794/// # .https_or_http()
16795/// # .enable_http1()
16796/// # .build()
16797/// # );
16798/// # let mut hub = CloudKMS::new(client, auth);
16799/// // You can configure optional parameters by calling the respective setters at will, and
16800/// // execute the final call using `doit()`.
16801/// // Values shown here are possibly random and not representative !
16802/// let result = hub.projects().locations_key_rings_import_jobs_get("name")
16803/// .doit().await;
16804/// # }
16805/// ```
16806pub struct ProjectLocationKeyRingImportJobGetCall<'a, C>
16807where
16808 C: 'a,
16809{
16810 hub: &'a CloudKMS<C>,
16811 _name: String,
16812 _delegate: Option<&'a mut dyn common::Delegate>,
16813 _additional_params: HashMap<String, String>,
16814 _scopes: BTreeSet<String>,
16815}
16816
16817impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobGetCall<'a, C> {}
16818
16819impl<'a, C> ProjectLocationKeyRingImportJobGetCall<'a, C>
16820where
16821 C: common::Connector,
16822{
16823 /// Perform the operation you have build so far.
16824 pub async fn doit(mut self) -> common::Result<(common::Response, ImportJob)> {
16825 use std::borrow::Cow;
16826 use std::io::{Read, Seek};
16827
16828 use common::{url::Params, ToParts};
16829 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16830
16831 let mut dd = common::DefaultDelegate;
16832 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16833 dlg.begin(common::MethodInfo {
16834 id: "cloudkms.projects.locations.keyRings.importJobs.get",
16835 http_method: hyper::Method::GET,
16836 });
16837
16838 for &field in ["alt", "name"].iter() {
16839 if self._additional_params.contains_key(field) {
16840 dlg.finished(false);
16841 return Err(common::Error::FieldClash(field));
16842 }
16843 }
16844
16845 let mut params = Params::with_capacity(3 + self._additional_params.len());
16846 params.push("name", self._name);
16847
16848 params.extend(self._additional_params.iter());
16849
16850 params.push("alt", "json");
16851 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16852 if self._scopes.is_empty() {
16853 self._scopes
16854 .insert(Scope::CloudPlatform.as_ref().to_string());
16855 }
16856
16857 #[allow(clippy::single_element_loop)]
16858 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16859 url = params.uri_replacement(url, param_name, find_this, true);
16860 }
16861 {
16862 let to_remove = ["name"];
16863 params.remove_params(&to_remove);
16864 }
16865
16866 let url = params.parse_with_url(&url);
16867
16868 loop {
16869 let token = match self
16870 .hub
16871 .auth
16872 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16873 .await
16874 {
16875 Ok(token) => token,
16876 Err(e) => match dlg.token(e) {
16877 Ok(token) => token,
16878 Err(e) => {
16879 dlg.finished(false);
16880 return Err(common::Error::MissingToken(e));
16881 }
16882 },
16883 };
16884 let mut req_result = {
16885 let client = &self.hub.client;
16886 dlg.pre_request();
16887 let mut req_builder = hyper::Request::builder()
16888 .method(hyper::Method::GET)
16889 .uri(url.as_str())
16890 .header(USER_AGENT, self.hub._user_agent.clone());
16891
16892 if let Some(token) = token.as_ref() {
16893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16894 }
16895
16896 let request = req_builder
16897 .header(CONTENT_LENGTH, 0_u64)
16898 .body(common::to_body::<String>(None));
16899
16900 client.request(request.unwrap()).await
16901 };
16902
16903 match req_result {
16904 Err(err) => {
16905 if let common::Retry::After(d) = dlg.http_error(&err) {
16906 sleep(d).await;
16907 continue;
16908 }
16909 dlg.finished(false);
16910 return Err(common::Error::HttpError(err));
16911 }
16912 Ok(res) => {
16913 let (mut parts, body) = res.into_parts();
16914 let mut body = common::Body::new(body);
16915 if !parts.status.is_success() {
16916 let bytes = common::to_bytes(body).await.unwrap_or_default();
16917 let error = serde_json::from_str(&common::to_string(&bytes));
16918 let response = common::to_response(parts, bytes.into());
16919
16920 if let common::Retry::After(d) =
16921 dlg.http_failure(&response, error.as_ref().ok())
16922 {
16923 sleep(d).await;
16924 continue;
16925 }
16926
16927 dlg.finished(false);
16928
16929 return Err(match error {
16930 Ok(value) => common::Error::BadRequest(value),
16931 _ => common::Error::Failure(response),
16932 });
16933 }
16934 let response = {
16935 let bytes = common::to_bytes(body).await.unwrap_or_default();
16936 let encoded = common::to_string(&bytes);
16937 match serde_json::from_str(&encoded) {
16938 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16939 Err(error) => {
16940 dlg.response_json_decode_error(&encoded, &error);
16941 return Err(common::Error::JsonDecodeError(
16942 encoded.to_string(),
16943 error,
16944 ));
16945 }
16946 }
16947 };
16948
16949 dlg.finished(true);
16950 return Ok(response);
16951 }
16952 }
16953 }
16954 }
16955
16956 /// Required. The name of the ImportJob to get.
16957 ///
16958 /// Sets the *name* path property to the given value.
16959 ///
16960 /// Even though the property as already been set when instantiating this call,
16961 /// we provide this method for API completeness.
16962 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
16963 self._name = new_value.to_string();
16964 self
16965 }
16966 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16967 /// while executing the actual API request.
16968 ///
16969 /// ````text
16970 /// It should be used to handle progress information, and to implement a certain level of resilience.
16971 /// ````
16972 ///
16973 /// Sets the *delegate* property to the given value.
16974 pub fn delegate(
16975 mut self,
16976 new_value: &'a mut dyn common::Delegate,
16977 ) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
16978 self._delegate = Some(new_value);
16979 self
16980 }
16981
16982 /// Set any additional parameter of the query string used in the request.
16983 /// It should be used to set parameters which are not yet available through their own
16984 /// setters.
16985 ///
16986 /// Please note that this method must not be used to set any of the known parameters
16987 /// which have their own setter method. If done anyway, the request will fail.
16988 ///
16989 /// # Additional Parameters
16990 ///
16991 /// * *$.xgafv* (query-string) - V1 error format.
16992 /// * *access_token* (query-string) - OAuth access token.
16993 /// * *alt* (query-string) - Data format for response.
16994 /// * *callback* (query-string) - JSONP
16995 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16996 /// * *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.
16997 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16998 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16999 /// * *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.
17000 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17001 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17002 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
17003 where
17004 T: AsRef<str>,
17005 {
17006 self._additional_params
17007 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17008 self
17009 }
17010
17011 /// Identifies the authorization scope for the method you are building.
17012 ///
17013 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17014 /// [`Scope::CloudPlatform`].
17015 ///
17016 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17017 /// tokens for more than one scope.
17018 ///
17019 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17020 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17021 /// sufficient, a read-write scope will do as well.
17022 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
17023 where
17024 St: AsRef<str>,
17025 {
17026 self._scopes.insert(String::from(scope.as_ref()));
17027 self
17028 }
17029 /// Identifies the authorization scope(s) for the method you are building.
17030 ///
17031 /// See [`Self::add_scope()`] for details.
17032 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingImportJobGetCall<'a, C>
17033 where
17034 I: IntoIterator<Item = St>,
17035 St: AsRef<str>,
17036 {
17037 self._scopes
17038 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17039 self
17040 }
17041
17042 /// Removes all scopes, and no default scope will be used either.
17043 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17044 /// for details).
17045 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobGetCall<'a, C> {
17046 self._scopes.clear();
17047 self
17048 }
17049}
17050
17051/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
17052///
17053/// A builder for the *locations.keyRings.importJobs.getIamPolicy* method supported by a *project* resource.
17054/// It is not used directly, but through a [`ProjectMethods`] instance.
17055///
17056/// # Example
17057///
17058/// Instantiate a resource method builder
17059///
17060/// ```test_harness,no_run
17061/// # extern crate hyper;
17062/// # extern crate hyper_rustls;
17063/// # extern crate google_cloudkms1 as cloudkms1;
17064/// # async fn dox() {
17065/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17066///
17067/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17068/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17069/// # secret,
17070/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17071/// # ).build().await.unwrap();
17072///
17073/// # let client = hyper_util::client::legacy::Client::builder(
17074/// # hyper_util::rt::TokioExecutor::new()
17075/// # )
17076/// # .build(
17077/// # hyper_rustls::HttpsConnectorBuilder::new()
17078/// # .with_native_roots()
17079/// # .unwrap()
17080/// # .https_or_http()
17081/// # .enable_http1()
17082/// # .build()
17083/// # );
17084/// # let mut hub = CloudKMS::new(client, auth);
17085/// // You can configure optional parameters by calling the respective setters at will, and
17086/// // execute the final call using `doit()`.
17087/// // Values shown here are possibly random and not representative !
17088/// let result = hub.projects().locations_key_rings_import_jobs_get_iam_policy("resource")
17089/// .options_requested_policy_version(-46)
17090/// .doit().await;
17091/// # }
17092/// ```
17093pub struct ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
17094where
17095 C: 'a,
17096{
17097 hub: &'a CloudKMS<C>,
17098 _resource: String,
17099 _options_requested_policy_version: Option<i32>,
17100 _delegate: Option<&'a mut dyn common::Delegate>,
17101 _additional_params: HashMap<String, String>,
17102 _scopes: BTreeSet<String>,
17103}
17104
17105impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {}
17106
17107impl<'a, C> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
17108where
17109 C: common::Connector,
17110{
17111 /// Perform the operation you have build so far.
17112 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17113 use std::borrow::Cow;
17114 use std::io::{Read, Seek};
17115
17116 use common::{url::Params, ToParts};
17117 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17118
17119 let mut dd = common::DefaultDelegate;
17120 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17121 dlg.begin(common::MethodInfo {
17122 id: "cloudkms.projects.locations.keyRings.importJobs.getIamPolicy",
17123 http_method: hyper::Method::GET,
17124 });
17125
17126 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
17127 if self._additional_params.contains_key(field) {
17128 dlg.finished(false);
17129 return Err(common::Error::FieldClash(field));
17130 }
17131 }
17132
17133 let mut params = Params::with_capacity(4 + self._additional_params.len());
17134 params.push("resource", self._resource);
17135 if let Some(value) = self._options_requested_policy_version.as_ref() {
17136 params.push("options.requestedPolicyVersion", value.to_string());
17137 }
17138
17139 params.extend(self._additional_params.iter());
17140
17141 params.push("alt", "json");
17142 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
17143 if self._scopes.is_empty() {
17144 self._scopes
17145 .insert(Scope::CloudPlatform.as_ref().to_string());
17146 }
17147
17148 #[allow(clippy::single_element_loop)]
17149 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17150 url = params.uri_replacement(url, param_name, find_this, true);
17151 }
17152 {
17153 let to_remove = ["resource"];
17154 params.remove_params(&to_remove);
17155 }
17156
17157 let url = params.parse_with_url(&url);
17158
17159 loop {
17160 let token = match self
17161 .hub
17162 .auth
17163 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17164 .await
17165 {
17166 Ok(token) => token,
17167 Err(e) => match dlg.token(e) {
17168 Ok(token) => token,
17169 Err(e) => {
17170 dlg.finished(false);
17171 return Err(common::Error::MissingToken(e));
17172 }
17173 },
17174 };
17175 let mut req_result = {
17176 let client = &self.hub.client;
17177 dlg.pre_request();
17178 let mut req_builder = hyper::Request::builder()
17179 .method(hyper::Method::GET)
17180 .uri(url.as_str())
17181 .header(USER_AGENT, self.hub._user_agent.clone());
17182
17183 if let Some(token) = token.as_ref() {
17184 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17185 }
17186
17187 let request = req_builder
17188 .header(CONTENT_LENGTH, 0_u64)
17189 .body(common::to_body::<String>(None));
17190
17191 client.request(request.unwrap()).await
17192 };
17193
17194 match req_result {
17195 Err(err) => {
17196 if let common::Retry::After(d) = dlg.http_error(&err) {
17197 sleep(d).await;
17198 continue;
17199 }
17200 dlg.finished(false);
17201 return Err(common::Error::HttpError(err));
17202 }
17203 Ok(res) => {
17204 let (mut parts, body) = res.into_parts();
17205 let mut body = common::Body::new(body);
17206 if !parts.status.is_success() {
17207 let bytes = common::to_bytes(body).await.unwrap_or_default();
17208 let error = serde_json::from_str(&common::to_string(&bytes));
17209 let response = common::to_response(parts, bytes.into());
17210
17211 if let common::Retry::After(d) =
17212 dlg.http_failure(&response, error.as_ref().ok())
17213 {
17214 sleep(d).await;
17215 continue;
17216 }
17217
17218 dlg.finished(false);
17219
17220 return Err(match error {
17221 Ok(value) => common::Error::BadRequest(value),
17222 _ => common::Error::Failure(response),
17223 });
17224 }
17225 let response = {
17226 let bytes = common::to_bytes(body).await.unwrap_or_default();
17227 let encoded = common::to_string(&bytes);
17228 match serde_json::from_str(&encoded) {
17229 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17230 Err(error) => {
17231 dlg.response_json_decode_error(&encoded, &error);
17232 return Err(common::Error::JsonDecodeError(
17233 encoded.to_string(),
17234 error,
17235 ));
17236 }
17237 }
17238 };
17239
17240 dlg.finished(true);
17241 return Ok(response);
17242 }
17243 }
17244 }
17245 }
17246
17247 /// 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.
17248 ///
17249 /// Sets the *resource* path property to the given value.
17250 ///
17251 /// Even though the property as already been set when instantiating this call,
17252 /// we provide this method for API completeness.
17253 pub fn resource(
17254 mut self,
17255 new_value: &str,
17256 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
17257 self._resource = new_value.to_string();
17258 self
17259 }
17260 /// 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).
17261 ///
17262 /// Sets the *options.requested policy version* query property to the given value.
17263 pub fn options_requested_policy_version(
17264 mut self,
17265 new_value: i32,
17266 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
17267 self._options_requested_policy_version = Some(new_value);
17268 self
17269 }
17270 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17271 /// while executing the actual API request.
17272 ///
17273 /// ````text
17274 /// It should be used to handle progress information, and to implement a certain level of resilience.
17275 /// ````
17276 ///
17277 /// Sets the *delegate* property to the given value.
17278 pub fn delegate(
17279 mut self,
17280 new_value: &'a mut dyn common::Delegate,
17281 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
17282 self._delegate = Some(new_value);
17283 self
17284 }
17285
17286 /// Set any additional parameter of the query string used in the request.
17287 /// It should be used to set parameters which are not yet available through their own
17288 /// setters.
17289 ///
17290 /// Please note that this method must not be used to set any of the known parameters
17291 /// which have their own setter method. If done anyway, the request will fail.
17292 ///
17293 /// # Additional Parameters
17294 ///
17295 /// * *$.xgafv* (query-string) - V1 error format.
17296 /// * *access_token* (query-string) - OAuth access token.
17297 /// * *alt* (query-string) - Data format for response.
17298 /// * *callback* (query-string) - JSONP
17299 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17300 /// * *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.
17301 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17302 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17303 /// * *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.
17304 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17305 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17306 pub fn param<T>(
17307 mut self,
17308 name: T,
17309 value: T,
17310 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
17311 where
17312 T: AsRef<str>,
17313 {
17314 self._additional_params
17315 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17316 self
17317 }
17318
17319 /// Identifies the authorization scope for the method you are building.
17320 ///
17321 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17322 /// [`Scope::CloudPlatform`].
17323 ///
17324 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17325 /// tokens for more than one scope.
17326 ///
17327 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17328 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17329 /// sufficient, a read-write scope will do as well.
17330 pub fn add_scope<St>(
17331 mut self,
17332 scope: St,
17333 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
17334 where
17335 St: AsRef<str>,
17336 {
17337 self._scopes.insert(String::from(scope.as_ref()));
17338 self
17339 }
17340 /// Identifies the authorization scope(s) for the method you are building.
17341 ///
17342 /// See [`Self::add_scope()`] for details.
17343 pub fn add_scopes<I, St>(
17344 mut self,
17345 scopes: I,
17346 ) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C>
17347 where
17348 I: IntoIterator<Item = St>,
17349 St: AsRef<str>,
17350 {
17351 self._scopes
17352 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17353 self
17354 }
17355
17356 /// Removes all scopes, and no default scope will be used either.
17357 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17358 /// for details).
17359 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobGetIamPolicyCall<'a, C> {
17360 self._scopes.clear();
17361 self
17362 }
17363}
17364
17365/// Lists ImportJobs.
17366///
17367/// A builder for the *locations.keyRings.importJobs.list* method supported by a *project* resource.
17368/// It is not used directly, but through a [`ProjectMethods`] instance.
17369///
17370/// # Example
17371///
17372/// Instantiate a resource method builder
17373///
17374/// ```test_harness,no_run
17375/// # extern crate hyper;
17376/// # extern crate hyper_rustls;
17377/// # extern crate google_cloudkms1 as cloudkms1;
17378/// # async fn dox() {
17379/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17380///
17381/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17382/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17383/// # secret,
17384/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17385/// # ).build().await.unwrap();
17386///
17387/// # let client = hyper_util::client::legacy::Client::builder(
17388/// # hyper_util::rt::TokioExecutor::new()
17389/// # )
17390/// # .build(
17391/// # hyper_rustls::HttpsConnectorBuilder::new()
17392/// # .with_native_roots()
17393/// # .unwrap()
17394/// # .https_or_http()
17395/// # .enable_http1()
17396/// # .build()
17397/// # );
17398/// # let mut hub = CloudKMS::new(client, auth);
17399/// // You can configure optional parameters by calling the respective setters at will, and
17400/// // execute the final call using `doit()`.
17401/// // Values shown here are possibly random and not representative !
17402/// let result = hub.projects().locations_key_rings_import_jobs_list("parent")
17403/// .page_token("et")
17404/// .page_size(-31)
17405/// .order_by("consetetur")
17406/// .filter("amet.")
17407/// .doit().await;
17408/// # }
17409/// ```
17410pub struct ProjectLocationKeyRingImportJobListCall<'a, C>
17411where
17412 C: 'a,
17413{
17414 hub: &'a CloudKMS<C>,
17415 _parent: String,
17416 _page_token: Option<String>,
17417 _page_size: Option<i32>,
17418 _order_by: Option<String>,
17419 _filter: Option<String>,
17420 _delegate: Option<&'a mut dyn common::Delegate>,
17421 _additional_params: HashMap<String, String>,
17422 _scopes: BTreeSet<String>,
17423}
17424
17425impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobListCall<'a, C> {}
17426
17427impl<'a, C> ProjectLocationKeyRingImportJobListCall<'a, C>
17428where
17429 C: common::Connector,
17430{
17431 /// Perform the operation you have build so far.
17432 pub async fn doit(mut self) -> common::Result<(common::Response, ListImportJobsResponse)> {
17433 use std::borrow::Cow;
17434 use std::io::{Read, Seek};
17435
17436 use common::{url::Params, ToParts};
17437 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17438
17439 let mut dd = common::DefaultDelegate;
17440 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17441 dlg.begin(common::MethodInfo {
17442 id: "cloudkms.projects.locations.keyRings.importJobs.list",
17443 http_method: hyper::Method::GET,
17444 });
17445
17446 for &field in [
17447 "alt",
17448 "parent",
17449 "pageToken",
17450 "pageSize",
17451 "orderBy",
17452 "filter",
17453 ]
17454 .iter()
17455 {
17456 if self._additional_params.contains_key(field) {
17457 dlg.finished(false);
17458 return Err(common::Error::FieldClash(field));
17459 }
17460 }
17461
17462 let mut params = Params::with_capacity(7 + self._additional_params.len());
17463 params.push("parent", self._parent);
17464 if let Some(value) = self._page_token.as_ref() {
17465 params.push("pageToken", value);
17466 }
17467 if let Some(value) = self._page_size.as_ref() {
17468 params.push("pageSize", value.to_string());
17469 }
17470 if let Some(value) = self._order_by.as_ref() {
17471 params.push("orderBy", value);
17472 }
17473 if let Some(value) = self._filter.as_ref() {
17474 params.push("filter", value);
17475 }
17476
17477 params.extend(self._additional_params.iter());
17478
17479 params.push("alt", "json");
17480 let mut url = self.hub._base_url.clone() + "v1/{+parent}/importJobs";
17481 if self._scopes.is_empty() {
17482 self._scopes
17483 .insert(Scope::CloudPlatform.as_ref().to_string());
17484 }
17485
17486 #[allow(clippy::single_element_loop)]
17487 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17488 url = params.uri_replacement(url, param_name, find_this, true);
17489 }
17490 {
17491 let to_remove = ["parent"];
17492 params.remove_params(&to_remove);
17493 }
17494
17495 let url = params.parse_with_url(&url);
17496
17497 loop {
17498 let token = match self
17499 .hub
17500 .auth
17501 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17502 .await
17503 {
17504 Ok(token) => token,
17505 Err(e) => match dlg.token(e) {
17506 Ok(token) => token,
17507 Err(e) => {
17508 dlg.finished(false);
17509 return Err(common::Error::MissingToken(e));
17510 }
17511 },
17512 };
17513 let mut req_result = {
17514 let client = &self.hub.client;
17515 dlg.pre_request();
17516 let mut req_builder = hyper::Request::builder()
17517 .method(hyper::Method::GET)
17518 .uri(url.as_str())
17519 .header(USER_AGENT, self.hub._user_agent.clone());
17520
17521 if let Some(token) = token.as_ref() {
17522 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17523 }
17524
17525 let request = req_builder
17526 .header(CONTENT_LENGTH, 0_u64)
17527 .body(common::to_body::<String>(None));
17528
17529 client.request(request.unwrap()).await
17530 };
17531
17532 match req_result {
17533 Err(err) => {
17534 if let common::Retry::After(d) = dlg.http_error(&err) {
17535 sleep(d).await;
17536 continue;
17537 }
17538 dlg.finished(false);
17539 return Err(common::Error::HttpError(err));
17540 }
17541 Ok(res) => {
17542 let (mut parts, body) = res.into_parts();
17543 let mut body = common::Body::new(body);
17544 if !parts.status.is_success() {
17545 let bytes = common::to_bytes(body).await.unwrap_or_default();
17546 let error = serde_json::from_str(&common::to_string(&bytes));
17547 let response = common::to_response(parts, bytes.into());
17548
17549 if let common::Retry::After(d) =
17550 dlg.http_failure(&response, error.as_ref().ok())
17551 {
17552 sleep(d).await;
17553 continue;
17554 }
17555
17556 dlg.finished(false);
17557
17558 return Err(match error {
17559 Ok(value) => common::Error::BadRequest(value),
17560 _ => common::Error::Failure(response),
17561 });
17562 }
17563 let response = {
17564 let bytes = common::to_bytes(body).await.unwrap_or_default();
17565 let encoded = common::to_string(&bytes);
17566 match serde_json::from_str(&encoded) {
17567 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17568 Err(error) => {
17569 dlg.response_json_decode_error(&encoded, &error);
17570 return Err(common::Error::JsonDecodeError(
17571 encoded.to_string(),
17572 error,
17573 ));
17574 }
17575 }
17576 };
17577
17578 dlg.finished(true);
17579 return Ok(response);
17580 }
17581 }
17582 }
17583 }
17584
17585 /// Required. The resource name of the KeyRing to list, in the format `projects/*/locations/*/keyRings/*`.
17586 ///
17587 /// Sets the *parent* path property to the given value.
17588 ///
17589 /// Even though the property as already been set when instantiating this call,
17590 /// we provide this method for API completeness.
17591 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17592 self._parent = new_value.to_string();
17593 self
17594 }
17595 /// Optional. Optional pagination token, returned earlier via ListImportJobsResponse.next_page_token.
17596 ///
17597 /// Sets the *page token* query property to the given value.
17598 pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17599 self._page_token = Some(new_value.to_string());
17600 self
17601 }
17602 /// 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.
17603 ///
17604 /// Sets the *page size* query property to the given value.
17605 pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17606 self._page_size = Some(new_value);
17607 self
17608 }
17609 /// 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).
17610 ///
17611 /// Sets the *order by* query property to the given value.
17612 pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17613 self._order_by = Some(new_value.to_string());
17614 self
17615 }
17616 /// 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).
17617 ///
17618 /// Sets the *filter* query property to the given value.
17619 pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17620 self._filter = Some(new_value.to_string());
17621 self
17622 }
17623 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17624 /// while executing the actual API request.
17625 ///
17626 /// ````text
17627 /// It should be used to handle progress information, and to implement a certain level of resilience.
17628 /// ````
17629 ///
17630 /// Sets the *delegate* property to the given value.
17631 pub fn delegate(
17632 mut self,
17633 new_value: &'a mut dyn common::Delegate,
17634 ) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17635 self._delegate = Some(new_value);
17636 self
17637 }
17638
17639 /// Set any additional parameter of the query string used in the request.
17640 /// It should be used to set parameters which are not yet available through their own
17641 /// setters.
17642 ///
17643 /// Please note that this method must not be used to set any of the known parameters
17644 /// which have their own setter method. If done anyway, the request will fail.
17645 ///
17646 /// # Additional Parameters
17647 ///
17648 /// * *$.xgafv* (query-string) - V1 error format.
17649 /// * *access_token* (query-string) - OAuth access token.
17650 /// * *alt* (query-string) - Data format for response.
17651 /// * *callback* (query-string) - JSONP
17652 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17653 /// * *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.
17654 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17655 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17656 /// * *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.
17657 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17658 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17659 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingImportJobListCall<'a, C>
17660 where
17661 T: AsRef<str>,
17662 {
17663 self._additional_params
17664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17665 self
17666 }
17667
17668 /// Identifies the authorization scope for the method you are building.
17669 ///
17670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17671 /// [`Scope::CloudPlatform`].
17672 ///
17673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17674 /// tokens for more than one scope.
17675 ///
17676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17678 /// sufficient, a read-write scope will do as well.
17679 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingImportJobListCall<'a, C>
17680 where
17681 St: AsRef<str>,
17682 {
17683 self._scopes.insert(String::from(scope.as_ref()));
17684 self
17685 }
17686 /// Identifies the authorization scope(s) for the method you are building.
17687 ///
17688 /// See [`Self::add_scope()`] for details.
17689 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingImportJobListCall<'a, C>
17690 where
17691 I: IntoIterator<Item = St>,
17692 St: AsRef<str>,
17693 {
17694 self._scopes
17695 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17696 self
17697 }
17698
17699 /// Removes all scopes, and no default scope will be used either.
17700 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17701 /// for details).
17702 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobListCall<'a, C> {
17703 self._scopes.clear();
17704 self
17705 }
17706}
17707
17708/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
17709///
17710/// A builder for the *locations.keyRings.importJobs.setIamPolicy* method supported by a *project* resource.
17711/// It is not used directly, but through a [`ProjectMethods`] instance.
17712///
17713/// # Example
17714///
17715/// Instantiate a resource method builder
17716///
17717/// ```test_harness,no_run
17718/// # extern crate hyper;
17719/// # extern crate hyper_rustls;
17720/// # extern crate google_cloudkms1 as cloudkms1;
17721/// use cloudkms1::api::SetIamPolicyRequest;
17722/// # async fn dox() {
17723/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17724///
17725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17727/// # secret,
17728/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17729/// # ).build().await.unwrap();
17730///
17731/// # let client = hyper_util::client::legacy::Client::builder(
17732/// # hyper_util::rt::TokioExecutor::new()
17733/// # )
17734/// # .build(
17735/// # hyper_rustls::HttpsConnectorBuilder::new()
17736/// # .with_native_roots()
17737/// # .unwrap()
17738/// # .https_or_http()
17739/// # .enable_http1()
17740/// # .build()
17741/// # );
17742/// # let mut hub = CloudKMS::new(client, auth);
17743/// // As the method needs a request, you would usually fill it with the desired information
17744/// // into the respective structure. Some of the parts shown here might not be applicable !
17745/// // Values shown here are possibly random and not representative !
17746/// let mut req = SetIamPolicyRequest::default();
17747///
17748/// // You can configure optional parameters by calling the respective setters at will, and
17749/// // execute the final call using `doit()`.
17750/// // Values shown here are possibly random and not representative !
17751/// let result = hub.projects().locations_key_rings_import_jobs_set_iam_policy(req, "resource")
17752/// .doit().await;
17753/// # }
17754/// ```
17755pub struct ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
17756where
17757 C: 'a,
17758{
17759 hub: &'a CloudKMS<C>,
17760 _request: SetIamPolicyRequest,
17761 _resource: String,
17762 _delegate: Option<&'a mut dyn common::Delegate>,
17763 _additional_params: HashMap<String, String>,
17764 _scopes: BTreeSet<String>,
17765}
17766
17767impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {}
17768
17769impl<'a, C> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
17770where
17771 C: common::Connector,
17772{
17773 /// Perform the operation you have build so far.
17774 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17775 use std::borrow::Cow;
17776 use std::io::{Read, Seek};
17777
17778 use common::{url::Params, ToParts};
17779 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17780
17781 let mut dd = common::DefaultDelegate;
17782 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17783 dlg.begin(common::MethodInfo {
17784 id: "cloudkms.projects.locations.keyRings.importJobs.setIamPolicy",
17785 http_method: hyper::Method::POST,
17786 });
17787
17788 for &field in ["alt", "resource"].iter() {
17789 if self._additional_params.contains_key(field) {
17790 dlg.finished(false);
17791 return Err(common::Error::FieldClash(field));
17792 }
17793 }
17794
17795 let mut params = Params::with_capacity(4 + self._additional_params.len());
17796 params.push("resource", self._resource);
17797
17798 params.extend(self._additional_params.iter());
17799
17800 params.push("alt", "json");
17801 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
17802 if self._scopes.is_empty() {
17803 self._scopes
17804 .insert(Scope::CloudPlatform.as_ref().to_string());
17805 }
17806
17807 #[allow(clippy::single_element_loop)]
17808 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17809 url = params.uri_replacement(url, param_name, find_this, true);
17810 }
17811 {
17812 let to_remove = ["resource"];
17813 params.remove_params(&to_remove);
17814 }
17815
17816 let url = params.parse_with_url(&url);
17817
17818 let mut json_mime_type = mime::APPLICATION_JSON;
17819 let mut request_value_reader = {
17820 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17821 common::remove_json_null_values(&mut value);
17822 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17823 serde_json::to_writer(&mut dst, &value).unwrap();
17824 dst
17825 };
17826 let request_size = request_value_reader
17827 .seek(std::io::SeekFrom::End(0))
17828 .unwrap();
17829 request_value_reader
17830 .seek(std::io::SeekFrom::Start(0))
17831 .unwrap();
17832
17833 loop {
17834 let token = match self
17835 .hub
17836 .auth
17837 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17838 .await
17839 {
17840 Ok(token) => token,
17841 Err(e) => match dlg.token(e) {
17842 Ok(token) => token,
17843 Err(e) => {
17844 dlg.finished(false);
17845 return Err(common::Error::MissingToken(e));
17846 }
17847 },
17848 };
17849 request_value_reader
17850 .seek(std::io::SeekFrom::Start(0))
17851 .unwrap();
17852 let mut req_result = {
17853 let client = &self.hub.client;
17854 dlg.pre_request();
17855 let mut req_builder = hyper::Request::builder()
17856 .method(hyper::Method::POST)
17857 .uri(url.as_str())
17858 .header(USER_AGENT, self.hub._user_agent.clone());
17859
17860 if let Some(token) = token.as_ref() {
17861 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17862 }
17863
17864 let request = req_builder
17865 .header(CONTENT_TYPE, json_mime_type.to_string())
17866 .header(CONTENT_LENGTH, request_size as u64)
17867 .body(common::to_body(
17868 request_value_reader.get_ref().clone().into(),
17869 ));
17870
17871 client.request(request.unwrap()).await
17872 };
17873
17874 match req_result {
17875 Err(err) => {
17876 if let common::Retry::After(d) = dlg.http_error(&err) {
17877 sleep(d).await;
17878 continue;
17879 }
17880 dlg.finished(false);
17881 return Err(common::Error::HttpError(err));
17882 }
17883 Ok(res) => {
17884 let (mut parts, body) = res.into_parts();
17885 let mut body = common::Body::new(body);
17886 if !parts.status.is_success() {
17887 let bytes = common::to_bytes(body).await.unwrap_or_default();
17888 let error = serde_json::from_str(&common::to_string(&bytes));
17889 let response = common::to_response(parts, bytes.into());
17890
17891 if let common::Retry::After(d) =
17892 dlg.http_failure(&response, error.as_ref().ok())
17893 {
17894 sleep(d).await;
17895 continue;
17896 }
17897
17898 dlg.finished(false);
17899
17900 return Err(match error {
17901 Ok(value) => common::Error::BadRequest(value),
17902 _ => common::Error::Failure(response),
17903 });
17904 }
17905 let response = {
17906 let bytes = common::to_bytes(body).await.unwrap_or_default();
17907 let encoded = common::to_string(&bytes);
17908 match serde_json::from_str(&encoded) {
17909 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17910 Err(error) => {
17911 dlg.response_json_decode_error(&encoded, &error);
17912 return Err(common::Error::JsonDecodeError(
17913 encoded.to_string(),
17914 error,
17915 ));
17916 }
17917 }
17918 };
17919
17920 dlg.finished(true);
17921 return Ok(response);
17922 }
17923 }
17924 }
17925 }
17926
17927 ///
17928 /// Sets the *request* property to the given value.
17929 ///
17930 /// Even though the property as already been set when instantiating this call,
17931 /// we provide this method for API completeness.
17932 pub fn request(
17933 mut self,
17934 new_value: SetIamPolicyRequest,
17935 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
17936 self._request = new_value;
17937 self
17938 }
17939 /// 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.
17940 ///
17941 /// Sets the *resource* path property to the given value.
17942 ///
17943 /// Even though the property as already been set when instantiating this call,
17944 /// we provide this method for API completeness.
17945 pub fn resource(
17946 mut self,
17947 new_value: &str,
17948 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
17949 self._resource = new_value.to_string();
17950 self
17951 }
17952 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17953 /// while executing the actual API request.
17954 ///
17955 /// ````text
17956 /// It should be used to handle progress information, and to implement a certain level of resilience.
17957 /// ````
17958 ///
17959 /// Sets the *delegate* property to the given value.
17960 pub fn delegate(
17961 mut self,
17962 new_value: &'a mut dyn common::Delegate,
17963 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
17964 self._delegate = Some(new_value);
17965 self
17966 }
17967
17968 /// Set any additional parameter of the query string used in the request.
17969 /// It should be used to set parameters which are not yet available through their own
17970 /// setters.
17971 ///
17972 /// Please note that this method must not be used to set any of the known parameters
17973 /// which have their own setter method. If done anyway, the request will fail.
17974 ///
17975 /// # Additional Parameters
17976 ///
17977 /// * *$.xgafv* (query-string) - V1 error format.
17978 /// * *access_token* (query-string) - OAuth access token.
17979 /// * *alt* (query-string) - Data format for response.
17980 /// * *callback* (query-string) - JSONP
17981 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17982 /// * *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.
17983 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17984 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17985 /// * *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.
17986 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17987 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17988 pub fn param<T>(
17989 mut self,
17990 name: T,
17991 value: T,
17992 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
17993 where
17994 T: AsRef<str>,
17995 {
17996 self._additional_params
17997 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17998 self
17999 }
18000
18001 /// Identifies the authorization scope for the method you are building.
18002 ///
18003 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18004 /// [`Scope::CloudPlatform`].
18005 ///
18006 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18007 /// tokens for more than one scope.
18008 ///
18009 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18010 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18011 /// sufficient, a read-write scope will do as well.
18012 pub fn add_scope<St>(
18013 mut self,
18014 scope: St,
18015 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
18016 where
18017 St: AsRef<str>,
18018 {
18019 self._scopes.insert(String::from(scope.as_ref()));
18020 self
18021 }
18022 /// Identifies the authorization scope(s) for the method you are building.
18023 ///
18024 /// See [`Self::add_scope()`] for details.
18025 pub fn add_scopes<I, St>(
18026 mut self,
18027 scopes: I,
18028 ) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C>
18029 where
18030 I: IntoIterator<Item = St>,
18031 St: AsRef<str>,
18032 {
18033 self._scopes
18034 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18035 self
18036 }
18037
18038 /// Removes all scopes, and no default scope will be used either.
18039 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18040 /// for details).
18041 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobSetIamPolicyCall<'a, C> {
18042 self._scopes.clear();
18043 self
18044 }
18045}
18046
18047/// 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.
18048///
18049/// A builder for the *locations.keyRings.importJobs.testIamPermissions* method supported by a *project* resource.
18050/// It is not used directly, but through a [`ProjectMethods`] instance.
18051///
18052/// # Example
18053///
18054/// Instantiate a resource method builder
18055///
18056/// ```test_harness,no_run
18057/// # extern crate hyper;
18058/// # extern crate hyper_rustls;
18059/// # extern crate google_cloudkms1 as cloudkms1;
18060/// use cloudkms1::api::TestIamPermissionsRequest;
18061/// # async fn dox() {
18062/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18063///
18064/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18065/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18066/// # secret,
18067/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18068/// # ).build().await.unwrap();
18069///
18070/// # let client = hyper_util::client::legacy::Client::builder(
18071/// # hyper_util::rt::TokioExecutor::new()
18072/// # )
18073/// # .build(
18074/// # hyper_rustls::HttpsConnectorBuilder::new()
18075/// # .with_native_roots()
18076/// # .unwrap()
18077/// # .https_or_http()
18078/// # .enable_http1()
18079/// # .build()
18080/// # );
18081/// # let mut hub = CloudKMS::new(client, auth);
18082/// // As the method needs a request, you would usually fill it with the desired information
18083/// // into the respective structure. Some of the parts shown here might not be applicable !
18084/// // Values shown here are possibly random and not representative !
18085/// let mut req = TestIamPermissionsRequest::default();
18086///
18087/// // You can configure optional parameters by calling the respective setters at will, and
18088/// // execute the final call using `doit()`.
18089/// // Values shown here are possibly random and not representative !
18090/// let result = hub.projects().locations_key_rings_import_jobs_test_iam_permissions(req, "resource")
18091/// .doit().await;
18092/// # }
18093/// ```
18094pub struct ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
18095where
18096 C: 'a,
18097{
18098 hub: &'a CloudKMS<C>,
18099 _request: TestIamPermissionsRequest,
18100 _resource: String,
18101 _delegate: Option<&'a mut dyn common::Delegate>,
18102 _additional_params: HashMap<String, String>,
18103 _scopes: BTreeSet<String>,
18104}
18105
18106impl<'a, C> common::CallBuilder for ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {}
18107
18108impl<'a, C> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
18109where
18110 C: common::Connector,
18111{
18112 /// Perform the operation you have build so far.
18113 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
18114 use std::borrow::Cow;
18115 use std::io::{Read, Seek};
18116
18117 use common::{url::Params, ToParts};
18118 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18119
18120 let mut dd = common::DefaultDelegate;
18121 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18122 dlg.begin(common::MethodInfo {
18123 id: "cloudkms.projects.locations.keyRings.importJobs.testIamPermissions",
18124 http_method: hyper::Method::POST,
18125 });
18126
18127 for &field in ["alt", "resource"].iter() {
18128 if self._additional_params.contains_key(field) {
18129 dlg.finished(false);
18130 return Err(common::Error::FieldClash(field));
18131 }
18132 }
18133
18134 let mut params = Params::with_capacity(4 + self._additional_params.len());
18135 params.push("resource", self._resource);
18136
18137 params.extend(self._additional_params.iter());
18138
18139 params.push("alt", "json");
18140 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
18141 if self._scopes.is_empty() {
18142 self._scopes
18143 .insert(Scope::CloudPlatform.as_ref().to_string());
18144 }
18145
18146 #[allow(clippy::single_element_loop)]
18147 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18148 url = params.uri_replacement(url, param_name, find_this, true);
18149 }
18150 {
18151 let to_remove = ["resource"];
18152 params.remove_params(&to_remove);
18153 }
18154
18155 let url = params.parse_with_url(&url);
18156
18157 let mut json_mime_type = mime::APPLICATION_JSON;
18158 let mut request_value_reader = {
18159 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18160 common::remove_json_null_values(&mut value);
18161 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18162 serde_json::to_writer(&mut dst, &value).unwrap();
18163 dst
18164 };
18165 let request_size = request_value_reader
18166 .seek(std::io::SeekFrom::End(0))
18167 .unwrap();
18168 request_value_reader
18169 .seek(std::io::SeekFrom::Start(0))
18170 .unwrap();
18171
18172 loop {
18173 let token = match self
18174 .hub
18175 .auth
18176 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18177 .await
18178 {
18179 Ok(token) => token,
18180 Err(e) => match dlg.token(e) {
18181 Ok(token) => token,
18182 Err(e) => {
18183 dlg.finished(false);
18184 return Err(common::Error::MissingToken(e));
18185 }
18186 },
18187 };
18188 request_value_reader
18189 .seek(std::io::SeekFrom::Start(0))
18190 .unwrap();
18191 let mut req_result = {
18192 let client = &self.hub.client;
18193 dlg.pre_request();
18194 let mut req_builder = hyper::Request::builder()
18195 .method(hyper::Method::POST)
18196 .uri(url.as_str())
18197 .header(USER_AGENT, self.hub._user_agent.clone());
18198
18199 if let Some(token) = token.as_ref() {
18200 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18201 }
18202
18203 let request = req_builder
18204 .header(CONTENT_TYPE, json_mime_type.to_string())
18205 .header(CONTENT_LENGTH, request_size as u64)
18206 .body(common::to_body(
18207 request_value_reader.get_ref().clone().into(),
18208 ));
18209
18210 client.request(request.unwrap()).await
18211 };
18212
18213 match req_result {
18214 Err(err) => {
18215 if let common::Retry::After(d) = dlg.http_error(&err) {
18216 sleep(d).await;
18217 continue;
18218 }
18219 dlg.finished(false);
18220 return Err(common::Error::HttpError(err));
18221 }
18222 Ok(res) => {
18223 let (mut parts, body) = res.into_parts();
18224 let mut body = common::Body::new(body);
18225 if !parts.status.is_success() {
18226 let bytes = common::to_bytes(body).await.unwrap_or_default();
18227 let error = serde_json::from_str(&common::to_string(&bytes));
18228 let response = common::to_response(parts, bytes.into());
18229
18230 if let common::Retry::After(d) =
18231 dlg.http_failure(&response, error.as_ref().ok())
18232 {
18233 sleep(d).await;
18234 continue;
18235 }
18236
18237 dlg.finished(false);
18238
18239 return Err(match error {
18240 Ok(value) => common::Error::BadRequest(value),
18241 _ => common::Error::Failure(response),
18242 });
18243 }
18244 let response = {
18245 let bytes = common::to_bytes(body).await.unwrap_or_default();
18246 let encoded = common::to_string(&bytes);
18247 match serde_json::from_str(&encoded) {
18248 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18249 Err(error) => {
18250 dlg.response_json_decode_error(&encoded, &error);
18251 return Err(common::Error::JsonDecodeError(
18252 encoded.to_string(),
18253 error,
18254 ));
18255 }
18256 }
18257 };
18258
18259 dlg.finished(true);
18260 return Ok(response);
18261 }
18262 }
18263 }
18264 }
18265
18266 ///
18267 /// Sets the *request* property to the given value.
18268 ///
18269 /// Even though the property as already been set when instantiating this call,
18270 /// we provide this method for API completeness.
18271 pub fn request(
18272 mut self,
18273 new_value: TestIamPermissionsRequest,
18274 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
18275 self._request = new_value;
18276 self
18277 }
18278 /// 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.
18279 ///
18280 /// Sets the *resource* path property to the given value.
18281 ///
18282 /// Even though the property as already been set when instantiating this call,
18283 /// we provide this method for API completeness.
18284 pub fn resource(
18285 mut self,
18286 new_value: &str,
18287 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
18288 self._resource = new_value.to_string();
18289 self
18290 }
18291 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18292 /// while executing the actual API request.
18293 ///
18294 /// ````text
18295 /// It should be used to handle progress information, and to implement a certain level of resilience.
18296 /// ````
18297 ///
18298 /// Sets the *delegate* property to the given value.
18299 pub fn delegate(
18300 mut self,
18301 new_value: &'a mut dyn common::Delegate,
18302 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
18303 self._delegate = Some(new_value);
18304 self
18305 }
18306
18307 /// Set any additional parameter of the query string used in the request.
18308 /// It should be used to set parameters which are not yet available through their own
18309 /// setters.
18310 ///
18311 /// Please note that this method must not be used to set any of the known parameters
18312 /// which have their own setter method. If done anyway, the request will fail.
18313 ///
18314 /// # Additional Parameters
18315 ///
18316 /// * *$.xgafv* (query-string) - V1 error format.
18317 /// * *access_token* (query-string) - OAuth access token.
18318 /// * *alt* (query-string) - Data format for response.
18319 /// * *callback* (query-string) - JSONP
18320 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18321 /// * *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.
18322 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18323 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18324 /// * *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.
18325 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18326 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18327 pub fn param<T>(
18328 mut self,
18329 name: T,
18330 value: T,
18331 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
18332 where
18333 T: AsRef<str>,
18334 {
18335 self._additional_params
18336 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18337 self
18338 }
18339
18340 /// Identifies the authorization scope for the method you are building.
18341 ///
18342 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18343 /// [`Scope::CloudPlatform`].
18344 ///
18345 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18346 /// tokens for more than one scope.
18347 ///
18348 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18349 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18350 /// sufficient, a read-write scope will do as well.
18351 pub fn add_scope<St>(
18352 mut self,
18353 scope: St,
18354 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
18355 where
18356 St: AsRef<str>,
18357 {
18358 self._scopes.insert(String::from(scope.as_ref()));
18359 self
18360 }
18361 /// Identifies the authorization scope(s) for the method you are building.
18362 ///
18363 /// See [`Self::add_scope()`] for details.
18364 pub fn add_scopes<I, St>(
18365 mut self,
18366 scopes: I,
18367 ) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C>
18368 where
18369 I: IntoIterator<Item = St>,
18370 St: AsRef<str>,
18371 {
18372 self._scopes
18373 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18374 self
18375 }
18376
18377 /// Removes all scopes, and no default scope will be used either.
18378 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18379 /// for details).
18380 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingImportJobTestIamPermissionCall<'a, C> {
18381 self._scopes.clear();
18382 self
18383 }
18384}
18385
18386/// Create a new KeyRing in a given Project and Location.
18387///
18388/// A builder for the *locations.keyRings.create* method supported by a *project* resource.
18389/// It is not used directly, but through a [`ProjectMethods`] instance.
18390///
18391/// # Example
18392///
18393/// Instantiate a resource method builder
18394///
18395/// ```test_harness,no_run
18396/// # extern crate hyper;
18397/// # extern crate hyper_rustls;
18398/// # extern crate google_cloudkms1 as cloudkms1;
18399/// use cloudkms1::api::KeyRing;
18400/// # async fn dox() {
18401/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18402///
18403/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18405/// # secret,
18406/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18407/// # ).build().await.unwrap();
18408///
18409/// # let client = hyper_util::client::legacy::Client::builder(
18410/// # hyper_util::rt::TokioExecutor::new()
18411/// # )
18412/// # .build(
18413/// # hyper_rustls::HttpsConnectorBuilder::new()
18414/// # .with_native_roots()
18415/// # .unwrap()
18416/// # .https_or_http()
18417/// # .enable_http1()
18418/// # .build()
18419/// # );
18420/// # let mut hub = CloudKMS::new(client, auth);
18421/// // As the method needs a request, you would usually fill it with the desired information
18422/// // into the respective structure. Some of the parts shown here might not be applicable !
18423/// // Values shown here are possibly random and not representative !
18424/// let mut req = KeyRing::default();
18425///
18426/// // You can configure optional parameters by calling the respective setters at will, and
18427/// // execute the final call using `doit()`.
18428/// // Values shown here are possibly random and not representative !
18429/// let result = hub.projects().locations_key_rings_create(req, "parent")
18430/// .key_ring_id("gubergren")
18431/// .doit().await;
18432/// # }
18433/// ```
18434pub struct ProjectLocationKeyRingCreateCall<'a, C>
18435where
18436 C: 'a,
18437{
18438 hub: &'a CloudKMS<C>,
18439 _request: KeyRing,
18440 _parent: String,
18441 _key_ring_id: Option<String>,
18442 _delegate: Option<&'a mut dyn common::Delegate>,
18443 _additional_params: HashMap<String, String>,
18444 _scopes: BTreeSet<String>,
18445}
18446
18447impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCreateCall<'a, C> {}
18448
18449impl<'a, C> ProjectLocationKeyRingCreateCall<'a, C>
18450where
18451 C: common::Connector,
18452{
18453 /// Perform the operation you have build so far.
18454 pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
18455 use std::borrow::Cow;
18456 use std::io::{Read, Seek};
18457
18458 use common::{url::Params, ToParts};
18459 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18460
18461 let mut dd = common::DefaultDelegate;
18462 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18463 dlg.begin(common::MethodInfo {
18464 id: "cloudkms.projects.locations.keyRings.create",
18465 http_method: hyper::Method::POST,
18466 });
18467
18468 for &field in ["alt", "parent", "keyRingId"].iter() {
18469 if self._additional_params.contains_key(field) {
18470 dlg.finished(false);
18471 return Err(common::Error::FieldClash(field));
18472 }
18473 }
18474
18475 let mut params = Params::with_capacity(5 + self._additional_params.len());
18476 params.push("parent", self._parent);
18477 if let Some(value) = self._key_ring_id.as_ref() {
18478 params.push("keyRingId", value);
18479 }
18480
18481 params.extend(self._additional_params.iter());
18482
18483 params.push("alt", "json");
18484 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyRings";
18485 if self._scopes.is_empty() {
18486 self._scopes
18487 .insert(Scope::CloudPlatform.as_ref().to_string());
18488 }
18489
18490 #[allow(clippy::single_element_loop)]
18491 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18492 url = params.uri_replacement(url, param_name, find_this, true);
18493 }
18494 {
18495 let to_remove = ["parent"];
18496 params.remove_params(&to_remove);
18497 }
18498
18499 let url = params.parse_with_url(&url);
18500
18501 let mut json_mime_type = mime::APPLICATION_JSON;
18502 let mut request_value_reader = {
18503 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18504 common::remove_json_null_values(&mut value);
18505 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18506 serde_json::to_writer(&mut dst, &value).unwrap();
18507 dst
18508 };
18509 let request_size = request_value_reader
18510 .seek(std::io::SeekFrom::End(0))
18511 .unwrap();
18512 request_value_reader
18513 .seek(std::io::SeekFrom::Start(0))
18514 .unwrap();
18515
18516 loop {
18517 let token = match self
18518 .hub
18519 .auth
18520 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18521 .await
18522 {
18523 Ok(token) => token,
18524 Err(e) => match dlg.token(e) {
18525 Ok(token) => token,
18526 Err(e) => {
18527 dlg.finished(false);
18528 return Err(common::Error::MissingToken(e));
18529 }
18530 },
18531 };
18532 request_value_reader
18533 .seek(std::io::SeekFrom::Start(0))
18534 .unwrap();
18535 let mut req_result = {
18536 let client = &self.hub.client;
18537 dlg.pre_request();
18538 let mut req_builder = hyper::Request::builder()
18539 .method(hyper::Method::POST)
18540 .uri(url.as_str())
18541 .header(USER_AGENT, self.hub._user_agent.clone());
18542
18543 if let Some(token) = token.as_ref() {
18544 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18545 }
18546
18547 let request = req_builder
18548 .header(CONTENT_TYPE, json_mime_type.to_string())
18549 .header(CONTENT_LENGTH, request_size as u64)
18550 .body(common::to_body(
18551 request_value_reader.get_ref().clone().into(),
18552 ));
18553
18554 client.request(request.unwrap()).await
18555 };
18556
18557 match req_result {
18558 Err(err) => {
18559 if let common::Retry::After(d) = dlg.http_error(&err) {
18560 sleep(d).await;
18561 continue;
18562 }
18563 dlg.finished(false);
18564 return Err(common::Error::HttpError(err));
18565 }
18566 Ok(res) => {
18567 let (mut parts, body) = res.into_parts();
18568 let mut body = common::Body::new(body);
18569 if !parts.status.is_success() {
18570 let bytes = common::to_bytes(body).await.unwrap_or_default();
18571 let error = serde_json::from_str(&common::to_string(&bytes));
18572 let response = common::to_response(parts, bytes.into());
18573
18574 if let common::Retry::After(d) =
18575 dlg.http_failure(&response, error.as_ref().ok())
18576 {
18577 sleep(d).await;
18578 continue;
18579 }
18580
18581 dlg.finished(false);
18582
18583 return Err(match error {
18584 Ok(value) => common::Error::BadRequest(value),
18585 _ => common::Error::Failure(response),
18586 });
18587 }
18588 let response = {
18589 let bytes = common::to_bytes(body).await.unwrap_or_default();
18590 let encoded = common::to_string(&bytes);
18591 match serde_json::from_str(&encoded) {
18592 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18593 Err(error) => {
18594 dlg.response_json_decode_error(&encoded, &error);
18595 return Err(common::Error::JsonDecodeError(
18596 encoded.to_string(),
18597 error,
18598 ));
18599 }
18600 }
18601 };
18602
18603 dlg.finished(true);
18604 return Ok(response);
18605 }
18606 }
18607 }
18608 }
18609
18610 ///
18611 /// Sets the *request* property to the given value.
18612 ///
18613 /// Even though the property as already been set when instantiating this call,
18614 /// we provide this method for API completeness.
18615 pub fn request(mut self, new_value: KeyRing) -> ProjectLocationKeyRingCreateCall<'a, C> {
18616 self._request = new_value;
18617 self
18618 }
18619 /// Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
18620 ///
18621 /// Sets the *parent* path property to the given value.
18622 ///
18623 /// Even though the property as already been set when instantiating this call,
18624 /// we provide this method for API completeness.
18625 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
18626 self._parent = new_value.to_string();
18627 self
18628 }
18629 /// Required. It must be unique within a location and match the regular expression `[a-zA-Z0-9_-]{1,63}`
18630 ///
18631 /// Sets the *key ring id* query property to the given value.
18632 pub fn key_ring_id(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
18633 self._key_ring_id = Some(new_value.to_string());
18634 self
18635 }
18636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18637 /// while executing the actual API request.
18638 ///
18639 /// ````text
18640 /// It should be used to handle progress information, and to implement a certain level of resilience.
18641 /// ````
18642 ///
18643 /// Sets the *delegate* property to the given value.
18644 pub fn delegate(
18645 mut self,
18646 new_value: &'a mut dyn common::Delegate,
18647 ) -> ProjectLocationKeyRingCreateCall<'a, C> {
18648 self._delegate = Some(new_value);
18649 self
18650 }
18651
18652 /// Set any additional parameter of the query string used in the request.
18653 /// It should be used to set parameters which are not yet available through their own
18654 /// setters.
18655 ///
18656 /// Please note that this method must not be used to set any of the known parameters
18657 /// which have their own setter method. If done anyway, the request will fail.
18658 ///
18659 /// # Additional Parameters
18660 ///
18661 /// * *$.xgafv* (query-string) - V1 error format.
18662 /// * *access_token* (query-string) - OAuth access token.
18663 /// * *alt* (query-string) - Data format for response.
18664 /// * *callback* (query-string) - JSONP
18665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18666 /// * *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.
18667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18669 /// * *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.
18670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18672 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCreateCall<'a, C>
18673 where
18674 T: AsRef<str>,
18675 {
18676 self._additional_params
18677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18678 self
18679 }
18680
18681 /// Identifies the authorization scope for the method you are building.
18682 ///
18683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18684 /// [`Scope::CloudPlatform`].
18685 ///
18686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18687 /// tokens for more than one scope.
18688 ///
18689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18691 /// sufficient, a read-write scope will do as well.
18692 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCreateCall<'a, C>
18693 where
18694 St: AsRef<str>,
18695 {
18696 self._scopes.insert(String::from(scope.as_ref()));
18697 self
18698 }
18699 /// Identifies the authorization scope(s) for the method you are building.
18700 ///
18701 /// See [`Self::add_scope()`] for details.
18702 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCreateCall<'a, C>
18703 where
18704 I: IntoIterator<Item = St>,
18705 St: AsRef<str>,
18706 {
18707 self._scopes
18708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18709 self
18710 }
18711
18712 /// Removes all scopes, and no default scope will be used either.
18713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18714 /// for details).
18715 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCreateCall<'a, C> {
18716 self._scopes.clear();
18717 self
18718 }
18719}
18720
18721/// Returns metadata for a given KeyRing.
18722///
18723/// A builder for the *locations.keyRings.get* method supported by a *project* resource.
18724/// It is not used directly, but through a [`ProjectMethods`] instance.
18725///
18726/// # Example
18727///
18728/// Instantiate a resource method builder
18729///
18730/// ```test_harness,no_run
18731/// # extern crate hyper;
18732/// # extern crate hyper_rustls;
18733/// # extern crate google_cloudkms1 as cloudkms1;
18734/// # async fn dox() {
18735/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18736///
18737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18739/// # secret,
18740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18741/// # ).build().await.unwrap();
18742///
18743/// # let client = hyper_util::client::legacy::Client::builder(
18744/// # hyper_util::rt::TokioExecutor::new()
18745/// # )
18746/// # .build(
18747/// # hyper_rustls::HttpsConnectorBuilder::new()
18748/// # .with_native_roots()
18749/// # .unwrap()
18750/// # .https_or_http()
18751/// # .enable_http1()
18752/// # .build()
18753/// # );
18754/// # let mut hub = CloudKMS::new(client, auth);
18755/// // You can configure optional parameters by calling the respective setters at will, and
18756/// // execute the final call using `doit()`.
18757/// // Values shown here are possibly random and not representative !
18758/// let result = hub.projects().locations_key_rings_get("name")
18759/// .doit().await;
18760/// # }
18761/// ```
18762pub struct ProjectLocationKeyRingGetCall<'a, C>
18763where
18764 C: 'a,
18765{
18766 hub: &'a CloudKMS<C>,
18767 _name: String,
18768 _delegate: Option<&'a mut dyn common::Delegate>,
18769 _additional_params: HashMap<String, String>,
18770 _scopes: BTreeSet<String>,
18771}
18772
18773impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetCall<'a, C> {}
18774
18775impl<'a, C> ProjectLocationKeyRingGetCall<'a, C>
18776where
18777 C: common::Connector,
18778{
18779 /// Perform the operation you have build so far.
18780 pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
18781 use std::borrow::Cow;
18782 use std::io::{Read, Seek};
18783
18784 use common::{url::Params, ToParts};
18785 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18786
18787 let mut dd = common::DefaultDelegate;
18788 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18789 dlg.begin(common::MethodInfo {
18790 id: "cloudkms.projects.locations.keyRings.get",
18791 http_method: hyper::Method::GET,
18792 });
18793
18794 for &field in ["alt", "name"].iter() {
18795 if self._additional_params.contains_key(field) {
18796 dlg.finished(false);
18797 return Err(common::Error::FieldClash(field));
18798 }
18799 }
18800
18801 let mut params = Params::with_capacity(3 + self._additional_params.len());
18802 params.push("name", self._name);
18803
18804 params.extend(self._additional_params.iter());
18805
18806 params.push("alt", "json");
18807 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18808 if self._scopes.is_empty() {
18809 self._scopes
18810 .insert(Scope::CloudPlatform.as_ref().to_string());
18811 }
18812
18813 #[allow(clippy::single_element_loop)]
18814 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18815 url = params.uri_replacement(url, param_name, find_this, true);
18816 }
18817 {
18818 let to_remove = ["name"];
18819 params.remove_params(&to_remove);
18820 }
18821
18822 let url = params.parse_with_url(&url);
18823
18824 loop {
18825 let token = match self
18826 .hub
18827 .auth
18828 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18829 .await
18830 {
18831 Ok(token) => token,
18832 Err(e) => match dlg.token(e) {
18833 Ok(token) => token,
18834 Err(e) => {
18835 dlg.finished(false);
18836 return Err(common::Error::MissingToken(e));
18837 }
18838 },
18839 };
18840 let mut req_result = {
18841 let client = &self.hub.client;
18842 dlg.pre_request();
18843 let mut req_builder = hyper::Request::builder()
18844 .method(hyper::Method::GET)
18845 .uri(url.as_str())
18846 .header(USER_AGENT, self.hub._user_agent.clone());
18847
18848 if let Some(token) = token.as_ref() {
18849 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18850 }
18851
18852 let request = req_builder
18853 .header(CONTENT_LENGTH, 0_u64)
18854 .body(common::to_body::<String>(None));
18855
18856 client.request(request.unwrap()).await
18857 };
18858
18859 match req_result {
18860 Err(err) => {
18861 if let common::Retry::After(d) = dlg.http_error(&err) {
18862 sleep(d).await;
18863 continue;
18864 }
18865 dlg.finished(false);
18866 return Err(common::Error::HttpError(err));
18867 }
18868 Ok(res) => {
18869 let (mut parts, body) = res.into_parts();
18870 let mut body = common::Body::new(body);
18871 if !parts.status.is_success() {
18872 let bytes = common::to_bytes(body).await.unwrap_or_default();
18873 let error = serde_json::from_str(&common::to_string(&bytes));
18874 let response = common::to_response(parts, bytes.into());
18875
18876 if let common::Retry::After(d) =
18877 dlg.http_failure(&response, error.as_ref().ok())
18878 {
18879 sleep(d).await;
18880 continue;
18881 }
18882
18883 dlg.finished(false);
18884
18885 return Err(match error {
18886 Ok(value) => common::Error::BadRequest(value),
18887 _ => common::Error::Failure(response),
18888 });
18889 }
18890 let response = {
18891 let bytes = common::to_bytes(body).await.unwrap_or_default();
18892 let encoded = common::to_string(&bytes);
18893 match serde_json::from_str(&encoded) {
18894 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18895 Err(error) => {
18896 dlg.response_json_decode_error(&encoded, &error);
18897 return Err(common::Error::JsonDecodeError(
18898 encoded.to_string(),
18899 error,
18900 ));
18901 }
18902 }
18903 };
18904
18905 dlg.finished(true);
18906 return Ok(response);
18907 }
18908 }
18909 }
18910 }
18911
18912 /// Required. The name of the KeyRing to get.
18913 ///
18914 /// Sets the *name* path property to the given value.
18915 ///
18916 /// Even though the property as already been set when instantiating this call,
18917 /// we provide this method for API completeness.
18918 pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
18919 self._name = new_value.to_string();
18920 self
18921 }
18922 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18923 /// while executing the actual API request.
18924 ///
18925 /// ````text
18926 /// It should be used to handle progress information, and to implement a certain level of resilience.
18927 /// ````
18928 ///
18929 /// Sets the *delegate* property to the given value.
18930 pub fn delegate(
18931 mut self,
18932 new_value: &'a mut dyn common::Delegate,
18933 ) -> ProjectLocationKeyRingGetCall<'a, C> {
18934 self._delegate = Some(new_value);
18935 self
18936 }
18937
18938 /// Set any additional parameter of the query string used in the request.
18939 /// It should be used to set parameters which are not yet available through their own
18940 /// setters.
18941 ///
18942 /// Please note that this method must not be used to set any of the known parameters
18943 /// which have their own setter method. If done anyway, the request will fail.
18944 ///
18945 /// # Additional Parameters
18946 ///
18947 /// * *$.xgafv* (query-string) - V1 error format.
18948 /// * *access_token* (query-string) - OAuth access token.
18949 /// * *alt* (query-string) - Data format for response.
18950 /// * *callback* (query-string) - JSONP
18951 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18952 /// * *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.
18953 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18954 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18955 /// * *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.
18956 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18957 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18958 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetCall<'a, C>
18959 where
18960 T: AsRef<str>,
18961 {
18962 self._additional_params
18963 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18964 self
18965 }
18966
18967 /// Identifies the authorization scope for the method you are building.
18968 ///
18969 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18970 /// [`Scope::CloudPlatform`].
18971 ///
18972 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18973 /// tokens for more than one scope.
18974 ///
18975 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18976 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18977 /// sufficient, a read-write scope will do as well.
18978 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetCall<'a, C>
18979 where
18980 St: AsRef<str>,
18981 {
18982 self._scopes.insert(String::from(scope.as_ref()));
18983 self
18984 }
18985 /// Identifies the authorization scope(s) for the method you are building.
18986 ///
18987 /// See [`Self::add_scope()`] for details.
18988 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetCall<'a, C>
18989 where
18990 I: IntoIterator<Item = St>,
18991 St: AsRef<str>,
18992 {
18993 self._scopes
18994 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18995 self
18996 }
18997
18998 /// Removes all scopes, and no default scope will be used either.
18999 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19000 /// for details).
19001 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetCall<'a, C> {
19002 self._scopes.clear();
19003 self
19004 }
19005}
19006
19007/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
19008///
19009/// A builder for the *locations.keyRings.getIamPolicy* method supported by a *project* resource.
19010/// It is not used directly, but through a [`ProjectMethods`] instance.
19011///
19012/// # Example
19013///
19014/// Instantiate a resource method builder
19015///
19016/// ```test_harness,no_run
19017/// # extern crate hyper;
19018/// # extern crate hyper_rustls;
19019/// # extern crate google_cloudkms1 as cloudkms1;
19020/// # async fn dox() {
19021/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19022///
19023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19025/// # secret,
19026/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19027/// # ).build().await.unwrap();
19028///
19029/// # let client = hyper_util::client::legacy::Client::builder(
19030/// # hyper_util::rt::TokioExecutor::new()
19031/// # )
19032/// # .build(
19033/// # hyper_rustls::HttpsConnectorBuilder::new()
19034/// # .with_native_roots()
19035/// # .unwrap()
19036/// # .https_or_http()
19037/// # .enable_http1()
19038/// # .build()
19039/// # );
19040/// # let mut hub = CloudKMS::new(client, auth);
19041/// // You can configure optional parameters by calling the respective setters at will, and
19042/// // execute the final call using `doit()`.
19043/// // Values shown here are possibly random and not representative !
19044/// let result = hub.projects().locations_key_rings_get_iam_policy("resource")
19045/// .options_requested_policy_version(-78)
19046/// .doit().await;
19047/// # }
19048/// ```
19049pub struct ProjectLocationKeyRingGetIamPolicyCall<'a, C>
19050where
19051 C: 'a,
19052{
19053 hub: &'a CloudKMS<C>,
19054 _resource: String,
19055 _options_requested_policy_version: Option<i32>,
19056 _delegate: Option<&'a mut dyn common::Delegate>,
19057 _additional_params: HashMap<String, String>,
19058 _scopes: BTreeSet<String>,
19059}
19060
19061impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetIamPolicyCall<'a, C> {}
19062
19063impl<'a, C> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
19064where
19065 C: common::Connector,
19066{
19067 /// Perform the operation you have build so far.
19068 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19069 use std::borrow::Cow;
19070 use std::io::{Read, Seek};
19071
19072 use common::{url::Params, ToParts};
19073 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19074
19075 let mut dd = common::DefaultDelegate;
19076 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19077 dlg.begin(common::MethodInfo {
19078 id: "cloudkms.projects.locations.keyRings.getIamPolicy",
19079 http_method: hyper::Method::GET,
19080 });
19081
19082 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
19083 if self._additional_params.contains_key(field) {
19084 dlg.finished(false);
19085 return Err(common::Error::FieldClash(field));
19086 }
19087 }
19088
19089 let mut params = Params::with_capacity(4 + self._additional_params.len());
19090 params.push("resource", self._resource);
19091 if let Some(value) = self._options_requested_policy_version.as_ref() {
19092 params.push("options.requestedPolicyVersion", value.to_string());
19093 }
19094
19095 params.extend(self._additional_params.iter());
19096
19097 params.push("alt", "json");
19098 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
19099 if self._scopes.is_empty() {
19100 self._scopes
19101 .insert(Scope::CloudPlatform.as_ref().to_string());
19102 }
19103
19104 #[allow(clippy::single_element_loop)]
19105 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19106 url = params.uri_replacement(url, param_name, find_this, true);
19107 }
19108 {
19109 let to_remove = ["resource"];
19110 params.remove_params(&to_remove);
19111 }
19112
19113 let url = params.parse_with_url(&url);
19114
19115 loop {
19116 let token = match self
19117 .hub
19118 .auth
19119 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19120 .await
19121 {
19122 Ok(token) => token,
19123 Err(e) => match dlg.token(e) {
19124 Ok(token) => token,
19125 Err(e) => {
19126 dlg.finished(false);
19127 return Err(common::Error::MissingToken(e));
19128 }
19129 },
19130 };
19131 let mut req_result = {
19132 let client = &self.hub.client;
19133 dlg.pre_request();
19134 let mut req_builder = hyper::Request::builder()
19135 .method(hyper::Method::GET)
19136 .uri(url.as_str())
19137 .header(USER_AGENT, self.hub._user_agent.clone());
19138
19139 if let Some(token) = token.as_ref() {
19140 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19141 }
19142
19143 let request = req_builder
19144 .header(CONTENT_LENGTH, 0_u64)
19145 .body(common::to_body::<String>(None));
19146
19147 client.request(request.unwrap()).await
19148 };
19149
19150 match req_result {
19151 Err(err) => {
19152 if let common::Retry::After(d) = dlg.http_error(&err) {
19153 sleep(d).await;
19154 continue;
19155 }
19156 dlg.finished(false);
19157 return Err(common::Error::HttpError(err));
19158 }
19159 Ok(res) => {
19160 let (mut parts, body) = res.into_parts();
19161 let mut body = common::Body::new(body);
19162 if !parts.status.is_success() {
19163 let bytes = common::to_bytes(body).await.unwrap_or_default();
19164 let error = serde_json::from_str(&common::to_string(&bytes));
19165 let response = common::to_response(parts, bytes.into());
19166
19167 if let common::Retry::After(d) =
19168 dlg.http_failure(&response, error.as_ref().ok())
19169 {
19170 sleep(d).await;
19171 continue;
19172 }
19173
19174 dlg.finished(false);
19175
19176 return Err(match error {
19177 Ok(value) => common::Error::BadRequest(value),
19178 _ => common::Error::Failure(response),
19179 });
19180 }
19181 let response = {
19182 let bytes = common::to_bytes(body).await.unwrap_or_default();
19183 let encoded = common::to_string(&bytes);
19184 match serde_json::from_str(&encoded) {
19185 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19186 Err(error) => {
19187 dlg.response_json_decode_error(&encoded, &error);
19188 return Err(common::Error::JsonDecodeError(
19189 encoded.to_string(),
19190 error,
19191 ));
19192 }
19193 }
19194 };
19195
19196 dlg.finished(true);
19197 return Ok(response);
19198 }
19199 }
19200 }
19201 }
19202
19203 /// 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.
19204 ///
19205 /// Sets the *resource* path property to the given value.
19206 ///
19207 /// Even though the property as already been set when instantiating this call,
19208 /// we provide this method for API completeness.
19209 pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
19210 self._resource = new_value.to_string();
19211 self
19212 }
19213 /// 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).
19214 ///
19215 /// Sets the *options.requested policy version* query property to the given value.
19216 pub fn options_requested_policy_version(
19217 mut self,
19218 new_value: i32,
19219 ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
19220 self._options_requested_policy_version = Some(new_value);
19221 self
19222 }
19223 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19224 /// while executing the actual API request.
19225 ///
19226 /// ````text
19227 /// It should be used to handle progress information, and to implement a certain level of resilience.
19228 /// ````
19229 ///
19230 /// Sets the *delegate* property to the given value.
19231 pub fn delegate(
19232 mut self,
19233 new_value: &'a mut dyn common::Delegate,
19234 ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
19235 self._delegate = Some(new_value);
19236 self
19237 }
19238
19239 /// Set any additional parameter of the query string used in the request.
19240 /// It should be used to set parameters which are not yet available through their own
19241 /// setters.
19242 ///
19243 /// Please note that this method must not be used to set any of the known parameters
19244 /// which have their own setter method. If done anyway, the request will fail.
19245 ///
19246 /// # Additional Parameters
19247 ///
19248 /// * *$.xgafv* (query-string) - V1 error format.
19249 /// * *access_token* (query-string) - OAuth access token.
19250 /// * *alt* (query-string) - Data format for response.
19251 /// * *callback* (query-string) - JSONP
19252 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19253 /// * *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.
19254 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19255 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19256 /// * *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.
19257 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19258 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19259 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
19260 where
19261 T: AsRef<str>,
19262 {
19263 self._additional_params
19264 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19265 self
19266 }
19267
19268 /// Identifies the authorization scope for the method you are building.
19269 ///
19270 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19271 /// [`Scope::CloudPlatform`].
19272 ///
19273 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19274 /// tokens for more than one scope.
19275 ///
19276 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19277 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19278 /// sufficient, a read-write scope will do as well.
19279 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
19280 where
19281 St: AsRef<str>,
19282 {
19283 self._scopes.insert(String::from(scope.as_ref()));
19284 self
19285 }
19286 /// Identifies the authorization scope(s) for the method you are building.
19287 ///
19288 /// See [`Self::add_scope()`] for details.
19289 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
19290 where
19291 I: IntoIterator<Item = St>,
19292 St: AsRef<str>,
19293 {
19294 self._scopes
19295 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19296 self
19297 }
19298
19299 /// Removes all scopes, and no default scope will be used either.
19300 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19301 /// for details).
19302 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
19303 self._scopes.clear();
19304 self
19305 }
19306}
19307
19308/// Lists KeyRings.
19309///
19310/// A builder for the *locations.keyRings.list* method supported by a *project* resource.
19311/// It is not used directly, but through a [`ProjectMethods`] instance.
19312///
19313/// # Example
19314///
19315/// Instantiate a resource method builder
19316///
19317/// ```test_harness,no_run
19318/// # extern crate hyper;
19319/// # extern crate hyper_rustls;
19320/// # extern crate google_cloudkms1 as cloudkms1;
19321/// # async fn dox() {
19322/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19323///
19324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19325/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19326/// # secret,
19327/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19328/// # ).build().await.unwrap();
19329///
19330/// # let client = hyper_util::client::legacy::Client::builder(
19331/// # hyper_util::rt::TokioExecutor::new()
19332/// # )
19333/// # .build(
19334/// # hyper_rustls::HttpsConnectorBuilder::new()
19335/// # .with_native_roots()
19336/// # .unwrap()
19337/// # .https_or_http()
19338/// # .enable_http1()
19339/// # .build()
19340/// # );
19341/// # let mut hub = CloudKMS::new(client, auth);
19342/// // You can configure optional parameters by calling the respective setters at will, and
19343/// // execute the final call using `doit()`.
19344/// // Values shown here are possibly random and not representative !
19345/// let result = hub.projects().locations_key_rings_list("parent")
19346/// .page_token("dolore")
19347/// .page_size(-34)
19348/// .order_by("voluptua.")
19349/// .filter("amet.")
19350/// .doit().await;
19351/// # }
19352/// ```
19353pub struct ProjectLocationKeyRingListCall<'a, C>
19354where
19355 C: 'a,
19356{
19357 hub: &'a CloudKMS<C>,
19358 _parent: String,
19359 _page_token: Option<String>,
19360 _page_size: Option<i32>,
19361 _order_by: Option<String>,
19362 _filter: Option<String>,
19363 _delegate: Option<&'a mut dyn common::Delegate>,
19364 _additional_params: HashMap<String, String>,
19365 _scopes: BTreeSet<String>,
19366}
19367
19368impl<'a, C> common::CallBuilder for ProjectLocationKeyRingListCall<'a, C> {}
19369
19370impl<'a, C> ProjectLocationKeyRingListCall<'a, C>
19371where
19372 C: common::Connector,
19373{
19374 /// Perform the operation you have build so far.
19375 pub async fn doit(mut self) -> common::Result<(common::Response, ListKeyRingsResponse)> {
19376 use std::borrow::Cow;
19377 use std::io::{Read, Seek};
19378
19379 use common::{url::Params, ToParts};
19380 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19381
19382 let mut dd = common::DefaultDelegate;
19383 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19384 dlg.begin(common::MethodInfo {
19385 id: "cloudkms.projects.locations.keyRings.list",
19386 http_method: hyper::Method::GET,
19387 });
19388
19389 for &field in [
19390 "alt",
19391 "parent",
19392 "pageToken",
19393 "pageSize",
19394 "orderBy",
19395 "filter",
19396 ]
19397 .iter()
19398 {
19399 if self._additional_params.contains_key(field) {
19400 dlg.finished(false);
19401 return Err(common::Error::FieldClash(field));
19402 }
19403 }
19404
19405 let mut params = Params::with_capacity(7 + self._additional_params.len());
19406 params.push("parent", self._parent);
19407 if let Some(value) = self._page_token.as_ref() {
19408 params.push("pageToken", value);
19409 }
19410 if let Some(value) = self._page_size.as_ref() {
19411 params.push("pageSize", value.to_string());
19412 }
19413 if let Some(value) = self._order_by.as_ref() {
19414 params.push("orderBy", value);
19415 }
19416 if let Some(value) = self._filter.as_ref() {
19417 params.push("filter", value);
19418 }
19419
19420 params.extend(self._additional_params.iter());
19421
19422 params.push("alt", "json");
19423 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyRings";
19424 if self._scopes.is_empty() {
19425 self._scopes
19426 .insert(Scope::CloudPlatform.as_ref().to_string());
19427 }
19428
19429 #[allow(clippy::single_element_loop)]
19430 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19431 url = params.uri_replacement(url, param_name, find_this, true);
19432 }
19433 {
19434 let to_remove = ["parent"];
19435 params.remove_params(&to_remove);
19436 }
19437
19438 let url = params.parse_with_url(&url);
19439
19440 loop {
19441 let token = match self
19442 .hub
19443 .auth
19444 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19445 .await
19446 {
19447 Ok(token) => token,
19448 Err(e) => match dlg.token(e) {
19449 Ok(token) => token,
19450 Err(e) => {
19451 dlg.finished(false);
19452 return Err(common::Error::MissingToken(e));
19453 }
19454 },
19455 };
19456 let mut req_result = {
19457 let client = &self.hub.client;
19458 dlg.pre_request();
19459 let mut req_builder = hyper::Request::builder()
19460 .method(hyper::Method::GET)
19461 .uri(url.as_str())
19462 .header(USER_AGENT, self.hub._user_agent.clone());
19463
19464 if let Some(token) = token.as_ref() {
19465 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19466 }
19467
19468 let request = req_builder
19469 .header(CONTENT_LENGTH, 0_u64)
19470 .body(common::to_body::<String>(None));
19471
19472 client.request(request.unwrap()).await
19473 };
19474
19475 match req_result {
19476 Err(err) => {
19477 if let common::Retry::After(d) = dlg.http_error(&err) {
19478 sleep(d).await;
19479 continue;
19480 }
19481 dlg.finished(false);
19482 return Err(common::Error::HttpError(err));
19483 }
19484 Ok(res) => {
19485 let (mut parts, body) = res.into_parts();
19486 let mut body = common::Body::new(body);
19487 if !parts.status.is_success() {
19488 let bytes = common::to_bytes(body).await.unwrap_or_default();
19489 let error = serde_json::from_str(&common::to_string(&bytes));
19490 let response = common::to_response(parts, bytes.into());
19491
19492 if let common::Retry::After(d) =
19493 dlg.http_failure(&response, error.as_ref().ok())
19494 {
19495 sleep(d).await;
19496 continue;
19497 }
19498
19499 dlg.finished(false);
19500
19501 return Err(match error {
19502 Ok(value) => common::Error::BadRequest(value),
19503 _ => common::Error::Failure(response),
19504 });
19505 }
19506 let response = {
19507 let bytes = common::to_bytes(body).await.unwrap_or_default();
19508 let encoded = common::to_string(&bytes);
19509 match serde_json::from_str(&encoded) {
19510 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19511 Err(error) => {
19512 dlg.response_json_decode_error(&encoded, &error);
19513 return Err(common::Error::JsonDecodeError(
19514 encoded.to_string(),
19515 error,
19516 ));
19517 }
19518 }
19519 };
19520
19521 dlg.finished(true);
19522 return Ok(response);
19523 }
19524 }
19525 }
19526 }
19527
19528 /// Required. The resource name of the location associated with the KeyRings, in the format `projects/*/locations/*`.
19529 ///
19530 /// Sets the *parent* path property to the given value.
19531 ///
19532 /// Even though the property as already been set when instantiating this call,
19533 /// we provide this method for API completeness.
19534 pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
19535 self._parent = new_value.to_string();
19536 self
19537 }
19538 /// Optional. Optional pagination token, returned earlier via ListKeyRingsResponse.next_page_token.
19539 ///
19540 /// Sets the *page token* query property to the given value.
19541 pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
19542 self._page_token = Some(new_value.to_string());
19543 self
19544 }
19545 /// 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.
19546 ///
19547 /// Sets the *page size* query property to the given value.
19548 pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingListCall<'a, C> {
19549 self._page_size = Some(new_value);
19550 self
19551 }
19552 /// 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).
19553 ///
19554 /// Sets the *order by* query property to the given value.
19555 pub fn order_by(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
19556 self._order_by = Some(new_value.to_string());
19557 self
19558 }
19559 /// 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).
19560 ///
19561 /// Sets the *filter* query property to the given value.
19562 pub fn filter(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
19563 self._filter = Some(new_value.to_string());
19564 self
19565 }
19566 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19567 /// while executing the actual API request.
19568 ///
19569 /// ````text
19570 /// It should be used to handle progress information, and to implement a certain level of resilience.
19571 /// ````
19572 ///
19573 /// Sets the *delegate* property to the given value.
19574 pub fn delegate(
19575 mut self,
19576 new_value: &'a mut dyn common::Delegate,
19577 ) -> ProjectLocationKeyRingListCall<'a, C> {
19578 self._delegate = Some(new_value);
19579 self
19580 }
19581
19582 /// Set any additional parameter of the query string used in the request.
19583 /// It should be used to set parameters which are not yet available through their own
19584 /// setters.
19585 ///
19586 /// Please note that this method must not be used to set any of the known parameters
19587 /// which have their own setter method. If done anyway, the request will fail.
19588 ///
19589 /// # Additional Parameters
19590 ///
19591 /// * *$.xgafv* (query-string) - V1 error format.
19592 /// * *access_token* (query-string) - OAuth access token.
19593 /// * *alt* (query-string) - Data format for response.
19594 /// * *callback* (query-string) - JSONP
19595 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19596 /// * *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.
19597 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19598 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19599 /// * *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.
19600 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19601 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19602 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingListCall<'a, C>
19603 where
19604 T: AsRef<str>,
19605 {
19606 self._additional_params
19607 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19608 self
19609 }
19610
19611 /// Identifies the authorization scope for the method you are building.
19612 ///
19613 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19614 /// [`Scope::CloudPlatform`].
19615 ///
19616 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19617 /// tokens for more than one scope.
19618 ///
19619 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19620 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19621 /// sufficient, a read-write scope will do as well.
19622 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingListCall<'a, C>
19623 where
19624 St: AsRef<str>,
19625 {
19626 self._scopes.insert(String::from(scope.as_ref()));
19627 self
19628 }
19629 /// Identifies the authorization scope(s) for the method you are building.
19630 ///
19631 /// See [`Self::add_scope()`] for details.
19632 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingListCall<'a, C>
19633 where
19634 I: IntoIterator<Item = St>,
19635 St: AsRef<str>,
19636 {
19637 self._scopes
19638 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19639 self
19640 }
19641
19642 /// Removes all scopes, and no default scope will be used either.
19643 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19644 /// for details).
19645 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingListCall<'a, C> {
19646 self._scopes.clear();
19647 self
19648 }
19649}
19650
19651/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
19652///
19653/// A builder for the *locations.keyRings.setIamPolicy* method supported by a *project* resource.
19654/// It is not used directly, but through a [`ProjectMethods`] instance.
19655///
19656/// # Example
19657///
19658/// Instantiate a resource method builder
19659///
19660/// ```test_harness,no_run
19661/// # extern crate hyper;
19662/// # extern crate hyper_rustls;
19663/// # extern crate google_cloudkms1 as cloudkms1;
19664/// use cloudkms1::api::SetIamPolicyRequest;
19665/// # async fn dox() {
19666/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19667///
19668/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19669/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19670/// # secret,
19671/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19672/// # ).build().await.unwrap();
19673///
19674/// # let client = hyper_util::client::legacy::Client::builder(
19675/// # hyper_util::rt::TokioExecutor::new()
19676/// # )
19677/// # .build(
19678/// # hyper_rustls::HttpsConnectorBuilder::new()
19679/// # .with_native_roots()
19680/// # .unwrap()
19681/// # .https_or_http()
19682/// # .enable_http1()
19683/// # .build()
19684/// # );
19685/// # let mut hub = CloudKMS::new(client, auth);
19686/// // As the method needs a request, you would usually fill it with the desired information
19687/// // into the respective structure. Some of the parts shown here might not be applicable !
19688/// // Values shown here are possibly random and not representative !
19689/// let mut req = SetIamPolicyRequest::default();
19690///
19691/// // You can configure optional parameters by calling the respective setters at will, and
19692/// // execute the final call using `doit()`.
19693/// // Values shown here are possibly random and not representative !
19694/// let result = hub.projects().locations_key_rings_set_iam_policy(req, "resource")
19695/// .doit().await;
19696/// # }
19697/// ```
19698pub struct ProjectLocationKeyRingSetIamPolicyCall<'a, C>
19699where
19700 C: 'a,
19701{
19702 hub: &'a CloudKMS<C>,
19703 _request: SetIamPolicyRequest,
19704 _resource: String,
19705 _delegate: Option<&'a mut dyn common::Delegate>,
19706 _additional_params: HashMap<String, String>,
19707 _scopes: BTreeSet<String>,
19708}
19709
19710impl<'a, C> common::CallBuilder for ProjectLocationKeyRingSetIamPolicyCall<'a, C> {}
19711
19712impl<'a, C> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
19713where
19714 C: common::Connector,
19715{
19716 /// Perform the operation you have build so far.
19717 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19718 use std::borrow::Cow;
19719 use std::io::{Read, Seek};
19720
19721 use common::{url::Params, ToParts};
19722 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19723
19724 let mut dd = common::DefaultDelegate;
19725 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19726 dlg.begin(common::MethodInfo {
19727 id: "cloudkms.projects.locations.keyRings.setIamPolicy",
19728 http_method: hyper::Method::POST,
19729 });
19730
19731 for &field in ["alt", "resource"].iter() {
19732 if self._additional_params.contains_key(field) {
19733 dlg.finished(false);
19734 return Err(common::Error::FieldClash(field));
19735 }
19736 }
19737
19738 let mut params = Params::with_capacity(4 + self._additional_params.len());
19739 params.push("resource", self._resource);
19740
19741 params.extend(self._additional_params.iter());
19742
19743 params.push("alt", "json");
19744 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
19745 if self._scopes.is_empty() {
19746 self._scopes
19747 .insert(Scope::CloudPlatform.as_ref().to_string());
19748 }
19749
19750 #[allow(clippy::single_element_loop)]
19751 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19752 url = params.uri_replacement(url, param_name, find_this, true);
19753 }
19754 {
19755 let to_remove = ["resource"];
19756 params.remove_params(&to_remove);
19757 }
19758
19759 let url = params.parse_with_url(&url);
19760
19761 let mut json_mime_type = mime::APPLICATION_JSON;
19762 let mut request_value_reader = {
19763 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19764 common::remove_json_null_values(&mut value);
19765 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19766 serde_json::to_writer(&mut dst, &value).unwrap();
19767 dst
19768 };
19769 let request_size = request_value_reader
19770 .seek(std::io::SeekFrom::End(0))
19771 .unwrap();
19772 request_value_reader
19773 .seek(std::io::SeekFrom::Start(0))
19774 .unwrap();
19775
19776 loop {
19777 let token = match self
19778 .hub
19779 .auth
19780 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19781 .await
19782 {
19783 Ok(token) => token,
19784 Err(e) => match dlg.token(e) {
19785 Ok(token) => token,
19786 Err(e) => {
19787 dlg.finished(false);
19788 return Err(common::Error::MissingToken(e));
19789 }
19790 },
19791 };
19792 request_value_reader
19793 .seek(std::io::SeekFrom::Start(0))
19794 .unwrap();
19795 let mut req_result = {
19796 let client = &self.hub.client;
19797 dlg.pre_request();
19798 let mut req_builder = hyper::Request::builder()
19799 .method(hyper::Method::POST)
19800 .uri(url.as_str())
19801 .header(USER_AGENT, self.hub._user_agent.clone());
19802
19803 if let Some(token) = token.as_ref() {
19804 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19805 }
19806
19807 let request = req_builder
19808 .header(CONTENT_TYPE, json_mime_type.to_string())
19809 .header(CONTENT_LENGTH, request_size as u64)
19810 .body(common::to_body(
19811 request_value_reader.get_ref().clone().into(),
19812 ));
19813
19814 client.request(request.unwrap()).await
19815 };
19816
19817 match req_result {
19818 Err(err) => {
19819 if let common::Retry::After(d) = dlg.http_error(&err) {
19820 sleep(d).await;
19821 continue;
19822 }
19823 dlg.finished(false);
19824 return Err(common::Error::HttpError(err));
19825 }
19826 Ok(res) => {
19827 let (mut parts, body) = res.into_parts();
19828 let mut body = common::Body::new(body);
19829 if !parts.status.is_success() {
19830 let bytes = common::to_bytes(body).await.unwrap_or_default();
19831 let error = serde_json::from_str(&common::to_string(&bytes));
19832 let response = common::to_response(parts, bytes.into());
19833
19834 if let common::Retry::After(d) =
19835 dlg.http_failure(&response, error.as_ref().ok())
19836 {
19837 sleep(d).await;
19838 continue;
19839 }
19840
19841 dlg.finished(false);
19842
19843 return Err(match error {
19844 Ok(value) => common::Error::BadRequest(value),
19845 _ => common::Error::Failure(response),
19846 });
19847 }
19848 let response = {
19849 let bytes = common::to_bytes(body).await.unwrap_or_default();
19850 let encoded = common::to_string(&bytes);
19851 match serde_json::from_str(&encoded) {
19852 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19853 Err(error) => {
19854 dlg.response_json_decode_error(&encoded, &error);
19855 return Err(common::Error::JsonDecodeError(
19856 encoded.to_string(),
19857 error,
19858 ));
19859 }
19860 }
19861 };
19862
19863 dlg.finished(true);
19864 return Ok(response);
19865 }
19866 }
19867 }
19868 }
19869
19870 ///
19871 /// Sets the *request* property to the given value.
19872 ///
19873 /// Even though the property as already been set when instantiating this call,
19874 /// we provide this method for API completeness.
19875 pub fn request(
19876 mut self,
19877 new_value: SetIamPolicyRequest,
19878 ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
19879 self._request = new_value;
19880 self
19881 }
19882 /// 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.
19883 ///
19884 /// Sets the *resource* path property to the given value.
19885 ///
19886 /// Even though the property as already been set when instantiating this call,
19887 /// we provide this method for API completeness.
19888 pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
19889 self._resource = new_value.to_string();
19890 self
19891 }
19892 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19893 /// while executing the actual API request.
19894 ///
19895 /// ````text
19896 /// It should be used to handle progress information, and to implement a certain level of resilience.
19897 /// ````
19898 ///
19899 /// Sets the *delegate* property to the given value.
19900 pub fn delegate(
19901 mut self,
19902 new_value: &'a mut dyn common::Delegate,
19903 ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
19904 self._delegate = Some(new_value);
19905 self
19906 }
19907
19908 /// Set any additional parameter of the query string used in the request.
19909 /// It should be used to set parameters which are not yet available through their own
19910 /// setters.
19911 ///
19912 /// Please note that this method must not be used to set any of the known parameters
19913 /// which have their own setter method. If done anyway, the request will fail.
19914 ///
19915 /// # Additional Parameters
19916 ///
19917 /// * *$.xgafv* (query-string) - V1 error format.
19918 /// * *access_token* (query-string) - OAuth access token.
19919 /// * *alt* (query-string) - Data format for response.
19920 /// * *callback* (query-string) - JSONP
19921 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19922 /// * *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.
19923 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19924 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19925 /// * *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.
19926 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19927 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19928 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
19929 where
19930 T: AsRef<str>,
19931 {
19932 self._additional_params
19933 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19934 self
19935 }
19936
19937 /// Identifies the authorization scope for the method you are building.
19938 ///
19939 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19940 /// [`Scope::CloudPlatform`].
19941 ///
19942 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19943 /// tokens for more than one scope.
19944 ///
19945 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19946 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19947 /// sufficient, a read-write scope will do as well.
19948 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
19949 where
19950 St: AsRef<str>,
19951 {
19952 self._scopes.insert(String::from(scope.as_ref()));
19953 self
19954 }
19955 /// Identifies the authorization scope(s) for the method you are building.
19956 ///
19957 /// See [`Self::add_scope()`] for details.
19958 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
19959 where
19960 I: IntoIterator<Item = St>,
19961 St: AsRef<str>,
19962 {
19963 self._scopes
19964 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19965 self
19966 }
19967
19968 /// Removes all scopes, and no default scope will be used either.
19969 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19970 /// for details).
19971 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
19972 self._scopes.clear();
19973 self
19974 }
19975}
19976
19977/// 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.
19978///
19979/// A builder for the *locations.keyRings.testIamPermissions* method supported by a *project* resource.
19980/// It is not used directly, but through a [`ProjectMethods`] instance.
19981///
19982/// # Example
19983///
19984/// Instantiate a resource method builder
19985///
19986/// ```test_harness,no_run
19987/// # extern crate hyper;
19988/// # extern crate hyper_rustls;
19989/// # extern crate google_cloudkms1 as cloudkms1;
19990/// use cloudkms1::api::TestIamPermissionsRequest;
19991/// # async fn dox() {
19992/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19993///
19994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19996/// # secret,
19997/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19998/// # ).build().await.unwrap();
19999///
20000/// # let client = hyper_util::client::legacy::Client::builder(
20001/// # hyper_util::rt::TokioExecutor::new()
20002/// # )
20003/// # .build(
20004/// # hyper_rustls::HttpsConnectorBuilder::new()
20005/// # .with_native_roots()
20006/// # .unwrap()
20007/// # .https_or_http()
20008/// # .enable_http1()
20009/// # .build()
20010/// # );
20011/// # let mut hub = CloudKMS::new(client, auth);
20012/// // As the method needs a request, you would usually fill it with the desired information
20013/// // into the respective structure. Some of the parts shown here might not be applicable !
20014/// // Values shown here are possibly random and not representative !
20015/// let mut req = TestIamPermissionsRequest::default();
20016///
20017/// // You can configure optional parameters by calling the respective setters at will, and
20018/// // execute the final call using `doit()`.
20019/// // Values shown here are possibly random and not representative !
20020/// let result = hub.projects().locations_key_rings_test_iam_permissions(req, "resource")
20021/// .doit().await;
20022/// # }
20023/// ```
20024pub struct ProjectLocationKeyRingTestIamPermissionCall<'a, C>
20025where
20026 C: 'a,
20027{
20028 hub: &'a CloudKMS<C>,
20029 _request: TestIamPermissionsRequest,
20030 _resource: String,
20031 _delegate: Option<&'a mut dyn common::Delegate>,
20032 _additional_params: HashMap<String, String>,
20033 _scopes: BTreeSet<String>,
20034}
20035
20036impl<'a, C> common::CallBuilder for ProjectLocationKeyRingTestIamPermissionCall<'a, C> {}
20037
20038impl<'a, C> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
20039where
20040 C: common::Connector,
20041{
20042 /// Perform the operation you have build so far.
20043 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
20044 use std::borrow::Cow;
20045 use std::io::{Read, Seek};
20046
20047 use common::{url::Params, ToParts};
20048 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20049
20050 let mut dd = common::DefaultDelegate;
20051 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20052 dlg.begin(common::MethodInfo {
20053 id: "cloudkms.projects.locations.keyRings.testIamPermissions",
20054 http_method: hyper::Method::POST,
20055 });
20056
20057 for &field in ["alt", "resource"].iter() {
20058 if self._additional_params.contains_key(field) {
20059 dlg.finished(false);
20060 return Err(common::Error::FieldClash(field));
20061 }
20062 }
20063
20064 let mut params = Params::with_capacity(4 + self._additional_params.len());
20065 params.push("resource", self._resource);
20066
20067 params.extend(self._additional_params.iter());
20068
20069 params.push("alt", "json");
20070 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
20071 if self._scopes.is_empty() {
20072 self._scopes
20073 .insert(Scope::CloudPlatform.as_ref().to_string());
20074 }
20075
20076 #[allow(clippy::single_element_loop)]
20077 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
20078 url = params.uri_replacement(url, param_name, find_this, true);
20079 }
20080 {
20081 let to_remove = ["resource"];
20082 params.remove_params(&to_remove);
20083 }
20084
20085 let url = params.parse_with_url(&url);
20086
20087 let mut json_mime_type = mime::APPLICATION_JSON;
20088 let mut request_value_reader = {
20089 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20090 common::remove_json_null_values(&mut value);
20091 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20092 serde_json::to_writer(&mut dst, &value).unwrap();
20093 dst
20094 };
20095 let request_size = request_value_reader
20096 .seek(std::io::SeekFrom::End(0))
20097 .unwrap();
20098 request_value_reader
20099 .seek(std::io::SeekFrom::Start(0))
20100 .unwrap();
20101
20102 loop {
20103 let token = match self
20104 .hub
20105 .auth
20106 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20107 .await
20108 {
20109 Ok(token) => token,
20110 Err(e) => match dlg.token(e) {
20111 Ok(token) => token,
20112 Err(e) => {
20113 dlg.finished(false);
20114 return Err(common::Error::MissingToken(e));
20115 }
20116 },
20117 };
20118 request_value_reader
20119 .seek(std::io::SeekFrom::Start(0))
20120 .unwrap();
20121 let mut req_result = {
20122 let client = &self.hub.client;
20123 dlg.pre_request();
20124 let mut req_builder = hyper::Request::builder()
20125 .method(hyper::Method::POST)
20126 .uri(url.as_str())
20127 .header(USER_AGENT, self.hub._user_agent.clone());
20128
20129 if let Some(token) = token.as_ref() {
20130 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20131 }
20132
20133 let request = req_builder
20134 .header(CONTENT_TYPE, json_mime_type.to_string())
20135 .header(CONTENT_LENGTH, request_size as u64)
20136 .body(common::to_body(
20137 request_value_reader.get_ref().clone().into(),
20138 ));
20139
20140 client.request(request.unwrap()).await
20141 };
20142
20143 match req_result {
20144 Err(err) => {
20145 if let common::Retry::After(d) = dlg.http_error(&err) {
20146 sleep(d).await;
20147 continue;
20148 }
20149 dlg.finished(false);
20150 return Err(common::Error::HttpError(err));
20151 }
20152 Ok(res) => {
20153 let (mut parts, body) = res.into_parts();
20154 let mut body = common::Body::new(body);
20155 if !parts.status.is_success() {
20156 let bytes = common::to_bytes(body).await.unwrap_or_default();
20157 let error = serde_json::from_str(&common::to_string(&bytes));
20158 let response = common::to_response(parts, bytes.into());
20159
20160 if let common::Retry::After(d) =
20161 dlg.http_failure(&response, error.as_ref().ok())
20162 {
20163 sleep(d).await;
20164 continue;
20165 }
20166
20167 dlg.finished(false);
20168
20169 return Err(match error {
20170 Ok(value) => common::Error::BadRequest(value),
20171 _ => common::Error::Failure(response),
20172 });
20173 }
20174 let response = {
20175 let bytes = common::to_bytes(body).await.unwrap_or_default();
20176 let encoded = common::to_string(&bytes);
20177 match serde_json::from_str(&encoded) {
20178 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20179 Err(error) => {
20180 dlg.response_json_decode_error(&encoded, &error);
20181 return Err(common::Error::JsonDecodeError(
20182 encoded.to_string(),
20183 error,
20184 ));
20185 }
20186 }
20187 };
20188
20189 dlg.finished(true);
20190 return Ok(response);
20191 }
20192 }
20193 }
20194 }
20195
20196 ///
20197 /// Sets the *request* property to the given value.
20198 ///
20199 /// Even though the property as already been set when instantiating this call,
20200 /// we provide this method for API completeness.
20201 pub fn request(
20202 mut self,
20203 new_value: TestIamPermissionsRequest,
20204 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
20205 self._request = new_value;
20206 self
20207 }
20208 /// 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.
20209 ///
20210 /// Sets the *resource* path property to the given value.
20211 ///
20212 /// Even though the property as already been set when instantiating this call,
20213 /// we provide this method for API completeness.
20214 pub fn resource(
20215 mut self,
20216 new_value: &str,
20217 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
20218 self._resource = new_value.to_string();
20219 self
20220 }
20221 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20222 /// while executing the actual API request.
20223 ///
20224 /// ````text
20225 /// It should be used to handle progress information, and to implement a certain level of resilience.
20226 /// ````
20227 ///
20228 /// Sets the *delegate* property to the given value.
20229 pub fn delegate(
20230 mut self,
20231 new_value: &'a mut dyn common::Delegate,
20232 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
20233 self._delegate = Some(new_value);
20234 self
20235 }
20236
20237 /// Set any additional parameter of the query string used in the request.
20238 /// It should be used to set parameters which are not yet available through their own
20239 /// setters.
20240 ///
20241 /// Please note that this method must not be used to set any of the known parameters
20242 /// which have their own setter method. If done anyway, the request will fail.
20243 ///
20244 /// # Additional Parameters
20245 ///
20246 /// * *$.xgafv* (query-string) - V1 error format.
20247 /// * *access_token* (query-string) - OAuth access token.
20248 /// * *alt* (query-string) - Data format for response.
20249 /// * *callback* (query-string) - JSONP
20250 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20251 /// * *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.
20252 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20253 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20254 /// * *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.
20255 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20256 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20257 pub fn param<T>(
20258 mut self,
20259 name: T,
20260 value: T,
20261 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
20262 where
20263 T: AsRef<str>,
20264 {
20265 self._additional_params
20266 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20267 self
20268 }
20269
20270 /// Identifies the authorization scope for the method you are building.
20271 ///
20272 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20273 /// [`Scope::CloudPlatform`].
20274 ///
20275 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20276 /// tokens for more than one scope.
20277 ///
20278 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20279 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20280 /// sufficient, a read-write scope will do as well.
20281 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
20282 where
20283 St: AsRef<str>,
20284 {
20285 self._scopes.insert(String::from(scope.as_ref()));
20286 self
20287 }
20288 /// Identifies the authorization scope(s) for the method you are building.
20289 ///
20290 /// See [`Self::add_scope()`] for details.
20291 pub fn add_scopes<I, St>(
20292 mut self,
20293 scopes: I,
20294 ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
20295 where
20296 I: IntoIterator<Item = St>,
20297 St: AsRef<str>,
20298 {
20299 self._scopes
20300 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20301 self
20302 }
20303
20304 /// Removes all scopes, and no default scope will be used either.
20305 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20306 /// for details).
20307 pub fn clear_scopes(mut self) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
20308 self._scopes.clear();
20309 self
20310 }
20311}
20312
20313/// 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.
20314///
20315/// A builder for the *locations.operations.get* method supported by a *project* resource.
20316/// It is not used directly, but through a [`ProjectMethods`] instance.
20317///
20318/// # Example
20319///
20320/// Instantiate a resource method builder
20321///
20322/// ```test_harness,no_run
20323/// # extern crate hyper;
20324/// # extern crate hyper_rustls;
20325/// # extern crate google_cloudkms1 as cloudkms1;
20326/// # async fn dox() {
20327/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20328///
20329/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20331/// # secret,
20332/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20333/// # ).build().await.unwrap();
20334///
20335/// # let client = hyper_util::client::legacy::Client::builder(
20336/// # hyper_util::rt::TokioExecutor::new()
20337/// # )
20338/// # .build(
20339/// # hyper_rustls::HttpsConnectorBuilder::new()
20340/// # .with_native_roots()
20341/// # .unwrap()
20342/// # .https_or_http()
20343/// # .enable_http1()
20344/// # .build()
20345/// # );
20346/// # let mut hub = CloudKMS::new(client, auth);
20347/// // You can configure optional parameters by calling the respective setters at will, and
20348/// // execute the final call using `doit()`.
20349/// // Values shown here are possibly random and not representative !
20350/// let result = hub.projects().locations_operations_get("name")
20351/// .doit().await;
20352/// # }
20353/// ```
20354pub struct ProjectLocationOperationGetCall<'a, C>
20355where
20356 C: 'a,
20357{
20358 hub: &'a CloudKMS<C>,
20359 _name: String,
20360 _delegate: Option<&'a mut dyn common::Delegate>,
20361 _additional_params: HashMap<String, String>,
20362 _scopes: BTreeSet<String>,
20363}
20364
20365impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
20366
20367impl<'a, C> ProjectLocationOperationGetCall<'a, C>
20368where
20369 C: common::Connector,
20370{
20371 /// Perform the operation you have build so far.
20372 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20373 use std::borrow::Cow;
20374 use std::io::{Read, Seek};
20375
20376 use common::{url::Params, ToParts};
20377 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20378
20379 let mut dd = common::DefaultDelegate;
20380 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20381 dlg.begin(common::MethodInfo {
20382 id: "cloudkms.projects.locations.operations.get",
20383 http_method: hyper::Method::GET,
20384 });
20385
20386 for &field in ["alt", "name"].iter() {
20387 if self._additional_params.contains_key(field) {
20388 dlg.finished(false);
20389 return Err(common::Error::FieldClash(field));
20390 }
20391 }
20392
20393 let mut params = Params::with_capacity(3 + self._additional_params.len());
20394 params.push("name", self._name);
20395
20396 params.extend(self._additional_params.iter());
20397
20398 params.push("alt", "json");
20399 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20400 if self._scopes.is_empty() {
20401 self._scopes
20402 .insert(Scope::CloudPlatform.as_ref().to_string());
20403 }
20404
20405 #[allow(clippy::single_element_loop)]
20406 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20407 url = params.uri_replacement(url, param_name, find_this, true);
20408 }
20409 {
20410 let to_remove = ["name"];
20411 params.remove_params(&to_remove);
20412 }
20413
20414 let url = params.parse_with_url(&url);
20415
20416 loop {
20417 let token = match self
20418 .hub
20419 .auth
20420 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20421 .await
20422 {
20423 Ok(token) => token,
20424 Err(e) => match dlg.token(e) {
20425 Ok(token) => token,
20426 Err(e) => {
20427 dlg.finished(false);
20428 return Err(common::Error::MissingToken(e));
20429 }
20430 },
20431 };
20432 let mut req_result = {
20433 let client = &self.hub.client;
20434 dlg.pre_request();
20435 let mut req_builder = hyper::Request::builder()
20436 .method(hyper::Method::GET)
20437 .uri(url.as_str())
20438 .header(USER_AGENT, self.hub._user_agent.clone());
20439
20440 if let Some(token) = token.as_ref() {
20441 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20442 }
20443
20444 let request = req_builder
20445 .header(CONTENT_LENGTH, 0_u64)
20446 .body(common::to_body::<String>(None));
20447
20448 client.request(request.unwrap()).await
20449 };
20450
20451 match req_result {
20452 Err(err) => {
20453 if let common::Retry::After(d) = dlg.http_error(&err) {
20454 sleep(d).await;
20455 continue;
20456 }
20457 dlg.finished(false);
20458 return Err(common::Error::HttpError(err));
20459 }
20460 Ok(res) => {
20461 let (mut parts, body) = res.into_parts();
20462 let mut body = common::Body::new(body);
20463 if !parts.status.is_success() {
20464 let bytes = common::to_bytes(body).await.unwrap_or_default();
20465 let error = serde_json::from_str(&common::to_string(&bytes));
20466 let response = common::to_response(parts, bytes.into());
20467
20468 if let common::Retry::After(d) =
20469 dlg.http_failure(&response, error.as_ref().ok())
20470 {
20471 sleep(d).await;
20472 continue;
20473 }
20474
20475 dlg.finished(false);
20476
20477 return Err(match error {
20478 Ok(value) => common::Error::BadRequest(value),
20479 _ => common::Error::Failure(response),
20480 });
20481 }
20482 let response = {
20483 let bytes = common::to_bytes(body).await.unwrap_or_default();
20484 let encoded = common::to_string(&bytes);
20485 match serde_json::from_str(&encoded) {
20486 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20487 Err(error) => {
20488 dlg.response_json_decode_error(&encoded, &error);
20489 return Err(common::Error::JsonDecodeError(
20490 encoded.to_string(),
20491 error,
20492 ));
20493 }
20494 }
20495 };
20496
20497 dlg.finished(true);
20498 return Ok(response);
20499 }
20500 }
20501 }
20502 }
20503
20504 /// The name of the operation resource.
20505 ///
20506 /// Sets the *name* path property to the given value.
20507 ///
20508 /// Even though the property as already been set when instantiating this call,
20509 /// we provide this method for API completeness.
20510 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
20511 self._name = new_value.to_string();
20512 self
20513 }
20514 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20515 /// while executing the actual API request.
20516 ///
20517 /// ````text
20518 /// It should be used to handle progress information, and to implement a certain level of resilience.
20519 /// ````
20520 ///
20521 /// Sets the *delegate* property to the given value.
20522 pub fn delegate(
20523 mut self,
20524 new_value: &'a mut dyn common::Delegate,
20525 ) -> ProjectLocationOperationGetCall<'a, C> {
20526 self._delegate = Some(new_value);
20527 self
20528 }
20529
20530 /// Set any additional parameter of the query string used in the request.
20531 /// It should be used to set parameters which are not yet available through their own
20532 /// setters.
20533 ///
20534 /// Please note that this method must not be used to set any of the known parameters
20535 /// which have their own setter method. If done anyway, the request will fail.
20536 ///
20537 /// # Additional Parameters
20538 ///
20539 /// * *$.xgafv* (query-string) - V1 error format.
20540 /// * *access_token* (query-string) - OAuth access token.
20541 /// * *alt* (query-string) - Data format for response.
20542 /// * *callback* (query-string) - JSONP
20543 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20544 /// * *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.
20545 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20546 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20547 /// * *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.
20548 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20549 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20550 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
20551 where
20552 T: AsRef<str>,
20553 {
20554 self._additional_params
20555 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20556 self
20557 }
20558
20559 /// Identifies the authorization scope for the method you are building.
20560 ///
20561 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20562 /// [`Scope::CloudPlatform`].
20563 ///
20564 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20565 /// tokens for more than one scope.
20566 ///
20567 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20568 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20569 /// sufficient, a read-write scope will do as well.
20570 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
20571 where
20572 St: AsRef<str>,
20573 {
20574 self._scopes.insert(String::from(scope.as_ref()));
20575 self
20576 }
20577 /// Identifies the authorization scope(s) for the method you are building.
20578 ///
20579 /// See [`Self::add_scope()`] for details.
20580 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
20581 where
20582 I: IntoIterator<Item = St>,
20583 St: AsRef<str>,
20584 {
20585 self._scopes
20586 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20587 self
20588 }
20589
20590 /// Removes all scopes, and no default scope will be used either.
20591 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20592 /// for details).
20593 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
20594 self._scopes.clear();
20595 self
20596 }
20597}
20598
20599/// Generate random bytes using the Cloud KMS randomness source in the provided location.
20600///
20601/// A builder for the *locations.generateRandomBytes* method supported by a *project* resource.
20602/// It is not used directly, but through a [`ProjectMethods`] instance.
20603///
20604/// # Example
20605///
20606/// Instantiate a resource method builder
20607///
20608/// ```test_harness,no_run
20609/// # extern crate hyper;
20610/// # extern crate hyper_rustls;
20611/// # extern crate google_cloudkms1 as cloudkms1;
20612/// use cloudkms1::api::GenerateRandomBytesRequest;
20613/// # async fn dox() {
20614/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20615///
20616/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20618/// # secret,
20619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20620/// # ).build().await.unwrap();
20621///
20622/// # let client = hyper_util::client::legacy::Client::builder(
20623/// # hyper_util::rt::TokioExecutor::new()
20624/// # )
20625/// # .build(
20626/// # hyper_rustls::HttpsConnectorBuilder::new()
20627/// # .with_native_roots()
20628/// # .unwrap()
20629/// # .https_or_http()
20630/// # .enable_http1()
20631/// # .build()
20632/// # );
20633/// # let mut hub = CloudKMS::new(client, auth);
20634/// // As the method needs a request, you would usually fill it with the desired information
20635/// // into the respective structure. Some of the parts shown here might not be applicable !
20636/// // Values shown here are possibly random and not representative !
20637/// let mut req = GenerateRandomBytesRequest::default();
20638///
20639/// // You can configure optional parameters by calling the respective setters at will, and
20640/// // execute the final call using `doit()`.
20641/// // Values shown here are possibly random and not representative !
20642/// let result = hub.projects().locations_generate_random_bytes(req, "location")
20643/// .doit().await;
20644/// # }
20645/// ```
20646pub struct ProjectLocationGenerateRandomByteCall<'a, C>
20647where
20648 C: 'a,
20649{
20650 hub: &'a CloudKMS<C>,
20651 _request: GenerateRandomBytesRequest,
20652 _location: String,
20653 _delegate: Option<&'a mut dyn common::Delegate>,
20654 _additional_params: HashMap<String, String>,
20655 _scopes: BTreeSet<String>,
20656}
20657
20658impl<'a, C> common::CallBuilder for ProjectLocationGenerateRandomByteCall<'a, C> {}
20659
20660impl<'a, C> ProjectLocationGenerateRandomByteCall<'a, C>
20661where
20662 C: common::Connector,
20663{
20664 /// Perform the operation you have build so far.
20665 pub async fn doit(mut self) -> common::Result<(common::Response, GenerateRandomBytesResponse)> {
20666 use std::borrow::Cow;
20667 use std::io::{Read, Seek};
20668
20669 use common::{url::Params, ToParts};
20670 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20671
20672 let mut dd = common::DefaultDelegate;
20673 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20674 dlg.begin(common::MethodInfo {
20675 id: "cloudkms.projects.locations.generateRandomBytes",
20676 http_method: hyper::Method::POST,
20677 });
20678
20679 for &field in ["alt", "location"].iter() {
20680 if self._additional_params.contains_key(field) {
20681 dlg.finished(false);
20682 return Err(common::Error::FieldClash(field));
20683 }
20684 }
20685
20686 let mut params = Params::with_capacity(4 + self._additional_params.len());
20687 params.push("location", self._location);
20688
20689 params.extend(self._additional_params.iter());
20690
20691 params.push("alt", "json");
20692 let mut url = self.hub._base_url.clone() + "v1/{+location}:generateRandomBytes";
20693 if self._scopes.is_empty() {
20694 self._scopes
20695 .insert(Scope::CloudPlatform.as_ref().to_string());
20696 }
20697
20698 #[allow(clippy::single_element_loop)]
20699 for &(find_this, param_name) in [("{+location}", "location")].iter() {
20700 url = params.uri_replacement(url, param_name, find_this, true);
20701 }
20702 {
20703 let to_remove = ["location"];
20704 params.remove_params(&to_remove);
20705 }
20706
20707 let url = params.parse_with_url(&url);
20708
20709 let mut json_mime_type = mime::APPLICATION_JSON;
20710 let mut request_value_reader = {
20711 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20712 common::remove_json_null_values(&mut value);
20713 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20714 serde_json::to_writer(&mut dst, &value).unwrap();
20715 dst
20716 };
20717 let request_size = request_value_reader
20718 .seek(std::io::SeekFrom::End(0))
20719 .unwrap();
20720 request_value_reader
20721 .seek(std::io::SeekFrom::Start(0))
20722 .unwrap();
20723
20724 loop {
20725 let token = match self
20726 .hub
20727 .auth
20728 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20729 .await
20730 {
20731 Ok(token) => token,
20732 Err(e) => match dlg.token(e) {
20733 Ok(token) => token,
20734 Err(e) => {
20735 dlg.finished(false);
20736 return Err(common::Error::MissingToken(e));
20737 }
20738 },
20739 };
20740 request_value_reader
20741 .seek(std::io::SeekFrom::Start(0))
20742 .unwrap();
20743 let mut req_result = {
20744 let client = &self.hub.client;
20745 dlg.pre_request();
20746 let mut req_builder = hyper::Request::builder()
20747 .method(hyper::Method::POST)
20748 .uri(url.as_str())
20749 .header(USER_AGENT, self.hub._user_agent.clone());
20750
20751 if let Some(token) = token.as_ref() {
20752 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20753 }
20754
20755 let request = req_builder
20756 .header(CONTENT_TYPE, json_mime_type.to_string())
20757 .header(CONTENT_LENGTH, request_size as u64)
20758 .body(common::to_body(
20759 request_value_reader.get_ref().clone().into(),
20760 ));
20761
20762 client.request(request.unwrap()).await
20763 };
20764
20765 match req_result {
20766 Err(err) => {
20767 if let common::Retry::After(d) = dlg.http_error(&err) {
20768 sleep(d).await;
20769 continue;
20770 }
20771 dlg.finished(false);
20772 return Err(common::Error::HttpError(err));
20773 }
20774 Ok(res) => {
20775 let (mut parts, body) = res.into_parts();
20776 let mut body = common::Body::new(body);
20777 if !parts.status.is_success() {
20778 let bytes = common::to_bytes(body).await.unwrap_or_default();
20779 let error = serde_json::from_str(&common::to_string(&bytes));
20780 let response = common::to_response(parts, bytes.into());
20781
20782 if let common::Retry::After(d) =
20783 dlg.http_failure(&response, error.as_ref().ok())
20784 {
20785 sleep(d).await;
20786 continue;
20787 }
20788
20789 dlg.finished(false);
20790
20791 return Err(match error {
20792 Ok(value) => common::Error::BadRequest(value),
20793 _ => common::Error::Failure(response),
20794 });
20795 }
20796 let response = {
20797 let bytes = common::to_bytes(body).await.unwrap_or_default();
20798 let encoded = common::to_string(&bytes);
20799 match serde_json::from_str(&encoded) {
20800 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20801 Err(error) => {
20802 dlg.response_json_decode_error(&encoded, &error);
20803 return Err(common::Error::JsonDecodeError(
20804 encoded.to_string(),
20805 error,
20806 ));
20807 }
20808 }
20809 };
20810
20811 dlg.finished(true);
20812 return Ok(response);
20813 }
20814 }
20815 }
20816 }
20817
20818 ///
20819 /// Sets the *request* property to the given value.
20820 ///
20821 /// Even though the property as already been set when instantiating this call,
20822 /// we provide this method for API completeness.
20823 pub fn request(
20824 mut self,
20825 new_value: GenerateRandomBytesRequest,
20826 ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
20827 self._request = new_value;
20828 self
20829 }
20830 /// The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".
20831 ///
20832 /// Sets the *location* path property to the given value.
20833 ///
20834 /// Even though the property as already been set when instantiating this call,
20835 /// we provide this method for API completeness.
20836 pub fn location(mut self, new_value: &str) -> ProjectLocationGenerateRandomByteCall<'a, C> {
20837 self._location = new_value.to_string();
20838 self
20839 }
20840 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20841 /// while executing the actual API request.
20842 ///
20843 /// ````text
20844 /// It should be used to handle progress information, and to implement a certain level of resilience.
20845 /// ````
20846 ///
20847 /// Sets the *delegate* property to the given value.
20848 pub fn delegate(
20849 mut self,
20850 new_value: &'a mut dyn common::Delegate,
20851 ) -> ProjectLocationGenerateRandomByteCall<'a, C> {
20852 self._delegate = Some(new_value);
20853 self
20854 }
20855
20856 /// Set any additional parameter of the query string used in the request.
20857 /// It should be used to set parameters which are not yet available through their own
20858 /// setters.
20859 ///
20860 /// Please note that this method must not be used to set any of the known parameters
20861 /// which have their own setter method. If done anyway, the request will fail.
20862 ///
20863 /// # Additional Parameters
20864 ///
20865 /// * *$.xgafv* (query-string) - V1 error format.
20866 /// * *access_token* (query-string) - OAuth access token.
20867 /// * *alt* (query-string) - Data format for response.
20868 /// * *callback* (query-string) - JSONP
20869 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20870 /// * *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.
20871 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20872 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20873 /// * *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.
20874 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20875 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20876 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGenerateRandomByteCall<'a, C>
20877 where
20878 T: AsRef<str>,
20879 {
20880 self._additional_params
20881 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20882 self
20883 }
20884
20885 /// Identifies the authorization scope for the method you are building.
20886 ///
20887 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20888 /// [`Scope::CloudPlatform`].
20889 ///
20890 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20891 /// tokens for more than one scope.
20892 ///
20893 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20894 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20895 /// sufficient, a read-write scope will do as well.
20896 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGenerateRandomByteCall<'a, C>
20897 where
20898 St: AsRef<str>,
20899 {
20900 self._scopes.insert(String::from(scope.as_ref()));
20901 self
20902 }
20903 /// Identifies the authorization scope(s) for the method you are building.
20904 ///
20905 /// See [`Self::add_scope()`] for details.
20906 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGenerateRandomByteCall<'a, C>
20907 where
20908 I: IntoIterator<Item = St>,
20909 St: AsRef<str>,
20910 {
20911 self._scopes
20912 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20913 self
20914 }
20915
20916 /// Removes all scopes, and no default scope will be used either.
20917 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20918 /// for details).
20919 pub fn clear_scopes(mut self) -> ProjectLocationGenerateRandomByteCall<'a, C> {
20920 self._scopes.clear();
20921 self
20922 }
20923}
20924
20925/// Gets information about a location.
20926///
20927/// A builder for the *locations.get* method supported by a *project* resource.
20928/// It is not used directly, but through a [`ProjectMethods`] instance.
20929///
20930/// # Example
20931///
20932/// Instantiate a resource method builder
20933///
20934/// ```test_harness,no_run
20935/// # extern crate hyper;
20936/// # extern crate hyper_rustls;
20937/// # extern crate google_cloudkms1 as cloudkms1;
20938/// # async fn dox() {
20939/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20940///
20941/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20942/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20943/// # secret,
20944/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20945/// # ).build().await.unwrap();
20946///
20947/// # let client = hyper_util::client::legacy::Client::builder(
20948/// # hyper_util::rt::TokioExecutor::new()
20949/// # )
20950/// # .build(
20951/// # hyper_rustls::HttpsConnectorBuilder::new()
20952/// # .with_native_roots()
20953/// # .unwrap()
20954/// # .https_or_http()
20955/// # .enable_http1()
20956/// # .build()
20957/// # );
20958/// # let mut hub = CloudKMS::new(client, auth);
20959/// // You can configure optional parameters by calling the respective setters at will, and
20960/// // execute the final call using `doit()`.
20961/// // Values shown here are possibly random and not representative !
20962/// let result = hub.projects().locations_get("name")
20963/// .doit().await;
20964/// # }
20965/// ```
20966pub struct ProjectLocationGetCall<'a, C>
20967where
20968 C: 'a,
20969{
20970 hub: &'a CloudKMS<C>,
20971 _name: String,
20972 _delegate: Option<&'a mut dyn common::Delegate>,
20973 _additional_params: HashMap<String, String>,
20974 _scopes: BTreeSet<String>,
20975}
20976
20977impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
20978
20979impl<'a, C> ProjectLocationGetCall<'a, C>
20980where
20981 C: common::Connector,
20982{
20983 /// Perform the operation you have build so far.
20984 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
20985 use std::borrow::Cow;
20986 use std::io::{Read, Seek};
20987
20988 use common::{url::Params, ToParts};
20989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20990
20991 let mut dd = common::DefaultDelegate;
20992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20993 dlg.begin(common::MethodInfo {
20994 id: "cloudkms.projects.locations.get",
20995 http_method: hyper::Method::GET,
20996 });
20997
20998 for &field in ["alt", "name"].iter() {
20999 if self._additional_params.contains_key(field) {
21000 dlg.finished(false);
21001 return Err(common::Error::FieldClash(field));
21002 }
21003 }
21004
21005 let mut params = Params::with_capacity(3 + self._additional_params.len());
21006 params.push("name", self._name);
21007
21008 params.extend(self._additional_params.iter());
21009
21010 params.push("alt", "json");
21011 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21012 if self._scopes.is_empty() {
21013 self._scopes
21014 .insert(Scope::CloudPlatform.as_ref().to_string());
21015 }
21016
21017 #[allow(clippy::single_element_loop)]
21018 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21019 url = params.uri_replacement(url, param_name, find_this, true);
21020 }
21021 {
21022 let to_remove = ["name"];
21023 params.remove_params(&to_remove);
21024 }
21025
21026 let url = params.parse_with_url(&url);
21027
21028 loop {
21029 let token = match self
21030 .hub
21031 .auth
21032 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21033 .await
21034 {
21035 Ok(token) => token,
21036 Err(e) => match dlg.token(e) {
21037 Ok(token) => token,
21038 Err(e) => {
21039 dlg.finished(false);
21040 return Err(common::Error::MissingToken(e));
21041 }
21042 },
21043 };
21044 let mut req_result = {
21045 let client = &self.hub.client;
21046 dlg.pre_request();
21047 let mut req_builder = hyper::Request::builder()
21048 .method(hyper::Method::GET)
21049 .uri(url.as_str())
21050 .header(USER_AGENT, self.hub._user_agent.clone());
21051
21052 if let Some(token) = token.as_ref() {
21053 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21054 }
21055
21056 let request = req_builder
21057 .header(CONTENT_LENGTH, 0_u64)
21058 .body(common::to_body::<String>(None));
21059
21060 client.request(request.unwrap()).await
21061 };
21062
21063 match req_result {
21064 Err(err) => {
21065 if let common::Retry::After(d) = dlg.http_error(&err) {
21066 sleep(d).await;
21067 continue;
21068 }
21069 dlg.finished(false);
21070 return Err(common::Error::HttpError(err));
21071 }
21072 Ok(res) => {
21073 let (mut parts, body) = res.into_parts();
21074 let mut body = common::Body::new(body);
21075 if !parts.status.is_success() {
21076 let bytes = common::to_bytes(body).await.unwrap_or_default();
21077 let error = serde_json::from_str(&common::to_string(&bytes));
21078 let response = common::to_response(parts, bytes.into());
21079
21080 if let common::Retry::After(d) =
21081 dlg.http_failure(&response, error.as_ref().ok())
21082 {
21083 sleep(d).await;
21084 continue;
21085 }
21086
21087 dlg.finished(false);
21088
21089 return Err(match error {
21090 Ok(value) => common::Error::BadRequest(value),
21091 _ => common::Error::Failure(response),
21092 });
21093 }
21094 let response = {
21095 let bytes = common::to_bytes(body).await.unwrap_or_default();
21096 let encoded = common::to_string(&bytes);
21097 match serde_json::from_str(&encoded) {
21098 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21099 Err(error) => {
21100 dlg.response_json_decode_error(&encoded, &error);
21101 return Err(common::Error::JsonDecodeError(
21102 encoded.to_string(),
21103 error,
21104 ));
21105 }
21106 }
21107 };
21108
21109 dlg.finished(true);
21110 return Ok(response);
21111 }
21112 }
21113 }
21114 }
21115
21116 /// Resource name for the location.
21117 ///
21118 /// Sets the *name* path property to the given value.
21119 ///
21120 /// Even though the property as already been set when instantiating this call,
21121 /// we provide this method for API completeness.
21122 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
21123 self._name = new_value.to_string();
21124 self
21125 }
21126 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21127 /// while executing the actual API request.
21128 ///
21129 /// ````text
21130 /// It should be used to handle progress information, and to implement a certain level of resilience.
21131 /// ````
21132 ///
21133 /// Sets the *delegate* property to the given value.
21134 pub fn delegate(
21135 mut self,
21136 new_value: &'a mut dyn common::Delegate,
21137 ) -> ProjectLocationGetCall<'a, C> {
21138 self._delegate = Some(new_value);
21139 self
21140 }
21141
21142 /// Set any additional parameter of the query string used in the request.
21143 /// It should be used to set parameters which are not yet available through their own
21144 /// setters.
21145 ///
21146 /// Please note that this method must not be used to set any of the known parameters
21147 /// which have their own setter method. If done anyway, the request will fail.
21148 ///
21149 /// # Additional Parameters
21150 ///
21151 /// * *$.xgafv* (query-string) - V1 error format.
21152 /// * *access_token* (query-string) - OAuth access token.
21153 /// * *alt* (query-string) - Data format for response.
21154 /// * *callback* (query-string) - JSONP
21155 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21156 /// * *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.
21157 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21158 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21159 /// * *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.
21160 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21161 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21162 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
21163 where
21164 T: AsRef<str>,
21165 {
21166 self._additional_params
21167 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21168 self
21169 }
21170
21171 /// Identifies the authorization scope for the method you are building.
21172 ///
21173 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21174 /// [`Scope::CloudPlatform`].
21175 ///
21176 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21177 /// tokens for more than one scope.
21178 ///
21179 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21180 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21181 /// sufficient, a read-write scope will do as well.
21182 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
21183 where
21184 St: AsRef<str>,
21185 {
21186 self._scopes.insert(String::from(scope.as_ref()));
21187 self
21188 }
21189 /// Identifies the authorization scope(s) for the method you are building.
21190 ///
21191 /// See [`Self::add_scope()`] for details.
21192 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
21193 where
21194 I: IntoIterator<Item = St>,
21195 St: AsRef<str>,
21196 {
21197 self._scopes
21198 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21199 self
21200 }
21201
21202 /// Removes all scopes, and no default scope will be used either.
21203 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21204 /// for details).
21205 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
21206 self._scopes.clear();
21207 self
21208 }
21209}
21210
21211/// Returns the EkmConfig singleton resource for a given project and location.
21212///
21213/// A builder for the *locations.getEkmConfig* method supported by a *project* resource.
21214/// It is not used directly, but through a [`ProjectMethods`] instance.
21215///
21216/// # Example
21217///
21218/// Instantiate a resource method builder
21219///
21220/// ```test_harness,no_run
21221/// # extern crate hyper;
21222/// # extern crate hyper_rustls;
21223/// # extern crate google_cloudkms1 as cloudkms1;
21224/// # async fn dox() {
21225/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21226///
21227/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21229/// # secret,
21230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21231/// # ).build().await.unwrap();
21232///
21233/// # let client = hyper_util::client::legacy::Client::builder(
21234/// # hyper_util::rt::TokioExecutor::new()
21235/// # )
21236/// # .build(
21237/// # hyper_rustls::HttpsConnectorBuilder::new()
21238/// # .with_native_roots()
21239/// # .unwrap()
21240/// # .https_or_http()
21241/// # .enable_http1()
21242/// # .build()
21243/// # );
21244/// # let mut hub = CloudKMS::new(client, auth);
21245/// // You can configure optional parameters by calling the respective setters at will, and
21246/// // execute the final call using `doit()`.
21247/// // Values shown here are possibly random and not representative !
21248/// let result = hub.projects().locations_get_ekm_config("name")
21249/// .doit().await;
21250/// # }
21251/// ```
21252pub struct ProjectLocationGetEkmConfigCall<'a, C>
21253where
21254 C: 'a,
21255{
21256 hub: &'a CloudKMS<C>,
21257 _name: String,
21258 _delegate: Option<&'a mut dyn common::Delegate>,
21259 _additional_params: HashMap<String, String>,
21260 _scopes: BTreeSet<String>,
21261}
21262
21263impl<'a, C> common::CallBuilder for ProjectLocationGetEkmConfigCall<'a, C> {}
21264
21265impl<'a, C> ProjectLocationGetEkmConfigCall<'a, C>
21266where
21267 C: common::Connector,
21268{
21269 /// Perform the operation you have build so far.
21270 pub async fn doit(mut self) -> common::Result<(common::Response, EkmConfig)> {
21271 use std::borrow::Cow;
21272 use std::io::{Read, Seek};
21273
21274 use common::{url::Params, ToParts};
21275 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21276
21277 let mut dd = common::DefaultDelegate;
21278 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21279 dlg.begin(common::MethodInfo {
21280 id: "cloudkms.projects.locations.getEkmConfig",
21281 http_method: hyper::Method::GET,
21282 });
21283
21284 for &field in ["alt", "name"].iter() {
21285 if self._additional_params.contains_key(field) {
21286 dlg.finished(false);
21287 return Err(common::Error::FieldClash(field));
21288 }
21289 }
21290
21291 let mut params = Params::with_capacity(3 + self._additional_params.len());
21292 params.push("name", self._name);
21293
21294 params.extend(self._additional_params.iter());
21295
21296 params.push("alt", "json");
21297 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21298 if self._scopes.is_empty() {
21299 self._scopes
21300 .insert(Scope::CloudPlatform.as_ref().to_string());
21301 }
21302
21303 #[allow(clippy::single_element_loop)]
21304 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21305 url = params.uri_replacement(url, param_name, find_this, true);
21306 }
21307 {
21308 let to_remove = ["name"];
21309 params.remove_params(&to_remove);
21310 }
21311
21312 let url = params.parse_with_url(&url);
21313
21314 loop {
21315 let token = match self
21316 .hub
21317 .auth
21318 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21319 .await
21320 {
21321 Ok(token) => token,
21322 Err(e) => match dlg.token(e) {
21323 Ok(token) => token,
21324 Err(e) => {
21325 dlg.finished(false);
21326 return Err(common::Error::MissingToken(e));
21327 }
21328 },
21329 };
21330 let mut req_result = {
21331 let client = &self.hub.client;
21332 dlg.pre_request();
21333 let mut req_builder = hyper::Request::builder()
21334 .method(hyper::Method::GET)
21335 .uri(url.as_str())
21336 .header(USER_AGENT, self.hub._user_agent.clone());
21337
21338 if let Some(token) = token.as_ref() {
21339 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21340 }
21341
21342 let request = req_builder
21343 .header(CONTENT_LENGTH, 0_u64)
21344 .body(common::to_body::<String>(None));
21345
21346 client.request(request.unwrap()).await
21347 };
21348
21349 match req_result {
21350 Err(err) => {
21351 if let common::Retry::After(d) = dlg.http_error(&err) {
21352 sleep(d).await;
21353 continue;
21354 }
21355 dlg.finished(false);
21356 return Err(common::Error::HttpError(err));
21357 }
21358 Ok(res) => {
21359 let (mut parts, body) = res.into_parts();
21360 let mut body = common::Body::new(body);
21361 if !parts.status.is_success() {
21362 let bytes = common::to_bytes(body).await.unwrap_or_default();
21363 let error = serde_json::from_str(&common::to_string(&bytes));
21364 let response = common::to_response(parts, bytes.into());
21365
21366 if let common::Retry::After(d) =
21367 dlg.http_failure(&response, error.as_ref().ok())
21368 {
21369 sleep(d).await;
21370 continue;
21371 }
21372
21373 dlg.finished(false);
21374
21375 return Err(match error {
21376 Ok(value) => common::Error::BadRequest(value),
21377 _ => common::Error::Failure(response),
21378 });
21379 }
21380 let response = {
21381 let bytes = common::to_bytes(body).await.unwrap_or_default();
21382 let encoded = common::to_string(&bytes);
21383 match serde_json::from_str(&encoded) {
21384 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21385 Err(error) => {
21386 dlg.response_json_decode_error(&encoded, &error);
21387 return Err(common::Error::JsonDecodeError(
21388 encoded.to_string(),
21389 error,
21390 ));
21391 }
21392 }
21393 };
21394
21395 dlg.finished(true);
21396 return Ok(response);
21397 }
21398 }
21399 }
21400 }
21401
21402 /// Required. The name of the EkmConfig to get.
21403 ///
21404 /// Sets the *name* path property to the given value.
21405 ///
21406 /// Even though the property as already been set when instantiating this call,
21407 /// we provide this method for API completeness.
21408 pub fn name(mut self, new_value: &str) -> ProjectLocationGetEkmConfigCall<'a, C> {
21409 self._name = new_value.to_string();
21410 self
21411 }
21412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21413 /// while executing the actual API request.
21414 ///
21415 /// ````text
21416 /// It should be used to handle progress information, and to implement a certain level of resilience.
21417 /// ````
21418 ///
21419 /// Sets the *delegate* property to the given value.
21420 pub fn delegate(
21421 mut self,
21422 new_value: &'a mut dyn common::Delegate,
21423 ) -> ProjectLocationGetEkmConfigCall<'a, C> {
21424 self._delegate = Some(new_value);
21425 self
21426 }
21427
21428 /// Set any additional parameter of the query string used in the request.
21429 /// It should be used to set parameters which are not yet available through their own
21430 /// setters.
21431 ///
21432 /// Please note that this method must not be used to set any of the known parameters
21433 /// which have their own setter method. If done anyway, the request will fail.
21434 ///
21435 /// # Additional Parameters
21436 ///
21437 /// * *$.xgafv* (query-string) - V1 error format.
21438 /// * *access_token* (query-string) - OAuth access token.
21439 /// * *alt* (query-string) - Data format for response.
21440 /// * *callback* (query-string) - JSONP
21441 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21442 /// * *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.
21443 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21444 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21445 /// * *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.
21446 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21447 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21448 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetEkmConfigCall<'a, C>
21449 where
21450 T: AsRef<str>,
21451 {
21452 self._additional_params
21453 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21454 self
21455 }
21456
21457 /// Identifies the authorization scope for the method you are building.
21458 ///
21459 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21460 /// [`Scope::CloudPlatform`].
21461 ///
21462 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21463 /// tokens for more than one scope.
21464 ///
21465 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21466 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21467 /// sufficient, a read-write scope will do as well.
21468 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetEkmConfigCall<'a, C>
21469 where
21470 St: AsRef<str>,
21471 {
21472 self._scopes.insert(String::from(scope.as_ref()));
21473 self
21474 }
21475 /// Identifies the authorization scope(s) for the method you are building.
21476 ///
21477 /// See [`Self::add_scope()`] for details.
21478 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetEkmConfigCall<'a, C>
21479 where
21480 I: IntoIterator<Item = St>,
21481 St: AsRef<str>,
21482 {
21483 self._scopes
21484 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21485 self
21486 }
21487
21488 /// Removes all scopes, and no default scope will be used either.
21489 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21490 /// for details).
21491 pub fn clear_scopes(mut self) -> ProjectLocationGetEkmConfigCall<'a, C> {
21492 self._scopes.clear();
21493 self
21494 }
21495}
21496
21497/// Lists information about the supported locations for this service.
21498///
21499/// A builder for the *locations.list* method supported by a *project* resource.
21500/// It is not used directly, but through a [`ProjectMethods`] instance.
21501///
21502/// # Example
21503///
21504/// Instantiate a resource method builder
21505///
21506/// ```test_harness,no_run
21507/// # extern crate hyper;
21508/// # extern crate hyper_rustls;
21509/// # extern crate google_cloudkms1 as cloudkms1;
21510/// # async fn dox() {
21511/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21512///
21513/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21514/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21515/// # secret,
21516/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21517/// # ).build().await.unwrap();
21518///
21519/// # let client = hyper_util::client::legacy::Client::builder(
21520/// # hyper_util::rt::TokioExecutor::new()
21521/// # )
21522/// # .build(
21523/// # hyper_rustls::HttpsConnectorBuilder::new()
21524/// # .with_native_roots()
21525/// # .unwrap()
21526/// # .https_or_http()
21527/// # .enable_http1()
21528/// # .build()
21529/// # );
21530/// # let mut hub = CloudKMS::new(client, auth);
21531/// // You can configure optional parameters by calling the respective setters at will, and
21532/// // execute the final call using `doit()`.
21533/// // Values shown here are possibly random and not representative !
21534/// let result = hub.projects().locations_list("name")
21535/// .page_token("sed")
21536/// .page_size(-98)
21537/// .filter("et")
21538/// .doit().await;
21539/// # }
21540/// ```
21541pub struct ProjectLocationListCall<'a, C>
21542where
21543 C: 'a,
21544{
21545 hub: &'a CloudKMS<C>,
21546 _name: String,
21547 _page_token: Option<String>,
21548 _page_size: Option<i32>,
21549 _filter: Option<String>,
21550 _delegate: Option<&'a mut dyn common::Delegate>,
21551 _additional_params: HashMap<String, String>,
21552 _scopes: BTreeSet<String>,
21553}
21554
21555impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
21556
21557impl<'a, C> ProjectLocationListCall<'a, C>
21558where
21559 C: common::Connector,
21560{
21561 /// Perform the operation you have build so far.
21562 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
21563 use std::borrow::Cow;
21564 use std::io::{Read, Seek};
21565
21566 use common::{url::Params, ToParts};
21567 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21568
21569 let mut dd = common::DefaultDelegate;
21570 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21571 dlg.begin(common::MethodInfo {
21572 id: "cloudkms.projects.locations.list",
21573 http_method: hyper::Method::GET,
21574 });
21575
21576 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
21577 if self._additional_params.contains_key(field) {
21578 dlg.finished(false);
21579 return Err(common::Error::FieldClash(field));
21580 }
21581 }
21582
21583 let mut params = Params::with_capacity(6 + self._additional_params.len());
21584 params.push("name", self._name);
21585 if let Some(value) = self._page_token.as_ref() {
21586 params.push("pageToken", value);
21587 }
21588 if let Some(value) = self._page_size.as_ref() {
21589 params.push("pageSize", value.to_string());
21590 }
21591 if let Some(value) = self._filter.as_ref() {
21592 params.push("filter", value);
21593 }
21594
21595 params.extend(self._additional_params.iter());
21596
21597 params.push("alt", "json");
21598 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
21599 if self._scopes.is_empty() {
21600 self._scopes
21601 .insert(Scope::CloudPlatform.as_ref().to_string());
21602 }
21603
21604 #[allow(clippy::single_element_loop)]
21605 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21606 url = params.uri_replacement(url, param_name, find_this, true);
21607 }
21608 {
21609 let to_remove = ["name"];
21610 params.remove_params(&to_remove);
21611 }
21612
21613 let url = params.parse_with_url(&url);
21614
21615 loop {
21616 let token = match self
21617 .hub
21618 .auth
21619 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21620 .await
21621 {
21622 Ok(token) => token,
21623 Err(e) => match dlg.token(e) {
21624 Ok(token) => token,
21625 Err(e) => {
21626 dlg.finished(false);
21627 return Err(common::Error::MissingToken(e));
21628 }
21629 },
21630 };
21631 let mut req_result = {
21632 let client = &self.hub.client;
21633 dlg.pre_request();
21634 let mut req_builder = hyper::Request::builder()
21635 .method(hyper::Method::GET)
21636 .uri(url.as_str())
21637 .header(USER_AGENT, self.hub._user_agent.clone());
21638
21639 if let Some(token) = token.as_ref() {
21640 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21641 }
21642
21643 let request = req_builder
21644 .header(CONTENT_LENGTH, 0_u64)
21645 .body(common::to_body::<String>(None));
21646
21647 client.request(request.unwrap()).await
21648 };
21649
21650 match req_result {
21651 Err(err) => {
21652 if let common::Retry::After(d) = dlg.http_error(&err) {
21653 sleep(d).await;
21654 continue;
21655 }
21656 dlg.finished(false);
21657 return Err(common::Error::HttpError(err));
21658 }
21659 Ok(res) => {
21660 let (mut parts, body) = res.into_parts();
21661 let mut body = common::Body::new(body);
21662 if !parts.status.is_success() {
21663 let bytes = common::to_bytes(body).await.unwrap_or_default();
21664 let error = serde_json::from_str(&common::to_string(&bytes));
21665 let response = common::to_response(parts, bytes.into());
21666
21667 if let common::Retry::After(d) =
21668 dlg.http_failure(&response, error.as_ref().ok())
21669 {
21670 sleep(d).await;
21671 continue;
21672 }
21673
21674 dlg.finished(false);
21675
21676 return Err(match error {
21677 Ok(value) => common::Error::BadRequest(value),
21678 _ => common::Error::Failure(response),
21679 });
21680 }
21681 let response = {
21682 let bytes = common::to_bytes(body).await.unwrap_or_default();
21683 let encoded = common::to_string(&bytes);
21684 match serde_json::from_str(&encoded) {
21685 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21686 Err(error) => {
21687 dlg.response_json_decode_error(&encoded, &error);
21688 return Err(common::Error::JsonDecodeError(
21689 encoded.to_string(),
21690 error,
21691 ));
21692 }
21693 }
21694 };
21695
21696 dlg.finished(true);
21697 return Ok(response);
21698 }
21699 }
21700 }
21701 }
21702
21703 /// The resource that owns the locations collection, if applicable.
21704 ///
21705 /// Sets the *name* path property to the given value.
21706 ///
21707 /// Even though the property as already been set when instantiating this call,
21708 /// we provide this method for API completeness.
21709 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
21710 self._name = new_value.to_string();
21711 self
21712 }
21713 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
21714 ///
21715 /// Sets the *page token* query property to the given value.
21716 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
21717 self._page_token = Some(new_value.to_string());
21718 self
21719 }
21720 /// The maximum number of results to return. If not set, the service selects a default.
21721 ///
21722 /// Sets the *page size* query property to the given value.
21723 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
21724 self._page_size = Some(new_value);
21725 self
21726 }
21727 /// 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).
21728 ///
21729 /// Sets the *filter* query property to the given value.
21730 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
21731 self._filter = Some(new_value.to_string());
21732 self
21733 }
21734 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21735 /// while executing the actual API request.
21736 ///
21737 /// ````text
21738 /// It should be used to handle progress information, and to implement a certain level of resilience.
21739 /// ````
21740 ///
21741 /// Sets the *delegate* property to the given value.
21742 pub fn delegate(
21743 mut self,
21744 new_value: &'a mut dyn common::Delegate,
21745 ) -> ProjectLocationListCall<'a, C> {
21746 self._delegate = Some(new_value);
21747 self
21748 }
21749
21750 /// Set any additional parameter of the query string used in the request.
21751 /// It should be used to set parameters which are not yet available through their own
21752 /// setters.
21753 ///
21754 /// Please note that this method must not be used to set any of the known parameters
21755 /// which have their own setter method. If done anyway, the request will fail.
21756 ///
21757 /// # Additional Parameters
21758 ///
21759 /// * *$.xgafv* (query-string) - V1 error format.
21760 /// * *access_token* (query-string) - OAuth access token.
21761 /// * *alt* (query-string) - Data format for response.
21762 /// * *callback* (query-string) - JSONP
21763 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21764 /// * *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.
21765 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21766 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21767 /// * *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.
21768 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21769 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21770 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
21771 where
21772 T: AsRef<str>,
21773 {
21774 self._additional_params
21775 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21776 self
21777 }
21778
21779 /// Identifies the authorization scope for the method you are building.
21780 ///
21781 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21782 /// [`Scope::CloudPlatform`].
21783 ///
21784 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21785 /// tokens for more than one scope.
21786 ///
21787 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21788 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21789 /// sufficient, a read-write scope will do as well.
21790 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
21791 where
21792 St: AsRef<str>,
21793 {
21794 self._scopes.insert(String::from(scope.as_ref()));
21795 self
21796 }
21797 /// Identifies the authorization scope(s) for the method you are building.
21798 ///
21799 /// See [`Self::add_scope()`] for details.
21800 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
21801 where
21802 I: IntoIterator<Item = St>,
21803 St: AsRef<str>,
21804 {
21805 self._scopes
21806 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21807 self
21808 }
21809
21810 /// Removes all scopes, and no default scope will be used either.
21811 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21812 /// for details).
21813 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
21814 self._scopes.clear();
21815 self
21816 }
21817}
21818
21819/// Updates the EkmConfig singleton resource for a given project and location.
21820///
21821/// A builder for the *locations.updateEkmConfig* method supported by a *project* resource.
21822/// It is not used directly, but through a [`ProjectMethods`] instance.
21823///
21824/// # Example
21825///
21826/// Instantiate a resource method builder
21827///
21828/// ```test_harness,no_run
21829/// # extern crate hyper;
21830/// # extern crate hyper_rustls;
21831/// # extern crate google_cloudkms1 as cloudkms1;
21832/// use cloudkms1::api::EkmConfig;
21833/// # async fn dox() {
21834/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21835///
21836/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21837/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21838/// # secret,
21839/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21840/// # ).build().await.unwrap();
21841///
21842/// # let client = hyper_util::client::legacy::Client::builder(
21843/// # hyper_util::rt::TokioExecutor::new()
21844/// # )
21845/// # .build(
21846/// # hyper_rustls::HttpsConnectorBuilder::new()
21847/// # .with_native_roots()
21848/// # .unwrap()
21849/// # .https_or_http()
21850/// # .enable_http1()
21851/// # .build()
21852/// # );
21853/// # let mut hub = CloudKMS::new(client, auth);
21854/// // As the method needs a request, you would usually fill it with the desired information
21855/// // into the respective structure. Some of the parts shown here might not be applicable !
21856/// // Values shown here are possibly random and not representative !
21857/// let mut req = EkmConfig::default();
21858///
21859/// // You can configure optional parameters by calling the respective setters at will, and
21860/// // execute the final call using `doit()`.
21861/// // Values shown here are possibly random and not representative !
21862/// let result = hub.projects().locations_update_ekm_config(req, "name")
21863/// .update_mask(FieldMask::new::<&str>(&[]))
21864/// .doit().await;
21865/// # }
21866/// ```
21867pub struct ProjectLocationUpdateEkmConfigCall<'a, C>
21868where
21869 C: 'a,
21870{
21871 hub: &'a CloudKMS<C>,
21872 _request: EkmConfig,
21873 _name: String,
21874 _update_mask: Option<common::FieldMask>,
21875 _delegate: Option<&'a mut dyn common::Delegate>,
21876 _additional_params: HashMap<String, String>,
21877 _scopes: BTreeSet<String>,
21878}
21879
21880impl<'a, C> common::CallBuilder for ProjectLocationUpdateEkmConfigCall<'a, C> {}
21881
21882impl<'a, C> ProjectLocationUpdateEkmConfigCall<'a, C>
21883where
21884 C: common::Connector,
21885{
21886 /// Perform the operation you have build so far.
21887 pub async fn doit(mut self) -> common::Result<(common::Response, EkmConfig)> {
21888 use std::borrow::Cow;
21889 use std::io::{Read, Seek};
21890
21891 use common::{url::Params, ToParts};
21892 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21893
21894 let mut dd = common::DefaultDelegate;
21895 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21896 dlg.begin(common::MethodInfo {
21897 id: "cloudkms.projects.locations.updateEkmConfig",
21898 http_method: hyper::Method::PATCH,
21899 });
21900
21901 for &field in ["alt", "name", "updateMask"].iter() {
21902 if self._additional_params.contains_key(field) {
21903 dlg.finished(false);
21904 return Err(common::Error::FieldClash(field));
21905 }
21906 }
21907
21908 let mut params = Params::with_capacity(5 + self._additional_params.len());
21909 params.push("name", self._name);
21910 if let Some(value) = self._update_mask.as_ref() {
21911 params.push("updateMask", value.to_string());
21912 }
21913
21914 params.extend(self._additional_params.iter());
21915
21916 params.push("alt", "json");
21917 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21918 if self._scopes.is_empty() {
21919 self._scopes
21920 .insert(Scope::CloudPlatform.as_ref().to_string());
21921 }
21922
21923 #[allow(clippy::single_element_loop)]
21924 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21925 url = params.uri_replacement(url, param_name, find_this, true);
21926 }
21927 {
21928 let to_remove = ["name"];
21929 params.remove_params(&to_remove);
21930 }
21931
21932 let url = params.parse_with_url(&url);
21933
21934 let mut json_mime_type = mime::APPLICATION_JSON;
21935 let mut request_value_reader = {
21936 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21937 common::remove_json_null_values(&mut value);
21938 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21939 serde_json::to_writer(&mut dst, &value).unwrap();
21940 dst
21941 };
21942 let request_size = request_value_reader
21943 .seek(std::io::SeekFrom::End(0))
21944 .unwrap();
21945 request_value_reader
21946 .seek(std::io::SeekFrom::Start(0))
21947 .unwrap();
21948
21949 loop {
21950 let token = match self
21951 .hub
21952 .auth
21953 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21954 .await
21955 {
21956 Ok(token) => token,
21957 Err(e) => match dlg.token(e) {
21958 Ok(token) => token,
21959 Err(e) => {
21960 dlg.finished(false);
21961 return Err(common::Error::MissingToken(e));
21962 }
21963 },
21964 };
21965 request_value_reader
21966 .seek(std::io::SeekFrom::Start(0))
21967 .unwrap();
21968 let mut req_result = {
21969 let client = &self.hub.client;
21970 dlg.pre_request();
21971 let mut req_builder = hyper::Request::builder()
21972 .method(hyper::Method::PATCH)
21973 .uri(url.as_str())
21974 .header(USER_AGENT, self.hub._user_agent.clone());
21975
21976 if let Some(token) = token.as_ref() {
21977 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21978 }
21979
21980 let request = req_builder
21981 .header(CONTENT_TYPE, json_mime_type.to_string())
21982 .header(CONTENT_LENGTH, request_size as u64)
21983 .body(common::to_body(
21984 request_value_reader.get_ref().clone().into(),
21985 ));
21986
21987 client.request(request.unwrap()).await
21988 };
21989
21990 match req_result {
21991 Err(err) => {
21992 if let common::Retry::After(d) = dlg.http_error(&err) {
21993 sleep(d).await;
21994 continue;
21995 }
21996 dlg.finished(false);
21997 return Err(common::Error::HttpError(err));
21998 }
21999 Ok(res) => {
22000 let (mut parts, body) = res.into_parts();
22001 let mut body = common::Body::new(body);
22002 if !parts.status.is_success() {
22003 let bytes = common::to_bytes(body).await.unwrap_or_default();
22004 let error = serde_json::from_str(&common::to_string(&bytes));
22005 let response = common::to_response(parts, bytes.into());
22006
22007 if let common::Retry::After(d) =
22008 dlg.http_failure(&response, error.as_ref().ok())
22009 {
22010 sleep(d).await;
22011 continue;
22012 }
22013
22014 dlg.finished(false);
22015
22016 return Err(match error {
22017 Ok(value) => common::Error::BadRequest(value),
22018 _ => common::Error::Failure(response),
22019 });
22020 }
22021 let response = {
22022 let bytes = common::to_bytes(body).await.unwrap_or_default();
22023 let encoded = common::to_string(&bytes);
22024 match serde_json::from_str(&encoded) {
22025 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22026 Err(error) => {
22027 dlg.response_json_decode_error(&encoded, &error);
22028 return Err(common::Error::JsonDecodeError(
22029 encoded.to_string(),
22030 error,
22031 ));
22032 }
22033 }
22034 };
22035
22036 dlg.finished(true);
22037 return Ok(response);
22038 }
22039 }
22040 }
22041 }
22042
22043 ///
22044 /// Sets the *request* property to the given value.
22045 ///
22046 /// Even though the property as already been set when instantiating this call,
22047 /// we provide this method for API completeness.
22048 pub fn request(mut self, new_value: EkmConfig) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
22049 self._request = new_value;
22050 self
22051 }
22052 /// Output only. The resource name for the EkmConfig in the format `projects/*/locations/*/ekmConfig`.
22053 ///
22054 /// Sets the *name* path property to the given value.
22055 ///
22056 /// Even though the property as already been set when instantiating this call,
22057 /// we provide this method for API completeness.
22058 pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
22059 self._name = new_value.to_string();
22060 self
22061 }
22062 /// Required. List of fields to be updated in this request.
22063 ///
22064 /// Sets the *update mask* query property to the given value.
22065 pub fn update_mask(
22066 mut self,
22067 new_value: common::FieldMask,
22068 ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
22069 self._update_mask = Some(new_value);
22070 self
22071 }
22072 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22073 /// while executing the actual API request.
22074 ///
22075 /// ````text
22076 /// It should be used to handle progress information, and to implement a certain level of resilience.
22077 /// ````
22078 ///
22079 /// Sets the *delegate* property to the given value.
22080 pub fn delegate(
22081 mut self,
22082 new_value: &'a mut dyn common::Delegate,
22083 ) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
22084 self._delegate = Some(new_value);
22085 self
22086 }
22087
22088 /// Set any additional parameter of the query string used in the request.
22089 /// It should be used to set parameters which are not yet available through their own
22090 /// setters.
22091 ///
22092 /// Please note that this method must not be used to set any of the known parameters
22093 /// which have their own setter method. If done anyway, the request will fail.
22094 ///
22095 /// # Additional Parameters
22096 ///
22097 /// * *$.xgafv* (query-string) - V1 error format.
22098 /// * *access_token* (query-string) - OAuth access token.
22099 /// * *alt* (query-string) - Data format for response.
22100 /// * *callback* (query-string) - JSONP
22101 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22102 /// * *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.
22103 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22104 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22105 /// * *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.
22106 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22107 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22108 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateEkmConfigCall<'a, C>
22109 where
22110 T: AsRef<str>,
22111 {
22112 self._additional_params
22113 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22114 self
22115 }
22116
22117 /// Identifies the authorization scope for the method you are building.
22118 ///
22119 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22120 /// [`Scope::CloudPlatform`].
22121 ///
22122 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22123 /// tokens for more than one scope.
22124 ///
22125 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22126 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22127 /// sufficient, a read-write scope will do as well.
22128 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateEkmConfigCall<'a, C>
22129 where
22130 St: AsRef<str>,
22131 {
22132 self._scopes.insert(String::from(scope.as_ref()));
22133 self
22134 }
22135 /// Identifies the authorization scope(s) for the method you are building.
22136 ///
22137 /// See [`Self::add_scope()`] for details.
22138 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateEkmConfigCall<'a, C>
22139 where
22140 I: IntoIterator<Item = St>,
22141 St: AsRef<str>,
22142 {
22143 self._scopes
22144 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22145 self
22146 }
22147
22148 /// Removes all scopes, and no default scope will be used either.
22149 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22150 /// for details).
22151 pub fn clear_scopes(mut self) -> ProjectLocationUpdateEkmConfigCall<'a, C> {
22152 self._scopes.clear();
22153 self
22154 }
22155}
22156
22157/// Returns the effective Cloud KMS Autokey configuration for a given project.
22158///
22159/// A builder for the *showEffectiveAutokeyConfig* method supported by a *project* resource.
22160/// It is not used directly, but through a [`ProjectMethods`] instance.
22161///
22162/// # Example
22163///
22164/// Instantiate a resource method builder
22165///
22166/// ```test_harness,no_run
22167/// # extern crate hyper;
22168/// # extern crate hyper_rustls;
22169/// # extern crate google_cloudkms1 as cloudkms1;
22170/// # async fn dox() {
22171/// # use cloudkms1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22172///
22173/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22174/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22175/// # secret,
22176/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22177/// # ).build().await.unwrap();
22178///
22179/// # let client = hyper_util::client::legacy::Client::builder(
22180/// # hyper_util::rt::TokioExecutor::new()
22181/// # )
22182/// # .build(
22183/// # hyper_rustls::HttpsConnectorBuilder::new()
22184/// # .with_native_roots()
22185/// # .unwrap()
22186/// # .https_or_http()
22187/// # .enable_http1()
22188/// # .build()
22189/// # );
22190/// # let mut hub = CloudKMS::new(client, auth);
22191/// // You can configure optional parameters by calling the respective setters at will, and
22192/// // execute the final call using `doit()`.
22193/// // Values shown here are possibly random and not representative !
22194/// let result = hub.projects().show_effective_autokey_config("parent")
22195/// .doit().await;
22196/// # }
22197/// ```
22198pub struct ProjectShowEffectiveAutokeyConfigCall<'a, C>
22199where
22200 C: 'a,
22201{
22202 hub: &'a CloudKMS<C>,
22203 _parent: String,
22204 _delegate: Option<&'a mut dyn common::Delegate>,
22205 _additional_params: HashMap<String, String>,
22206 _scopes: BTreeSet<String>,
22207}
22208
22209impl<'a, C> common::CallBuilder for ProjectShowEffectiveAutokeyConfigCall<'a, C> {}
22210
22211impl<'a, C> ProjectShowEffectiveAutokeyConfigCall<'a, C>
22212where
22213 C: common::Connector,
22214{
22215 /// Perform the operation you have build so far.
22216 pub async fn doit(
22217 mut self,
22218 ) -> common::Result<(common::Response, ShowEffectiveAutokeyConfigResponse)> {
22219 use std::borrow::Cow;
22220 use std::io::{Read, Seek};
22221
22222 use common::{url::Params, ToParts};
22223 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22224
22225 let mut dd = common::DefaultDelegate;
22226 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22227 dlg.begin(common::MethodInfo {
22228 id: "cloudkms.projects.showEffectiveAutokeyConfig",
22229 http_method: hyper::Method::GET,
22230 });
22231
22232 for &field in ["alt", "parent"].iter() {
22233 if self._additional_params.contains_key(field) {
22234 dlg.finished(false);
22235 return Err(common::Error::FieldClash(field));
22236 }
22237 }
22238
22239 let mut params = Params::with_capacity(3 + self._additional_params.len());
22240 params.push("parent", self._parent);
22241
22242 params.extend(self._additional_params.iter());
22243
22244 params.push("alt", "json");
22245 let mut url = self.hub._base_url.clone() + "v1/{+parent}:showEffectiveAutokeyConfig";
22246 if self._scopes.is_empty() {
22247 self._scopes
22248 .insert(Scope::CloudPlatform.as_ref().to_string());
22249 }
22250
22251 #[allow(clippy::single_element_loop)]
22252 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22253 url = params.uri_replacement(url, param_name, find_this, true);
22254 }
22255 {
22256 let to_remove = ["parent"];
22257 params.remove_params(&to_remove);
22258 }
22259
22260 let url = params.parse_with_url(&url);
22261
22262 loop {
22263 let token = match self
22264 .hub
22265 .auth
22266 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22267 .await
22268 {
22269 Ok(token) => token,
22270 Err(e) => match dlg.token(e) {
22271 Ok(token) => token,
22272 Err(e) => {
22273 dlg.finished(false);
22274 return Err(common::Error::MissingToken(e));
22275 }
22276 },
22277 };
22278 let mut req_result = {
22279 let client = &self.hub.client;
22280 dlg.pre_request();
22281 let mut req_builder = hyper::Request::builder()
22282 .method(hyper::Method::GET)
22283 .uri(url.as_str())
22284 .header(USER_AGENT, self.hub._user_agent.clone());
22285
22286 if let Some(token) = token.as_ref() {
22287 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22288 }
22289
22290 let request = req_builder
22291 .header(CONTENT_LENGTH, 0_u64)
22292 .body(common::to_body::<String>(None));
22293
22294 client.request(request.unwrap()).await
22295 };
22296
22297 match req_result {
22298 Err(err) => {
22299 if let common::Retry::After(d) = dlg.http_error(&err) {
22300 sleep(d).await;
22301 continue;
22302 }
22303 dlg.finished(false);
22304 return Err(common::Error::HttpError(err));
22305 }
22306 Ok(res) => {
22307 let (mut parts, body) = res.into_parts();
22308 let mut body = common::Body::new(body);
22309 if !parts.status.is_success() {
22310 let bytes = common::to_bytes(body).await.unwrap_or_default();
22311 let error = serde_json::from_str(&common::to_string(&bytes));
22312 let response = common::to_response(parts, bytes.into());
22313
22314 if let common::Retry::After(d) =
22315 dlg.http_failure(&response, error.as_ref().ok())
22316 {
22317 sleep(d).await;
22318 continue;
22319 }
22320
22321 dlg.finished(false);
22322
22323 return Err(match error {
22324 Ok(value) => common::Error::BadRequest(value),
22325 _ => common::Error::Failure(response),
22326 });
22327 }
22328 let response = {
22329 let bytes = common::to_bytes(body).await.unwrap_or_default();
22330 let encoded = common::to_string(&bytes);
22331 match serde_json::from_str(&encoded) {
22332 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22333 Err(error) => {
22334 dlg.response_json_decode_error(&encoded, &error);
22335 return Err(common::Error::JsonDecodeError(
22336 encoded.to_string(),
22337 error,
22338 ));
22339 }
22340 }
22341 };
22342
22343 dlg.finished(true);
22344 return Ok(response);
22345 }
22346 }
22347 }
22348 }
22349
22350 /// 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.
22351 ///
22352 /// Sets the *parent* path property to the given value.
22353 ///
22354 /// Even though the property as already been set when instantiating this call,
22355 /// we provide this method for API completeness.
22356 pub fn parent(mut self, new_value: &str) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
22357 self._parent = new_value.to_string();
22358 self
22359 }
22360 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22361 /// while executing the actual API request.
22362 ///
22363 /// ````text
22364 /// It should be used to handle progress information, and to implement a certain level of resilience.
22365 /// ````
22366 ///
22367 /// Sets the *delegate* property to the given value.
22368 pub fn delegate(
22369 mut self,
22370 new_value: &'a mut dyn common::Delegate,
22371 ) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
22372 self._delegate = Some(new_value);
22373 self
22374 }
22375
22376 /// Set any additional parameter of the query string used in the request.
22377 /// It should be used to set parameters which are not yet available through their own
22378 /// setters.
22379 ///
22380 /// Please note that this method must not be used to set any of the known parameters
22381 /// which have their own setter method. If done anyway, the request will fail.
22382 ///
22383 /// # Additional Parameters
22384 ///
22385 /// * *$.xgafv* (query-string) - V1 error format.
22386 /// * *access_token* (query-string) - OAuth access token.
22387 /// * *alt* (query-string) - Data format for response.
22388 /// * *callback* (query-string) - JSONP
22389 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22390 /// * *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.
22391 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22392 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22393 /// * *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.
22394 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22395 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22396 pub fn param<T>(mut self, name: T, value: T) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
22397 where
22398 T: AsRef<str>,
22399 {
22400 self._additional_params
22401 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22402 self
22403 }
22404
22405 /// Identifies the authorization scope for the method you are building.
22406 ///
22407 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22408 /// [`Scope::CloudPlatform`].
22409 ///
22410 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22411 /// tokens for more than one scope.
22412 ///
22413 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22414 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22415 /// sufficient, a read-write scope will do as well.
22416 pub fn add_scope<St>(mut self, scope: St) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
22417 where
22418 St: AsRef<str>,
22419 {
22420 self._scopes.insert(String::from(scope.as_ref()));
22421 self
22422 }
22423 /// Identifies the authorization scope(s) for the method you are building.
22424 ///
22425 /// See [`Self::add_scope()`] for details.
22426 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectShowEffectiveAutokeyConfigCall<'a, C>
22427 where
22428 I: IntoIterator<Item = St>,
22429 St: AsRef<str>,
22430 {
22431 self._scopes
22432 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22433 self
22434 }
22435
22436 /// Removes all scopes, and no default scope will be used either.
22437 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22438 /// for details).
22439 pub fn clear_scopes(mut self) -> ProjectShowEffectiveAutokeyConfigCall<'a, C> {
22440 self._scopes.clear();
22441 self
22442 }
22443}