google_cloudkms1_beta1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and manage your data across Google Cloud Platform services
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudKMS related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
49/// use cloudkms1_beta1::api::CryptoKeyVersion;
50/// use cloudkms1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudKMS::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = CryptoKeyVersion::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
99///              .update_mask(FieldMask::new::<&str>(&[]))
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudKMS<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudKMS<C> {}
131
132impl<'a, C> CloudKMS<C> {
133    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudKMS<C> {
134        CloudKMS {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://cloudkms.googleapis.com/".to_string(),
139            _root_url: "https://cloudkms.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
144        ProjectMethods { hub: self }
145    }
146
147    /// Set the user-agent header field to use in all requests to the server.
148    /// It defaults to `google-api-rust-client/7.0.0`.
149    ///
150    /// Returns the previously set user-agent.
151    pub fn user_agent(&mut self, agent_name: String) -> String {
152        std::mem::replace(&mut self._user_agent, agent_name)
153    }
154
155    /// Set the base url to use in all requests to the server.
156    /// It defaults to `https://cloudkms.googleapis.com/`.
157    ///
158    /// Returns the previously set base url.
159    pub fn base_url(&mut self, new_base_url: String) -> String {
160        std::mem::replace(&mut self._base_url, new_base_url)
161    }
162
163    /// Set the root url to use in all requests to the server.
164    /// It defaults to `https://cloudkms.googleapis.com/`.
165    ///
166    /// Returns the previously set root url.
167    pub fn root_url(&mut self, new_root_url: String) -> String {
168        std::mem::replace(&mut self._root_url, new_root_url)
169    }
170}
171
172// ############
173// SCHEMAS ###
174// ##########
175/// Request message for `TestIamPermissions` method.
176///
177/// # Activities
178///
179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
181///
182/// * [locations key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (request)
183/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (request)
184#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
185#[serde_with::serde_as]
186#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
187pub struct TestIamPermissionsRequest {
188    /// The set of permissions to check for the `resource`. Permissions with
189    /// wildcards (such as '*' or 'storage.*') are not allowed. For more
190    /// information see
191    /// [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
192    pub permissions: Option<Vec<String>>,
193}
194
195impl common::RequestValue for TestIamPermissionsRequest {}
196
197/// Defines an Identity and Access Management (IAM) policy. It is used to
198/// specify access control policies for Cloud Platform resources.
199///
200/// A `Policy` consists of a list of `bindings`. A `Binding` binds a list of
201/// `members` to a `role`, where the members can be user accounts, Google groups,
202/// Google domains, and service accounts. A `role` is a named list of permissions
203/// defined by IAM.
204///
205/// **Example**
206///
207/// ````text
208/// {
209///   "bindings": [
210///     {
211///       "role": "roles/owner",
212///       "members": [
213///         "user:mike@example.com",
214///         "group:admins@example.com",
215///         "domain:google.com",
216///         "serviceAccount:my-other-app@appspot.gserviceaccount.com",
217///       ]
218///     },
219///     {
220///       "role": "roles/viewer",
221///       "members": ["user:sean@example.com"]
222///     }
223///   ]
224/// }
225/// ````
226///
227/// For a description of IAM and its features, see the
228/// [IAM developer’s guide](https://cloud.google.com/iam).
229///
230/// # Activities
231///
232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
234///
235/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (response)
236/// * [locations key rings crypto keys get iam policy projects](ProjectLocationKeyRingCryptoKeyGetIamPolicyCall) (response)
237/// * [locations key rings get iam policy projects](ProjectLocationKeyRingGetIamPolicyCall) (response)
238/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (response)
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct Policy {
243    /// no description provided
244    #[serde(rename = "iamOwned")]
245    pub iam_owned: Option<bool>,
246    /// If more than one rule is specified, the rules are applied in the following
247    /// manner:
248    /// - All matching LOG rules are always applied.
249    /// - If any DENY/DENY_WITH_LOG rule matches, permission is denied.
250    ///   Logging will be applied if one or more matching rule requires logging.
251    /// - Otherwise, if any ALLOW/ALLOW_WITH_LOG rule matches, permission is
252    ///   granted.
253    ///   Logging will be applied if one or more matching rule requires logging.
254    /// - Otherwise, if no rule applies, permission is denied.
255    pub rules: Option<Vec<Rule>>,
256    /// Version of the `Policy`. The default version is 0.
257    pub version: Option<i32>,
258    /// Specifies cloud audit logging configuration for this policy.
259    #[serde(rename = "auditConfigs")]
260    pub audit_configs: Option<Vec<AuditConfig>>,
261    /// Associates a list of `members` to a `role`.
262    /// Multiple `bindings` must not be specified for the same `role`.
263    /// `bindings` with no members will result in an error.
264    pub bindings: Option<Vec<Binding>>,
265    /// `etag` is used for optimistic concurrency control as a way to help
266    /// prevent simultaneous updates of a policy from overwriting each other.
267    /// It is strongly suggested that systems make use of the `etag` in the
268    /// read-modify-write cycle to perform policy updates in order to avoid race
269    /// conditions: An `etag` is returned in the response to `getIamPolicy`, and
270    /// systems are expected to put that etag in the request to `setIamPolicy` to
271    /// ensure that their change will be applied to the same version of the policy.
272    ///
273    /// If no `etag` is provided in the call to `setIamPolicy`, then the existing
274    /// policy is overwritten blindly.
275    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
276    pub etag: Option<Vec<u8>>,
277}
278
279impl common::ResponseResult for Policy {}
280
281/// The response message for Locations.ListLocations.
282///
283/// # Activities
284///
285/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
286/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
287///
288/// * [locations list projects](ProjectLocationListCall) (response)
289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
290#[serde_with::serde_as]
291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
292pub struct ListLocationsResponse {
293    /// A list of locations that matches the specified filter in the request.
294    pub locations: Option<Vec<Location>>,
295    /// The standard List next-page token.
296    #[serde(rename = "nextPageToken")]
297    pub next_page_token: Option<String>,
298}
299
300impl common::ResponseResult for ListLocationsResponse {}
301
302/// A KeyRing is a toplevel logical grouping of CryptoKeys.
303///
304/// # Activities
305///
306/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
307/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
308///
309/// * [locations key rings get projects](ProjectLocationKeyRingGetCall) (response)
310/// * [locations key rings create projects](ProjectLocationKeyRingCreateCall) (request|response)
311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
312#[serde_with::serde_as]
313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
314pub struct KeyRing {
315    /// Output only. The time at which this KeyRing was created.
316    #[serde(rename = "createTime")]
317    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
318    /// Output only. The resource name for the KeyRing in the format
319    /// `projects/*/locations/*/keyRings/*`.
320    pub name: Option<String>,
321}
322
323impl common::RequestValue for KeyRing {}
324impl common::ResponseResult for KeyRing {}
325
326/// Response message for KeyManagementService.Encrypt.
327///
328/// # Activities
329///
330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
332///
333/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (response)
334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
335#[serde_with::serde_as]
336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
337pub struct EncryptResponse {
338    /// The resource name of the CryptoKeyVersion used in encryption.
339    pub name: Option<String>,
340    /// The encrypted data.
341    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
342    pub ciphertext: Option<Vec<u8>>,
343}
344
345impl common::ResponseResult for EncryptResponse {}
346
347/// Request message for KeyManagementService.UpdateCryptoKeyPrimaryVersion.
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (request)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct UpdateCryptoKeyPrimaryVersionRequest {
359    /// The id of the child CryptoKeyVersion to use as primary.
360    #[serde(rename = "cryptoKeyVersionId")]
361    pub crypto_key_version_id: Option<String>,
362}
363
364impl common::RequestValue for UpdateCryptoKeyPrimaryVersionRequest {}
365
366/// Request message for KeyManagementService.RestoreCryptoKeyVersion.
367///
368/// # Activities
369///
370/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
371/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
372///
373/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (request)
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct RestoreCryptoKeyVersionRequest {
378    _never_set: Option<bool>,
379}
380
381impl common::RequestValue for RestoreCryptoKeyVersionRequest {}
382
383/// Response message for KeyManagementService.ListKeyRings.
384///
385/// # Activities
386///
387/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
388/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
389///
390/// * [locations key rings list projects](ProjectLocationKeyRingListCall) (response)
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct ListKeyRingsResponse {
395    /// A token to retrieve next page of results. Pass this value in
396    /// ListKeyRingsRequest.page_token to retrieve the next page of results.
397    #[serde(rename = "nextPageToken")]
398    pub next_page_token: Option<String>,
399    /// The total number of KeyRings that matched the query.
400    #[serde(rename = "totalSize")]
401    pub total_size: Option<i32>,
402    /// The list of KeyRings.
403    #[serde(rename = "keyRings")]
404    pub key_rings: Option<Vec<KeyRing>>,
405}
406
407impl common::ResponseResult for ListKeyRingsResponse {}
408
409/// Write a Data Access (Gin) log
410///
411/// This type is not used in any activity, and only used as *part* of another schema.
412///
413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
414#[serde_with::serde_as]
415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
416pub struct DataAccessOptions {
417    _never_set: Option<bool>,
418}
419
420impl common::Part for DataAccessOptions {}
421
422/// Specifies the audit configuration for a service.
423/// The configuration determines which permission types are logged, and what
424/// identities, if any, are exempted from logging.
425/// An AuditConfig must have one or more AuditLogConfigs.
426///
427/// If there are AuditConfigs for both `allServices` and a specific service,
428/// the union of the two AuditConfigs is used for that service: the log_types
429/// specified in each AuditConfig are enabled, and the exempted_members in each
430/// AuditConfig are exempted.
431///
432/// Example Policy with multiple AuditConfigs:
433///
434/// ````text
435/// {
436///   "audit_configs": [
437///     {
438///       "service": "allServices"
439///       "audit_log_configs": [
440///         {
441///           "log_type": "DATA_READ",
442///           "exempted_members": [
443///             "user:foo@gmail.com"
444///           ]
445///         },
446///         {
447///           "log_type": "DATA_WRITE",
448///         },
449///         {
450///           "log_type": "ADMIN_READ",
451///         }
452///       ]
453///     },
454///     {
455///       "service": "fooservice.googleapis.com"
456///       "audit_log_configs": [
457///         {
458///           "log_type": "DATA_READ",
459///         },
460///         {
461///           "log_type": "DATA_WRITE",
462///           "exempted_members": [
463///             "user:bar@gmail.com"
464///           ]
465///         }
466///       ]
467///     }
468///   ]
469/// }
470/// ````
471///
472/// For fooservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ
473/// logging. It also exempts foo@gmail.com from DATA_READ logging, and
474/// bar@gmail.com from DATA_WRITE logging.
475///
476/// This type is not used in any activity, and only used as *part* of another schema.
477#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
478#[serde_with::serde_as]
479#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
480pub struct AuditConfig {
481    /// Specifies a service that will be enabled for audit logging.
482    /// For example, `storage.googleapis.com`, `cloudsql.googleapis.com`.
483    /// `allServices` is a special value that covers all services.
484    pub service: Option<String>,
485    /// The configuration for logging of each type of permission.
486    /// Next ID: 4
487    #[serde(rename = "auditLogConfigs")]
488    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
489    /// no description provided
490    #[serde(rename = "exemptedMembers")]
491    pub exempted_members: Option<Vec<String>>,
492}
493
494impl common::Part for AuditConfig {}
495
496/// A CryptoKeyVersion represents an individual cryptographic key, and the
497/// associated key material.
498///
499/// It can be used for cryptographic operations either directly, or via its
500/// parent CryptoKey, in which case the server will choose the appropriate
501/// version for the operation.
502///
503/// # Activities
504///
505/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
506/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
507///
508/// * [locations key rings crypto keys crypto key versions create projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall) (request|response)
509/// * [locations key rings crypto keys crypto key versions destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (response)
510/// * [locations key rings crypto keys crypto key versions restore projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall) (response)
511/// * [locations key rings crypto keys crypto key versions patch projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall) (request|response)
512/// * [locations key rings crypto keys crypto key versions get projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall) (response)
513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
514#[serde_with::serde_as]
515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
516pub struct CryptoKeyVersion {
517    /// Output only. The time at which this CryptoKeyVersion was created.
518    #[serde(rename = "createTime")]
519    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
520    /// The current state of the CryptoKeyVersion.
521    pub state: Option<String>,
522    /// Output only. The resource name for this CryptoKeyVersion in the format
523    /// `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
524    pub name: Option<String>,
525    /// Output only. The time this CryptoKeyVersion's key material was
526    /// destroyed. Only present if state is
527    /// DESTROYED.
528    #[serde(rename = "destroyEventTime")]
529    pub destroy_event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
530    /// Output only. The time this CryptoKeyVersion's key material is scheduled
531    /// for destruction. Only present if state is
532    /// DESTROY_SCHEDULED.
533    #[serde(rename = "destroyTime")]
534    pub destroy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
535}
536
537impl common::RequestValue for CryptoKeyVersion {}
538impl common::ResponseResult for CryptoKeyVersion {}
539
540/// Write a Cloud Audit log
541///
542/// This type is not used in any activity, and only used as *part* of another schema.
543///
544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
545#[serde_with::serde_as]
546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
547pub struct CloudAuditOptions {
548    /// The log_name to populate in the Cloud Audit Record.
549    #[serde(rename = "logName")]
550    pub log_name: Option<String>,
551}
552
553impl common::Part for CloudAuditOptions {}
554
555/// Associates `members` with a `role`.
556///
557/// This type is not used in any activity, and only used as *part* of another schema.
558///
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct Binding {
563    /// Specifies the identities requesting access for a Cloud Platform resource.
564    /// `members` can have the following values:
565    ///
566    /// * `allUsers`: A special identifier that represents anyone who is
567    ///    on the internet; with or without a Google account.
568    ///
569    /// * `allAuthenticatedUsers`: A special identifier that represents anyone
570    ///    who is authenticated with a Google account or a service account.
571    ///
572    /// * `user:{emailid}`: An email address that represents a specific Google
573    ///    account. For example, `alice@gmail.com` or `joe@example.com`.
574    ///
575    ///
576    /// * `serviceAccount:{emailid}`: An email address that represents a service
577    ///    account. For example, `my-other-app@appspot.gserviceaccount.com`.
578    ///
579    /// * `group:{emailid}`: An email address that represents a Google group.
580    ///    For example, `admins@example.com`.
581    ///
582    ///
583    /// * `domain:{domain}`: A Google Apps domain name that represents all the
584    ///    users of that domain. For example, `google.com` or `example.com`.
585    ///
586    ///
587    pub members: Option<Vec<String>>,
588    /// Role that is assigned to `members`.
589    /// For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
590    /// Required
591    pub role: Option<String>,
592}
593
594impl common::Part for Binding {}
595
596/// Request message for KeyManagementService.Encrypt.
597///
598/// # Activities
599///
600/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
601/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
602///
603/// * [locations key rings crypto keys encrypt projects](ProjectLocationKeyRingCryptoKeyEncryptCall) (request)
604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
605#[serde_with::serde_as]
606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
607pub struct EncryptRequest {
608    /// Optional data that, if specified, must also be provided during decryption
609    /// through DecryptRequest.additional_authenticated_data.  Must be no
610    /// larger than 64KiB.
611    #[serde(rename = "additionalAuthenticatedData")]
612    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
613    pub additional_authenticated_data: Option<Vec<u8>>,
614    /// Required. The data to encrypt. Must be no larger than 64KiB.
615    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
616    pub plaintext: Option<Vec<u8>>,
617}
618
619impl common::RequestValue for EncryptRequest {}
620
621/// Response message for KeyManagementService.ListCryptoKeyVersions.
622///
623/// # Activities
624///
625/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
627///
628/// * [locations key rings crypto keys crypto key versions list projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall) (response)
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as]
631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
632pub struct ListCryptoKeyVersionsResponse {
633    /// The list of CryptoKeyVersions.
634    #[serde(rename = "cryptoKeyVersions")]
635    pub crypto_key_versions: Option<Vec<CryptoKeyVersion>>,
636    /// A token to retrieve next page of results. Pass this value in
637    /// ListCryptoKeyVersionsRequest.page_token to retrieve the next page of
638    /// results.
639    #[serde(rename = "nextPageToken")]
640    pub next_page_token: Option<String>,
641    /// The total number of CryptoKeyVersions that matched the
642    /// query.
643    #[serde(rename = "totalSize")]
644    pub total_size: Option<i32>,
645}
646
647impl common::ResponseResult for ListCryptoKeyVersionsResponse {}
648
649/// Response message for `TestIamPermissions` method.
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 key rings crypto keys test iam permissions projects](ProjectLocationKeyRingCryptoKeyTestIamPermissionCall) (response)
657/// * [locations key rings test iam permissions projects](ProjectLocationKeyRingTestIamPermissionCall) (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 TestIamPermissionsResponse {
662    /// A subset of `TestPermissionsRequest.permissions` that the caller is
663    /// allowed.
664    pub permissions: Option<Vec<String>>,
665}
666
667impl common::ResponseResult for TestIamPermissionsResponse {}
668
669/// Request message for KeyManagementService.DestroyCryptoKeyVersion.
670///
671/// # Activities
672///
673/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
674/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
675///
676/// * [locations key rings crypto keys crypto key versions destroy projects](ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall) (request)
677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
678#[serde_with::serde_as]
679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
680pub struct DestroyCryptoKeyVersionRequest {
681    _never_set: Option<bool>,
682}
683
684impl common::RequestValue for DestroyCryptoKeyVersionRequest {}
685
686/// A CryptoKey represents a logical key that can be used for cryptographic
687/// operations.
688///
689/// A CryptoKey is made up of one or more versions, which
690/// represent the actual key material used in cryptographic operations.
691///
692/// # Activities
693///
694/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
695/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
696///
697/// * [locations key rings crypto keys patch projects](ProjectLocationKeyRingCryptoKeyPatchCall) (request|response)
698/// * [locations key rings crypto keys get projects](ProjectLocationKeyRingCryptoKeyGetCall) (response)
699/// * [locations key rings crypto keys create projects](ProjectLocationKeyRingCryptoKeyCreateCall) (request|response)
700/// * [locations key rings crypto keys update primary version projects](ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall) (response)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct CryptoKey {
705    /// Output only. The time at which this CryptoKey was created.
706    #[serde(rename = "createTime")]
707    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
708    /// next_rotation_time will be advanced by this period when the service
709    /// automatically rotates a key. Must be at least one day.
710    ///
711    /// If rotation_period is set, next_rotation_time must also be set.
712    #[serde(rename = "rotationPeriod")]
713    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
714    pub rotation_period: Option<chrono::Duration>,
715    /// Output only. A copy of the "primary" CryptoKeyVersion that will be used
716    /// by Encrypt when this CryptoKey is given
717    /// in EncryptRequest.name.
718    ///
719    /// The CryptoKey's primary version can be updated via
720    /// UpdateCryptoKeyPrimaryVersion.
721    pub primary: Option<CryptoKeyVersion>,
722    /// Output only. The resource name for this CryptoKey in the format
723    /// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
724    pub name: Option<String>,
725    /// The immutable purpose of this CryptoKey. Currently, the only acceptable
726    /// purpose is ENCRYPT_DECRYPT.
727    pub purpose: Option<String>,
728    /// At next_rotation_time, the Key Management Service will automatically:
729    ///
730    /// 1. Create a new version of this CryptoKey.
731    /// 2. Mark the new version as primary.
732    ///
733    /// Key rotations performed manually via
734    /// CreateCryptoKeyVersion and
735    /// UpdateCryptoKeyPrimaryVersion
736    /// do not affect next_rotation_time.
737    #[serde(rename = "nextRotationTime")]
738    pub next_rotation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
739}
740
741impl common::RequestValue for CryptoKey {}
742impl common::ResponseResult for CryptoKey {}
743
744/// A rule to be applied in a Policy.
745///
746/// This type is not used in any activity, and only used as *part* of another schema.
747///
748#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
749#[serde_with::serde_as]
750#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
751pub struct Rule {
752    /// Human-readable description of the rule.
753    pub description: Option<String>,
754    /// Additional restrictions that must be met
755    pub conditions: Option<Vec<Condition>>,
756    /// The config returned to callers of tech.iam.IAM.CheckPolicy for any entries
757    /// that match the LOG action.
758    #[serde(rename = "logConfig")]
759    pub log_config: Option<Vec<LogConfig>>,
760    /// If one or more 'in' clauses are specified, the rule matches if
761    /// the PRINCIPAL/AUTHORITY_SELECTOR is in at least one of these entries.
762    #[serde(rename = "in")]
763    pub in_: Option<Vec<String>>,
764    /// A permission is a string of form '<service>.<resource type>.<verb>'
765    /// (e.g., 'storage.buckets.list'). A value of '*' matches all permissions,
766    /// and a verb part of '*' (e.g., 'storage.buckets.*') matches all verbs.
767    pub permissions: Option<Vec<String>>,
768    /// Required
769    pub action: Option<String>,
770    /// If one or more 'not_in' clauses are specified, the rule matches
771    /// if the PRINCIPAL/AUTHORITY_SELECTOR is in none of the entries.
772    /// The format for in and not_in entries is the same as for members in a
773    /// Binding (see google/iam/v1/policy.proto).
774    #[serde(rename = "notIn")]
775    pub not_in: Option<Vec<String>>,
776}
777
778impl common::Part for Rule {}
779
780/// Specifies what kind of log the caller must write
781///
782/// This type is not used in any activity, and only used as *part* of another schema.
783///
784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
785#[serde_with::serde_as]
786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
787pub struct LogConfig {
788    /// Counter options.
789    pub counter: Option<CounterOptions>,
790    /// Data access options.
791    #[serde(rename = "dataAccess")]
792    pub data_access: Option<DataAccessOptions>,
793    /// Cloud audit options.
794    #[serde(rename = "cloudAudit")]
795    pub cloud_audit: Option<CloudAuditOptions>,
796}
797
798impl common::Part for LogConfig {}
799
800/// Request message for `SetIamPolicy` method.
801///
802/// # Activities
803///
804/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
805/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
806///
807/// * [locations key rings crypto keys set iam policy projects](ProjectLocationKeyRingCryptoKeySetIamPolicyCall) (request)
808/// * [locations key rings set iam policy projects](ProjectLocationKeyRingSetIamPolicyCall) (request)
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct SetIamPolicyRequest {
813    /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
814    /// the fields in the mask will be modified. If no mask is provided, the
815    /// following default mask is used:
816    /// paths: "bindings, etag"
817    /// This field is only used by Cloud IAM.
818    #[serde(rename = "updateMask")]
819    pub update_mask: Option<common::FieldMask>,
820    /// REQUIRED: The complete policy to be applied to the `resource`. The size of
821    /// the policy is limited to a few 10s of KB. An empty policy is a
822    /// valid policy but certain Cloud Platform services (such as Projects)
823    /// might reject them.
824    pub policy: Option<Policy>,
825}
826
827impl common::RequestValue for SetIamPolicyRequest {}
828
829/// Request message for KeyManagementService.Decrypt.
830///
831/// # Activities
832///
833/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
834/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
835///
836/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (request)
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct DecryptRequest {
841    /// Required. The encrypted data originally returned in
842    /// EncryptResponse.ciphertext.
843    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
844    pub ciphertext: Option<Vec<u8>>,
845    /// Optional data that must match the data originally supplied in
846    /// EncryptRequest.additional_authenticated_data.
847    #[serde(rename = "additionalAuthenticatedData")]
848    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
849    pub additional_authenticated_data: Option<Vec<u8>>,
850}
851
852impl common::RequestValue for DecryptRequest {}
853
854/// A resource that represents Google Cloud Platform location.
855///
856/// # Activities
857///
858/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
859/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
860///
861/// * [locations get projects](ProjectLocationGetCall) (response)
862#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
863#[serde_with::serde_as]
864#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
865pub struct Location {
866    /// The canonical id for this location. For example: `"us-east1"`.
867    #[serde(rename = "locationId")]
868    pub location_id: Option<String>,
869    /// Service-specific metadata. For example the available capacity at the given
870    /// location.
871    pub metadata: Option<HashMap<String, serde_json::Value>>,
872    /// Cross-service attributes for the location. For example
873    ///
874    /// ````text
875    /// {"cloud.googleapis.com/region": "us-east1"}
876    /// ````
877    pub labels: Option<HashMap<String, String>>,
878    /// Resource name for the location, which may vary between implementations.
879    /// For example: `"projects/example-project/locations/us-east1"`
880    pub name: Option<String>,
881}
882
883impl common::ResponseResult for Location {}
884
885/// Response message for KeyManagementService.ListCryptoKeys.
886///
887/// # Activities
888///
889/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
890/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
891///
892/// * [locations key rings crypto keys list projects](ProjectLocationKeyRingCryptoKeyListCall) (response)
893#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
894#[serde_with::serde_as]
895#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
896pub struct ListCryptoKeysResponse {
897    /// A token to retrieve next page of results. Pass this value in
898    /// ListCryptoKeysRequest.page_token to retrieve the next page of results.
899    #[serde(rename = "nextPageToken")]
900    pub next_page_token: Option<String>,
901    /// The list of CryptoKeys.
902    #[serde(rename = "cryptoKeys")]
903    pub crypto_keys: Option<Vec<CryptoKey>>,
904    /// The total number of CryptoKeys that matched the query.
905    #[serde(rename = "totalSize")]
906    pub total_size: Option<i32>,
907}
908
909impl common::ResponseResult for ListCryptoKeysResponse {}
910
911/// A condition to be met.
912///
913/// This type is not used in any activity, and only used as *part* of another schema.
914///
915#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
916#[serde_with::serde_as]
917#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
918pub struct Condition {
919    /// An operator to apply the subject with.
920    pub op: Option<String>,
921    /// Trusted attributes discharged by the service.
922    pub svc: Option<String>,
923    /// Trusted attributes supplied by any service that owns resources and uses
924    /// the IAM system for access control.
925    pub sys: Option<String>,
926    /// DEPRECATED. Use 'values' instead.
927    pub value: Option<String>,
928    /// Trusted attributes supplied by the IAM system.
929    pub iam: Option<String>,
930    /// The objects of the condition. This is mutually exclusive with 'value'.
931    pub values: Option<Vec<String>>,
932}
933
934impl common::Part for Condition {}
935
936/// Options for counters
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct CounterOptions {
944    /// The metric to update.
945    pub metric: Option<String>,
946    /// The field value to attribute.
947    pub field: Option<String>,
948}
949
950impl common::Part for CounterOptions {}
951
952/// Provides the configuration for logging a type of permissions.
953/// Example:
954///
955/// ````text
956/// {
957///   "audit_log_configs": [
958///     {
959///       "log_type": "DATA_READ",
960///       "exempted_members": [
961///         "user:foo@gmail.com"
962///       ]
963///     },
964///     {
965///       "log_type": "DATA_WRITE",
966///     }
967///   ]
968/// }
969/// ````
970///
971/// This enables ‘DATA_READ’ and ‘DATA_WRITE’ logging, while exempting
972/// foo@gmail.com from DATA_READ logging.
973///
974/// This type is not used in any activity, and only used as *part* of another schema.
975#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
976#[serde_with::serde_as]
977#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
978pub struct AuditLogConfig {
979    /// Specifies the identities that do not cause logging for this type of
980    /// permission.
981    /// Follows the same format of Binding.members.
982    #[serde(rename = "exemptedMembers")]
983    pub exempted_members: Option<Vec<String>>,
984    /// The log type that this config enables.
985    #[serde(rename = "logType")]
986    pub log_type: Option<String>,
987}
988
989impl common::Part for AuditLogConfig {}
990
991/// Response message for KeyManagementService.Decrypt.
992///
993/// # Activities
994///
995/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
996/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
997///
998/// * [locations key rings crypto keys decrypt projects](ProjectLocationKeyRingCryptoKeyDecryptCall) (response)
999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1000#[serde_with::serde_as]
1001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1002pub struct DecryptResponse {
1003    /// The decrypted data originally supplied in EncryptRequest.plaintext.
1004    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1005    pub plaintext: Option<Vec<u8>>,
1006}
1007
1008impl common::ResponseResult for DecryptResponse {}
1009
1010// ###################
1011// MethodBuilders ###
1012// #################
1013
1014/// A builder providing access to all methods supported on *project* resources.
1015/// It is not used directly, but through the [`CloudKMS`] hub.
1016///
1017/// # Example
1018///
1019/// Instantiate a resource builder
1020///
1021/// ```test_harness,no_run
1022/// extern crate hyper;
1023/// extern crate hyper_rustls;
1024/// extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
1025///
1026/// # async fn dox() {
1027/// use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1028///
1029/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1030/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1031///     .with_native_roots()
1032///     .unwrap()
1033///     .https_only()
1034///     .enable_http2()
1035///     .build();
1036///
1037/// let executor = hyper_util::rt::TokioExecutor::new();
1038/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1039///     secret,
1040///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1041///     yup_oauth2::client::CustomHyperClientBuilder::from(
1042///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1043///     ),
1044/// ).build().await.unwrap();
1045///
1046/// let client = hyper_util::client::legacy::Client::builder(
1047///     hyper_util::rt::TokioExecutor::new()
1048/// )
1049/// .build(
1050///     hyper_rustls::HttpsConnectorBuilder::new()
1051///         .with_native_roots()
1052///         .unwrap()
1053///         .https_or_http()
1054///         .enable_http2()
1055///         .build()
1056/// );
1057/// let mut hub = CloudKMS::new(client, auth);
1058/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1059/// // like `locations_get(...)`, `locations_key_rings_create(...)`, `locations_key_rings_crypto_keys_create(...)`, `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_list(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_patch(...)`, `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_list(...)`, `locations_key_rings_set_iam_policy(...)`, `locations_key_rings_test_iam_permissions(...)` and `locations_list(...)`
1060/// // to build up your call.
1061/// let rb = hub.projects();
1062/// # }
1063/// ```
1064pub struct ProjectMethods<'a, C>
1065where
1066    C: 'a,
1067{
1068    hub: &'a CloudKMS<C>,
1069}
1070
1071impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1072
1073impl<'a, C> ProjectMethods<'a, C> {
1074    /// Create a builder to help you perform the following task:
1075    ///
1076    /// Lists CryptoKeyVersions.
1077    ///
1078    /// # Arguments
1079    ///
1080    /// * `parent` - Required. The resource name of the CryptoKey to list, in the format
1081    ///              `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
1082    pub fn locations_key_rings_crypto_keys_crypto_key_versions_list(
1083        &self,
1084        parent: &str,
1085    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
1086        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall {
1087            hub: self.hub,
1088            _parent: parent.to_string(),
1089            _page_token: Default::default(),
1090            _page_size: Default::default(),
1091            _delegate: Default::default(),
1092            _additional_params: Default::default(),
1093            _scopes: Default::default(),
1094        }
1095    }
1096
1097    /// Create a builder to help you perform the following task:
1098    ///
1099    /// Create a new CryptoKeyVersion in a CryptoKey.
1100    ///
1101    /// The server will assign the next sequential id. If unset,
1102    /// state will be set to
1103    /// ENABLED.
1104    ///
1105    /// # Arguments
1106    ///
1107    /// * `request` - No description provided.
1108    /// * `parent` - Required. The name of the CryptoKey associated with
1109    ///              the CryptoKeyVersions.
1110    pub fn locations_key_rings_crypto_keys_crypto_key_versions_create(
1111        &self,
1112        request: CryptoKeyVersion,
1113        parent: &str,
1114    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
1115        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall {
1116            hub: self.hub,
1117            _request: request,
1118            _parent: parent.to_string(),
1119            _delegate: Default::default(),
1120            _additional_params: Default::default(),
1121            _scopes: Default::default(),
1122        }
1123    }
1124
1125    /// Create a builder to help you perform the following task:
1126    ///
1127    /// Schedule a CryptoKeyVersion for destruction.
1128    ///
1129    /// Upon calling this method, CryptoKeyVersion.state will be set to
1130    /// DESTROY_SCHEDULED
1131    /// and destroy_time will be set to a time 24
1132    /// hours in the future, at which point the state
1133    /// will be changed to
1134    /// DESTROYED, and the key
1135    /// material will be irrevocably destroyed.
1136    ///
1137    /// Before the destroy_time is reached,
1138    /// RestoreCryptoKeyVersion may be called to reverse the process.
1139    ///
1140    /// # Arguments
1141    ///
1142    /// * `request` - No description provided.
1143    /// * `name` - The resource name of the CryptoKeyVersion to destroy.
1144    pub fn locations_key_rings_crypto_keys_crypto_key_versions_destroy(
1145        &self,
1146        request: DestroyCryptoKeyVersionRequest,
1147        name: &str,
1148    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
1149        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall {
1150            hub: self.hub,
1151            _request: request,
1152            _name: name.to_string(),
1153            _delegate: Default::default(),
1154            _additional_params: Default::default(),
1155            _scopes: Default::default(),
1156        }
1157    }
1158
1159    /// Create a builder to help you perform the following task:
1160    ///
1161    /// Restore a CryptoKeyVersion in the
1162    /// DESTROY_SCHEDULED,
1163    /// state.
1164    ///
1165    /// Upon restoration of the CryptoKeyVersion, state
1166    /// will be set to DISABLED,
1167    /// and destroy_time will be cleared.
1168    ///
1169    /// # Arguments
1170    ///
1171    /// * `request` - No description provided.
1172    /// * `name` - The resource name of the CryptoKeyVersion to restore.
1173    pub fn locations_key_rings_crypto_keys_crypto_key_versions_restore(
1174        &self,
1175        request: RestoreCryptoKeyVersionRequest,
1176        name: &str,
1177    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
1178        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall {
1179            hub: self.hub,
1180            _request: request,
1181            _name: name.to_string(),
1182            _delegate: Default::default(),
1183            _additional_params: Default::default(),
1184            _scopes: Default::default(),
1185        }
1186    }
1187
1188    /// Create a builder to help you perform the following task:
1189    ///
1190    /// Update a CryptoKeyVersion's metadata.
1191    ///
1192    /// state may be changed between
1193    /// ENABLED and
1194    /// DISABLED using this
1195    /// method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to
1196    /// move between other states.
1197    ///
1198    /// # Arguments
1199    ///
1200    /// * `request` - No description provided.
1201    /// * `name` - Output only. The resource name for this CryptoKeyVersion in the format
1202    ///            `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
1203    pub fn locations_key_rings_crypto_keys_crypto_key_versions_patch(
1204        &self,
1205        request: CryptoKeyVersion,
1206        name: &str,
1207    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
1208        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall {
1209            hub: self.hub,
1210            _request: request,
1211            _name: name.to_string(),
1212            _update_mask: Default::default(),
1213            _delegate: Default::default(),
1214            _additional_params: Default::default(),
1215            _scopes: Default::default(),
1216        }
1217    }
1218
1219    /// Create a builder to help you perform the following task:
1220    ///
1221    /// Returns metadata for a given CryptoKeyVersion.
1222    ///
1223    /// # Arguments
1224    ///
1225    /// * `name` - The name of the CryptoKeyVersion to get.
1226    pub fn locations_key_rings_crypto_keys_crypto_key_versions_get(
1227        &self,
1228        name: &str,
1229    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
1230        ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall {
1231            hub: self.hub,
1232            _name: name.to_string(),
1233            _delegate: Default::default(),
1234            _additional_params: Default::default(),
1235            _scopes: Default::default(),
1236        }
1237    }
1238
1239    /// Create a builder to help you perform the following task:
1240    ///
1241    /// Update a CryptoKey.
1242    ///
1243    /// # Arguments
1244    ///
1245    /// * `request` - No description provided.
1246    /// * `name` - Output only. The resource name for this CryptoKey in the format
1247    ///            `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
1248    pub fn locations_key_rings_crypto_keys_patch(
1249        &self,
1250        request: CryptoKey,
1251        name: &str,
1252    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
1253        ProjectLocationKeyRingCryptoKeyPatchCall {
1254            hub: self.hub,
1255            _request: request,
1256            _name: name.to_string(),
1257            _update_mask: Default::default(),
1258            _delegate: Default::default(),
1259            _additional_params: Default::default(),
1260            _scopes: Default::default(),
1261        }
1262    }
1263
1264    /// Create a builder to help you perform the following task:
1265    ///
1266    /// Returns metadata for a given CryptoKey, as well as its
1267    /// primary CryptoKeyVersion.
1268    ///
1269    /// # Arguments
1270    ///
1271    /// * `name` - The name of the CryptoKey to get.
1272    pub fn locations_key_rings_crypto_keys_get(
1273        &self,
1274        name: &str,
1275    ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
1276        ProjectLocationKeyRingCryptoKeyGetCall {
1277            hub: self.hub,
1278            _name: name.to_string(),
1279            _delegate: Default::default(),
1280            _additional_params: Default::default(),
1281            _scopes: Default::default(),
1282        }
1283    }
1284
1285    /// Create a builder to help you perform the following task:
1286    ///
1287    /// Returns permissions that a caller has on the specified resource.
1288    /// If the resource does not exist, this will return an empty set of
1289    /// permissions, not a NOT_FOUND error.
1290    ///
1291    /// Note: This operation is designed to be used for building permission-aware
1292    /// UIs and command-line tools, not for authorization checking. This operation
1293    /// may "fail open" without warning.
1294    ///
1295    /// # Arguments
1296    ///
1297    /// * `request` - No description provided.
1298    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested.
1299    ///                See the operation documentation for the appropriate value for this field.
1300    pub fn locations_key_rings_crypto_keys_test_iam_permissions(
1301        &self,
1302        request: TestIamPermissionsRequest,
1303        resource: &str,
1304    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
1305        ProjectLocationKeyRingCryptoKeyTestIamPermissionCall {
1306            hub: self.hub,
1307            _request: request,
1308            _resource: resource.to_string(),
1309            _delegate: Default::default(),
1310            _additional_params: Default::default(),
1311            _scopes: Default::default(),
1312        }
1313    }
1314
1315    /// Create a builder to help you perform the following task:
1316    ///
1317    /// Decrypt data that was protected by Encrypt.
1318    ///
1319    /// # Arguments
1320    ///
1321    /// * `request` - No description provided.
1322    /// * `name` - Required. The resource name of the CryptoKey to use for decryption.
1323    ///            The server will choose the appropriate version.
1324    pub fn locations_key_rings_crypto_keys_decrypt(
1325        &self,
1326        request: DecryptRequest,
1327        name: &str,
1328    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
1329        ProjectLocationKeyRingCryptoKeyDecryptCall {
1330            hub: self.hub,
1331            _request: request,
1332            _name: name.to_string(),
1333            _delegate: Default::default(),
1334            _additional_params: Default::default(),
1335            _scopes: Default::default(),
1336        }
1337    }
1338
1339    /// Create a builder to help you perform the following task:
1340    ///
1341    /// Lists CryptoKeys.
1342    ///
1343    /// # Arguments
1344    ///
1345    /// * `parent` - Required. The resource name of the KeyRing to list, in the format
1346    ///              `projects/*/locations/*/keyRings/*`.
1347    pub fn locations_key_rings_crypto_keys_list(
1348        &self,
1349        parent: &str,
1350    ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
1351        ProjectLocationKeyRingCryptoKeyListCall {
1352            hub: self.hub,
1353            _parent: parent.to_string(),
1354            _page_token: Default::default(),
1355            _page_size: Default::default(),
1356            _delegate: Default::default(),
1357            _additional_params: Default::default(),
1358            _scopes: Default::default(),
1359        }
1360    }
1361
1362    /// Create a builder to help you perform the following task:
1363    ///
1364    /// Encrypt data, so that it can only be recovered by a call to Decrypt.
1365    ///
1366    /// # Arguments
1367    ///
1368    /// * `request` - No description provided.
1369    /// * `name` - Required. The resource name of the CryptoKey or CryptoKeyVersion
1370    ///            to use for encryption.
1371    ///            If a CryptoKey is specified, the server will use its
1372    ///            primary version.
1373    pub fn locations_key_rings_crypto_keys_encrypt(
1374        &self,
1375        request: EncryptRequest,
1376        name: &str,
1377    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
1378        ProjectLocationKeyRingCryptoKeyEncryptCall {
1379            hub: self.hub,
1380            _request: request,
1381            _name: name.to_string(),
1382            _delegate: Default::default(),
1383            _additional_params: Default::default(),
1384            _scopes: Default::default(),
1385        }
1386    }
1387
1388    /// Create a builder to help you perform the following task:
1389    ///
1390    /// Create a new CryptoKey within a KeyRing.
1391    ///
1392    /// CryptoKey.purpose is required.
1393    ///
1394    /// # Arguments
1395    ///
1396    /// * `request` - No description provided.
1397    /// * `parent` - Required. The name of the KeyRing associated with the
1398    ///              CryptoKeys.
1399    pub fn locations_key_rings_crypto_keys_create(
1400        &self,
1401        request: CryptoKey,
1402        parent: &str,
1403    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
1404        ProjectLocationKeyRingCryptoKeyCreateCall {
1405            hub: self.hub,
1406            _request: request,
1407            _parent: parent.to_string(),
1408            _crypto_key_id: Default::default(),
1409            _delegate: Default::default(),
1410            _additional_params: Default::default(),
1411            _scopes: Default::default(),
1412        }
1413    }
1414
1415    /// Create a builder to help you perform the following task:
1416    ///
1417    /// Sets the access control policy on the specified resource. Replaces any
1418    /// existing policy.
1419    ///
1420    /// # Arguments
1421    ///
1422    /// * `request` - No description provided.
1423    /// * `resource` - REQUIRED: The resource for which the policy is being specified.
1424    ///                See the operation documentation for the appropriate value for this field.
1425    pub fn locations_key_rings_crypto_keys_set_iam_policy(
1426        &self,
1427        request: SetIamPolicyRequest,
1428        resource: &str,
1429    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
1430        ProjectLocationKeyRingCryptoKeySetIamPolicyCall {
1431            hub: self.hub,
1432            _request: request,
1433            _resource: resource.to_string(),
1434            _delegate: Default::default(),
1435            _additional_params: Default::default(),
1436            _scopes: Default::default(),
1437        }
1438    }
1439
1440    /// Create a builder to help you perform the following task:
1441    ///
1442    /// Update the version of a CryptoKey that will be used in Encrypt
1443    ///
1444    /// # Arguments
1445    ///
1446    /// * `request` - No description provided.
1447    /// * `name` - The resource name of the CryptoKey to update.
1448    pub fn locations_key_rings_crypto_keys_update_primary_version(
1449        &self,
1450        request: UpdateCryptoKeyPrimaryVersionRequest,
1451        name: &str,
1452    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
1453        ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall {
1454            hub: self.hub,
1455            _request: request,
1456            _name: name.to_string(),
1457            _delegate: Default::default(),
1458            _additional_params: Default::default(),
1459            _scopes: Default::default(),
1460        }
1461    }
1462
1463    /// Create a builder to help you perform the following task:
1464    ///
1465    /// Gets the access control policy for a resource.
1466    /// Returns an empty policy if the resource exists and does not have a policy
1467    /// set.
1468    ///
1469    /// # Arguments
1470    ///
1471    /// * `resource` - REQUIRED: The resource for which the policy is being requested.
1472    ///                See the operation documentation for the appropriate value for this field.
1473    pub fn locations_key_rings_crypto_keys_get_iam_policy(
1474        &self,
1475        resource: &str,
1476    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
1477        ProjectLocationKeyRingCryptoKeyGetIamPolicyCall {
1478            hub: self.hub,
1479            _resource: resource.to_string(),
1480            _delegate: Default::default(),
1481            _additional_params: Default::default(),
1482            _scopes: Default::default(),
1483        }
1484    }
1485
1486    /// Create a builder to help you perform the following task:
1487    ///
1488    /// Gets the access control policy for a resource.
1489    /// Returns an empty policy if the resource exists and does not have a policy
1490    /// set.
1491    ///
1492    /// # Arguments
1493    ///
1494    /// * `resource` - REQUIRED: The resource for which the policy is being requested.
1495    ///                See the operation documentation for the appropriate value for this field.
1496    pub fn locations_key_rings_get_iam_policy(
1497        &self,
1498        resource: &str,
1499    ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
1500        ProjectLocationKeyRingGetIamPolicyCall {
1501            hub: self.hub,
1502            _resource: resource.to_string(),
1503            _delegate: Default::default(),
1504            _additional_params: Default::default(),
1505            _scopes: Default::default(),
1506        }
1507    }
1508
1509    /// Create a builder to help you perform the following task:
1510    ///
1511    /// Returns metadata for a given KeyRing.
1512    ///
1513    /// # Arguments
1514    ///
1515    /// * `name` - The name of the KeyRing to get.
1516    pub fn locations_key_rings_get(&self, name: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
1517        ProjectLocationKeyRingGetCall {
1518            hub: self.hub,
1519            _name: name.to_string(),
1520            _delegate: Default::default(),
1521            _additional_params: Default::default(),
1522            _scopes: Default::default(),
1523        }
1524    }
1525
1526    /// Create a builder to help you perform the following task:
1527    ///
1528    /// Returns permissions that a caller has on the specified resource.
1529    /// If the resource does not exist, this will return an empty set of
1530    /// permissions, not a NOT_FOUND error.
1531    ///
1532    /// Note: This operation is designed to be used for building permission-aware
1533    /// UIs and command-line tools, not for authorization checking. This operation
1534    /// may "fail open" without warning.
1535    ///
1536    /// # Arguments
1537    ///
1538    /// * `request` - No description provided.
1539    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested.
1540    ///                See the operation documentation for the appropriate value for this field.
1541    pub fn locations_key_rings_test_iam_permissions(
1542        &self,
1543        request: TestIamPermissionsRequest,
1544        resource: &str,
1545    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
1546        ProjectLocationKeyRingTestIamPermissionCall {
1547            hub: self.hub,
1548            _request: request,
1549            _resource: resource.to_string(),
1550            _delegate: Default::default(),
1551            _additional_params: Default::default(),
1552            _scopes: Default::default(),
1553        }
1554    }
1555
1556    /// Create a builder to help you perform the following task:
1557    ///
1558    /// Lists KeyRings.
1559    ///
1560    /// # Arguments
1561    ///
1562    /// * `parent` - Required. The resource name of the location associated with the
1563    ///              KeyRings, in the format `projects/*/locations/*`.
1564    pub fn locations_key_rings_list(&self, parent: &str) -> ProjectLocationKeyRingListCall<'a, C> {
1565        ProjectLocationKeyRingListCall {
1566            hub: self.hub,
1567            _parent: parent.to_string(),
1568            _page_token: Default::default(),
1569            _page_size: Default::default(),
1570            _delegate: Default::default(),
1571            _additional_params: Default::default(),
1572            _scopes: Default::default(),
1573        }
1574    }
1575
1576    /// Create a builder to help you perform the following task:
1577    ///
1578    /// Sets the access control policy on the specified resource. Replaces any
1579    /// existing policy.
1580    ///
1581    /// # Arguments
1582    ///
1583    /// * `request` - No description provided.
1584    /// * `resource` - REQUIRED: The resource for which the policy is being specified.
1585    ///                See the operation documentation for the appropriate value for this field.
1586    pub fn locations_key_rings_set_iam_policy(
1587        &self,
1588        request: SetIamPolicyRequest,
1589        resource: &str,
1590    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
1591        ProjectLocationKeyRingSetIamPolicyCall {
1592            hub: self.hub,
1593            _request: request,
1594            _resource: resource.to_string(),
1595            _delegate: Default::default(),
1596            _additional_params: Default::default(),
1597            _scopes: Default::default(),
1598        }
1599    }
1600
1601    /// Create a builder to help you perform the following task:
1602    ///
1603    /// Create a new KeyRing in a given Project and Location.
1604    ///
1605    /// # Arguments
1606    ///
1607    /// * `request` - No description provided.
1608    /// * `parent` - Required. The resource name of the location associated with the
1609    ///              KeyRings, in the format `projects/*/locations/*`.
1610    pub fn locations_key_rings_create(
1611        &self,
1612        request: KeyRing,
1613        parent: &str,
1614    ) -> ProjectLocationKeyRingCreateCall<'a, C> {
1615        ProjectLocationKeyRingCreateCall {
1616            hub: self.hub,
1617            _request: request,
1618            _parent: parent.to_string(),
1619            _key_ring_id: Default::default(),
1620            _delegate: Default::default(),
1621            _additional_params: Default::default(),
1622            _scopes: Default::default(),
1623        }
1624    }
1625
1626    /// Create a builder to help you perform the following task:
1627    ///
1628    /// Lists information about the supported locations for this service.
1629    ///
1630    /// # Arguments
1631    ///
1632    /// * `name` - The resource that owns the locations collection, if applicable.
1633    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1634        ProjectLocationListCall {
1635            hub: self.hub,
1636            _name: name.to_string(),
1637            _page_token: Default::default(),
1638            _page_size: Default::default(),
1639            _filter: Default::default(),
1640            _delegate: Default::default(),
1641            _additional_params: Default::default(),
1642            _scopes: Default::default(),
1643        }
1644    }
1645
1646    /// Create a builder to help you perform the following task:
1647    ///
1648    /// Get information about a location.
1649    ///
1650    /// # Arguments
1651    ///
1652    /// * `name` - Resource name for the location.
1653    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1654        ProjectLocationGetCall {
1655            hub: self.hub,
1656            _name: name.to_string(),
1657            _delegate: Default::default(),
1658            _additional_params: Default::default(),
1659            _scopes: Default::default(),
1660        }
1661    }
1662}
1663
1664// ###################
1665// CallBuilders   ###
1666// #################
1667
1668/// Lists CryptoKeyVersions.
1669///
1670/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.list* method supported by a *project* resource.
1671/// It is not used directly, but through a [`ProjectMethods`] instance.
1672///
1673/// # Example
1674///
1675/// Instantiate a resource method builder
1676///
1677/// ```test_harness,no_run
1678/// # extern crate hyper;
1679/// # extern crate hyper_rustls;
1680/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
1681/// # async fn dox() {
1682/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1683///
1684/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1685/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1686/// #     .with_native_roots()
1687/// #     .unwrap()
1688/// #     .https_only()
1689/// #     .enable_http2()
1690/// #     .build();
1691///
1692/// # let executor = hyper_util::rt::TokioExecutor::new();
1693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1694/// #     secret,
1695/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1696/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1697/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1698/// #     ),
1699/// # ).build().await.unwrap();
1700///
1701/// # let client = hyper_util::client::legacy::Client::builder(
1702/// #     hyper_util::rt::TokioExecutor::new()
1703/// # )
1704/// # .build(
1705/// #     hyper_rustls::HttpsConnectorBuilder::new()
1706/// #         .with_native_roots()
1707/// #         .unwrap()
1708/// #         .https_or_http()
1709/// #         .enable_http2()
1710/// #         .build()
1711/// # );
1712/// # let mut hub = CloudKMS::new(client, auth);
1713/// // You can configure optional parameters by calling the respective setters at will, and
1714/// // execute the final call using `doit()`.
1715/// // Values shown here are possibly random and not representative !
1716/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_list("parent")
1717///              .page_token("voluptua.")
1718///              .page_size(-27)
1719///              .doit().await;
1720/// # }
1721/// ```
1722pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
1723where
1724    C: 'a,
1725{
1726    hub: &'a CloudKMS<C>,
1727    _parent: String,
1728    _page_token: Option<String>,
1729    _page_size: Option<i32>,
1730    _delegate: Option<&'a mut dyn common::Delegate>,
1731    _additional_params: HashMap<String, String>,
1732    _scopes: BTreeSet<String>,
1733}
1734
1735impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {}
1736
1737impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
1738where
1739    C: common::Connector,
1740{
1741    /// Perform the operation you have build so far.
1742    pub async fn doit(
1743        mut self,
1744    ) -> common::Result<(common::Response, ListCryptoKeyVersionsResponse)> {
1745        use std::borrow::Cow;
1746        use std::io::{Read, Seek};
1747
1748        use common::{url::Params, ToParts};
1749        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1750
1751        let mut dd = common::DefaultDelegate;
1752        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1753        dlg.begin(common::MethodInfo {
1754            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list",
1755            http_method: hyper::Method::GET,
1756        });
1757
1758        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
1759            if self._additional_params.contains_key(field) {
1760                dlg.finished(false);
1761                return Err(common::Error::FieldClash(field));
1762            }
1763        }
1764
1765        let mut params = Params::with_capacity(5 + self._additional_params.len());
1766        params.push("parent", self._parent);
1767        if let Some(value) = self._page_token.as_ref() {
1768            params.push("pageToken", value);
1769        }
1770        if let Some(value) = self._page_size.as_ref() {
1771            params.push("pageSize", value.to_string());
1772        }
1773
1774        params.extend(self._additional_params.iter());
1775
1776        params.push("alt", "json");
1777        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/cryptoKeyVersions";
1778        if self._scopes.is_empty() {
1779            self._scopes
1780                .insert(Scope::CloudPlatform.as_ref().to_string());
1781        }
1782
1783        #[allow(clippy::single_element_loop)]
1784        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1785            url = params.uri_replacement(url, param_name, find_this, true);
1786        }
1787        {
1788            let to_remove = ["parent"];
1789            params.remove_params(&to_remove);
1790        }
1791
1792        let url = params.parse_with_url(&url);
1793
1794        loop {
1795            let token = match self
1796                .hub
1797                .auth
1798                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1799                .await
1800            {
1801                Ok(token) => token,
1802                Err(e) => match dlg.token(e) {
1803                    Ok(token) => token,
1804                    Err(e) => {
1805                        dlg.finished(false);
1806                        return Err(common::Error::MissingToken(e));
1807                    }
1808                },
1809            };
1810            let mut req_result = {
1811                let client = &self.hub.client;
1812                dlg.pre_request();
1813                let mut req_builder = hyper::Request::builder()
1814                    .method(hyper::Method::GET)
1815                    .uri(url.as_str())
1816                    .header(USER_AGENT, self.hub._user_agent.clone());
1817
1818                if let Some(token) = token.as_ref() {
1819                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1820                }
1821
1822                let request = req_builder
1823                    .header(CONTENT_LENGTH, 0_u64)
1824                    .body(common::to_body::<String>(None));
1825
1826                client.request(request.unwrap()).await
1827            };
1828
1829            match req_result {
1830                Err(err) => {
1831                    if let common::Retry::After(d) = dlg.http_error(&err) {
1832                        sleep(d).await;
1833                        continue;
1834                    }
1835                    dlg.finished(false);
1836                    return Err(common::Error::HttpError(err));
1837                }
1838                Ok(res) => {
1839                    let (mut parts, body) = res.into_parts();
1840                    let mut body = common::Body::new(body);
1841                    if !parts.status.is_success() {
1842                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1843                        let error = serde_json::from_str(&common::to_string(&bytes));
1844                        let response = common::to_response(parts, bytes.into());
1845
1846                        if let common::Retry::After(d) =
1847                            dlg.http_failure(&response, error.as_ref().ok())
1848                        {
1849                            sleep(d).await;
1850                            continue;
1851                        }
1852
1853                        dlg.finished(false);
1854
1855                        return Err(match error {
1856                            Ok(value) => common::Error::BadRequest(value),
1857                            _ => common::Error::Failure(response),
1858                        });
1859                    }
1860                    let response = {
1861                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1862                        let encoded = common::to_string(&bytes);
1863                        match serde_json::from_str(&encoded) {
1864                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1865                            Err(error) => {
1866                                dlg.response_json_decode_error(&encoded, &error);
1867                                return Err(common::Error::JsonDecodeError(
1868                                    encoded.to_string(),
1869                                    error,
1870                                ));
1871                            }
1872                        }
1873                    };
1874
1875                    dlg.finished(true);
1876                    return Ok(response);
1877                }
1878            }
1879        }
1880    }
1881
1882    /// Required. The resource name of the CryptoKey to list, in the format
1883    /// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
1884    ///
1885    /// Sets the *parent* path property to the given value.
1886    ///
1887    /// Even though the property as already been set when instantiating this call,
1888    /// we provide this method for API completeness.
1889    pub fn parent(
1890        mut self,
1891        new_value: &str,
1892    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
1893        self._parent = new_value.to_string();
1894        self
1895    }
1896    /// Optional pagination token, returned earlier via
1897    /// ListCryptoKeyVersionsResponse.next_page_token.
1898    ///
1899    /// Sets the *page token* query property to the given value.
1900    pub fn page_token(
1901        mut self,
1902        new_value: &str,
1903    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
1904        self._page_token = Some(new_value.to_string());
1905        self
1906    }
1907    /// Optional limit on the number of CryptoKeyVersions to
1908    /// include in the response. Further CryptoKeyVersions can
1909    /// subsequently be obtained by including the
1910    /// ListCryptoKeyVersionsResponse.next_page_token in a subsequent request.
1911    /// If unspecified, the server will pick an appropriate default.
1912    ///
1913    /// Sets the *page size* query property to the given value.
1914    pub fn page_size(
1915        mut self,
1916        new_value: i32,
1917    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
1918        self._page_size = Some(new_value);
1919        self
1920    }
1921    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1922    /// while executing the actual API request.
1923    ///
1924    /// ````text
1925    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1926    /// ````
1927    ///
1928    /// Sets the *delegate* property to the given value.
1929    pub fn delegate(
1930        mut self,
1931        new_value: &'a mut dyn common::Delegate,
1932    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
1933        self._delegate = Some(new_value);
1934        self
1935    }
1936
1937    /// Set any additional parameter of the query string used in the request.
1938    /// It should be used to set parameters which are not yet available through their own
1939    /// setters.
1940    ///
1941    /// Please note that this method must not be used to set any of the known parameters
1942    /// which have their own setter method. If done anyway, the request will fail.
1943    ///
1944    /// # Additional Parameters
1945    ///
1946    /// * *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.
1947    /// * *access_token* (query-string) - OAuth access token.
1948    /// * *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.
1949    /// * *pp* (query-boolean) - Pretty-print response.
1950    /// * *bearer_token* (query-string) - OAuth bearer token.
1951    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1952    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1953    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1954    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1955    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1956    /// * *callback* (query-string) - JSONP
1957    /// * *$.xgafv* (query-string) - V1 error format.
1958    /// * *alt* (query-string) - Data format for response.
1959    pub fn param<T>(
1960        mut self,
1961        name: T,
1962        value: T,
1963    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
1964    where
1965        T: AsRef<str>,
1966    {
1967        self._additional_params
1968            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1969        self
1970    }
1971
1972    /// Identifies the authorization scope for the method you are building.
1973    ///
1974    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1975    /// [`Scope::CloudPlatform`].
1976    ///
1977    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1978    /// tokens for more than one scope.
1979    ///
1980    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1981    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1982    /// sufficient, a read-write scope will do as well.
1983    pub fn add_scope<St>(
1984        mut self,
1985        scope: St,
1986    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
1987    where
1988        St: AsRef<str>,
1989    {
1990        self._scopes.insert(String::from(scope.as_ref()));
1991        self
1992    }
1993    /// Identifies the authorization scope(s) for the method you are building.
1994    ///
1995    /// See [`Self::add_scope()`] for details.
1996    pub fn add_scopes<I, St>(
1997        mut self,
1998        scopes: I,
1999    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C>
2000    where
2001        I: IntoIterator<Item = St>,
2002        St: AsRef<str>,
2003    {
2004        self._scopes
2005            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2006        self
2007    }
2008
2009    /// Removes all scopes, and no default scope will be used either.
2010    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2011    /// for details).
2012    pub fn clear_scopes(
2013        mut self,
2014    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C> {
2015        self._scopes.clear();
2016        self
2017    }
2018}
2019
2020/// Create a new CryptoKeyVersion in a CryptoKey.
2021///
2022/// The server will assign the next sequential id. If unset,
2023/// state will be set to
2024/// ENABLED.
2025///
2026/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.create* method supported by a *project* resource.
2027/// It is not used directly, but through a [`ProjectMethods`] instance.
2028///
2029/// # Example
2030///
2031/// Instantiate a resource method builder
2032///
2033/// ```test_harness,no_run
2034/// # extern crate hyper;
2035/// # extern crate hyper_rustls;
2036/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
2037/// use cloudkms1_beta1::api::CryptoKeyVersion;
2038/// # async fn dox() {
2039/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2040///
2041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2042/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2043/// #     .with_native_roots()
2044/// #     .unwrap()
2045/// #     .https_only()
2046/// #     .enable_http2()
2047/// #     .build();
2048///
2049/// # let executor = hyper_util::rt::TokioExecutor::new();
2050/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2051/// #     secret,
2052/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2053/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2054/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2055/// #     ),
2056/// # ).build().await.unwrap();
2057///
2058/// # let client = hyper_util::client::legacy::Client::builder(
2059/// #     hyper_util::rt::TokioExecutor::new()
2060/// # )
2061/// # .build(
2062/// #     hyper_rustls::HttpsConnectorBuilder::new()
2063/// #         .with_native_roots()
2064/// #         .unwrap()
2065/// #         .https_or_http()
2066/// #         .enable_http2()
2067/// #         .build()
2068/// # );
2069/// # let mut hub = CloudKMS::new(client, auth);
2070/// // As the method needs a request, you would usually fill it with the desired information
2071/// // into the respective structure. Some of the parts shown here might not be applicable !
2072/// // Values shown here are possibly random and not representative !
2073/// let mut req = CryptoKeyVersion::default();
2074///
2075/// // You can configure optional parameters by calling the respective setters at will, and
2076/// // execute the final call using `doit()`.
2077/// // Values shown here are possibly random and not representative !
2078/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_create(req, "parent")
2079///              .doit().await;
2080/// # }
2081/// ```
2082pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2083where
2084    C: 'a,
2085{
2086    hub: &'a CloudKMS<C>,
2087    _request: CryptoKeyVersion,
2088    _parent: String,
2089    _delegate: Option<&'a mut dyn common::Delegate>,
2090    _additional_params: HashMap<String, String>,
2091    _scopes: BTreeSet<String>,
2092}
2093
2094impl<'a, C> common::CallBuilder
2095    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2096{
2097}
2098
2099impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2100where
2101    C: common::Connector,
2102{
2103    /// Perform the operation you have build so far.
2104    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
2105        use std::borrow::Cow;
2106        use std::io::{Read, Seek};
2107
2108        use common::{url::Params, ToParts};
2109        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2110
2111        let mut dd = common::DefaultDelegate;
2112        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2113        dlg.begin(common::MethodInfo {
2114            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create",
2115            http_method: hyper::Method::POST,
2116        });
2117
2118        for &field in ["alt", "parent"].iter() {
2119            if self._additional_params.contains_key(field) {
2120                dlg.finished(false);
2121                return Err(common::Error::FieldClash(field));
2122            }
2123        }
2124
2125        let mut params = Params::with_capacity(4 + self._additional_params.len());
2126        params.push("parent", self._parent);
2127
2128        params.extend(self._additional_params.iter());
2129
2130        params.push("alt", "json");
2131        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/cryptoKeyVersions";
2132        if self._scopes.is_empty() {
2133            self._scopes
2134                .insert(Scope::CloudPlatform.as_ref().to_string());
2135        }
2136
2137        #[allow(clippy::single_element_loop)]
2138        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2139            url = params.uri_replacement(url, param_name, find_this, true);
2140        }
2141        {
2142            let to_remove = ["parent"];
2143            params.remove_params(&to_remove);
2144        }
2145
2146        let url = params.parse_with_url(&url);
2147
2148        let mut json_mime_type = mime::APPLICATION_JSON;
2149        let mut request_value_reader = {
2150            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2151            common::remove_json_null_values(&mut value);
2152            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2153            serde_json::to_writer(&mut dst, &value).unwrap();
2154            dst
2155        };
2156        let request_size = request_value_reader
2157            .seek(std::io::SeekFrom::End(0))
2158            .unwrap();
2159        request_value_reader
2160            .seek(std::io::SeekFrom::Start(0))
2161            .unwrap();
2162
2163        loop {
2164            let token = match self
2165                .hub
2166                .auth
2167                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2168                .await
2169            {
2170                Ok(token) => token,
2171                Err(e) => match dlg.token(e) {
2172                    Ok(token) => token,
2173                    Err(e) => {
2174                        dlg.finished(false);
2175                        return Err(common::Error::MissingToken(e));
2176                    }
2177                },
2178            };
2179            request_value_reader
2180                .seek(std::io::SeekFrom::Start(0))
2181                .unwrap();
2182            let mut req_result = {
2183                let client = &self.hub.client;
2184                dlg.pre_request();
2185                let mut req_builder = hyper::Request::builder()
2186                    .method(hyper::Method::POST)
2187                    .uri(url.as_str())
2188                    .header(USER_AGENT, self.hub._user_agent.clone());
2189
2190                if let Some(token) = token.as_ref() {
2191                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2192                }
2193
2194                let request = req_builder
2195                    .header(CONTENT_TYPE, json_mime_type.to_string())
2196                    .header(CONTENT_LENGTH, request_size as u64)
2197                    .body(common::to_body(
2198                        request_value_reader.get_ref().clone().into(),
2199                    ));
2200
2201                client.request(request.unwrap()).await
2202            };
2203
2204            match req_result {
2205                Err(err) => {
2206                    if let common::Retry::After(d) = dlg.http_error(&err) {
2207                        sleep(d).await;
2208                        continue;
2209                    }
2210                    dlg.finished(false);
2211                    return Err(common::Error::HttpError(err));
2212                }
2213                Ok(res) => {
2214                    let (mut parts, body) = res.into_parts();
2215                    let mut body = common::Body::new(body);
2216                    if !parts.status.is_success() {
2217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2218                        let error = serde_json::from_str(&common::to_string(&bytes));
2219                        let response = common::to_response(parts, bytes.into());
2220
2221                        if let common::Retry::After(d) =
2222                            dlg.http_failure(&response, error.as_ref().ok())
2223                        {
2224                            sleep(d).await;
2225                            continue;
2226                        }
2227
2228                        dlg.finished(false);
2229
2230                        return Err(match error {
2231                            Ok(value) => common::Error::BadRequest(value),
2232                            _ => common::Error::Failure(response),
2233                        });
2234                    }
2235                    let response = {
2236                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2237                        let encoded = common::to_string(&bytes);
2238                        match serde_json::from_str(&encoded) {
2239                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2240                            Err(error) => {
2241                                dlg.response_json_decode_error(&encoded, &error);
2242                                return Err(common::Error::JsonDecodeError(
2243                                    encoded.to_string(),
2244                                    error,
2245                                ));
2246                            }
2247                        }
2248                    };
2249
2250                    dlg.finished(true);
2251                    return Ok(response);
2252                }
2253            }
2254        }
2255    }
2256
2257    ///
2258    /// Sets the *request* property to the given value.
2259    ///
2260    /// Even though the property as already been set when instantiating this call,
2261    /// we provide this method for API completeness.
2262    pub fn request(
2263        mut self,
2264        new_value: CryptoKeyVersion,
2265    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2266        self._request = new_value;
2267        self
2268    }
2269    /// Required. The name of the CryptoKey associated with
2270    /// the CryptoKeyVersions.
2271    ///
2272    /// Sets the *parent* path property to the given value.
2273    ///
2274    /// Even though the property as already been set when instantiating this call,
2275    /// we provide this method for API completeness.
2276    pub fn parent(
2277        mut self,
2278        new_value: &str,
2279    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2280        self._parent = new_value.to_string();
2281        self
2282    }
2283    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2284    /// while executing the actual API request.
2285    ///
2286    /// ````text
2287    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2288    /// ````
2289    ///
2290    /// Sets the *delegate* property to the given value.
2291    pub fn delegate(
2292        mut self,
2293        new_value: &'a mut dyn common::Delegate,
2294    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2295        self._delegate = Some(new_value);
2296        self
2297    }
2298
2299    /// Set any additional parameter of the query string used in the request.
2300    /// It should be used to set parameters which are not yet available through their own
2301    /// setters.
2302    ///
2303    /// Please note that this method must not be used to set any of the known parameters
2304    /// which have their own setter method. If done anyway, the request will fail.
2305    ///
2306    /// # Additional Parameters
2307    ///
2308    /// * *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.
2309    /// * *access_token* (query-string) - OAuth access token.
2310    /// * *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.
2311    /// * *pp* (query-boolean) - Pretty-print response.
2312    /// * *bearer_token* (query-string) - OAuth bearer token.
2313    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2314    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2316    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2317    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2318    /// * *callback* (query-string) - JSONP
2319    /// * *$.xgafv* (query-string) - V1 error format.
2320    /// * *alt* (query-string) - Data format for response.
2321    pub fn param<T>(
2322        mut self,
2323        name: T,
2324        value: T,
2325    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2326    where
2327        T: AsRef<str>,
2328    {
2329        self._additional_params
2330            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2331        self
2332    }
2333
2334    /// Identifies the authorization scope for the method you are building.
2335    ///
2336    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2337    /// [`Scope::CloudPlatform`].
2338    ///
2339    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2340    /// tokens for more than one scope.
2341    ///
2342    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2343    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2344    /// sufficient, a read-write scope will do as well.
2345    pub fn add_scope<St>(
2346        mut self,
2347        scope: St,
2348    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2349    where
2350        St: AsRef<str>,
2351    {
2352        self._scopes.insert(String::from(scope.as_ref()));
2353        self
2354    }
2355    /// Identifies the authorization scope(s) for the method you are building.
2356    ///
2357    /// See [`Self::add_scope()`] for details.
2358    pub fn add_scopes<I, St>(
2359        mut self,
2360        scopes: I,
2361    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C>
2362    where
2363        I: IntoIterator<Item = St>,
2364        St: AsRef<str>,
2365    {
2366        self._scopes
2367            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2368        self
2369    }
2370
2371    /// Removes all scopes, and no default scope will be used either.
2372    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2373    /// for details).
2374    pub fn clear_scopes(
2375        mut self,
2376    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C> {
2377        self._scopes.clear();
2378        self
2379    }
2380}
2381
2382/// Schedule a CryptoKeyVersion for destruction.
2383///
2384/// Upon calling this method, CryptoKeyVersion.state will be set to
2385/// DESTROY_SCHEDULED
2386/// and destroy_time will be set to a time 24
2387/// hours in the future, at which point the state
2388/// will be changed to
2389/// DESTROYED, and the key
2390/// material will be irrevocably destroyed.
2391///
2392/// Before the destroy_time is reached,
2393/// RestoreCryptoKeyVersion may be called to reverse the process.
2394///
2395/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy* method supported by a *project* resource.
2396/// It is not used directly, but through a [`ProjectMethods`] instance.
2397///
2398/// # Example
2399///
2400/// Instantiate a resource method builder
2401///
2402/// ```test_harness,no_run
2403/// # extern crate hyper;
2404/// # extern crate hyper_rustls;
2405/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
2406/// use cloudkms1_beta1::api::DestroyCryptoKeyVersionRequest;
2407/// # async fn dox() {
2408/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2409///
2410/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2411/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2412/// #     .with_native_roots()
2413/// #     .unwrap()
2414/// #     .https_only()
2415/// #     .enable_http2()
2416/// #     .build();
2417///
2418/// # let executor = hyper_util::rt::TokioExecutor::new();
2419/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2420/// #     secret,
2421/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2422/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2423/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2424/// #     ),
2425/// # ).build().await.unwrap();
2426///
2427/// # let client = hyper_util::client::legacy::Client::builder(
2428/// #     hyper_util::rt::TokioExecutor::new()
2429/// # )
2430/// # .build(
2431/// #     hyper_rustls::HttpsConnectorBuilder::new()
2432/// #         .with_native_roots()
2433/// #         .unwrap()
2434/// #         .https_or_http()
2435/// #         .enable_http2()
2436/// #         .build()
2437/// # );
2438/// # let mut hub = CloudKMS::new(client, auth);
2439/// // As the method needs a request, you would usually fill it with the desired information
2440/// // into the respective structure. Some of the parts shown here might not be applicable !
2441/// // Values shown here are possibly random and not representative !
2442/// let mut req = DestroyCryptoKeyVersionRequest::default();
2443///
2444/// // You can configure optional parameters by calling the respective setters at will, and
2445/// // execute the final call using `doit()`.
2446/// // Values shown here are possibly random and not representative !
2447/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_destroy(req, "name")
2448///              .doit().await;
2449/// # }
2450/// ```
2451pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2452where
2453    C: 'a,
2454{
2455    hub: &'a CloudKMS<C>,
2456    _request: DestroyCryptoKeyVersionRequest,
2457    _name: String,
2458    _delegate: Option<&'a mut dyn common::Delegate>,
2459    _additional_params: HashMap<String, String>,
2460    _scopes: BTreeSet<String>,
2461}
2462
2463impl<'a, C> common::CallBuilder
2464    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2465{
2466}
2467
2468impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2469where
2470    C: common::Connector,
2471{
2472    /// Perform the operation you have build so far.
2473    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
2474        use std::borrow::Cow;
2475        use std::io::{Read, Seek};
2476
2477        use common::{url::Params, ToParts};
2478        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2479
2480        let mut dd = common::DefaultDelegate;
2481        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2482        dlg.begin(common::MethodInfo {
2483            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy",
2484            http_method: hyper::Method::POST,
2485        });
2486
2487        for &field in ["alt", "name"].iter() {
2488            if self._additional_params.contains_key(field) {
2489                dlg.finished(false);
2490                return Err(common::Error::FieldClash(field));
2491            }
2492        }
2493
2494        let mut params = Params::with_capacity(4 + self._additional_params.len());
2495        params.push("name", self._name);
2496
2497        params.extend(self._additional_params.iter());
2498
2499        params.push("alt", "json");
2500        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:destroy";
2501        if self._scopes.is_empty() {
2502            self._scopes
2503                .insert(Scope::CloudPlatform.as_ref().to_string());
2504        }
2505
2506        #[allow(clippy::single_element_loop)]
2507        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2508            url = params.uri_replacement(url, param_name, find_this, true);
2509        }
2510        {
2511            let to_remove = ["name"];
2512            params.remove_params(&to_remove);
2513        }
2514
2515        let url = params.parse_with_url(&url);
2516
2517        let mut json_mime_type = mime::APPLICATION_JSON;
2518        let mut request_value_reader = {
2519            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2520            common::remove_json_null_values(&mut value);
2521            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2522            serde_json::to_writer(&mut dst, &value).unwrap();
2523            dst
2524        };
2525        let request_size = request_value_reader
2526            .seek(std::io::SeekFrom::End(0))
2527            .unwrap();
2528        request_value_reader
2529            .seek(std::io::SeekFrom::Start(0))
2530            .unwrap();
2531
2532        loop {
2533            let token = match self
2534                .hub
2535                .auth
2536                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2537                .await
2538            {
2539                Ok(token) => token,
2540                Err(e) => match dlg.token(e) {
2541                    Ok(token) => token,
2542                    Err(e) => {
2543                        dlg.finished(false);
2544                        return Err(common::Error::MissingToken(e));
2545                    }
2546                },
2547            };
2548            request_value_reader
2549                .seek(std::io::SeekFrom::Start(0))
2550                .unwrap();
2551            let mut req_result = {
2552                let client = &self.hub.client;
2553                dlg.pre_request();
2554                let mut req_builder = hyper::Request::builder()
2555                    .method(hyper::Method::POST)
2556                    .uri(url.as_str())
2557                    .header(USER_AGENT, self.hub._user_agent.clone());
2558
2559                if let Some(token) = token.as_ref() {
2560                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2561                }
2562
2563                let request = req_builder
2564                    .header(CONTENT_TYPE, json_mime_type.to_string())
2565                    .header(CONTENT_LENGTH, request_size as u64)
2566                    .body(common::to_body(
2567                        request_value_reader.get_ref().clone().into(),
2568                    ));
2569
2570                client.request(request.unwrap()).await
2571            };
2572
2573            match req_result {
2574                Err(err) => {
2575                    if let common::Retry::After(d) = dlg.http_error(&err) {
2576                        sleep(d).await;
2577                        continue;
2578                    }
2579                    dlg.finished(false);
2580                    return Err(common::Error::HttpError(err));
2581                }
2582                Ok(res) => {
2583                    let (mut parts, body) = res.into_parts();
2584                    let mut body = common::Body::new(body);
2585                    if !parts.status.is_success() {
2586                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2587                        let error = serde_json::from_str(&common::to_string(&bytes));
2588                        let response = common::to_response(parts, bytes.into());
2589
2590                        if let common::Retry::After(d) =
2591                            dlg.http_failure(&response, error.as_ref().ok())
2592                        {
2593                            sleep(d).await;
2594                            continue;
2595                        }
2596
2597                        dlg.finished(false);
2598
2599                        return Err(match error {
2600                            Ok(value) => common::Error::BadRequest(value),
2601                            _ => common::Error::Failure(response),
2602                        });
2603                    }
2604                    let response = {
2605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2606                        let encoded = common::to_string(&bytes);
2607                        match serde_json::from_str(&encoded) {
2608                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2609                            Err(error) => {
2610                                dlg.response_json_decode_error(&encoded, &error);
2611                                return Err(common::Error::JsonDecodeError(
2612                                    encoded.to_string(),
2613                                    error,
2614                                ));
2615                            }
2616                        }
2617                    };
2618
2619                    dlg.finished(true);
2620                    return Ok(response);
2621                }
2622            }
2623        }
2624    }
2625
2626    ///
2627    /// Sets the *request* property to the given value.
2628    ///
2629    /// Even though the property as already been set when instantiating this call,
2630    /// we provide this method for API completeness.
2631    pub fn request(
2632        mut self,
2633        new_value: DestroyCryptoKeyVersionRequest,
2634    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2635        self._request = new_value;
2636        self
2637    }
2638    /// The resource name of the CryptoKeyVersion to destroy.
2639    ///
2640    /// Sets the *name* path property to the given value.
2641    ///
2642    /// Even though the property as already been set when instantiating this call,
2643    /// we provide this method for API completeness.
2644    pub fn name(
2645        mut self,
2646        new_value: &str,
2647    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2648        self._name = new_value.to_string();
2649        self
2650    }
2651    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2652    /// while executing the actual API request.
2653    ///
2654    /// ````text
2655    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2656    /// ````
2657    ///
2658    /// Sets the *delegate* property to the given value.
2659    pub fn delegate(
2660        mut self,
2661        new_value: &'a mut dyn common::Delegate,
2662    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2663        self._delegate = Some(new_value);
2664        self
2665    }
2666
2667    /// Set any additional parameter of the query string used in the request.
2668    /// It should be used to set parameters which are not yet available through their own
2669    /// setters.
2670    ///
2671    /// Please note that this method must not be used to set any of the known parameters
2672    /// which have their own setter method. If done anyway, the request will fail.
2673    ///
2674    /// # Additional Parameters
2675    ///
2676    /// * *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.
2677    /// * *access_token* (query-string) - OAuth access token.
2678    /// * *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.
2679    /// * *pp* (query-boolean) - Pretty-print response.
2680    /// * *bearer_token* (query-string) - OAuth bearer token.
2681    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2682    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2683    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2684    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2685    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2686    /// * *callback* (query-string) - JSONP
2687    /// * *$.xgafv* (query-string) - V1 error format.
2688    /// * *alt* (query-string) - Data format for response.
2689    pub fn param<T>(
2690        mut self,
2691        name: T,
2692        value: T,
2693    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2694    where
2695        T: AsRef<str>,
2696    {
2697        self._additional_params
2698            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2699        self
2700    }
2701
2702    /// Identifies the authorization scope for the method you are building.
2703    ///
2704    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2705    /// [`Scope::CloudPlatform`].
2706    ///
2707    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2708    /// tokens for more than one scope.
2709    ///
2710    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2711    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2712    /// sufficient, a read-write scope will do as well.
2713    pub fn add_scope<St>(
2714        mut self,
2715        scope: St,
2716    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2717    where
2718        St: AsRef<str>,
2719    {
2720        self._scopes.insert(String::from(scope.as_ref()));
2721        self
2722    }
2723    /// Identifies the authorization scope(s) for the method you are building.
2724    ///
2725    /// See [`Self::add_scope()`] for details.
2726    pub fn add_scopes<I, St>(
2727        mut self,
2728        scopes: I,
2729    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C>
2730    where
2731        I: IntoIterator<Item = St>,
2732        St: AsRef<str>,
2733    {
2734        self._scopes
2735            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2736        self
2737    }
2738
2739    /// Removes all scopes, and no default scope will be used either.
2740    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2741    /// for details).
2742    pub fn clear_scopes(
2743        mut self,
2744    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C> {
2745        self._scopes.clear();
2746        self
2747    }
2748}
2749
2750/// Restore a CryptoKeyVersion in the
2751/// DESTROY_SCHEDULED,
2752/// state.
2753///
2754/// Upon restoration of the CryptoKeyVersion, state
2755/// will be set to DISABLED,
2756/// and destroy_time will be cleared.
2757///
2758/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.restore* method supported by a *project* resource.
2759/// It is not used directly, but through a [`ProjectMethods`] instance.
2760///
2761/// # Example
2762///
2763/// Instantiate a resource method builder
2764///
2765/// ```test_harness,no_run
2766/// # extern crate hyper;
2767/// # extern crate hyper_rustls;
2768/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
2769/// use cloudkms1_beta1::api::RestoreCryptoKeyVersionRequest;
2770/// # async fn dox() {
2771/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2772///
2773/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2774/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2775/// #     .with_native_roots()
2776/// #     .unwrap()
2777/// #     .https_only()
2778/// #     .enable_http2()
2779/// #     .build();
2780///
2781/// # let executor = hyper_util::rt::TokioExecutor::new();
2782/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2783/// #     secret,
2784/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2785/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2786/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2787/// #     ),
2788/// # ).build().await.unwrap();
2789///
2790/// # let client = hyper_util::client::legacy::Client::builder(
2791/// #     hyper_util::rt::TokioExecutor::new()
2792/// # )
2793/// # .build(
2794/// #     hyper_rustls::HttpsConnectorBuilder::new()
2795/// #         .with_native_roots()
2796/// #         .unwrap()
2797/// #         .https_or_http()
2798/// #         .enable_http2()
2799/// #         .build()
2800/// # );
2801/// # let mut hub = CloudKMS::new(client, auth);
2802/// // As the method needs a request, you would usually fill it with the desired information
2803/// // into the respective structure. Some of the parts shown here might not be applicable !
2804/// // Values shown here are possibly random and not representative !
2805/// let mut req = RestoreCryptoKeyVersionRequest::default();
2806///
2807/// // You can configure optional parameters by calling the respective setters at will, and
2808/// // execute the final call using `doit()`.
2809/// // Values shown here are possibly random and not representative !
2810/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_restore(req, "name")
2811///              .doit().await;
2812/// # }
2813/// ```
2814pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
2815where
2816    C: 'a,
2817{
2818    hub: &'a CloudKMS<C>,
2819    _request: RestoreCryptoKeyVersionRequest,
2820    _name: String,
2821    _delegate: Option<&'a mut dyn common::Delegate>,
2822    _additional_params: HashMap<String, String>,
2823    _scopes: BTreeSet<String>,
2824}
2825
2826impl<'a, C> common::CallBuilder
2827    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
2828{
2829}
2830
2831impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
2832where
2833    C: common::Connector,
2834{
2835    /// Perform the operation you have build so far.
2836    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
2837        use std::borrow::Cow;
2838        use std::io::{Read, Seek};
2839
2840        use common::{url::Params, ToParts};
2841        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2842
2843        let mut dd = common::DefaultDelegate;
2844        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2845        dlg.begin(common::MethodInfo {
2846            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore",
2847            http_method: hyper::Method::POST,
2848        });
2849
2850        for &field in ["alt", "name"].iter() {
2851            if self._additional_params.contains_key(field) {
2852                dlg.finished(false);
2853                return Err(common::Error::FieldClash(field));
2854            }
2855        }
2856
2857        let mut params = Params::with_capacity(4 + self._additional_params.len());
2858        params.push("name", self._name);
2859
2860        params.extend(self._additional_params.iter());
2861
2862        params.push("alt", "json");
2863        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:restore";
2864        if self._scopes.is_empty() {
2865            self._scopes
2866                .insert(Scope::CloudPlatform.as_ref().to_string());
2867        }
2868
2869        #[allow(clippy::single_element_loop)]
2870        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2871            url = params.uri_replacement(url, param_name, find_this, true);
2872        }
2873        {
2874            let to_remove = ["name"];
2875            params.remove_params(&to_remove);
2876        }
2877
2878        let url = params.parse_with_url(&url);
2879
2880        let mut json_mime_type = mime::APPLICATION_JSON;
2881        let mut request_value_reader = {
2882            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2883            common::remove_json_null_values(&mut value);
2884            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2885            serde_json::to_writer(&mut dst, &value).unwrap();
2886            dst
2887        };
2888        let request_size = request_value_reader
2889            .seek(std::io::SeekFrom::End(0))
2890            .unwrap();
2891        request_value_reader
2892            .seek(std::io::SeekFrom::Start(0))
2893            .unwrap();
2894
2895        loop {
2896            let token = match self
2897                .hub
2898                .auth
2899                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2900                .await
2901            {
2902                Ok(token) => token,
2903                Err(e) => match dlg.token(e) {
2904                    Ok(token) => token,
2905                    Err(e) => {
2906                        dlg.finished(false);
2907                        return Err(common::Error::MissingToken(e));
2908                    }
2909                },
2910            };
2911            request_value_reader
2912                .seek(std::io::SeekFrom::Start(0))
2913                .unwrap();
2914            let mut req_result = {
2915                let client = &self.hub.client;
2916                dlg.pre_request();
2917                let mut req_builder = hyper::Request::builder()
2918                    .method(hyper::Method::POST)
2919                    .uri(url.as_str())
2920                    .header(USER_AGENT, self.hub._user_agent.clone());
2921
2922                if let Some(token) = token.as_ref() {
2923                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2924                }
2925
2926                let request = req_builder
2927                    .header(CONTENT_TYPE, json_mime_type.to_string())
2928                    .header(CONTENT_LENGTH, request_size as u64)
2929                    .body(common::to_body(
2930                        request_value_reader.get_ref().clone().into(),
2931                    ));
2932
2933                client.request(request.unwrap()).await
2934            };
2935
2936            match req_result {
2937                Err(err) => {
2938                    if let common::Retry::After(d) = dlg.http_error(&err) {
2939                        sleep(d).await;
2940                        continue;
2941                    }
2942                    dlg.finished(false);
2943                    return Err(common::Error::HttpError(err));
2944                }
2945                Ok(res) => {
2946                    let (mut parts, body) = res.into_parts();
2947                    let mut body = common::Body::new(body);
2948                    if !parts.status.is_success() {
2949                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2950                        let error = serde_json::from_str(&common::to_string(&bytes));
2951                        let response = common::to_response(parts, bytes.into());
2952
2953                        if let common::Retry::After(d) =
2954                            dlg.http_failure(&response, error.as_ref().ok())
2955                        {
2956                            sleep(d).await;
2957                            continue;
2958                        }
2959
2960                        dlg.finished(false);
2961
2962                        return Err(match error {
2963                            Ok(value) => common::Error::BadRequest(value),
2964                            _ => common::Error::Failure(response),
2965                        });
2966                    }
2967                    let response = {
2968                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2969                        let encoded = common::to_string(&bytes);
2970                        match serde_json::from_str(&encoded) {
2971                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2972                            Err(error) => {
2973                                dlg.response_json_decode_error(&encoded, &error);
2974                                return Err(common::Error::JsonDecodeError(
2975                                    encoded.to_string(),
2976                                    error,
2977                                ));
2978                            }
2979                        }
2980                    };
2981
2982                    dlg.finished(true);
2983                    return Ok(response);
2984                }
2985            }
2986        }
2987    }
2988
2989    ///
2990    /// Sets the *request* property to the given value.
2991    ///
2992    /// Even though the property as already been set when instantiating this call,
2993    /// we provide this method for API completeness.
2994    pub fn request(
2995        mut self,
2996        new_value: RestoreCryptoKeyVersionRequest,
2997    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
2998        self._request = new_value;
2999        self
3000    }
3001    /// The resource name of the CryptoKeyVersion to restore.
3002    ///
3003    /// Sets the *name* path property to the given value.
3004    ///
3005    /// Even though the property as already been set when instantiating this call,
3006    /// we provide this method for API completeness.
3007    pub fn name(
3008        mut self,
3009        new_value: &str,
3010    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
3011        self._name = new_value.to_string();
3012        self
3013    }
3014    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3015    /// while executing the actual API request.
3016    ///
3017    /// ````text
3018    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3019    /// ````
3020    ///
3021    /// Sets the *delegate* property to the given value.
3022    pub fn delegate(
3023        mut self,
3024        new_value: &'a mut dyn common::Delegate,
3025    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
3026        self._delegate = Some(new_value);
3027        self
3028    }
3029
3030    /// Set any additional parameter of the query string used in the request.
3031    /// It should be used to set parameters which are not yet available through their own
3032    /// setters.
3033    ///
3034    /// Please note that this method must not be used to set any of the known parameters
3035    /// which have their own setter method. If done anyway, the request will fail.
3036    ///
3037    /// # Additional Parameters
3038    ///
3039    /// * *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.
3040    /// * *access_token* (query-string) - OAuth access token.
3041    /// * *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.
3042    /// * *pp* (query-boolean) - Pretty-print response.
3043    /// * *bearer_token* (query-string) - OAuth bearer token.
3044    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3045    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3046    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3047    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3048    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3049    /// * *callback* (query-string) - JSONP
3050    /// * *$.xgafv* (query-string) - V1 error format.
3051    /// * *alt* (query-string) - Data format for response.
3052    pub fn param<T>(
3053        mut self,
3054        name: T,
3055        value: T,
3056    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
3057    where
3058        T: AsRef<str>,
3059    {
3060        self._additional_params
3061            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3062        self
3063    }
3064
3065    /// Identifies the authorization scope for the method you are building.
3066    ///
3067    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3068    /// [`Scope::CloudPlatform`].
3069    ///
3070    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3071    /// tokens for more than one scope.
3072    ///
3073    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3074    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3075    /// sufficient, a read-write scope will do as well.
3076    pub fn add_scope<St>(
3077        mut self,
3078        scope: St,
3079    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
3080    where
3081        St: AsRef<str>,
3082    {
3083        self._scopes.insert(String::from(scope.as_ref()));
3084        self
3085    }
3086    /// Identifies the authorization scope(s) for the method you are building.
3087    ///
3088    /// See [`Self::add_scope()`] for details.
3089    pub fn add_scopes<I, St>(
3090        mut self,
3091        scopes: I,
3092    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C>
3093    where
3094        I: IntoIterator<Item = St>,
3095        St: AsRef<str>,
3096    {
3097        self._scopes
3098            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3099        self
3100    }
3101
3102    /// Removes all scopes, and no default scope will be used either.
3103    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3104    /// for details).
3105    pub fn clear_scopes(
3106        mut self,
3107    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C> {
3108        self._scopes.clear();
3109        self
3110    }
3111}
3112
3113/// Update a CryptoKeyVersion's metadata.
3114///
3115/// state may be changed between
3116/// ENABLED and
3117/// DISABLED using this
3118/// method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to
3119/// move between other states.
3120///
3121/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.patch* method supported by a *project* resource.
3122/// It is not used directly, but through a [`ProjectMethods`] instance.
3123///
3124/// # Example
3125///
3126/// Instantiate a resource method builder
3127///
3128/// ```test_harness,no_run
3129/// # extern crate hyper;
3130/// # extern crate hyper_rustls;
3131/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
3132/// use cloudkms1_beta1::api::CryptoKeyVersion;
3133/// # async fn dox() {
3134/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3135///
3136/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3137/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3138/// #     .with_native_roots()
3139/// #     .unwrap()
3140/// #     .https_only()
3141/// #     .enable_http2()
3142/// #     .build();
3143///
3144/// # let executor = hyper_util::rt::TokioExecutor::new();
3145/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3146/// #     secret,
3147/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3148/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3149/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3150/// #     ),
3151/// # ).build().await.unwrap();
3152///
3153/// # let client = hyper_util::client::legacy::Client::builder(
3154/// #     hyper_util::rt::TokioExecutor::new()
3155/// # )
3156/// # .build(
3157/// #     hyper_rustls::HttpsConnectorBuilder::new()
3158/// #         .with_native_roots()
3159/// #         .unwrap()
3160/// #         .https_or_http()
3161/// #         .enable_http2()
3162/// #         .build()
3163/// # );
3164/// # let mut hub = CloudKMS::new(client, auth);
3165/// // As the method needs a request, you would usually fill it with the desired information
3166/// // into the respective structure. Some of the parts shown here might not be applicable !
3167/// // Values shown here are possibly random and not representative !
3168/// let mut req = CryptoKeyVersion::default();
3169///
3170/// // You can configure optional parameters by calling the respective setters at will, and
3171/// // execute the final call using `doit()`.
3172/// // Values shown here are possibly random and not representative !
3173/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
3174///              .update_mask(FieldMask::new::<&str>(&[]))
3175///              .doit().await;
3176/// # }
3177/// ```
3178pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3179where
3180    C: 'a,
3181{
3182    hub: &'a CloudKMS<C>,
3183    _request: CryptoKeyVersion,
3184    _name: String,
3185    _update_mask: Option<common::FieldMask>,
3186    _delegate: Option<&'a mut dyn common::Delegate>,
3187    _additional_params: HashMap<String, String>,
3188    _scopes: BTreeSet<String>,
3189}
3190
3191impl<'a, C> common::CallBuilder
3192    for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3193{
3194}
3195
3196impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3197where
3198    C: common::Connector,
3199{
3200    /// Perform the operation you have build so far.
3201    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
3202        use std::borrow::Cow;
3203        use std::io::{Read, Seek};
3204
3205        use common::{url::Params, ToParts};
3206        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3207
3208        let mut dd = common::DefaultDelegate;
3209        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3210        dlg.begin(common::MethodInfo {
3211            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch",
3212            http_method: hyper::Method::PATCH,
3213        });
3214
3215        for &field in ["alt", "name", "updateMask"].iter() {
3216            if self._additional_params.contains_key(field) {
3217                dlg.finished(false);
3218                return Err(common::Error::FieldClash(field));
3219            }
3220        }
3221
3222        let mut params = Params::with_capacity(5 + self._additional_params.len());
3223        params.push("name", self._name);
3224        if let Some(value) = self._update_mask.as_ref() {
3225            params.push("updateMask", value.to_string());
3226        }
3227
3228        params.extend(self._additional_params.iter());
3229
3230        params.push("alt", "json");
3231        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3232        if self._scopes.is_empty() {
3233            self._scopes
3234                .insert(Scope::CloudPlatform.as_ref().to_string());
3235        }
3236
3237        #[allow(clippy::single_element_loop)]
3238        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3239            url = params.uri_replacement(url, param_name, find_this, true);
3240        }
3241        {
3242            let to_remove = ["name"];
3243            params.remove_params(&to_remove);
3244        }
3245
3246        let url = params.parse_with_url(&url);
3247
3248        let mut json_mime_type = mime::APPLICATION_JSON;
3249        let mut request_value_reader = {
3250            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3251            common::remove_json_null_values(&mut value);
3252            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3253            serde_json::to_writer(&mut dst, &value).unwrap();
3254            dst
3255        };
3256        let request_size = request_value_reader
3257            .seek(std::io::SeekFrom::End(0))
3258            .unwrap();
3259        request_value_reader
3260            .seek(std::io::SeekFrom::Start(0))
3261            .unwrap();
3262
3263        loop {
3264            let token = match self
3265                .hub
3266                .auth
3267                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3268                .await
3269            {
3270                Ok(token) => token,
3271                Err(e) => match dlg.token(e) {
3272                    Ok(token) => token,
3273                    Err(e) => {
3274                        dlg.finished(false);
3275                        return Err(common::Error::MissingToken(e));
3276                    }
3277                },
3278            };
3279            request_value_reader
3280                .seek(std::io::SeekFrom::Start(0))
3281                .unwrap();
3282            let mut req_result = {
3283                let client = &self.hub.client;
3284                dlg.pre_request();
3285                let mut req_builder = hyper::Request::builder()
3286                    .method(hyper::Method::PATCH)
3287                    .uri(url.as_str())
3288                    .header(USER_AGENT, self.hub._user_agent.clone());
3289
3290                if let Some(token) = token.as_ref() {
3291                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3292                }
3293
3294                let request = req_builder
3295                    .header(CONTENT_TYPE, json_mime_type.to_string())
3296                    .header(CONTENT_LENGTH, request_size as u64)
3297                    .body(common::to_body(
3298                        request_value_reader.get_ref().clone().into(),
3299                    ));
3300
3301                client.request(request.unwrap()).await
3302            };
3303
3304            match req_result {
3305                Err(err) => {
3306                    if let common::Retry::After(d) = dlg.http_error(&err) {
3307                        sleep(d).await;
3308                        continue;
3309                    }
3310                    dlg.finished(false);
3311                    return Err(common::Error::HttpError(err));
3312                }
3313                Ok(res) => {
3314                    let (mut parts, body) = res.into_parts();
3315                    let mut body = common::Body::new(body);
3316                    if !parts.status.is_success() {
3317                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3318                        let error = serde_json::from_str(&common::to_string(&bytes));
3319                        let response = common::to_response(parts, bytes.into());
3320
3321                        if let common::Retry::After(d) =
3322                            dlg.http_failure(&response, error.as_ref().ok())
3323                        {
3324                            sleep(d).await;
3325                            continue;
3326                        }
3327
3328                        dlg.finished(false);
3329
3330                        return Err(match error {
3331                            Ok(value) => common::Error::BadRequest(value),
3332                            _ => common::Error::Failure(response),
3333                        });
3334                    }
3335                    let response = {
3336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3337                        let encoded = common::to_string(&bytes);
3338                        match serde_json::from_str(&encoded) {
3339                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3340                            Err(error) => {
3341                                dlg.response_json_decode_error(&encoded, &error);
3342                                return Err(common::Error::JsonDecodeError(
3343                                    encoded.to_string(),
3344                                    error,
3345                                ));
3346                            }
3347                        }
3348                    };
3349
3350                    dlg.finished(true);
3351                    return Ok(response);
3352                }
3353            }
3354        }
3355    }
3356
3357    ///
3358    /// Sets the *request* property to the given value.
3359    ///
3360    /// Even though the property as already been set when instantiating this call,
3361    /// we provide this method for API completeness.
3362    pub fn request(
3363        mut self,
3364        new_value: CryptoKeyVersion,
3365    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
3366        self._request = new_value;
3367        self
3368    }
3369    /// Output only. The resource name for this CryptoKeyVersion in the format
3370    /// `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
3371    ///
3372    /// Sets the *name* path property to the given value.
3373    ///
3374    /// Even though the property as already been set when instantiating this call,
3375    /// we provide this method for API completeness.
3376    pub fn name(
3377        mut self,
3378        new_value: &str,
3379    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
3380        self._name = new_value.to_string();
3381        self
3382    }
3383    /// Required list of fields to be updated in this request.
3384    ///
3385    /// Sets the *update mask* query property to the given value.
3386    pub fn update_mask(
3387        mut self,
3388        new_value: common::FieldMask,
3389    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
3390        self._update_mask = Some(new_value);
3391        self
3392    }
3393    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3394    /// while executing the actual API request.
3395    ///
3396    /// ````text
3397    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3398    /// ````
3399    ///
3400    /// Sets the *delegate* property to the given value.
3401    pub fn delegate(
3402        mut self,
3403        new_value: &'a mut dyn common::Delegate,
3404    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
3405        self._delegate = Some(new_value);
3406        self
3407    }
3408
3409    /// Set any additional parameter of the query string used in the request.
3410    /// It should be used to set parameters which are not yet available through their own
3411    /// setters.
3412    ///
3413    /// Please note that this method must not be used to set any of the known parameters
3414    /// which have their own setter method. If done anyway, the request will fail.
3415    ///
3416    /// # Additional Parameters
3417    ///
3418    /// * *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.
3419    /// * *access_token* (query-string) - OAuth access token.
3420    /// * *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.
3421    /// * *pp* (query-boolean) - Pretty-print response.
3422    /// * *bearer_token* (query-string) - OAuth bearer token.
3423    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3424    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3425    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3426    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3427    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3428    /// * *callback* (query-string) - JSONP
3429    /// * *$.xgafv* (query-string) - V1 error format.
3430    /// * *alt* (query-string) - Data format for response.
3431    pub fn param<T>(
3432        mut self,
3433        name: T,
3434        value: T,
3435    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3436    where
3437        T: AsRef<str>,
3438    {
3439        self._additional_params
3440            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3441        self
3442    }
3443
3444    /// Identifies the authorization scope for the method you are building.
3445    ///
3446    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3447    /// [`Scope::CloudPlatform`].
3448    ///
3449    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3450    /// tokens for more than one scope.
3451    ///
3452    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3453    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3454    /// sufficient, a read-write scope will do as well.
3455    pub fn add_scope<St>(
3456        mut self,
3457        scope: St,
3458    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3459    where
3460        St: AsRef<str>,
3461    {
3462        self._scopes.insert(String::from(scope.as_ref()));
3463        self
3464    }
3465    /// Identifies the authorization scope(s) for the method you are building.
3466    ///
3467    /// See [`Self::add_scope()`] for details.
3468    pub fn add_scopes<I, St>(
3469        mut self,
3470        scopes: I,
3471    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C>
3472    where
3473        I: IntoIterator<Item = St>,
3474        St: AsRef<str>,
3475    {
3476        self._scopes
3477            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3478        self
3479    }
3480
3481    /// Removes all scopes, and no default scope will be used either.
3482    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3483    /// for details).
3484    pub fn clear_scopes(
3485        mut self,
3486    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C> {
3487        self._scopes.clear();
3488        self
3489    }
3490}
3491
3492/// Returns metadata for a given CryptoKeyVersion.
3493///
3494/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.get* method supported by a *project* resource.
3495/// It is not used directly, but through a [`ProjectMethods`] instance.
3496///
3497/// # Example
3498///
3499/// Instantiate a resource method builder
3500///
3501/// ```test_harness,no_run
3502/// # extern crate hyper;
3503/// # extern crate hyper_rustls;
3504/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
3505/// # async fn dox() {
3506/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3507///
3508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3509/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3510/// #     .with_native_roots()
3511/// #     .unwrap()
3512/// #     .https_only()
3513/// #     .enable_http2()
3514/// #     .build();
3515///
3516/// # let executor = hyper_util::rt::TokioExecutor::new();
3517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3518/// #     secret,
3519/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3520/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3521/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3522/// #     ),
3523/// # ).build().await.unwrap();
3524///
3525/// # let client = hyper_util::client::legacy::Client::builder(
3526/// #     hyper_util::rt::TokioExecutor::new()
3527/// # )
3528/// # .build(
3529/// #     hyper_rustls::HttpsConnectorBuilder::new()
3530/// #         .with_native_roots()
3531/// #         .unwrap()
3532/// #         .https_or_http()
3533/// #         .enable_http2()
3534/// #         .build()
3535/// # );
3536/// # let mut hub = CloudKMS::new(client, auth);
3537/// // You can configure optional parameters by calling the respective setters at will, and
3538/// // execute the final call using `doit()`.
3539/// // Values shown here are possibly random and not representative !
3540/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get("name")
3541///              .doit().await;
3542/// # }
3543/// ```
3544pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
3545where
3546    C: 'a,
3547{
3548    hub: &'a CloudKMS<C>,
3549    _name: String,
3550    _delegate: Option<&'a mut dyn common::Delegate>,
3551    _additional_params: HashMap<String, String>,
3552    _scopes: BTreeSet<String>,
3553}
3554
3555impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {}
3556
3557impl<'a, C> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
3558where
3559    C: common::Connector,
3560{
3561    /// Perform the operation you have build so far.
3562    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKeyVersion)> {
3563        use std::borrow::Cow;
3564        use std::io::{Read, Seek};
3565
3566        use common::{url::Params, ToParts};
3567        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3568
3569        let mut dd = common::DefaultDelegate;
3570        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3571        dlg.begin(common::MethodInfo {
3572            id: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get",
3573            http_method: hyper::Method::GET,
3574        });
3575
3576        for &field in ["alt", "name"].iter() {
3577            if self._additional_params.contains_key(field) {
3578                dlg.finished(false);
3579                return Err(common::Error::FieldClash(field));
3580            }
3581        }
3582
3583        let mut params = Params::with_capacity(3 + self._additional_params.len());
3584        params.push("name", self._name);
3585
3586        params.extend(self._additional_params.iter());
3587
3588        params.push("alt", "json");
3589        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3590        if self._scopes.is_empty() {
3591            self._scopes
3592                .insert(Scope::CloudPlatform.as_ref().to_string());
3593        }
3594
3595        #[allow(clippy::single_element_loop)]
3596        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3597            url = params.uri_replacement(url, param_name, find_this, true);
3598        }
3599        {
3600            let to_remove = ["name"];
3601            params.remove_params(&to_remove);
3602        }
3603
3604        let url = params.parse_with_url(&url);
3605
3606        loop {
3607            let token = match self
3608                .hub
3609                .auth
3610                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3611                .await
3612            {
3613                Ok(token) => token,
3614                Err(e) => match dlg.token(e) {
3615                    Ok(token) => token,
3616                    Err(e) => {
3617                        dlg.finished(false);
3618                        return Err(common::Error::MissingToken(e));
3619                    }
3620                },
3621            };
3622            let mut req_result = {
3623                let client = &self.hub.client;
3624                dlg.pre_request();
3625                let mut req_builder = hyper::Request::builder()
3626                    .method(hyper::Method::GET)
3627                    .uri(url.as_str())
3628                    .header(USER_AGENT, self.hub._user_agent.clone());
3629
3630                if let Some(token) = token.as_ref() {
3631                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3632                }
3633
3634                let request = req_builder
3635                    .header(CONTENT_LENGTH, 0_u64)
3636                    .body(common::to_body::<String>(None));
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    /// The name of the CryptoKeyVersion to get.
3695    ///
3696    /// Sets the *name* path property to the given value.
3697    ///
3698    /// Even though the property as already been set when instantiating this call,
3699    /// we provide this method for API completeness.
3700    pub fn name(
3701        mut self,
3702        new_value: &str,
3703    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
3704        self._name = new_value.to_string();
3705        self
3706    }
3707    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3708    /// while executing the actual API request.
3709    ///
3710    /// ````text
3711    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3712    /// ````
3713    ///
3714    /// Sets the *delegate* property to the given value.
3715    pub fn delegate(
3716        mut self,
3717        new_value: &'a mut dyn common::Delegate,
3718    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
3719        self._delegate = Some(new_value);
3720        self
3721    }
3722
3723    /// Set any additional parameter of the query string used in the request.
3724    /// It should be used to set parameters which are not yet available through their own
3725    /// setters.
3726    ///
3727    /// Please note that this method must not be used to set any of the known parameters
3728    /// which have their own setter method. If done anyway, the request will fail.
3729    ///
3730    /// # Additional Parameters
3731    ///
3732    /// * *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.
3733    /// * *access_token* (query-string) - OAuth access token.
3734    /// * *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.
3735    /// * *pp* (query-boolean) - Pretty-print response.
3736    /// * *bearer_token* (query-string) - OAuth bearer token.
3737    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3738    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3739    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3740    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3741    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3742    /// * *callback* (query-string) - JSONP
3743    /// * *$.xgafv* (query-string) - V1 error format.
3744    /// * *alt* (query-string) - Data format for response.
3745    pub fn param<T>(
3746        mut self,
3747        name: T,
3748        value: T,
3749    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
3750    where
3751        T: AsRef<str>,
3752    {
3753        self._additional_params
3754            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3755        self
3756    }
3757
3758    /// Identifies the authorization scope for the method you are building.
3759    ///
3760    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3761    /// [`Scope::CloudPlatform`].
3762    ///
3763    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3764    /// tokens for more than one scope.
3765    ///
3766    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3767    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3768    /// sufficient, a read-write scope will do as well.
3769    pub fn add_scope<St>(
3770        mut self,
3771        scope: St,
3772    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
3773    where
3774        St: AsRef<str>,
3775    {
3776        self._scopes.insert(String::from(scope.as_ref()));
3777        self
3778    }
3779    /// Identifies the authorization scope(s) for the method you are building.
3780    ///
3781    /// See [`Self::add_scope()`] for details.
3782    pub fn add_scopes<I, St>(
3783        mut self,
3784        scopes: I,
3785    ) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C>
3786    where
3787        I: IntoIterator<Item = St>,
3788        St: AsRef<str>,
3789    {
3790        self._scopes
3791            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3792        self
3793    }
3794
3795    /// Removes all scopes, and no default scope will be used either.
3796    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3797    /// for details).
3798    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C> {
3799        self._scopes.clear();
3800        self
3801    }
3802}
3803
3804/// Update a CryptoKey.
3805///
3806/// A builder for the *locations.keyRings.cryptoKeys.patch* method supported by a *project* resource.
3807/// It is not used directly, but through a [`ProjectMethods`] instance.
3808///
3809/// # Example
3810///
3811/// Instantiate a resource method builder
3812///
3813/// ```test_harness,no_run
3814/// # extern crate hyper;
3815/// # extern crate hyper_rustls;
3816/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
3817/// use cloudkms1_beta1::api::CryptoKey;
3818/// # async fn dox() {
3819/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3820///
3821/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3822/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3823/// #     .with_native_roots()
3824/// #     .unwrap()
3825/// #     .https_only()
3826/// #     .enable_http2()
3827/// #     .build();
3828///
3829/// # let executor = hyper_util::rt::TokioExecutor::new();
3830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3831/// #     secret,
3832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3833/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3834/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3835/// #     ),
3836/// # ).build().await.unwrap();
3837///
3838/// # let client = hyper_util::client::legacy::Client::builder(
3839/// #     hyper_util::rt::TokioExecutor::new()
3840/// # )
3841/// # .build(
3842/// #     hyper_rustls::HttpsConnectorBuilder::new()
3843/// #         .with_native_roots()
3844/// #         .unwrap()
3845/// #         .https_or_http()
3846/// #         .enable_http2()
3847/// #         .build()
3848/// # );
3849/// # let mut hub = CloudKMS::new(client, auth);
3850/// // As the method needs a request, you would usually fill it with the desired information
3851/// // into the respective structure. Some of the parts shown here might not be applicable !
3852/// // Values shown here are possibly random and not representative !
3853/// let mut req = CryptoKey::default();
3854///
3855/// // You can configure optional parameters by calling the respective setters at will, and
3856/// // execute the final call using `doit()`.
3857/// // Values shown here are possibly random and not representative !
3858/// let result = hub.projects().locations_key_rings_crypto_keys_patch(req, "name")
3859///              .update_mask(FieldMask::new::<&str>(&[]))
3860///              .doit().await;
3861/// # }
3862/// ```
3863pub struct ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
3864where
3865    C: 'a,
3866{
3867    hub: &'a CloudKMS<C>,
3868    _request: CryptoKey,
3869    _name: String,
3870    _update_mask: Option<common::FieldMask>,
3871    _delegate: Option<&'a mut dyn common::Delegate>,
3872    _additional_params: HashMap<String, String>,
3873    _scopes: BTreeSet<String>,
3874}
3875
3876impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {}
3877
3878impl<'a, C> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
3879where
3880    C: common::Connector,
3881{
3882    /// Perform the operation you have build so far.
3883    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
3884        use std::borrow::Cow;
3885        use std::io::{Read, Seek};
3886
3887        use common::{url::Params, ToParts};
3888        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3889
3890        let mut dd = common::DefaultDelegate;
3891        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3892        dlg.begin(common::MethodInfo {
3893            id: "cloudkms.projects.locations.keyRings.cryptoKeys.patch",
3894            http_method: hyper::Method::PATCH,
3895        });
3896
3897        for &field in ["alt", "name", "updateMask"].iter() {
3898            if self._additional_params.contains_key(field) {
3899                dlg.finished(false);
3900                return Err(common::Error::FieldClash(field));
3901            }
3902        }
3903
3904        let mut params = Params::with_capacity(5 + self._additional_params.len());
3905        params.push("name", self._name);
3906        if let Some(value) = self._update_mask.as_ref() {
3907            params.push("updateMask", value.to_string());
3908        }
3909
3910        params.extend(self._additional_params.iter());
3911
3912        params.push("alt", "json");
3913        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3914        if self._scopes.is_empty() {
3915            self._scopes
3916                .insert(Scope::CloudPlatform.as_ref().to_string());
3917        }
3918
3919        #[allow(clippy::single_element_loop)]
3920        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3921            url = params.uri_replacement(url, param_name, find_this, true);
3922        }
3923        {
3924            let to_remove = ["name"];
3925            params.remove_params(&to_remove);
3926        }
3927
3928        let url = params.parse_with_url(&url);
3929
3930        let mut json_mime_type = mime::APPLICATION_JSON;
3931        let mut request_value_reader = {
3932            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3933            common::remove_json_null_values(&mut value);
3934            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3935            serde_json::to_writer(&mut dst, &value).unwrap();
3936            dst
3937        };
3938        let request_size = request_value_reader
3939            .seek(std::io::SeekFrom::End(0))
3940            .unwrap();
3941        request_value_reader
3942            .seek(std::io::SeekFrom::Start(0))
3943            .unwrap();
3944
3945        loop {
3946            let token = match self
3947                .hub
3948                .auth
3949                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3950                .await
3951            {
3952                Ok(token) => token,
3953                Err(e) => match dlg.token(e) {
3954                    Ok(token) => token,
3955                    Err(e) => {
3956                        dlg.finished(false);
3957                        return Err(common::Error::MissingToken(e));
3958                    }
3959                },
3960            };
3961            request_value_reader
3962                .seek(std::io::SeekFrom::Start(0))
3963                .unwrap();
3964            let mut req_result = {
3965                let client = &self.hub.client;
3966                dlg.pre_request();
3967                let mut req_builder = hyper::Request::builder()
3968                    .method(hyper::Method::PATCH)
3969                    .uri(url.as_str())
3970                    .header(USER_AGENT, self.hub._user_agent.clone());
3971
3972                if let Some(token) = token.as_ref() {
3973                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3974                }
3975
3976                let request = req_builder
3977                    .header(CONTENT_TYPE, json_mime_type.to_string())
3978                    .header(CONTENT_LENGTH, request_size as u64)
3979                    .body(common::to_body(
3980                        request_value_reader.get_ref().clone().into(),
3981                    ));
3982
3983                client.request(request.unwrap()).await
3984            };
3985
3986            match req_result {
3987                Err(err) => {
3988                    if let common::Retry::After(d) = dlg.http_error(&err) {
3989                        sleep(d).await;
3990                        continue;
3991                    }
3992                    dlg.finished(false);
3993                    return Err(common::Error::HttpError(err));
3994                }
3995                Ok(res) => {
3996                    let (mut parts, body) = res.into_parts();
3997                    let mut body = common::Body::new(body);
3998                    if !parts.status.is_success() {
3999                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4000                        let error = serde_json::from_str(&common::to_string(&bytes));
4001                        let response = common::to_response(parts, bytes.into());
4002
4003                        if let common::Retry::After(d) =
4004                            dlg.http_failure(&response, error.as_ref().ok())
4005                        {
4006                            sleep(d).await;
4007                            continue;
4008                        }
4009
4010                        dlg.finished(false);
4011
4012                        return Err(match error {
4013                            Ok(value) => common::Error::BadRequest(value),
4014                            _ => common::Error::Failure(response),
4015                        });
4016                    }
4017                    let response = {
4018                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4019                        let encoded = common::to_string(&bytes);
4020                        match serde_json::from_str(&encoded) {
4021                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4022                            Err(error) => {
4023                                dlg.response_json_decode_error(&encoded, &error);
4024                                return Err(common::Error::JsonDecodeError(
4025                                    encoded.to_string(),
4026                                    error,
4027                                ));
4028                            }
4029                        }
4030                    };
4031
4032                    dlg.finished(true);
4033                    return Ok(response);
4034                }
4035            }
4036        }
4037    }
4038
4039    ///
4040    /// Sets the *request* property to the given value.
4041    ///
4042    /// Even though the property as already been set when instantiating this call,
4043    /// we provide this method for API completeness.
4044    pub fn request(
4045        mut self,
4046        new_value: CryptoKey,
4047    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
4048        self._request = new_value;
4049        self
4050    }
4051    /// Output only. The resource name for this CryptoKey in the format
4052    /// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
4053    ///
4054    /// Sets the *name* path property to the given value.
4055    ///
4056    /// Even though the property as already been set when instantiating this call,
4057    /// we provide this method for API completeness.
4058    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
4059        self._name = new_value.to_string();
4060        self
4061    }
4062    /// Required list of fields to be updated in this request.
4063    ///
4064    /// Sets the *update mask* query property to the given value.
4065    pub fn update_mask(
4066        mut self,
4067        new_value: common::FieldMask,
4068    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
4069        self._update_mask = Some(new_value);
4070        self
4071    }
4072    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4073    /// while executing the actual API request.
4074    ///
4075    /// ````text
4076    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4077    /// ````
4078    ///
4079    /// Sets the *delegate* property to the given value.
4080    pub fn delegate(
4081        mut self,
4082        new_value: &'a mut dyn common::Delegate,
4083    ) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
4084        self._delegate = Some(new_value);
4085        self
4086    }
4087
4088    /// Set any additional parameter of the query string used in the request.
4089    /// It should be used to set parameters which are not yet available through their own
4090    /// setters.
4091    ///
4092    /// Please note that this method must not be used to set any of the known parameters
4093    /// which have their own setter method. If done anyway, the request will fail.
4094    ///
4095    /// # Additional Parameters
4096    ///
4097    /// * *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.
4098    /// * *access_token* (query-string) - OAuth access token.
4099    /// * *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.
4100    /// * *pp* (query-boolean) - Pretty-print response.
4101    /// * *bearer_token* (query-string) - OAuth bearer token.
4102    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4103    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4104    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4105    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4106    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4107    /// * *callback* (query-string) - JSONP
4108    /// * *$.xgafv* (query-string) - V1 error format.
4109    /// * *alt* (query-string) - Data format for response.
4110    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
4111    where
4112        T: AsRef<str>,
4113    {
4114        self._additional_params
4115            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4116        self
4117    }
4118
4119    /// Identifies the authorization scope for the method you are building.
4120    ///
4121    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4122    /// [`Scope::CloudPlatform`].
4123    ///
4124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4125    /// tokens for more than one scope.
4126    ///
4127    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4128    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4129    /// sufficient, a read-write scope will do as well.
4130    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
4131    where
4132        St: AsRef<str>,
4133    {
4134        self._scopes.insert(String::from(scope.as_ref()));
4135        self
4136    }
4137    /// Identifies the authorization scope(s) for the method you are building.
4138    ///
4139    /// See [`Self::add_scope()`] for details.
4140    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C>
4141    where
4142        I: IntoIterator<Item = St>,
4143        St: AsRef<str>,
4144    {
4145        self._scopes
4146            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4147        self
4148    }
4149
4150    /// Removes all scopes, and no default scope will be used either.
4151    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4152    /// for details).
4153    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C> {
4154        self._scopes.clear();
4155        self
4156    }
4157}
4158
4159/// Returns metadata for a given CryptoKey, as well as its
4160/// primary CryptoKeyVersion.
4161///
4162/// A builder for the *locations.keyRings.cryptoKeys.get* method supported by a *project* resource.
4163/// It is not used directly, but through a [`ProjectMethods`] instance.
4164///
4165/// # Example
4166///
4167/// Instantiate a resource method builder
4168///
4169/// ```test_harness,no_run
4170/// # extern crate hyper;
4171/// # extern crate hyper_rustls;
4172/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
4173/// # async fn dox() {
4174/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4175///
4176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4177/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4178/// #     .with_native_roots()
4179/// #     .unwrap()
4180/// #     .https_only()
4181/// #     .enable_http2()
4182/// #     .build();
4183///
4184/// # let executor = hyper_util::rt::TokioExecutor::new();
4185/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4186/// #     secret,
4187/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4188/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4189/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4190/// #     ),
4191/// # ).build().await.unwrap();
4192///
4193/// # let client = hyper_util::client::legacy::Client::builder(
4194/// #     hyper_util::rt::TokioExecutor::new()
4195/// # )
4196/// # .build(
4197/// #     hyper_rustls::HttpsConnectorBuilder::new()
4198/// #         .with_native_roots()
4199/// #         .unwrap()
4200/// #         .https_or_http()
4201/// #         .enable_http2()
4202/// #         .build()
4203/// # );
4204/// # let mut hub = CloudKMS::new(client, auth);
4205/// // You can configure optional parameters by calling the respective setters at will, and
4206/// // execute the final call using `doit()`.
4207/// // Values shown here are possibly random and not representative !
4208/// let result = hub.projects().locations_key_rings_crypto_keys_get("name")
4209///              .doit().await;
4210/// # }
4211/// ```
4212pub struct ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
4213where
4214    C: 'a,
4215{
4216    hub: &'a CloudKMS<C>,
4217    _name: String,
4218    _delegate: Option<&'a mut dyn common::Delegate>,
4219    _additional_params: HashMap<String, String>,
4220    _scopes: BTreeSet<String>,
4221}
4222
4223impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {}
4224
4225impl<'a, C> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
4226where
4227    C: common::Connector,
4228{
4229    /// Perform the operation you have build so far.
4230    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
4231        use std::borrow::Cow;
4232        use std::io::{Read, Seek};
4233
4234        use common::{url::Params, ToParts};
4235        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4236
4237        let mut dd = common::DefaultDelegate;
4238        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4239        dlg.begin(common::MethodInfo {
4240            id: "cloudkms.projects.locations.keyRings.cryptoKeys.get",
4241            http_method: hyper::Method::GET,
4242        });
4243
4244        for &field in ["alt", "name"].iter() {
4245            if self._additional_params.contains_key(field) {
4246                dlg.finished(false);
4247                return Err(common::Error::FieldClash(field));
4248            }
4249        }
4250
4251        let mut params = Params::with_capacity(3 + self._additional_params.len());
4252        params.push("name", self._name);
4253
4254        params.extend(self._additional_params.iter());
4255
4256        params.push("alt", "json");
4257        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4258        if self._scopes.is_empty() {
4259            self._scopes
4260                .insert(Scope::CloudPlatform.as_ref().to_string());
4261        }
4262
4263        #[allow(clippy::single_element_loop)]
4264        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4265            url = params.uri_replacement(url, param_name, find_this, true);
4266        }
4267        {
4268            let to_remove = ["name"];
4269            params.remove_params(&to_remove);
4270        }
4271
4272        let url = params.parse_with_url(&url);
4273
4274        loop {
4275            let token = match self
4276                .hub
4277                .auth
4278                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4279                .await
4280            {
4281                Ok(token) => token,
4282                Err(e) => match dlg.token(e) {
4283                    Ok(token) => token,
4284                    Err(e) => {
4285                        dlg.finished(false);
4286                        return Err(common::Error::MissingToken(e));
4287                    }
4288                },
4289            };
4290            let mut req_result = {
4291                let client = &self.hub.client;
4292                dlg.pre_request();
4293                let mut req_builder = hyper::Request::builder()
4294                    .method(hyper::Method::GET)
4295                    .uri(url.as_str())
4296                    .header(USER_AGENT, self.hub._user_agent.clone());
4297
4298                if let Some(token) = token.as_ref() {
4299                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4300                }
4301
4302                let request = req_builder
4303                    .header(CONTENT_LENGTH, 0_u64)
4304                    .body(common::to_body::<String>(None));
4305
4306                client.request(request.unwrap()).await
4307            };
4308
4309            match req_result {
4310                Err(err) => {
4311                    if let common::Retry::After(d) = dlg.http_error(&err) {
4312                        sleep(d).await;
4313                        continue;
4314                    }
4315                    dlg.finished(false);
4316                    return Err(common::Error::HttpError(err));
4317                }
4318                Ok(res) => {
4319                    let (mut parts, body) = res.into_parts();
4320                    let mut body = common::Body::new(body);
4321                    if !parts.status.is_success() {
4322                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4323                        let error = serde_json::from_str(&common::to_string(&bytes));
4324                        let response = common::to_response(parts, bytes.into());
4325
4326                        if let common::Retry::After(d) =
4327                            dlg.http_failure(&response, error.as_ref().ok())
4328                        {
4329                            sleep(d).await;
4330                            continue;
4331                        }
4332
4333                        dlg.finished(false);
4334
4335                        return Err(match error {
4336                            Ok(value) => common::Error::BadRequest(value),
4337                            _ => common::Error::Failure(response),
4338                        });
4339                    }
4340                    let response = {
4341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4342                        let encoded = common::to_string(&bytes);
4343                        match serde_json::from_str(&encoded) {
4344                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4345                            Err(error) => {
4346                                dlg.response_json_decode_error(&encoded, &error);
4347                                return Err(common::Error::JsonDecodeError(
4348                                    encoded.to_string(),
4349                                    error,
4350                                ));
4351                            }
4352                        }
4353                    };
4354
4355                    dlg.finished(true);
4356                    return Ok(response);
4357                }
4358            }
4359        }
4360    }
4361
4362    /// The name of the CryptoKey to get.
4363    ///
4364    /// Sets the *name* path property to the given value.
4365    ///
4366    /// Even though the property as already been set when instantiating this call,
4367    /// we provide this method for API completeness.
4368    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
4369        self._name = new_value.to_string();
4370        self
4371    }
4372    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4373    /// while executing the actual API request.
4374    ///
4375    /// ````text
4376    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4377    /// ````
4378    ///
4379    /// Sets the *delegate* property to the given value.
4380    pub fn delegate(
4381        mut self,
4382        new_value: &'a mut dyn common::Delegate,
4383    ) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
4384        self._delegate = Some(new_value);
4385        self
4386    }
4387
4388    /// Set any additional parameter of the query string used in the request.
4389    /// It should be used to set parameters which are not yet available through their own
4390    /// setters.
4391    ///
4392    /// Please note that this method must not be used to set any of the known parameters
4393    /// which have their own setter method. If done anyway, the request will fail.
4394    ///
4395    /// # Additional Parameters
4396    ///
4397    /// * *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.
4398    /// * *access_token* (query-string) - OAuth access token.
4399    /// * *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.
4400    /// * *pp* (query-boolean) - Pretty-print response.
4401    /// * *bearer_token* (query-string) - OAuth bearer token.
4402    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4403    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4404    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4405    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4406    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4407    /// * *callback* (query-string) - JSONP
4408    /// * *$.xgafv* (query-string) - V1 error format.
4409    /// * *alt* (query-string) - Data format for response.
4410    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
4411    where
4412        T: AsRef<str>,
4413    {
4414        self._additional_params
4415            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4416        self
4417    }
4418
4419    /// Identifies the authorization scope for the method you are building.
4420    ///
4421    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4422    /// [`Scope::CloudPlatform`].
4423    ///
4424    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4425    /// tokens for more than one scope.
4426    ///
4427    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4428    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4429    /// sufficient, a read-write scope will do as well.
4430    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
4431    where
4432        St: AsRef<str>,
4433    {
4434        self._scopes.insert(String::from(scope.as_ref()));
4435        self
4436    }
4437    /// Identifies the authorization scope(s) for the method you are building.
4438    ///
4439    /// See [`Self::add_scope()`] for details.
4440    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C>
4441    where
4442        I: IntoIterator<Item = St>,
4443        St: AsRef<str>,
4444    {
4445        self._scopes
4446            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4447        self
4448    }
4449
4450    /// Removes all scopes, and no default scope will be used either.
4451    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4452    /// for details).
4453    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C> {
4454        self._scopes.clear();
4455        self
4456    }
4457}
4458
4459/// Returns permissions that a caller has on the specified resource.
4460/// If the resource does not exist, this will return an empty set of
4461/// permissions, not a NOT_FOUND error.
4462///
4463/// Note: This operation is designed to be used for building permission-aware
4464/// UIs and command-line tools, not for authorization checking. This operation
4465/// may "fail open" without warning.
4466///
4467/// A builder for the *locations.keyRings.cryptoKeys.testIamPermissions* method supported by a *project* resource.
4468/// It is not used directly, but through a [`ProjectMethods`] instance.
4469///
4470/// # Example
4471///
4472/// Instantiate a resource method builder
4473///
4474/// ```test_harness,no_run
4475/// # extern crate hyper;
4476/// # extern crate hyper_rustls;
4477/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
4478/// use cloudkms1_beta1::api::TestIamPermissionsRequest;
4479/// # async fn dox() {
4480/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4481///
4482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4483/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4484/// #     .with_native_roots()
4485/// #     .unwrap()
4486/// #     .https_only()
4487/// #     .enable_http2()
4488/// #     .build();
4489///
4490/// # let executor = hyper_util::rt::TokioExecutor::new();
4491/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4492/// #     secret,
4493/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4494/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4495/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4496/// #     ),
4497/// # ).build().await.unwrap();
4498///
4499/// # let client = hyper_util::client::legacy::Client::builder(
4500/// #     hyper_util::rt::TokioExecutor::new()
4501/// # )
4502/// # .build(
4503/// #     hyper_rustls::HttpsConnectorBuilder::new()
4504/// #         .with_native_roots()
4505/// #         .unwrap()
4506/// #         .https_or_http()
4507/// #         .enable_http2()
4508/// #         .build()
4509/// # );
4510/// # let mut hub = CloudKMS::new(client, auth);
4511/// // As the method needs a request, you would usually fill it with the desired information
4512/// // into the respective structure. Some of the parts shown here might not be applicable !
4513/// // Values shown here are possibly random and not representative !
4514/// let mut req = TestIamPermissionsRequest::default();
4515///
4516/// // You can configure optional parameters by calling the respective setters at will, and
4517/// // execute the final call using `doit()`.
4518/// // Values shown here are possibly random and not representative !
4519/// let result = hub.projects().locations_key_rings_crypto_keys_test_iam_permissions(req, "resource")
4520///              .doit().await;
4521/// # }
4522/// ```
4523pub struct ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
4524where
4525    C: 'a,
4526{
4527    hub: &'a CloudKMS<C>,
4528    _request: TestIamPermissionsRequest,
4529    _resource: String,
4530    _delegate: Option<&'a mut dyn common::Delegate>,
4531    _additional_params: HashMap<String, String>,
4532    _scopes: BTreeSet<String>,
4533}
4534
4535impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {}
4536
4537impl<'a, C> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
4538where
4539    C: common::Connector,
4540{
4541    /// Perform the operation you have build so far.
4542    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4543        use std::borrow::Cow;
4544        use std::io::{Read, Seek};
4545
4546        use common::{url::Params, ToParts};
4547        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4548
4549        let mut dd = common::DefaultDelegate;
4550        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4551        dlg.begin(common::MethodInfo {
4552            id: "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions",
4553            http_method: hyper::Method::POST,
4554        });
4555
4556        for &field in ["alt", "resource"].iter() {
4557            if self._additional_params.contains_key(field) {
4558                dlg.finished(false);
4559                return Err(common::Error::FieldClash(field));
4560            }
4561        }
4562
4563        let mut params = Params::with_capacity(4 + self._additional_params.len());
4564        params.push("resource", self._resource);
4565
4566        params.extend(self._additional_params.iter());
4567
4568        params.push("alt", "json");
4569        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
4570        if self._scopes.is_empty() {
4571            self._scopes
4572                .insert(Scope::CloudPlatform.as_ref().to_string());
4573        }
4574
4575        #[allow(clippy::single_element_loop)]
4576        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4577            url = params.uri_replacement(url, param_name, find_this, true);
4578        }
4579        {
4580            let to_remove = ["resource"];
4581            params.remove_params(&to_remove);
4582        }
4583
4584        let url = params.parse_with_url(&url);
4585
4586        let mut json_mime_type = mime::APPLICATION_JSON;
4587        let mut request_value_reader = {
4588            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4589            common::remove_json_null_values(&mut value);
4590            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4591            serde_json::to_writer(&mut dst, &value).unwrap();
4592            dst
4593        };
4594        let request_size = request_value_reader
4595            .seek(std::io::SeekFrom::End(0))
4596            .unwrap();
4597        request_value_reader
4598            .seek(std::io::SeekFrom::Start(0))
4599            .unwrap();
4600
4601        loop {
4602            let token = match self
4603                .hub
4604                .auth
4605                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4606                .await
4607            {
4608                Ok(token) => token,
4609                Err(e) => match dlg.token(e) {
4610                    Ok(token) => token,
4611                    Err(e) => {
4612                        dlg.finished(false);
4613                        return Err(common::Error::MissingToken(e));
4614                    }
4615                },
4616            };
4617            request_value_reader
4618                .seek(std::io::SeekFrom::Start(0))
4619                .unwrap();
4620            let mut req_result = {
4621                let client = &self.hub.client;
4622                dlg.pre_request();
4623                let mut req_builder = hyper::Request::builder()
4624                    .method(hyper::Method::POST)
4625                    .uri(url.as_str())
4626                    .header(USER_AGENT, self.hub._user_agent.clone());
4627
4628                if let Some(token) = token.as_ref() {
4629                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4630                }
4631
4632                let request = req_builder
4633                    .header(CONTENT_TYPE, json_mime_type.to_string())
4634                    .header(CONTENT_LENGTH, request_size as u64)
4635                    .body(common::to_body(
4636                        request_value_reader.get_ref().clone().into(),
4637                    ));
4638
4639                client.request(request.unwrap()).await
4640            };
4641
4642            match req_result {
4643                Err(err) => {
4644                    if let common::Retry::After(d) = dlg.http_error(&err) {
4645                        sleep(d).await;
4646                        continue;
4647                    }
4648                    dlg.finished(false);
4649                    return Err(common::Error::HttpError(err));
4650                }
4651                Ok(res) => {
4652                    let (mut parts, body) = res.into_parts();
4653                    let mut body = common::Body::new(body);
4654                    if !parts.status.is_success() {
4655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4656                        let error = serde_json::from_str(&common::to_string(&bytes));
4657                        let response = common::to_response(parts, bytes.into());
4658
4659                        if let common::Retry::After(d) =
4660                            dlg.http_failure(&response, error.as_ref().ok())
4661                        {
4662                            sleep(d).await;
4663                            continue;
4664                        }
4665
4666                        dlg.finished(false);
4667
4668                        return Err(match error {
4669                            Ok(value) => common::Error::BadRequest(value),
4670                            _ => common::Error::Failure(response),
4671                        });
4672                    }
4673                    let response = {
4674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4675                        let encoded = common::to_string(&bytes);
4676                        match serde_json::from_str(&encoded) {
4677                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4678                            Err(error) => {
4679                                dlg.response_json_decode_error(&encoded, &error);
4680                                return Err(common::Error::JsonDecodeError(
4681                                    encoded.to_string(),
4682                                    error,
4683                                ));
4684                            }
4685                        }
4686                    };
4687
4688                    dlg.finished(true);
4689                    return Ok(response);
4690                }
4691            }
4692        }
4693    }
4694
4695    ///
4696    /// Sets the *request* property to the given value.
4697    ///
4698    /// Even though the property as already been set when instantiating this call,
4699    /// we provide this method for API completeness.
4700    pub fn request(
4701        mut self,
4702        new_value: TestIamPermissionsRequest,
4703    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
4704        self._request = new_value;
4705        self
4706    }
4707    /// REQUIRED: The resource for which the policy detail is being requested.
4708    /// See the operation documentation for the appropriate value for this field.
4709    ///
4710    /// Sets the *resource* path property to the given value.
4711    ///
4712    /// Even though the property as already been set when instantiating this call,
4713    /// we provide this method for API completeness.
4714    pub fn resource(
4715        mut self,
4716        new_value: &str,
4717    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
4718        self._resource = new_value.to_string();
4719        self
4720    }
4721    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4722    /// while executing the actual API request.
4723    ///
4724    /// ````text
4725    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4726    /// ````
4727    ///
4728    /// Sets the *delegate* property to the given value.
4729    pub fn delegate(
4730        mut self,
4731        new_value: &'a mut dyn common::Delegate,
4732    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
4733        self._delegate = Some(new_value);
4734        self
4735    }
4736
4737    /// Set any additional parameter of the query string used in the request.
4738    /// It should be used to set parameters which are not yet available through their own
4739    /// setters.
4740    ///
4741    /// Please note that this method must not be used to set any of the known parameters
4742    /// which have their own setter method. If done anyway, the request will fail.
4743    ///
4744    /// # Additional Parameters
4745    ///
4746    /// * *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.
4747    /// * *access_token* (query-string) - OAuth access token.
4748    /// * *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.
4749    /// * *pp* (query-boolean) - Pretty-print response.
4750    /// * *bearer_token* (query-string) - OAuth bearer token.
4751    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4752    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4753    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4754    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4756    /// * *callback* (query-string) - JSONP
4757    /// * *$.xgafv* (query-string) - V1 error format.
4758    /// * *alt* (query-string) - Data format for response.
4759    pub fn param<T>(
4760        mut self,
4761        name: T,
4762        value: T,
4763    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
4764    where
4765        T: AsRef<str>,
4766    {
4767        self._additional_params
4768            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4769        self
4770    }
4771
4772    /// Identifies the authorization scope for the method you are building.
4773    ///
4774    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4775    /// [`Scope::CloudPlatform`].
4776    ///
4777    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4778    /// tokens for more than one scope.
4779    ///
4780    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4781    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4782    /// sufficient, a read-write scope will do as well.
4783    pub fn add_scope<St>(
4784        mut self,
4785        scope: St,
4786    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
4787    where
4788        St: AsRef<str>,
4789    {
4790        self._scopes.insert(String::from(scope.as_ref()));
4791        self
4792    }
4793    /// Identifies the authorization scope(s) for the method you are building.
4794    ///
4795    /// See [`Self::add_scope()`] for details.
4796    pub fn add_scopes<I, St>(
4797        mut self,
4798        scopes: I,
4799    ) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C>
4800    where
4801        I: IntoIterator<Item = St>,
4802        St: AsRef<str>,
4803    {
4804        self._scopes
4805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4806        self
4807    }
4808
4809    /// Removes all scopes, and no default scope will be used either.
4810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4811    /// for details).
4812    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C> {
4813        self._scopes.clear();
4814        self
4815    }
4816}
4817
4818/// Decrypt data that was protected by Encrypt.
4819///
4820/// A builder for the *locations.keyRings.cryptoKeys.decrypt* method supported by a *project* resource.
4821/// It is not used directly, but through a [`ProjectMethods`] instance.
4822///
4823/// # Example
4824///
4825/// Instantiate a resource method builder
4826///
4827/// ```test_harness,no_run
4828/// # extern crate hyper;
4829/// # extern crate hyper_rustls;
4830/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
4831/// use cloudkms1_beta1::api::DecryptRequest;
4832/// # async fn dox() {
4833/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4834///
4835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4836/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4837/// #     .with_native_roots()
4838/// #     .unwrap()
4839/// #     .https_only()
4840/// #     .enable_http2()
4841/// #     .build();
4842///
4843/// # let executor = hyper_util::rt::TokioExecutor::new();
4844/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4845/// #     secret,
4846/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4847/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4848/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4849/// #     ),
4850/// # ).build().await.unwrap();
4851///
4852/// # let client = hyper_util::client::legacy::Client::builder(
4853/// #     hyper_util::rt::TokioExecutor::new()
4854/// # )
4855/// # .build(
4856/// #     hyper_rustls::HttpsConnectorBuilder::new()
4857/// #         .with_native_roots()
4858/// #         .unwrap()
4859/// #         .https_or_http()
4860/// #         .enable_http2()
4861/// #         .build()
4862/// # );
4863/// # let mut hub = CloudKMS::new(client, auth);
4864/// // As the method needs a request, you would usually fill it with the desired information
4865/// // into the respective structure. Some of the parts shown here might not be applicable !
4866/// // Values shown here are possibly random and not representative !
4867/// let mut req = DecryptRequest::default();
4868///
4869/// // You can configure optional parameters by calling the respective setters at will, and
4870/// // execute the final call using `doit()`.
4871/// // Values shown here are possibly random and not representative !
4872/// let result = hub.projects().locations_key_rings_crypto_keys_decrypt(req, "name")
4873///              .doit().await;
4874/// # }
4875/// ```
4876pub struct ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
4877where
4878    C: 'a,
4879{
4880    hub: &'a CloudKMS<C>,
4881    _request: DecryptRequest,
4882    _name: String,
4883    _delegate: Option<&'a mut dyn common::Delegate>,
4884    _additional_params: HashMap<String, String>,
4885    _scopes: BTreeSet<String>,
4886}
4887
4888impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {}
4889
4890impl<'a, C> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
4891where
4892    C: common::Connector,
4893{
4894    /// Perform the operation you have build so far.
4895    pub async fn doit(mut self) -> common::Result<(common::Response, DecryptResponse)> {
4896        use std::borrow::Cow;
4897        use std::io::{Read, Seek};
4898
4899        use common::{url::Params, ToParts};
4900        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4901
4902        let mut dd = common::DefaultDelegate;
4903        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4904        dlg.begin(common::MethodInfo {
4905            id: "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt",
4906            http_method: hyper::Method::POST,
4907        });
4908
4909        for &field in ["alt", "name"].iter() {
4910            if self._additional_params.contains_key(field) {
4911                dlg.finished(false);
4912                return Err(common::Error::FieldClash(field));
4913            }
4914        }
4915
4916        let mut params = Params::with_capacity(4 + self._additional_params.len());
4917        params.push("name", self._name);
4918
4919        params.extend(self._additional_params.iter());
4920
4921        params.push("alt", "json");
4922        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:decrypt";
4923        if self._scopes.is_empty() {
4924            self._scopes
4925                .insert(Scope::CloudPlatform.as_ref().to_string());
4926        }
4927
4928        #[allow(clippy::single_element_loop)]
4929        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4930            url = params.uri_replacement(url, param_name, find_this, true);
4931        }
4932        {
4933            let to_remove = ["name"];
4934            params.remove_params(&to_remove);
4935        }
4936
4937        let url = params.parse_with_url(&url);
4938
4939        let mut json_mime_type = mime::APPLICATION_JSON;
4940        let mut request_value_reader = {
4941            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4942            common::remove_json_null_values(&mut value);
4943            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4944            serde_json::to_writer(&mut dst, &value).unwrap();
4945            dst
4946        };
4947        let request_size = request_value_reader
4948            .seek(std::io::SeekFrom::End(0))
4949            .unwrap();
4950        request_value_reader
4951            .seek(std::io::SeekFrom::Start(0))
4952            .unwrap();
4953
4954        loop {
4955            let token = match self
4956                .hub
4957                .auth
4958                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4959                .await
4960            {
4961                Ok(token) => token,
4962                Err(e) => match dlg.token(e) {
4963                    Ok(token) => token,
4964                    Err(e) => {
4965                        dlg.finished(false);
4966                        return Err(common::Error::MissingToken(e));
4967                    }
4968                },
4969            };
4970            request_value_reader
4971                .seek(std::io::SeekFrom::Start(0))
4972                .unwrap();
4973            let mut req_result = {
4974                let client = &self.hub.client;
4975                dlg.pre_request();
4976                let mut req_builder = hyper::Request::builder()
4977                    .method(hyper::Method::POST)
4978                    .uri(url.as_str())
4979                    .header(USER_AGENT, self.hub._user_agent.clone());
4980
4981                if let Some(token) = token.as_ref() {
4982                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4983                }
4984
4985                let request = req_builder
4986                    .header(CONTENT_TYPE, json_mime_type.to_string())
4987                    .header(CONTENT_LENGTH, request_size as u64)
4988                    .body(common::to_body(
4989                        request_value_reader.get_ref().clone().into(),
4990                    ));
4991
4992                client.request(request.unwrap()).await
4993            };
4994
4995            match req_result {
4996                Err(err) => {
4997                    if let common::Retry::After(d) = dlg.http_error(&err) {
4998                        sleep(d).await;
4999                        continue;
5000                    }
5001                    dlg.finished(false);
5002                    return Err(common::Error::HttpError(err));
5003                }
5004                Ok(res) => {
5005                    let (mut parts, body) = res.into_parts();
5006                    let mut body = common::Body::new(body);
5007                    if !parts.status.is_success() {
5008                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5009                        let error = serde_json::from_str(&common::to_string(&bytes));
5010                        let response = common::to_response(parts, bytes.into());
5011
5012                        if let common::Retry::After(d) =
5013                            dlg.http_failure(&response, error.as_ref().ok())
5014                        {
5015                            sleep(d).await;
5016                            continue;
5017                        }
5018
5019                        dlg.finished(false);
5020
5021                        return Err(match error {
5022                            Ok(value) => common::Error::BadRequest(value),
5023                            _ => common::Error::Failure(response),
5024                        });
5025                    }
5026                    let response = {
5027                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5028                        let encoded = common::to_string(&bytes);
5029                        match serde_json::from_str(&encoded) {
5030                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5031                            Err(error) => {
5032                                dlg.response_json_decode_error(&encoded, &error);
5033                                return Err(common::Error::JsonDecodeError(
5034                                    encoded.to_string(),
5035                                    error,
5036                                ));
5037                            }
5038                        }
5039                    };
5040
5041                    dlg.finished(true);
5042                    return Ok(response);
5043                }
5044            }
5045        }
5046    }
5047
5048    ///
5049    /// Sets the *request* property to the given value.
5050    ///
5051    /// Even though the property as already been set when instantiating this call,
5052    /// we provide this method for API completeness.
5053    pub fn request(
5054        mut self,
5055        new_value: DecryptRequest,
5056    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
5057        self._request = new_value;
5058        self
5059    }
5060    /// Required. The resource name of the CryptoKey to use for decryption.
5061    /// The server will choose the appropriate version.
5062    ///
5063    /// Sets the *name* path property to the given value.
5064    ///
5065    /// Even though the property as already been set when instantiating this call,
5066    /// we provide this method for API completeness.
5067    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
5068        self._name = new_value.to_string();
5069        self
5070    }
5071    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5072    /// while executing the actual API request.
5073    ///
5074    /// ````text
5075    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5076    /// ````
5077    ///
5078    /// Sets the *delegate* property to the given value.
5079    pub fn delegate(
5080        mut self,
5081        new_value: &'a mut dyn common::Delegate,
5082    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
5083        self._delegate = Some(new_value);
5084        self
5085    }
5086
5087    /// Set any additional parameter of the query string used in the request.
5088    /// It should be used to set parameters which are not yet available through their own
5089    /// setters.
5090    ///
5091    /// Please note that this method must not be used to set any of the known parameters
5092    /// which have their own setter method. If done anyway, the request will fail.
5093    ///
5094    /// # Additional Parameters
5095    ///
5096    /// * *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.
5097    /// * *access_token* (query-string) - OAuth access token.
5098    /// * *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.
5099    /// * *pp* (query-boolean) - Pretty-print response.
5100    /// * *bearer_token* (query-string) - OAuth bearer token.
5101    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5102    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5103    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5104    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5105    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5106    /// * *callback* (query-string) - JSONP
5107    /// * *$.xgafv* (query-string) - V1 error format.
5108    /// * *alt* (query-string) - Data format for response.
5109    pub fn param<T>(
5110        mut self,
5111        name: T,
5112        value: T,
5113    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
5114    where
5115        T: AsRef<str>,
5116    {
5117        self._additional_params
5118            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5119        self
5120    }
5121
5122    /// Identifies the authorization scope for the method you are building.
5123    ///
5124    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5125    /// [`Scope::CloudPlatform`].
5126    ///
5127    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5128    /// tokens for more than one scope.
5129    ///
5130    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5131    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5132    /// sufficient, a read-write scope will do as well.
5133    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
5134    where
5135        St: AsRef<str>,
5136    {
5137        self._scopes.insert(String::from(scope.as_ref()));
5138        self
5139    }
5140    /// Identifies the authorization scope(s) for the method you are building.
5141    ///
5142    /// See [`Self::add_scope()`] for details.
5143    pub fn add_scopes<I, St>(
5144        mut self,
5145        scopes: I,
5146    ) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C>
5147    where
5148        I: IntoIterator<Item = St>,
5149        St: AsRef<str>,
5150    {
5151        self._scopes
5152            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5153        self
5154    }
5155
5156    /// Removes all scopes, and no default scope will be used either.
5157    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5158    /// for details).
5159    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C> {
5160        self._scopes.clear();
5161        self
5162    }
5163}
5164
5165/// Lists CryptoKeys.
5166///
5167/// A builder for the *locations.keyRings.cryptoKeys.list* method supported by a *project* resource.
5168/// It is not used directly, but through a [`ProjectMethods`] instance.
5169///
5170/// # Example
5171///
5172/// Instantiate a resource method builder
5173///
5174/// ```test_harness,no_run
5175/// # extern crate hyper;
5176/// # extern crate hyper_rustls;
5177/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
5178/// # async fn dox() {
5179/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5180///
5181/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5182/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5183/// #     .with_native_roots()
5184/// #     .unwrap()
5185/// #     .https_only()
5186/// #     .enable_http2()
5187/// #     .build();
5188///
5189/// # let executor = hyper_util::rt::TokioExecutor::new();
5190/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5191/// #     secret,
5192/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5193/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5194/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5195/// #     ),
5196/// # ).build().await.unwrap();
5197///
5198/// # let client = hyper_util::client::legacy::Client::builder(
5199/// #     hyper_util::rt::TokioExecutor::new()
5200/// # )
5201/// # .build(
5202/// #     hyper_rustls::HttpsConnectorBuilder::new()
5203/// #         .with_native_roots()
5204/// #         .unwrap()
5205/// #         .https_or_http()
5206/// #         .enable_http2()
5207/// #         .build()
5208/// # );
5209/// # let mut hub = CloudKMS::new(client, auth);
5210/// // You can configure optional parameters by calling the respective setters at will, and
5211/// // execute the final call using `doit()`.
5212/// // Values shown here are possibly random and not representative !
5213/// let result = hub.projects().locations_key_rings_crypto_keys_list("parent")
5214///              .page_token("eos")
5215///              .page_size(-4)
5216///              .doit().await;
5217/// # }
5218/// ```
5219pub struct ProjectLocationKeyRingCryptoKeyListCall<'a, C>
5220where
5221    C: 'a,
5222{
5223    hub: &'a CloudKMS<C>,
5224    _parent: String,
5225    _page_token: Option<String>,
5226    _page_size: Option<i32>,
5227    _delegate: Option<&'a mut dyn common::Delegate>,
5228    _additional_params: HashMap<String, String>,
5229    _scopes: BTreeSet<String>,
5230}
5231
5232impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyListCall<'a, C> {}
5233
5234impl<'a, C> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
5235where
5236    C: common::Connector,
5237{
5238    /// Perform the operation you have build so far.
5239    pub async fn doit(mut self) -> common::Result<(common::Response, ListCryptoKeysResponse)> {
5240        use std::borrow::Cow;
5241        use std::io::{Read, Seek};
5242
5243        use common::{url::Params, ToParts};
5244        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5245
5246        let mut dd = common::DefaultDelegate;
5247        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5248        dlg.begin(common::MethodInfo {
5249            id: "cloudkms.projects.locations.keyRings.cryptoKeys.list",
5250            http_method: hyper::Method::GET,
5251        });
5252
5253        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5254            if self._additional_params.contains_key(field) {
5255                dlg.finished(false);
5256                return Err(common::Error::FieldClash(field));
5257            }
5258        }
5259
5260        let mut params = Params::with_capacity(5 + self._additional_params.len());
5261        params.push("parent", self._parent);
5262        if let Some(value) = self._page_token.as_ref() {
5263            params.push("pageToken", value);
5264        }
5265        if let Some(value) = self._page_size.as_ref() {
5266            params.push("pageSize", value.to_string());
5267        }
5268
5269        params.extend(self._additional_params.iter());
5270
5271        params.push("alt", "json");
5272        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/cryptoKeys";
5273        if self._scopes.is_empty() {
5274            self._scopes
5275                .insert(Scope::CloudPlatform.as_ref().to_string());
5276        }
5277
5278        #[allow(clippy::single_element_loop)]
5279        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5280            url = params.uri_replacement(url, param_name, find_this, true);
5281        }
5282        {
5283            let to_remove = ["parent"];
5284            params.remove_params(&to_remove);
5285        }
5286
5287        let url = params.parse_with_url(&url);
5288
5289        loop {
5290            let token = match self
5291                .hub
5292                .auth
5293                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5294                .await
5295            {
5296                Ok(token) => token,
5297                Err(e) => match dlg.token(e) {
5298                    Ok(token) => token,
5299                    Err(e) => {
5300                        dlg.finished(false);
5301                        return Err(common::Error::MissingToken(e));
5302                    }
5303                },
5304            };
5305            let mut req_result = {
5306                let client = &self.hub.client;
5307                dlg.pre_request();
5308                let mut req_builder = hyper::Request::builder()
5309                    .method(hyper::Method::GET)
5310                    .uri(url.as_str())
5311                    .header(USER_AGENT, self.hub._user_agent.clone());
5312
5313                if let Some(token) = token.as_ref() {
5314                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5315                }
5316
5317                let request = req_builder
5318                    .header(CONTENT_LENGTH, 0_u64)
5319                    .body(common::to_body::<String>(None));
5320
5321                client.request(request.unwrap()).await
5322            };
5323
5324            match req_result {
5325                Err(err) => {
5326                    if let common::Retry::After(d) = dlg.http_error(&err) {
5327                        sleep(d).await;
5328                        continue;
5329                    }
5330                    dlg.finished(false);
5331                    return Err(common::Error::HttpError(err));
5332                }
5333                Ok(res) => {
5334                    let (mut parts, body) = res.into_parts();
5335                    let mut body = common::Body::new(body);
5336                    if !parts.status.is_success() {
5337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5338                        let error = serde_json::from_str(&common::to_string(&bytes));
5339                        let response = common::to_response(parts, bytes.into());
5340
5341                        if let common::Retry::After(d) =
5342                            dlg.http_failure(&response, error.as_ref().ok())
5343                        {
5344                            sleep(d).await;
5345                            continue;
5346                        }
5347
5348                        dlg.finished(false);
5349
5350                        return Err(match error {
5351                            Ok(value) => common::Error::BadRequest(value),
5352                            _ => common::Error::Failure(response),
5353                        });
5354                    }
5355                    let response = {
5356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5357                        let encoded = common::to_string(&bytes);
5358                        match serde_json::from_str(&encoded) {
5359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5360                            Err(error) => {
5361                                dlg.response_json_decode_error(&encoded, &error);
5362                                return Err(common::Error::JsonDecodeError(
5363                                    encoded.to_string(),
5364                                    error,
5365                                ));
5366                            }
5367                        }
5368                    };
5369
5370                    dlg.finished(true);
5371                    return Ok(response);
5372                }
5373            }
5374        }
5375    }
5376
5377    /// Required. The resource name of the KeyRing to list, in the format
5378    /// `projects/*/locations/*/keyRings/*`.
5379    ///
5380    /// Sets the *parent* path property to the given value.
5381    ///
5382    /// Even though the property as already been set when instantiating this call,
5383    /// we provide this method for API completeness.
5384    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
5385        self._parent = new_value.to_string();
5386        self
5387    }
5388    /// Optional pagination token, returned earlier via
5389    /// ListCryptoKeysResponse.next_page_token.
5390    ///
5391    /// Sets the *page token* query property to the given value.
5392    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
5393        self._page_token = Some(new_value.to_string());
5394        self
5395    }
5396    /// Optional limit on the number of CryptoKeys to include in the
5397    /// response.  Further CryptoKeys can subsequently be obtained by
5398    /// including the ListCryptoKeysResponse.next_page_token in a subsequent
5399    /// request.  If unspecified, the server will pick an appropriate default.
5400    ///
5401    /// Sets the *page size* query property to the given value.
5402    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
5403        self._page_size = Some(new_value);
5404        self
5405    }
5406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5407    /// while executing the actual API request.
5408    ///
5409    /// ````text
5410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5411    /// ````
5412    ///
5413    /// Sets the *delegate* property to the given value.
5414    pub fn delegate(
5415        mut self,
5416        new_value: &'a mut dyn common::Delegate,
5417    ) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
5418        self._delegate = Some(new_value);
5419        self
5420    }
5421
5422    /// Set any additional parameter of the query string used in the request.
5423    /// It should be used to set parameters which are not yet available through their own
5424    /// setters.
5425    ///
5426    /// Please note that this method must not be used to set any of the known parameters
5427    /// which have their own setter method. If done anyway, the request will fail.
5428    ///
5429    /// # Additional Parameters
5430    ///
5431    /// * *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.
5432    /// * *access_token* (query-string) - OAuth access token.
5433    /// * *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.
5434    /// * *pp* (query-boolean) - Pretty-print response.
5435    /// * *bearer_token* (query-string) - OAuth bearer token.
5436    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5437    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5438    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5439    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5440    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5441    /// * *callback* (query-string) - JSONP
5442    /// * *$.xgafv* (query-string) - V1 error format.
5443    /// * *alt* (query-string) - Data format for response.
5444    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
5445    where
5446        T: AsRef<str>,
5447    {
5448        self._additional_params
5449            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5450        self
5451    }
5452
5453    /// Identifies the authorization scope for the method you are building.
5454    ///
5455    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5456    /// [`Scope::CloudPlatform`].
5457    ///
5458    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5459    /// tokens for more than one scope.
5460    ///
5461    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5462    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5463    /// sufficient, a read-write scope will do as well.
5464    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
5465    where
5466        St: AsRef<str>,
5467    {
5468        self._scopes.insert(String::from(scope.as_ref()));
5469        self
5470    }
5471    /// Identifies the authorization scope(s) for the method you are building.
5472    ///
5473    /// See [`Self::add_scope()`] for details.
5474    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C>
5475    where
5476        I: IntoIterator<Item = St>,
5477        St: AsRef<str>,
5478    {
5479        self._scopes
5480            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5481        self
5482    }
5483
5484    /// Removes all scopes, and no default scope will be used either.
5485    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5486    /// for details).
5487    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C> {
5488        self._scopes.clear();
5489        self
5490    }
5491}
5492
5493/// Encrypt data, so that it can only be recovered by a call to Decrypt.
5494///
5495/// A builder for the *locations.keyRings.cryptoKeys.encrypt* method supported by a *project* resource.
5496/// It is not used directly, but through a [`ProjectMethods`] instance.
5497///
5498/// # Example
5499///
5500/// Instantiate a resource method builder
5501///
5502/// ```test_harness,no_run
5503/// # extern crate hyper;
5504/// # extern crate hyper_rustls;
5505/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
5506/// use cloudkms1_beta1::api::EncryptRequest;
5507/// # async fn dox() {
5508/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5509///
5510/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5511/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5512/// #     .with_native_roots()
5513/// #     .unwrap()
5514/// #     .https_only()
5515/// #     .enable_http2()
5516/// #     .build();
5517///
5518/// # let executor = hyper_util::rt::TokioExecutor::new();
5519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5520/// #     secret,
5521/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5522/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5523/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5524/// #     ),
5525/// # ).build().await.unwrap();
5526///
5527/// # let client = hyper_util::client::legacy::Client::builder(
5528/// #     hyper_util::rt::TokioExecutor::new()
5529/// # )
5530/// # .build(
5531/// #     hyper_rustls::HttpsConnectorBuilder::new()
5532/// #         .with_native_roots()
5533/// #         .unwrap()
5534/// #         .https_or_http()
5535/// #         .enable_http2()
5536/// #         .build()
5537/// # );
5538/// # let mut hub = CloudKMS::new(client, auth);
5539/// // As the method needs a request, you would usually fill it with the desired information
5540/// // into the respective structure. Some of the parts shown here might not be applicable !
5541/// // Values shown here are possibly random and not representative !
5542/// let mut req = EncryptRequest::default();
5543///
5544/// // You can configure optional parameters by calling the respective setters at will, and
5545/// // execute the final call using `doit()`.
5546/// // Values shown here are possibly random and not representative !
5547/// let result = hub.projects().locations_key_rings_crypto_keys_encrypt(req, "name")
5548///              .doit().await;
5549/// # }
5550/// ```
5551pub struct ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
5552where
5553    C: 'a,
5554{
5555    hub: &'a CloudKMS<C>,
5556    _request: EncryptRequest,
5557    _name: String,
5558    _delegate: Option<&'a mut dyn common::Delegate>,
5559    _additional_params: HashMap<String, String>,
5560    _scopes: BTreeSet<String>,
5561}
5562
5563impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {}
5564
5565impl<'a, C> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
5566where
5567    C: common::Connector,
5568{
5569    /// Perform the operation you have build so far.
5570    pub async fn doit(mut self) -> common::Result<(common::Response, EncryptResponse)> {
5571        use std::borrow::Cow;
5572        use std::io::{Read, Seek};
5573
5574        use common::{url::Params, ToParts};
5575        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5576
5577        let mut dd = common::DefaultDelegate;
5578        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5579        dlg.begin(common::MethodInfo {
5580            id: "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt",
5581            http_method: hyper::Method::POST,
5582        });
5583
5584        for &field in ["alt", "name"].iter() {
5585            if self._additional_params.contains_key(field) {
5586                dlg.finished(false);
5587                return Err(common::Error::FieldClash(field));
5588            }
5589        }
5590
5591        let mut params = Params::with_capacity(4 + self._additional_params.len());
5592        params.push("name", self._name);
5593
5594        params.extend(self._additional_params.iter());
5595
5596        params.push("alt", "json");
5597        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:encrypt";
5598        if self._scopes.is_empty() {
5599            self._scopes
5600                .insert(Scope::CloudPlatform.as_ref().to_string());
5601        }
5602
5603        #[allow(clippy::single_element_loop)]
5604        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5605            url = params.uri_replacement(url, param_name, find_this, true);
5606        }
5607        {
5608            let to_remove = ["name"];
5609            params.remove_params(&to_remove);
5610        }
5611
5612        let url = params.parse_with_url(&url);
5613
5614        let mut json_mime_type = mime::APPLICATION_JSON;
5615        let mut request_value_reader = {
5616            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5617            common::remove_json_null_values(&mut value);
5618            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5619            serde_json::to_writer(&mut dst, &value).unwrap();
5620            dst
5621        };
5622        let request_size = request_value_reader
5623            .seek(std::io::SeekFrom::End(0))
5624            .unwrap();
5625        request_value_reader
5626            .seek(std::io::SeekFrom::Start(0))
5627            .unwrap();
5628
5629        loop {
5630            let token = match self
5631                .hub
5632                .auth
5633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5634                .await
5635            {
5636                Ok(token) => token,
5637                Err(e) => match dlg.token(e) {
5638                    Ok(token) => token,
5639                    Err(e) => {
5640                        dlg.finished(false);
5641                        return Err(common::Error::MissingToken(e));
5642                    }
5643                },
5644            };
5645            request_value_reader
5646                .seek(std::io::SeekFrom::Start(0))
5647                .unwrap();
5648            let mut req_result = {
5649                let client = &self.hub.client;
5650                dlg.pre_request();
5651                let mut req_builder = hyper::Request::builder()
5652                    .method(hyper::Method::POST)
5653                    .uri(url.as_str())
5654                    .header(USER_AGENT, self.hub._user_agent.clone());
5655
5656                if let Some(token) = token.as_ref() {
5657                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5658                }
5659
5660                let request = req_builder
5661                    .header(CONTENT_TYPE, json_mime_type.to_string())
5662                    .header(CONTENT_LENGTH, request_size as u64)
5663                    .body(common::to_body(
5664                        request_value_reader.get_ref().clone().into(),
5665                    ));
5666
5667                client.request(request.unwrap()).await
5668            };
5669
5670            match req_result {
5671                Err(err) => {
5672                    if let common::Retry::After(d) = dlg.http_error(&err) {
5673                        sleep(d).await;
5674                        continue;
5675                    }
5676                    dlg.finished(false);
5677                    return Err(common::Error::HttpError(err));
5678                }
5679                Ok(res) => {
5680                    let (mut parts, body) = res.into_parts();
5681                    let mut body = common::Body::new(body);
5682                    if !parts.status.is_success() {
5683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5684                        let error = serde_json::from_str(&common::to_string(&bytes));
5685                        let response = common::to_response(parts, bytes.into());
5686
5687                        if let common::Retry::After(d) =
5688                            dlg.http_failure(&response, error.as_ref().ok())
5689                        {
5690                            sleep(d).await;
5691                            continue;
5692                        }
5693
5694                        dlg.finished(false);
5695
5696                        return Err(match error {
5697                            Ok(value) => common::Error::BadRequest(value),
5698                            _ => common::Error::Failure(response),
5699                        });
5700                    }
5701                    let response = {
5702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5703                        let encoded = common::to_string(&bytes);
5704                        match serde_json::from_str(&encoded) {
5705                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5706                            Err(error) => {
5707                                dlg.response_json_decode_error(&encoded, &error);
5708                                return Err(common::Error::JsonDecodeError(
5709                                    encoded.to_string(),
5710                                    error,
5711                                ));
5712                            }
5713                        }
5714                    };
5715
5716                    dlg.finished(true);
5717                    return Ok(response);
5718                }
5719            }
5720        }
5721    }
5722
5723    ///
5724    /// Sets the *request* property to the given value.
5725    ///
5726    /// Even though the property as already been set when instantiating this call,
5727    /// we provide this method for API completeness.
5728    pub fn request(
5729        mut self,
5730        new_value: EncryptRequest,
5731    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
5732        self._request = new_value;
5733        self
5734    }
5735    /// Required. The resource name of the CryptoKey or CryptoKeyVersion
5736    /// to use for encryption.
5737    ///
5738    /// If a CryptoKey is specified, the server will use its
5739    /// primary version.
5740    ///
5741    /// Sets the *name* path property to the given value.
5742    ///
5743    /// Even though the property as already been set when instantiating this call,
5744    /// we provide this method for API completeness.
5745    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
5746        self._name = new_value.to_string();
5747        self
5748    }
5749    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5750    /// while executing the actual API request.
5751    ///
5752    /// ````text
5753    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5754    /// ````
5755    ///
5756    /// Sets the *delegate* property to the given value.
5757    pub fn delegate(
5758        mut self,
5759        new_value: &'a mut dyn common::Delegate,
5760    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
5761        self._delegate = Some(new_value);
5762        self
5763    }
5764
5765    /// Set any additional parameter of the query string used in the request.
5766    /// It should be used to set parameters which are not yet available through their own
5767    /// setters.
5768    ///
5769    /// Please note that this method must not be used to set any of the known parameters
5770    /// which have their own setter method. If done anyway, the request will fail.
5771    ///
5772    /// # Additional Parameters
5773    ///
5774    /// * *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.
5775    /// * *access_token* (query-string) - OAuth access token.
5776    /// * *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.
5777    /// * *pp* (query-boolean) - Pretty-print response.
5778    /// * *bearer_token* (query-string) - OAuth bearer token.
5779    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5780    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5781    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5782    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5783    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5784    /// * *callback* (query-string) - JSONP
5785    /// * *$.xgafv* (query-string) - V1 error format.
5786    /// * *alt* (query-string) - Data format for response.
5787    pub fn param<T>(
5788        mut self,
5789        name: T,
5790        value: T,
5791    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
5792    where
5793        T: AsRef<str>,
5794    {
5795        self._additional_params
5796            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5797        self
5798    }
5799
5800    /// Identifies the authorization scope for the method you are building.
5801    ///
5802    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5803    /// [`Scope::CloudPlatform`].
5804    ///
5805    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5806    /// tokens for more than one scope.
5807    ///
5808    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5809    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5810    /// sufficient, a read-write scope will do as well.
5811    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
5812    where
5813        St: AsRef<str>,
5814    {
5815        self._scopes.insert(String::from(scope.as_ref()));
5816        self
5817    }
5818    /// Identifies the authorization scope(s) for the method you are building.
5819    ///
5820    /// See [`Self::add_scope()`] for details.
5821    pub fn add_scopes<I, St>(
5822        mut self,
5823        scopes: I,
5824    ) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C>
5825    where
5826        I: IntoIterator<Item = St>,
5827        St: AsRef<str>,
5828    {
5829        self._scopes
5830            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5831        self
5832    }
5833
5834    /// Removes all scopes, and no default scope will be used either.
5835    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5836    /// for details).
5837    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C> {
5838        self._scopes.clear();
5839        self
5840    }
5841}
5842
5843/// Create a new CryptoKey within a KeyRing.
5844///
5845/// CryptoKey.purpose is required.
5846///
5847/// A builder for the *locations.keyRings.cryptoKeys.create* method supported by a *project* resource.
5848/// It is not used directly, but through a [`ProjectMethods`] instance.
5849///
5850/// # Example
5851///
5852/// Instantiate a resource method builder
5853///
5854/// ```test_harness,no_run
5855/// # extern crate hyper;
5856/// # extern crate hyper_rustls;
5857/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
5858/// use cloudkms1_beta1::api::CryptoKey;
5859/// # async fn dox() {
5860/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5861///
5862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5863/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5864/// #     .with_native_roots()
5865/// #     .unwrap()
5866/// #     .https_only()
5867/// #     .enable_http2()
5868/// #     .build();
5869///
5870/// # let executor = hyper_util::rt::TokioExecutor::new();
5871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5872/// #     secret,
5873/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5874/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5875/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5876/// #     ),
5877/// # ).build().await.unwrap();
5878///
5879/// # let client = hyper_util::client::legacy::Client::builder(
5880/// #     hyper_util::rt::TokioExecutor::new()
5881/// # )
5882/// # .build(
5883/// #     hyper_rustls::HttpsConnectorBuilder::new()
5884/// #         .with_native_roots()
5885/// #         .unwrap()
5886/// #         .https_or_http()
5887/// #         .enable_http2()
5888/// #         .build()
5889/// # );
5890/// # let mut hub = CloudKMS::new(client, auth);
5891/// // As the method needs a request, you would usually fill it with the desired information
5892/// // into the respective structure. Some of the parts shown here might not be applicable !
5893/// // Values shown here are possibly random and not representative !
5894/// let mut req = CryptoKey::default();
5895///
5896/// // You can configure optional parameters by calling the respective setters at will, and
5897/// // execute the final call using `doit()`.
5898/// // Values shown here are possibly random and not representative !
5899/// let result = hub.projects().locations_key_rings_crypto_keys_create(req, "parent")
5900///              .crypto_key_id("invidunt")
5901///              .doit().await;
5902/// # }
5903/// ```
5904pub struct ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
5905where
5906    C: 'a,
5907{
5908    hub: &'a CloudKMS<C>,
5909    _request: CryptoKey,
5910    _parent: String,
5911    _crypto_key_id: Option<String>,
5912    _delegate: Option<&'a mut dyn common::Delegate>,
5913    _additional_params: HashMap<String, String>,
5914    _scopes: BTreeSet<String>,
5915}
5916
5917impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {}
5918
5919impl<'a, C> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
5920where
5921    C: common::Connector,
5922{
5923    /// Perform the operation you have build so far.
5924    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
5925        use std::borrow::Cow;
5926        use std::io::{Read, Seek};
5927
5928        use common::{url::Params, ToParts};
5929        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5930
5931        let mut dd = common::DefaultDelegate;
5932        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5933        dlg.begin(common::MethodInfo {
5934            id: "cloudkms.projects.locations.keyRings.cryptoKeys.create",
5935            http_method: hyper::Method::POST,
5936        });
5937
5938        for &field in ["alt", "parent", "cryptoKeyId"].iter() {
5939            if self._additional_params.contains_key(field) {
5940                dlg.finished(false);
5941                return Err(common::Error::FieldClash(field));
5942            }
5943        }
5944
5945        let mut params = Params::with_capacity(5 + self._additional_params.len());
5946        params.push("parent", self._parent);
5947        if let Some(value) = self._crypto_key_id.as_ref() {
5948            params.push("cryptoKeyId", value);
5949        }
5950
5951        params.extend(self._additional_params.iter());
5952
5953        params.push("alt", "json");
5954        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/cryptoKeys";
5955        if self._scopes.is_empty() {
5956            self._scopes
5957                .insert(Scope::CloudPlatform.as_ref().to_string());
5958        }
5959
5960        #[allow(clippy::single_element_loop)]
5961        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5962            url = params.uri_replacement(url, param_name, find_this, true);
5963        }
5964        {
5965            let to_remove = ["parent"];
5966            params.remove_params(&to_remove);
5967        }
5968
5969        let url = params.parse_with_url(&url);
5970
5971        let mut json_mime_type = mime::APPLICATION_JSON;
5972        let mut request_value_reader = {
5973            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5974            common::remove_json_null_values(&mut value);
5975            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5976            serde_json::to_writer(&mut dst, &value).unwrap();
5977            dst
5978        };
5979        let request_size = request_value_reader
5980            .seek(std::io::SeekFrom::End(0))
5981            .unwrap();
5982        request_value_reader
5983            .seek(std::io::SeekFrom::Start(0))
5984            .unwrap();
5985
5986        loop {
5987            let token = match self
5988                .hub
5989                .auth
5990                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5991                .await
5992            {
5993                Ok(token) => token,
5994                Err(e) => match dlg.token(e) {
5995                    Ok(token) => token,
5996                    Err(e) => {
5997                        dlg.finished(false);
5998                        return Err(common::Error::MissingToken(e));
5999                    }
6000                },
6001            };
6002            request_value_reader
6003                .seek(std::io::SeekFrom::Start(0))
6004                .unwrap();
6005            let mut req_result = {
6006                let client = &self.hub.client;
6007                dlg.pre_request();
6008                let mut req_builder = hyper::Request::builder()
6009                    .method(hyper::Method::POST)
6010                    .uri(url.as_str())
6011                    .header(USER_AGENT, self.hub._user_agent.clone());
6012
6013                if let Some(token) = token.as_ref() {
6014                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6015                }
6016
6017                let request = req_builder
6018                    .header(CONTENT_TYPE, json_mime_type.to_string())
6019                    .header(CONTENT_LENGTH, request_size as u64)
6020                    .body(common::to_body(
6021                        request_value_reader.get_ref().clone().into(),
6022                    ));
6023
6024                client.request(request.unwrap()).await
6025            };
6026
6027            match req_result {
6028                Err(err) => {
6029                    if let common::Retry::After(d) = dlg.http_error(&err) {
6030                        sleep(d).await;
6031                        continue;
6032                    }
6033                    dlg.finished(false);
6034                    return Err(common::Error::HttpError(err));
6035                }
6036                Ok(res) => {
6037                    let (mut parts, body) = res.into_parts();
6038                    let mut body = common::Body::new(body);
6039                    if !parts.status.is_success() {
6040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6041                        let error = serde_json::from_str(&common::to_string(&bytes));
6042                        let response = common::to_response(parts, bytes.into());
6043
6044                        if let common::Retry::After(d) =
6045                            dlg.http_failure(&response, error.as_ref().ok())
6046                        {
6047                            sleep(d).await;
6048                            continue;
6049                        }
6050
6051                        dlg.finished(false);
6052
6053                        return Err(match error {
6054                            Ok(value) => common::Error::BadRequest(value),
6055                            _ => common::Error::Failure(response),
6056                        });
6057                    }
6058                    let response = {
6059                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6060                        let encoded = common::to_string(&bytes);
6061                        match serde_json::from_str(&encoded) {
6062                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6063                            Err(error) => {
6064                                dlg.response_json_decode_error(&encoded, &error);
6065                                return Err(common::Error::JsonDecodeError(
6066                                    encoded.to_string(),
6067                                    error,
6068                                ));
6069                            }
6070                        }
6071                    };
6072
6073                    dlg.finished(true);
6074                    return Ok(response);
6075                }
6076            }
6077        }
6078    }
6079
6080    ///
6081    /// Sets the *request* property to the given value.
6082    ///
6083    /// Even though the property as already been set when instantiating this call,
6084    /// we provide this method for API completeness.
6085    pub fn request(
6086        mut self,
6087        new_value: CryptoKey,
6088    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
6089        self._request = new_value;
6090        self
6091    }
6092    /// Required. The name of the KeyRing associated with the
6093    /// CryptoKeys.
6094    ///
6095    /// Sets the *parent* path property to the given value.
6096    ///
6097    /// Even though the property as already been set when instantiating this call,
6098    /// we provide this method for API completeness.
6099    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
6100        self._parent = new_value.to_string();
6101        self
6102    }
6103    /// Required. It must be unique within a KeyRing and match the regular
6104    /// expression `[a-zA-Z0-9_-]{1,63}`
6105    ///
6106    /// Sets the *crypto key id* query property to the given value.
6107    pub fn crypto_key_id(
6108        mut self,
6109        new_value: &str,
6110    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
6111        self._crypto_key_id = Some(new_value.to_string());
6112        self
6113    }
6114    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6115    /// while executing the actual API request.
6116    ///
6117    /// ````text
6118    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6119    /// ````
6120    ///
6121    /// Sets the *delegate* property to the given value.
6122    pub fn delegate(
6123        mut self,
6124        new_value: &'a mut dyn common::Delegate,
6125    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
6126        self._delegate = Some(new_value);
6127        self
6128    }
6129
6130    /// Set any additional parameter of the query string used in the request.
6131    /// It should be used to set parameters which are not yet available through their own
6132    /// setters.
6133    ///
6134    /// Please note that this method must not be used to set any of the known parameters
6135    /// which have their own setter method. If done anyway, the request will fail.
6136    ///
6137    /// # Additional Parameters
6138    ///
6139    /// * *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.
6140    /// * *access_token* (query-string) - OAuth access token.
6141    /// * *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.
6142    /// * *pp* (query-boolean) - Pretty-print response.
6143    /// * *bearer_token* (query-string) - OAuth bearer token.
6144    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6145    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6146    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6147    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6148    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6149    /// * *callback* (query-string) - JSONP
6150    /// * *$.xgafv* (query-string) - V1 error format.
6151    /// * *alt* (query-string) - Data format for response.
6152    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
6153    where
6154        T: AsRef<str>,
6155    {
6156        self._additional_params
6157            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6158        self
6159    }
6160
6161    /// Identifies the authorization scope for the method you are building.
6162    ///
6163    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6164    /// [`Scope::CloudPlatform`].
6165    ///
6166    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6167    /// tokens for more than one scope.
6168    ///
6169    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6170    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6171    /// sufficient, a read-write scope will do as well.
6172    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
6173    where
6174        St: AsRef<str>,
6175    {
6176        self._scopes.insert(String::from(scope.as_ref()));
6177        self
6178    }
6179    /// Identifies the authorization scope(s) for the method you are building.
6180    ///
6181    /// See [`Self::add_scope()`] for details.
6182    pub fn add_scopes<I, St>(
6183        mut self,
6184        scopes: I,
6185    ) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C>
6186    where
6187        I: IntoIterator<Item = St>,
6188        St: AsRef<str>,
6189    {
6190        self._scopes
6191            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6192        self
6193    }
6194
6195    /// Removes all scopes, and no default scope will be used either.
6196    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6197    /// for details).
6198    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C> {
6199        self._scopes.clear();
6200        self
6201    }
6202}
6203
6204/// Sets the access control policy on the specified resource. Replaces any
6205/// existing policy.
6206///
6207/// A builder for the *locations.keyRings.cryptoKeys.setIamPolicy* method supported by a *project* resource.
6208/// It is not used directly, but through a [`ProjectMethods`] instance.
6209///
6210/// # Example
6211///
6212/// Instantiate a resource method builder
6213///
6214/// ```test_harness,no_run
6215/// # extern crate hyper;
6216/// # extern crate hyper_rustls;
6217/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
6218/// use cloudkms1_beta1::api::SetIamPolicyRequest;
6219/// # async fn dox() {
6220/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6221///
6222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6223/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6224/// #     .with_native_roots()
6225/// #     .unwrap()
6226/// #     .https_only()
6227/// #     .enable_http2()
6228/// #     .build();
6229///
6230/// # let executor = hyper_util::rt::TokioExecutor::new();
6231/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6232/// #     secret,
6233/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6234/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6235/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6236/// #     ),
6237/// # ).build().await.unwrap();
6238///
6239/// # let client = hyper_util::client::legacy::Client::builder(
6240/// #     hyper_util::rt::TokioExecutor::new()
6241/// # )
6242/// # .build(
6243/// #     hyper_rustls::HttpsConnectorBuilder::new()
6244/// #         .with_native_roots()
6245/// #         .unwrap()
6246/// #         .https_or_http()
6247/// #         .enable_http2()
6248/// #         .build()
6249/// # );
6250/// # let mut hub = CloudKMS::new(client, auth);
6251/// // As the method needs a request, you would usually fill it with the desired information
6252/// // into the respective structure. Some of the parts shown here might not be applicable !
6253/// // Values shown here are possibly random and not representative !
6254/// let mut req = SetIamPolicyRequest::default();
6255///
6256/// // You can configure optional parameters by calling the respective setters at will, and
6257/// // execute the final call using `doit()`.
6258/// // Values shown here are possibly random and not representative !
6259/// let result = hub.projects().locations_key_rings_crypto_keys_set_iam_policy(req, "resource")
6260///              .doit().await;
6261/// # }
6262/// ```
6263pub struct ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
6264where
6265    C: 'a,
6266{
6267    hub: &'a CloudKMS<C>,
6268    _request: SetIamPolicyRequest,
6269    _resource: String,
6270    _delegate: Option<&'a mut dyn common::Delegate>,
6271    _additional_params: HashMap<String, String>,
6272    _scopes: BTreeSet<String>,
6273}
6274
6275impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {}
6276
6277impl<'a, C> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
6278where
6279    C: common::Connector,
6280{
6281    /// Perform the operation you have build so far.
6282    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6283        use std::borrow::Cow;
6284        use std::io::{Read, Seek};
6285
6286        use common::{url::Params, ToParts};
6287        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6288
6289        let mut dd = common::DefaultDelegate;
6290        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6291        dlg.begin(common::MethodInfo {
6292            id: "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy",
6293            http_method: hyper::Method::POST,
6294        });
6295
6296        for &field in ["alt", "resource"].iter() {
6297            if self._additional_params.contains_key(field) {
6298                dlg.finished(false);
6299                return Err(common::Error::FieldClash(field));
6300            }
6301        }
6302
6303        let mut params = Params::with_capacity(4 + self._additional_params.len());
6304        params.push("resource", self._resource);
6305
6306        params.extend(self._additional_params.iter());
6307
6308        params.push("alt", "json");
6309        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
6310        if self._scopes.is_empty() {
6311            self._scopes
6312                .insert(Scope::CloudPlatform.as_ref().to_string());
6313        }
6314
6315        #[allow(clippy::single_element_loop)]
6316        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6317            url = params.uri_replacement(url, param_name, find_this, true);
6318        }
6319        {
6320            let to_remove = ["resource"];
6321            params.remove_params(&to_remove);
6322        }
6323
6324        let url = params.parse_with_url(&url);
6325
6326        let mut json_mime_type = mime::APPLICATION_JSON;
6327        let mut request_value_reader = {
6328            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6329            common::remove_json_null_values(&mut value);
6330            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6331            serde_json::to_writer(&mut dst, &value).unwrap();
6332            dst
6333        };
6334        let request_size = request_value_reader
6335            .seek(std::io::SeekFrom::End(0))
6336            .unwrap();
6337        request_value_reader
6338            .seek(std::io::SeekFrom::Start(0))
6339            .unwrap();
6340
6341        loop {
6342            let token = match self
6343                .hub
6344                .auth
6345                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6346                .await
6347            {
6348                Ok(token) => token,
6349                Err(e) => match dlg.token(e) {
6350                    Ok(token) => token,
6351                    Err(e) => {
6352                        dlg.finished(false);
6353                        return Err(common::Error::MissingToken(e));
6354                    }
6355                },
6356            };
6357            request_value_reader
6358                .seek(std::io::SeekFrom::Start(0))
6359                .unwrap();
6360            let mut req_result = {
6361                let client = &self.hub.client;
6362                dlg.pre_request();
6363                let mut req_builder = hyper::Request::builder()
6364                    .method(hyper::Method::POST)
6365                    .uri(url.as_str())
6366                    .header(USER_AGENT, self.hub._user_agent.clone());
6367
6368                if let Some(token) = token.as_ref() {
6369                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6370                }
6371
6372                let request = req_builder
6373                    .header(CONTENT_TYPE, json_mime_type.to_string())
6374                    .header(CONTENT_LENGTH, request_size as u64)
6375                    .body(common::to_body(
6376                        request_value_reader.get_ref().clone().into(),
6377                    ));
6378
6379                client.request(request.unwrap()).await
6380            };
6381
6382            match req_result {
6383                Err(err) => {
6384                    if let common::Retry::After(d) = dlg.http_error(&err) {
6385                        sleep(d).await;
6386                        continue;
6387                    }
6388                    dlg.finished(false);
6389                    return Err(common::Error::HttpError(err));
6390                }
6391                Ok(res) => {
6392                    let (mut parts, body) = res.into_parts();
6393                    let mut body = common::Body::new(body);
6394                    if !parts.status.is_success() {
6395                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6396                        let error = serde_json::from_str(&common::to_string(&bytes));
6397                        let response = common::to_response(parts, bytes.into());
6398
6399                        if let common::Retry::After(d) =
6400                            dlg.http_failure(&response, error.as_ref().ok())
6401                        {
6402                            sleep(d).await;
6403                            continue;
6404                        }
6405
6406                        dlg.finished(false);
6407
6408                        return Err(match error {
6409                            Ok(value) => common::Error::BadRequest(value),
6410                            _ => common::Error::Failure(response),
6411                        });
6412                    }
6413                    let response = {
6414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6415                        let encoded = common::to_string(&bytes);
6416                        match serde_json::from_str(&encoded) {
6417                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6418                            Err(error) => {
6419                                dlg.response_json_decode_error(&encoded, &error);
6420                                return Err(common::Error::JsonDecodeError(
6421                                    encoded.to_string(),
6422                                    error,
6423                                ));
6424                            }
6425                        }
6426                    };
6427
6428                    dlg.finished(true);
6429                    return Ok(response);
6430                }
6431            }
6432        }
6433    }
6434
6435    ///
6436    /// Sets the *request* property to the given value.
6437    ///
6438    /// Even though the property as already been set when instantiating this call,
6439    /// we provide this method for API completeness.
6440    pub fn request(
6441        mut self,
6442        new_value: SetIamPolicyRequest,
6443    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
6444        self._request = new_value;
6445        self
6446    }
6447    /// REQUIRED: The resource for which the policy is being specified.
6448    /// See the operation documentation for the appropriate value for this field.
6449    ///
6450    /// Sets the *resource* path property to the given value.
6451    ///
6452    /// Even though the property as already been set when instantiating this call,
6453    /// we provide this method for API completeness.
6454    pub fn resource(
6455        mut self,
6456        new_value: &str,
6457    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
6458        self._resource = new_value.to_string();
6459        self
6460    }
6461    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6462    /// while executing the actual API request.
6463    ///
6464    /// ````text
6465    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6466    /// ````
6467    ///
6468    /// Sets the *delegate* property to the given value.
6469    pub fn delegate(
6470        mut self,
6471        new_value: &'a mut dyn common::Delegate,
6472    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
6473        self._delegate = Some(new_value);
6474        self
6475    }
6476
6477    /// Set any additional parameter of the query string used in the request.
6478    /// It should be used to set parameters which are not yet available through their own
6479    /// setters.
6480    ///
6481    /// Please note that this method must not be used to set any of the known parameters
6482    /// which have their own setter method. If done anyway, the request will fail.
6483    ///
6484    /// # Additional Parameters
6485    ///
6486    /// * *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.
6487    /// * *access_token* (query-string) - OAuth access token.
6488    /// * *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.
6489    /// * *pp* (query-boolean) - Pretty-print response.
6490    /// * *bearer_token* (query-string) - OAuth bearer token.
6491    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6492    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6493    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6494    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6495    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6496    /// * *callback* (query-string) - JSONP
6497    /// * *$.xgafv* (query-string) - V1 error format.
6498    /// * *alt* (query-string) - Data format for response.
6499    pub fn param<T>(
6500        mut self,
6501        name: T,
6502        value: T,
6503    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
6504    where
6505        T: AsRef<str>,
6506    {
6507        self._additional_params
6508            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6509        self
6510    }
6511
6512    /// Identifies the authorization scope for the method you are building.
6513    ///
6514    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6515    /// [`Scope::CloudPlatform`].
6516    ///
6517    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6518    /// tokens for more than one scope.
6519    ///
6520    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6521    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6522    /// sufficient, a read-write scope will do as well.
6523    pub fn add_scope<St>(
6524        mut self,
6525        scope: St,
6526    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
6527    where
6528        St: AsRef<str>,
6529    {
6530        self._scopes.insert(String::from(scope.as_ref()));
6531        self
6532    }
6533    /// Identifies the authorization scope(s) for the method you are building.
6534    ///
6535    /// See [`Self::add_scope()`] for details.
6536    pub fn add_scopes<I, St>(
6537        mut self,
6538        scopes: I,
6539    ) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C>
6540    where
6541        I: IntoIterator<Item = St>,
6542        St: AsRef<str>,
6543    {
6544        self._scopes
6545            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6546        self
6547    }
6548
6549    /// Removes all scopes, and no default scope will be used either.
6550    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6551    /// for details).
6552    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C> {
6553        self._scopes.clear();
6554        self
6555    }
6556}
6557
6558/// Update the version of a CryptoKey that will be used in Encrypt
6559///
6560/// A builder for the *locations.keyRings.cryptoKeys.updatePrimaryVersion* method supported by a *project* resource.
6561/// It is not used directly, but through a [`ProjectMethods`] instance.
6562///
6563/// # Example
6564///
6565/// Instantiate a resource method builder
6566///
6567/// ```test_harness,no_run
6568/// # extern crate hyper;
6569/// # extern crate hyper_rustls;
6570/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
6571/// use cloudkms1_beta1::api::UpdateCryptoKeyPrimaryVersionRequest;
6572/// # async fn dox() {
6573/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6574///
6575/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6576/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6577/// #     .with_native_roots()
6578/// #     .unwrap()
6579/// #     .https_only()
6580/// #     .enable_http2()
6581/// #     .build();
6582///
6583/// # let executor = hyper_util::rt::TokioExecutor::new();
6584/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6585/// #     secret,
6586/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6587/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6588/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6589/// #     ),
6590/// # ).build().await.unwrap();
6591///
6592/// # let client = hyper_util::client::legacy::Client::builder(
6593/// #     hyper_util::rt::TokioExecutor::new()
6594/// # )
6595/// # .build(
6596/// #     hyper_rustls::HttpsConnectorBuilder::new()
6597/// #         .with_native_roots()
6598/// #         .unwrap()
6599/// #         .https_or_http()
6600/// #         .enable_http2()
6601/// #         .build()
6602/// # );
6603/// # let mut hub = CloudKMS::new(client, auth);
6604/// // As the method needs a request, you would usually fill it with the desired information
6605/// // into the respective structure. Some of the parts shown here might not be applicable !
6606/// // Values shown here are possibly random and not representative !
6607/// let mut req = UpdateCryptoKeyPrimaryVersionRequest::default();
6608///
6609/// // You can configure optional parameters by calling the respective setters at will, and
6610/// // execute the final call using `doit()`.
6611/// // Values shown here are possibly random and not representative !
6612/// let result = hub.projects().locations_key_rings_crypto_keys_update_primary_version(req, "name")
6613///              .doit().await;
6614/// # }
6615/// ```
6616pub struct ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
6617where
6618    C: 'a,
6619{
6620    hub: &'a CloudKMS<C>,
6621    _request: UpdateCryptoKeyPrimaryVersionRequest,
6622    _name: String,
6623    _delegate: Option<&'a mut dyn common::Delegate>,
6624    _additional_params: HashMap<String, String>,
6625    _scopes: BTreeSet<String>,
6626}
6627
6628impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {}
6629
6630impl<'a, C> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
6631where
6632    C: common::Connector,
6633{
6634    /// Perform the operation you have build so far.
6635    pub async fn doit(mut self) -> common::Result<(common::Response, CryptoKey)> {
6636        use std::borrow::Cow;
6637        use std::io::{Read, Seek};
6638
6639        use common::{url::Params, ToParts};
6640        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6641
6642        let mut dd = common::DefaultDelegate;
6643        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6644        dlg.begin(common::MethodInfo {
6645            id: "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion",
6646            http_method: hyper::Method::POST,
6647        });
6648
6649        for &field in ["alt", "name"].iter() {
6650            if self._additional_params.contains_key(field) {
6651                dlg.finished(false);
6652                return Err(common::Error::FieldClash(field));
6653            }
6654        }
6655
6656        let mut params = Params::with_capacity(4 + self._additional_params.len());
6657        params.push("name", self._name);
6658
6659        params.extend(self._additional_params.iter());
6660
6661        params.push("alt", "json");
6662        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:updatePrimaryVersion";
6663        if self._scopes.is_empty() {
6664            self._scopes
6665                .insert(Scope::CloudPlatform.as_ref().to_string());
6666        }
6667
6668        #[allow(clippy::single_element_loop)]
6669        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6670            url = params.uri_replacement(url, param_name, find_this, true);
6671        }
6672        {
6673            let to_remove = ["name"];
6674            params.remove_params(&to_remove);
6675        }
6676
6677        let url = params.parse_with_url(&url);
6678
6679        let mut json_mime_type = mime::APPLICATION_JSON;
6680        let mut request_value_reader = {
6681            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6682            common::remove_json_null_values(&mut value);
6683            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6684            serde_json::to_writer(&mut dst, &value).unwrap();
6685            dst
6686        };
6687        let request_size = request_value_reader
6688            .seek(std::io::SeekFrom::End(0))
6689            .unwrap();
6690        request_value_reader
6691            .seek(std::io::SeekFrom::Start(0))
6692            .unwrap();
6693
6694        loop {
6695            let token = match self
6696                .hub
6697                .auth
6698                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6699                .await
6700            {
6701                Ok(token) => token,
6702                Err(e) => match dlg.token(e) {
6703                    Ok(token) => token,
6704                    Err(e) => {
6705                        dlg.finished(false);
6706                        return Err(common::Error::MissingToken(e));
6707                    }
6708                },
6709            };
6710            request_value_reader
6711                .seek(std::io::SeekFrom::Start(0))
6712                .unwrap();
6713            let mut req_result = {
6714                let client = &self.hub.client;
6715                dlg.pre_request();
6716                let mut req_builder = hyper::Request::builder()
6717                    .method(hyper::Method::POST)
6718                    .uri(url.as_str())
6719                    .header(USER_AGENT, self.hub._user_agent.clone());
6720
6721                if let Some(token) = token.as_ref() {
6722                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6723                }
6724
6725                let request = req_builder
6726                    .header(CONTENT_TYPE, json_mime_type.to_string())
6727                    .header(CONTENT_LENGTH, request_size as u64)
6728                    .body(common::to_body(
6729                        request_value_reader.get_ref().clone().into(),
6730                    ));
6731
6732                client.request(request.unwrap()).await
6733            };
6734
6735            match req_result {
6736                Err(err) => {
6737                    if let common::Retry::After(d) = dlg.http_error(&err) {
6738                        sleep(d).await;
6739                        continue;
6740                    }
6741                    dlg.finished(false);
6742                    return Err(common::Error::HttpError(err));
6743                }
6744                Ok(res) => {
6745                    let (mut parts, body) = res.into_parts();
6746                    let mut body = common::Body::new(body);
6747                    if !parts.status.is_success() {
6748                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6749                        let error = serde_json::from_str(&common::to_string(&bytes));
6750                        let response = common::to_response(parts, bytes.into());
6751
6752                        if let common::Retry::After(d) =
6753                            dlg.http_failure(&response, error.as_ref().ok())
6754                        {
6755                            sleep(d).await;
6756                            continue;
6757                        }
6758
6759                        dlg.finished(false);
6760
6761                        return Err(match error {
6762                            Ok(value) => common::Error::BadRequest(value),
6763                            _ => common::Error::Failure(response),
6764                        });
6765                    }
6766                    let response = {
6767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6768                        let encoded = common::to_string(&bytes);
6769                        match serde_json::from_str(&encoded) {
6770                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6771                            Err(error) => {
6772                                dlg.response_json_decode_error(&encoded, &error);
6773                                return Err(common::Error::JsonDecodeError(
6774                                    encoded.to_string(),
6775                                    error,
6776                                ));
6777                            }
6778                        }
6779                    };
6780
6781                    dlg.finished(true);
6782                    return Ok(response);
6783                }
6784            }
6785        }
6786    }
6787
6788    ///
6789    /// Sets the *request* property to the given value.
6790    ///
6791    /// Even though the property as already been set when instantiating this call,
6792    /// we provide this method for API completeness.
6793    pub fn request(
6794        mut self,
6795        new_value: UpdateCryptoKeyPrimaryVersionRequest,
6796    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
6797        self._request = new_value;
6798        self
6799    }
6800    /// The resource name of the CryptoKey to update.
6801    ///
6802    /// Sets the *name* path property to the given value.
6803    ///
6804    /// Even though the property as already been set when instantiating this call,
6805    /// we provide this method for API completeness.
6806    pub fn name(
6807        mut self,
6808        new_value: &str,
6809    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
6810        self._name = new_value.to_string();
6811        self
6812    }
6813    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6814    /// while executing the actual API request.
6815    ///
6816    /// ````text
6817    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6818    /// ````
6819    ///
6820    /// Sets the *delegate* property to the given value.
6821    pub fn delegate(
6822        mut self,
6823        new_value: &'a mut dyn common::Delegate,
6824    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
6825        self._delegate = Some(new_value);
6826        self
6827    }
6828
6829    /// Set any additional parameter of the query string used in the request.
6830    /// It should be used to set parameters which are not yet available through their own
6831    /// setters.
6832    ///
6833    /// Please note that this method must not be used to set any of the known parameters
6834    /// which have their own setter method. If done anyway, the request will fail.
6835    ///
6836    /// # Additional Parameters
6837    ///
6838    /// * *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.
6839    /// * *access_token* (query-string) - OAuth access token.
6840    /// * *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.
6841    /// * *pp* (query-boolean) - Pretty-print response.
6842    /// * *bearer_token* (query-string) - OAuth bearer token.
6843    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6844    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6845    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6846    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6847    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6848    /// * *callback* (query-string) - JSONP
6849    /// * *$.xgafv* (query-string) - V1 error format.
6850    /// * *alt* (query-string) - Data format for response.
6851    pub fn param<T>(
6852        mut self,
6853        name: T,
6854        value: T,
6855    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
6856    where
6857        T: AsRef<str>,
6858    {
6859        self._additional_params
6860            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6861        self
6862    }
6863
6864    /// Identifies the authorization scope for the method you are building.
6865    ///
6866    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6867    /// [`Scope::CloudPlatform`].
6868    ///
6869    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6870    /// tokens for more than one scope.
6871    ///
6872    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6873    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6874    /// sufficient, a read-write scope will do as well.
6875    pub fn add_scope<St>(
6876        mut self,
6877        scope: St,
6878    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
6879    where
6880        St: AsRef<str>,
6881    {
6882        self._scopes.insert(String::from(scope.as_ref()));
6883        self
6884    }
6885    /// Identifies the authorization scope(s) for the method you are building.
6886    ///
6887    /// See [`Self::add_scope()`] for details.
6888    pub fn add_scopes<I, St>(
6889        mut self,
6890        scopes: I,
6891    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C>
6892    where
6893        I: IntoIterator<Item = St>,
6894        St: AsRef<str>,
6895    {
6896        self._scopes
6897            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6898        self
6899    }
6900
6901    /// Removes all scopes, and no default scope will be used either.
6902    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6903    /// for details).
6904    pub fn clear_scopes(
6905        mut self,
6906    ) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C> {
6907        self._scopes.clear();
6908        self
6909    }
6910}
6911
6912/// Gets the access control policy for a resource.
6913/// Returns an empty policy if the resource exists and does not have a policy
6914/// set.
6915///
6916/// A builder for the *locations.keyRings.cryptoKeys.getIamPolicy* method supported by a *project* resource.
6917/// It is not used directly, but through a [`ProjectMethods`] instance.
6918///
6919/// # Example
6920///
6921/// Instantiate a resource method builder
6922///
6923/// ```test_harness,no_run
6924/// # extern crate hyper;
6925/// # extern crate hyper_rustls;
6926/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
6927/// # async fn dox() {
6928/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6929///
6930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6932/// #     .with_native_roots()
6933/// #     .unwrap()
6934/// #     .https_only()
6935/// #     .enable_http2()
6936/// #     .build();
6937///
6938/// # let executor = hyper_util::rt::TokioExecutor::new();
6939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6940/// #     secret,
6941/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6942/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6943/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6944/// #     ),
6945/// # ).build().await.unwrap();
6946///
6947/// # let client = hyper_util::client::legacy::Client::builder(
6948/// #     hyper_util::rt::TokioExecutor::new()
6949/// # )
6950/// # .build(
6951/// #     hyper_rustls::HttpsConnectorBuilder::new()
6952/// #         .with_native_roots()
6953/// #         .unwrap()
6954/// #         .https_or_http()
6955/// #         .enable_http2()
6956/// #         .build()
6957/// # );
6958/// # let mut hub = CloudKMS::new(client, auth);
6959/// // You can configure optional parameters by calling the respective setters at will, and
6960/// // execute the final call using `doit()`.
6961/// // Values shown here are possibly random and not representative !
6962/// let result = hub.projects().locations_key_rings_crypto_keys_get_iam_policy("resource")
6963///              .doit().await;
6964/// # }
6965/// ```
6966pub struct ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
6967where
6968    C: 'a,
6969{
6970    hub: &'a CloudKMS<C>,
6971    _resource: String,
6972    _delegate: Option<&'a mut dyn common::Delegate>,
6973    _additional_params: HashMap<String, String>,
6974    _scopes: BTreeSet<String>,
6975}
6976
6977impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {}
6978
6979impl<'a, C> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
6980where
6981    C: common::Connector,
6982{
6983    /// Perform the operation you have build so far.
6984    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6985        use std::borrow::Cow;
6986        use std::io::{Read, Seek};
6987
6988        use common::{url::Params, ToParts};
6989        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6990
6991        let mut dd = common::DefaultDelegate;
6992        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6993        dlg.begin(common::MethodInfo {
6994            id: "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy",
6995            http_method: hyper::Method::GET,
6996        });
6997
6998        for &field in ["alt", "resource"].iter() {
6999            if self._additional_params.contains_key(field) {
7000                dlg.finished(false);
7001                return Err(common::Error::FieldClash(field));
7002            }
7003        }
7004
7005        let mut params = Params::with_capacity(3 + self._additional_params.len());
7006        params.push("resource", self._resource);
7007
7008        params.extend(self._additional_params.iter());
7009
7010        params.push("alt", "json");
7011        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
7012        if self._scopes.is_empty() {
7013            self._scopes
7014                .insert(Scope::CloudPlatform.as_ref().to_string());
7015        }
7016
7017        #[allow(clippy::single_element_loop)]
7018        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7019            url = params.uri_replacement(url, param_name, find_this, true);
7020        }
7021        {
7022            let to_remove = ["resource"];
7023            params.remove_params(&to_remove);
7024        }
7025
7026        let url = params.parse_with_url(&url);
7027
7028        loop {
7029            let token = match self
7030                .hub
7031                .auth
7032                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7033                .await
7034            {
7035                Ok(token) => token,
7036                Err(e) => match dlg.token(e) {
7037                    Ok(token) => token,
7038                    Err(e) => {
7039                        dlg.finished(false);
7040                        return Err(common::Error::MissingToken(e));
7041                    }
7042                },
7043            };
7044            let mut req_result = {
7045                let client = &self.hub.client;
7046                dlg.pre_request();
7047                let mut req_builder = hyper::Request::builder()
7048                    .method(hyper::Method::GET)
7049                    .uri(url.as_str())
7050                    .header(USER_AGENT, self.hub._user_agent.clone());
7051
7052                if let Some(token) = token.as_ref() {
7053                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7054                }
7055
7056                let request = req_builder
7057                    .header(CONTENT_LENGTH, 0_u64)
7058                    .body(common::to_body::<String>(None));
7059
7060                client.request(request.unwrap()).await
7061            };
7062
7063            match req_result {
7064                Err(err) => {
7065                    if let common::Retry::After(d) = dlg.http_error(&err) {
7066                        sleep(d).await;
7067                        continue;
7068                    }
7069                    dlg.finished(false);
7070                    return Err(common::Error::HttpError(err));
7071                }
7072                Ok(res) => {
7073                    let (mut parts, body) = res.into_parts();
7074                    let mut body = common::Body::new(body);
7075                    if !parts.status.is_success() {
7076                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7077                        let error = serde_json::from_str(&common::to_string(&bytes));
7078                        let response = common::to_response(parts, bytes.into());
7079
7080                        if let common::Retry::After(d) =
7081                            dlg.http_failure(&response, error.as_ref().ok())
7082                        {
7083                            sleep(d).await;
7084                            continue;
7085                        }
7086
7087                        dlg.finished(false);
7088
7089                        return Err(match error {
7090                            Ok(value) => common::Error::BadRequest(value),
7091                            _ => common::Error::Failure(response),
7092                        });
7093                    }
7094                    let response = {
7095                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7096                        let encoded = common::to_string(&bytes);
7097                        match serde_json::from_str(&encoded) {
7098                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7099                            Err(error) => {
7100                                dlg.response_json_decode_error(&encoded, &error);
7101                                return Err(common::Error::JsonDecodeError(
7102                                    encoded.to_string(),
7103                                    error,
7104                                ));
7105                            }
7106                        }
7107                    };
7108
7109                    dlg.finished(true);
7110                    return Ok(response);
7111                }
7112            }
7113        }
7114    }
7115
7116    /// REQUIRED: The resource for which the policy is being requested.
7117    /// See the operation documentation for the appropriate value for this field.
7118    ///
7119    /// Sets the *resource* path property to the given value.
7120    ///
7121    /// Even though the property as already been set when instantiating this call,
7122    /// we provide this method for API completeness.
7123    pub fn resource(
7124        mut self,
7125        new_value: &str,
7126    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
7127        self._resource = new_value.to_string();
7128        self
7129    }
7130    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7131    /// while executing the actual API request.
7132    ///
7133    /// ````text
7134    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7135    /// ````
7136    ///
7137    /// Sets the *delegate* property to the given value.
7138    pub fn delegate(
7139        mut self,
7140        new_value: &'a mut dyn common::Delegate,
7141    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
7142        self._delegate = Some(new_value);
7143        self
7144    }
7145
7146    /// Set any additional parameter of the query string used in the request.
7147    /// It should be used to set parameters which are not yet available through their own
7148    /// setters.
7149    ///
7150    /// Please note that this method must not be used to set any of the known parameters
7151    /// which have their own setter method. If done anyway, the request will fail.
7152    ///
7153    /// # Additional Parameters
7154    ///
7155    /// * *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.
7156    /// * *access_token* (query-string) - OAuth access token.
7157    /// * *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.
7158    /// * *pp* (query-boolean) - Pretty-print response.
7159    /// * *bearer_token* (query-string) - OAuth bearer token.
7160    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7161    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7162    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7163    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7164    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7165    /// * *callback* (query-string) - JSONP
7166    /// * *$.xgafv* (query-string) - V1 error format.
7167    /// * *alt* (query-string) - Data format for response.
7168    pub fn param<T>(
7169        mut self,
7170        name: T,
7171        value: T,
7172    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
7173    where
7174        T: AsRef<str>,
7175    {
7176        self._additional_params
7177            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7178        self
7179    }
7180
7181    /// Identifies the authorization scope for the method you are building.
7182    ///
7183    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7184    /// [`Scope::CloudPlatform`].
7185    ///
7186    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7187    /// tokens for more than one scope.
7188    ///
7189    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7190    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7191    /// sufficient, a read-write scope will do as well.
7192    pub fn add_scope<St>(
7193        mut self,
7194        scope: St,
7195    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
7196    where
7197        St: AsRef<str>,
7198    {
7199        self._scopes.insert(String::from(scope.as_ref()));
7200        self
7201    }
7202    /// Identifies the authorization scope(s) for the method you are building.
7203    ///
7204    /// See [`Self::add_scope()`] for details.
7205    pub fn add_scopes<I, St>(
7206        mut self,
7207        scopes: I,
7208    ) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C>
7209    where
7210        I: IntoIterator<Item = St>,
7211        St: AsRef<str>,
7212    {
7213        self._scopes
7214            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7215        self
7216    }
7217
7218    /// Removes all scopes, and no default scope will be used either.
7219    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7220    /// for details).
7221    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C> {
7222        self._scopes.clear();
7223        self
7224    }
7225}
7226
7227/// Gets the access control policy for a resource.
7228/// Returns an empty policy if the resource exists and does not have a policy
7229/// set.
7230///
7231/// A builder for the *locations.keyRings.getIamPolicy* method supported by a *project* resource.
7232/// It is not used directly, but through a [`ProjectMethods`] instance.
7233///
7234/// # Example
7235///
7236/// Instantiate a resource method builder
7237///
7238/// ```test_harness,no_run
7239/// # extern crate hyper;
7240/// # extern crate hyper_rustls;
7241/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
7242/// # async fn dox() {
7243/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7244///
7245/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7246/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7247/// #     .with_native_roots()
7248/// #     .unwrap()
7249/// #     .https_only()
7250/// #     .enable_http2()
7251/// #     .build();
7252///
7253/// # let executor = hyper_util::rt::TokioExecutor::new();
7254/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7255/// #     secret,
7256/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7257/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7258/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7259/// #     ),
7260/// # ).build().await.unwrap();
7261///
7262/// # let client = hyper_util::client::legacy::Client::builder(
7263/// #     hyper_util::rt::TokioExecutor::new()
7264/// # )
7265/// # .build(
7266/// #     hyper_rustls::HttpsConnectorBuilder::new()
7267/// #         .with_native_roots()
7268/// #         .unwrap()
7269/// #         .https_or_http()
7270/// #         .enable_http2()
7271/// #         .build()
7272/// # );
7273/// # let mut hub = CloudKMS::new(client, auth);
7274/// // You can configure optional parameters by calling the respective setters at will, and
7275/// // execute the final call using `doit()`.
7276/// // Values shown here are possibly random and not representative !
7277/// let result = hub.projects().locations_key_rings_get_iam_policy("resource")
7278///              .doit().await;
7279/// # }
7280/// ```
7281pub struct ProjectLocationKeyRingGetIamPolicyCall<'a, C>
7282where
7283    C: 'a,
7284{
7285    hub: &'a CloudKMS<C>,
7286    _resource: String,
7287    _delegate: Option<&'a mut dyn common::Delegate>,
7288    _additional_params: HashMap<String, String>,
7289    _scopes: BTreeSet<String>,
7290}
7291
7292impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetIamPolicyCall<'a, C> {}
7293
7294impl<'a, C> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
7295where
7296    C: common::Connector,
7297{
7298    /// Perform the operation you have build so far.
7299    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7300        use std::borrow::Cow;
7301        use std::io::{Read, Seek};
7302
7303        use common::{url::Params, ToParts};
7304        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7305
7306        let mut dd = common::DefaultDelegate;
7307        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7308        dlg.begin(common::MethodInfo {
7309            id: "cloudkms.projects.locations.keyRings.getIamPolicy",
7310            http_method: hyper::Method::GET,
7311        });
7312
7313        for &field in ["alt", "resource"].iter() {
7314            if self._additional_params.contains_key(field) {
7315                dlg.finished(false);
7316                return Err(common::Error::FieldClash(field));
7317            }
7318        }
7319
7320        let mut params = Params::with_capacity(3 + self._additional_params.len());
7321        params.push("resource", self._resource);
7322
7323        params.extend(self._additional_params.iter());
7324
7325        params.push("alt", "json");
7326        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
7327        if self._scopes.is_empty() {
7328            self._scopes
7329                .insert(Scope::CloudPlatform.as_ref().to_string());
7330        }
7331
7332        #[allow(clippy::single_element_loop)]
7333        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7334            url = params.uri_replacement(url, param_name, find_this, true);
7335        }
7336        {
7337            let to_remove = ["resource"];
7338            params.remove_params(&to_remove);
7339        }
7340
7341        let url = params.parse_with_url(&url);
7342
7343        loop {
7344            let token = match self
7345                .hub
7346                .auth
7347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7348                .await
7349            {
7350                Ok(token) => token,
7351                Err(e) => match dlg.token(e) {
7352                    Ok(token) => token,
7353                    Err(e) => {
7354                        dlg.finished(false);
7355                        return Err(common::Error::MissingToken(e));
7356                    }
7357                },
7358            };
7359            let mut req_result = {
7360                let client = &self.hub.client;
7361                dlg.pre_request();
7362                let mut req_builder = hyper::Request::builder()
7363                    .method(hyper::Method::GET)
7364                    .uri(url.as_str())
7365                    .header(USER_AGENT, self.hub._user_agent.clone());
7366
7367                if let Some(token) = token.as_ref() {
7368                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7369                }
7370
7371                let request = req_builder
7372                    .header(CONTENT_LENGTH, 0_u64)
7373                    .body(common::to_body::<String>(None));
7374
7375                client.request(request.unwrap()).await
7376            };
7377
7378            match req_result {
7379                Err(err) => {
7380                    if let common::Retry::After(d) = dlg.http_error(&err) {
7381                        sleep(d).await;
7382                        continue;
7383                    }
7384                    dlg.finished(false);
7385                    return Err(common::Error::HttpError(err));
7386                }
7387                Ok(res) => {
7388                    let (mut parts, body) = res.into_parts();
7389                    let mut body = common::Body::new(body);
7390                    if !parts.status.is_success() {
7391                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7392                        let error = serde_json::from_str(&common::to_string(&bytes));
7393                        let response = common::to_response(parts, bytes.into());
7394
7395                        if let common::Retry::After(d) =
7396                            dlg.http_failure(&response, error.as_ref().ok())
7397                        {
7398                            sleep(d).await;
7399                            continue;
7400                        }
7401
7402                        dlg.finished(false);
7403
7404                        return Err(match error {
7405                            Ok(value) => common::Error::BadRequest(value),
7406                            _ => common::Error::Failure(response),
7407                        });
7408                    }
7409                    let response = {
7410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7411                        let encoded = common::to_string(&bytes);
7412                        match serde_json::from_str(&encoded) {
7413                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7414                            Err(error) => {
7415                                dlg.response_json_decode_error(&encoded, &error);
7416                                return Err(common::Error::JsonDecodeError(
7417                                    encoded.to_string(),
7418                                    error,
7419                                ));
7420                            }
7421                        }
7422                    };
7423
7424                    dlg.finished(true);
7425                    return Ok(response);
7426                }
7427            }
7428        }
7429    }
7430
7431    /// REQUIRED: The resource for which the policy is being requested.
7432    /// See the operation documentation for the appropriate value for this field.
7433    ///
7434    /// Sets the *resource* path property to the given value.
7435    ///
7436    /// Even though the property as already been set when instantiating this call,
7437    /// we provide this method for API completeness.
7438    pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
7439        self._resource = new_value.to_string();
7440        self
7441    }
7442    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7443    /// while executing the actual API request.
7444    ///
7445    /// ````text
7446    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7447    /// ````
7448    ///
7449    /// Sets the *delegate* property to the given value.
7450    pub fn delegate(
7451        mut self,
7452        new_value: &'a mut dyn common::Delegate,
7453    ) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
7454        self._delegate = Some(new_value);
7455        self
7456    }
7457
7458    /// Set any additional parameter of the query string used in the request.
7459    /// It should be used to set parameters which are not yet available through their own
7460    /// setters.
7461    ///
7462    /// Please note that this method must not be used to set any of the known parameters
7463    /// which have their own setter method. If done anyway, the request will fail.
7464    ///
7465    /// # Additional Parameters
7466    ///
7467    /// * *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.
7468    /// * *access_token* (query-string) - OAuth access token.
7469    /// * *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.
7470    /// * *pp* (query-boolean) - Pretty-print response.
7471    /// * *bearer_token* (query-string) - OAuth bearer token.
7472    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7473    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7474    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7475    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7476    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7477    /// * *callback* (query-string) - JSONP
7478    /// * *$.xgafv* (query-string) - V1 error format.
7479    /// * *alt* (query-string) - Data format for response.
7480    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
7481    where
7482        T: AsRef<str>,
7483    {
7484        self._additional_params
7485            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7486        self
7487    }
7488
7489    /// Identifies the authorization scope for the method you are building.
7490    ///
7491    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7492    /// [`Scope::CloudPlatform`].
7493    ///
7494    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7495    /// tokens for more than one scope.
7496    ///
7497    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7498    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7499    /// sufficient, a read-write scope will do as well.
7500    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
7501    where
7502        St: AsRef<str>,
7503    {
7504        self._scopes.insert(String::from(scope.as_ref()));
7505        self
7506    }
7507    /// Identifies the authorization scope(s) for the method you are building.
7508    ///
7509    /// See [`Self::add_scope()`] for details.
7510    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C>
7511    where
7512        I: IntoIterator<Item = St>,
7513        St: AsRef<str>,
7514    {
7515        self._scopes
7516            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7517        self
7518    }
7519
7520    /// Removes all scopes, and no default scope will be used either.
7521    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7522    /// for details).
7523    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C> {
7524        self._scopes.clear();
7525        self
7526    }
7527}
7528
7529/// Returns metadata for a given KeyRing.
7530///
7531/// A builder for the *locations.keyRings.get* method supported by a *project* resource.
7532/// It is not used directly, but through a [`ProjectMethods`] instance.
7533///
7534/// # Example
7535///
7536/// Instantiate a resource method builder
7537///
7538/// ```test_harness,no_run
7539/// # extern crate hyper;
7540/// # extern crate hyper_rustls;
7541/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
7542/// # async fn dox() {
7543/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7544///
7545/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7546/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7547/// #     .with_native_roots()
7548/// #     .unwrap()
7549/// #     .https_only()
7550/// #     .enable_http2()
7551/// #     .build();
7552///
7553/// # let executor = hyper_util::rt::TokioExecutor::new();
7554/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7555/// #     secret,
7556/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7557/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7558/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7559/// #     ),
7560/// # ).build().await.unwrap();
7561///
7562/// # let client = hyper_util::client::legacy::Client::builder(
7563/// #     hyper_util::rt::TokioExecutor::new()
7564/// # )
7565/// # .build(
7566/// #     hyper_rustls::HttpsConnectorBuilder::new()
7567/// #         .with_native_roots()
7568/// #         .unwrap()
7569/// #         .https_or_http()
7570/// #         .enable_http2()
7571/// #         .build()
7572/// # );
7573/// # let mut hub = CloudKMS::new(client, auth);
7574/// // You can configure optional parameters by calling the respective setters at will, and
7575/// // execute the final call using `doit()`.
7576/// // Values shown here are possibly random and not representative !
7577/// let result = hub.projects().locations_key_rings_get("name")
7578///              .doit().await;
7579/// # }
7580/// ```
7581pub struct ProjectLocationKeyRingGetCall<'a, C>
7582where
7583    C: 'a,
7584{
7585    hub: &'a CloudKMS<C>,
7586    _name: String,
7587    _delegate: Option<&'a mut dyn common::Delegate>,
7588    _additional_params: HashMap<String, String>,
7589    _scopes: BTreeSet<String>,
7590}
7591
7592impl<'a, C> common::CallBuilder for ProjectLocationKeyRingGetCall<'a, C> {}
7593
7594impl<'a, C> ProjectLocationKeyRingGetCall<'a, C>
7595where
7596    C: common::Connector,
7597{
7598    /// Perform the operation you have build so far.
7599    pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
7600        use std::borrow::Cow;
7601        use std::io::{Read, Seek};
7602
7603        use common::{url::Params, ToParts};
7604        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7605
7606        let mut dd = common::DefaultDelegate;
7607        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7608        dlg.begin(common::MethodInfo {
7609            id: "cloudkms.projects.locations.keyRings.get",
7610            http_method: hyper::Method::GET,
7611        });
7612
7613        for &field in ["alt", "name"].iter() {
7614            if self._additional_params.contains_key(field) {
7615                dlg.finished(false);
7616                return Err(common::Error::FieldClash(field));
7617            }
7618        }
7619
7620        let mut params = Params::with_capacity(3 + self._additional_params.len());
7621        params.push("name", self._name);
7622
7623        params.extend(self._additional_params.iter());
7624
7625        params.push("alt", "json");
7626        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7627        if self._scopes.is_empty() {
7628            self._scopes
7629                .insert(Scope::CloudPlatform.as_ref().to_string());
7630        }
7631
7632        #[allow(clippy::single_element_loop)]
7633        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7634            url = params.uri_replacement(url, param_name, find_this, true);
7635        }
7636        {
7637            let to_remove = ["name"];
7638            params.remove_params(&to_remove);
7639        }
7640
7641        let url = params.parse_with_url(&url);
7642
7643        loop {
7644            let token = match self
7645                .hub
7646                .auth
7647                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7648                .await
7649            {
7650                Ok(token) => token,
7651                Err(e) => match dlg.token(e) {
7652                    Ok(token) => token,
7653                    Err(e) => {
7654                        dlg.finished(false);
7655                        return Err(common::Error::MissingToken(e));
7656                    }
7657                },
7658            };
7659            let mut req_result = {
7660                let client = &self.hub.client;
7661                dlg.pre_request();
7662                let mut req_builder = hyper::Request::builder()
7663                    .method(hyper::Method::GET)
7664                    .uri(url.as_str())
7665                    .header(USER_AGENT, self.hub._user_agent.clone());
7666
7667                if let Some(token) = token.as_ref() {
7668                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7669                }
7670
7671                let request = req_builder
7672                    .header(CONTENT_LENGTH, 0_u64)
7673                    .body(common::to_body::<String>(None));
7674
7675                client.request(request.unwrap()).await
7676            };
7677
7678            match req_result {
7679                Err(err) => {
7680                    if let common::Retry::After(d) = dlg.http_error(&err) {
7681                        sleep(d).await;
7682                        continue;
7683                    }
7684                    dlg.finished(false);
7685                    return Err(common::Error::HttpError(err));
7686                }
7687                Ok(res) => {
7688                    let (mut parts, body) = res.into_parts();
7689                    let mut body = common::Body::new(body);
7690                    if !parts.status.is_success() {
7691                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7692                        let error = serde_json::from_str(&common::to_string(&bytes));
7693                        let response = common::to_response(parts, bytes.into());
7694
7695                        if let common::Retry::After(d) =
7696                            dlg.http_failure(&response, error.as_ref().ok())
7697                        {
7698                            sleep(d).await;
7699                            continue;
7700                        }
7701
7702                        dlg.finished(false);
7703
7704                        return Err(match error {
7705                            Ok(value) => common::Error::BadRequest(value),
7706                            _ => common::Error::Failure(response),
7707                        });
7708                    }
7709                    let response = {
7710                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7711                        let encoded = common::to_string(&bytes);
7712                        match serde_json::from_str(&encoded) {
7713                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7714                            Err(error) => {
7715                                dlg.response_json_decode_error(&encoded, &error);
7716                                return Err(common::Error::JsonDecodeError(
7717                                    encoded.to_string(),
7718                                    error,
7719                                ));
7720                            }
7721                        }
7722                    };
7723
7724                    dlg.finished(true);
7725                    return Ok(response);
7726                }
7727            }
7728        }
7729    }
7730
7731    /// The name of the KeyRing to get.
7732    ///
7733    /// Sets the *name* path property to the given value.
7734    ///
7735    /// Even though the property as already been set when instantiating this call,
7736    /// we provide this method for API completeness.
7737    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyRingGetCall<'a, C> {
7738        self._name = new_value.to_string();
7739        self
7740    }
7741    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7742    /// while executing the actual API request.
7743    ///
7744    /// ````text
7745    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7746    /// ````
7747    ///
7748    /// Sets the *delegate* property to the given value.
7749    pub fn delegate(
7750        mut self,
7751        new_value: &'a mut dyn common::Delegate,
7752    ) -> ProjectLocationKeyRingGetCall<'a, C> {
7753        self._delegate = Some(new_value);
7754        self
7755    }
7756
7757    /// Set any additional parameter of the query string used in the request.
7758    /// It should be used to set parameters which are not yet available through their own
7759    /// setters.
7760    ///
7761    /// Please note that this method must not be used to set any of the known parameters
7762    /// which have their own setter method. If done anyway, the request will fail.
7763    ///
7764    /// # Additional Parameters
7765    ///
7766    /// * *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.
7767    /// * *access_token* (query-string) - OAuth access token.
7768    /// * *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.
7769    /// * *pp* (query-boolean) - Pretty-print response.
7770    /// * *bearer_token* (query-string) - OAuth bearer token.
7771    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7772    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7774    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7775    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7776    /// * *callback* (query-string) - JSONP
7777    /// * *$.xgafv* (query-string) - V1 error format.
7778    /// * *alt* (query-string) - Data format for response.
7779    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingGetCall<'a, C>
7780    where
7781        T: AsRef<str>,
7782    {
7783        self._additional_params
7784            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7785        self
7786    }
7787
7788    /// Identifies the authorization scope for the method you are building.
7789    ///
7790    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7791    /// [`Scope::CloudPlatform`].
7792    ///
7793    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7794    /// tokens for more than one scope.
7795    ///
7796    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7797    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7798    /// sufficient, a read-write scope will do as well.
7799    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingGetCall<'a, C>
7800    where
7801        St: AsRef<str>,
7802    {
7803        self._scopes.insert(String::from(scope.as_ref()));
7804        self
7805    }
7806    /// Identifies the authorization scope(s) for the method you are building.
7807    ///
7808    /// See [`Self::add_scope()`] for details.
7809    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingGetCall<'a, C>
7810    where
7811        I: IntoIterator<Item = St>,
7812        St: AsRef<str>,
7813    {
7814        self._scopes
7815            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7816        self
7817    }
7818
7819    /// Removes all scopes, and no default scope will be used either.
7820    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7821    /// for details).
7822    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingGetCall<'a, C> {
7823        self._scopes.clear();
7824        self
7825    }
7826}
7827
7828/// Returns permissions that a caller has on the specified resource.
7829/// If the resource does not exist, this will return an empty set of
7830/// permissions, not a NOT_FOUND error.
7831///
7832/// Note: This operation is designed to be used for building permission-aware
7833/// UIs and command-line tools, not for authorization checking. This operation
7834/// may "fail open" without warning.
7835///
7836/// A builder for the *locations.keyRings.testIamPermissions* method supported by a *project* resource.
7837/// It is not used directly, but through a [`ProjectMethods`] instance.
7838///
7839/// # Example
7840///
7841/// Instantiate a resource method builder
7842///
7843/// ```test_harness,no_run
7844/// # extern crate hyper;
7845/// # extern crate hyper_rustls;
7846/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
7847/// use cloudkms1_beta1::api::TestIamPermissionsRequest;
7848/// # async fn dox() {
7849/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7850///
7851/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7852/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7853/// #     .with_native_roots()
7854/// #     .unwrap()
7855/// #     .https_only()
7856/// #     .enable_http2()
7857/// #     .build();
7858///
7859/// # let executor = hyper_util::rt::TokioExecutor::new();
7860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7861/// #     secret,
7862/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7863/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7864/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7865/// #     ),
7866/// # ).build().await.unwrap();
7867///
7868/// # let client = hyper_util::client::legacy::Client::builder(
7869/// #     hyper_util::rt::TokioExecutor::new()
7870/// # )
7871/// # .build(
7872/// #     hyper_rustls::HttpsConnectorBuilder::new()
7873/// #         .with_native_roots()
7874/// #         .unwrap()
7875/// #         .https_or_http()
7876/// #         .enable_http2()
7877/// #         .build()
7878/// # );
7879/// # let mut hub = CloudKMS::new(client, auth);
7880/// // As the method needs a request, you would usually fill it with the desired information
7881/// // into the respective structure. Some of the parts shown here might not be applicable !
7882/// // Values shown here are possibly random and not representative !
7883/// let mut req = TestIamPermissionsRequest::default();
7884///
7885/// // You can configure optional parameters by calling the respective setters at will, and
7886/// // execute the final call using `doit()`.
7887/// // Values shown here are possibly random and not representative !
7888/// let result = hub.projects().locations_key_rings_test_iam_permissions(req, "resource")
7889///              .doit().await;
7890/// # }
7891/// ```
7892pub struct ProjectLocationKeyRingTestIamPermissionCall<'a, C>
7893where
7894    C: 'a,
7895{
7896    hub: &'a CloudKMS<C>,
7897    _request: TestIamPermissionsRequest,
7898    _resource: String,
7899    _delegate: Option<&'a mut dyn common::Delegate>,
7900    _additional_params: HashMap<String, String>,
7901    _scopes: BTreeSet<String>,
7902}
7903
7904impl<'a, C> common::CallBuilder for ProjectLocationKeyRingTestIamPermissionCall<'a, C> {}
7905
7906impl<'a, C> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
7907where
7908    C: common::Connector,
7909{
7910    /// Perform the operation you have build so far.
7911    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
7912        use std::borrow::Cow;
7913        use std::io::{Read, Seek};
7914
7915        use common::{url::Params, ToParts};
7916        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7917
7918        let mut dd = common::DefaultDelegate;
7919        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7920        dlg.begin(common::MethodInfo {
7921            id: "cloudkms.projects.locations.keyRings.testIamPermissions",
7922            http_method: hyper::Method::POST,
7923        });
7924
7925        for &field in ["alt", "resource"].iter() {
7926            if self._additional_params.contains_key(field) {
7927                dlg.finished(false);
7928                return Err(common::Error::FieldClash(field));
7929            }
7930        }
7931
7932        let mut params = Params::with_capacity(4 + self._additional_params.len());
7933        params.push("resource", self._resource);
7934
7935        params.extend(self._additional_params.iter());
7936
7937        params.push("alt", "json");
7938        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
7939        if self._scopes.is_empty() {
7940            self._scopes
7941                .insert(Scope::CloudPlatform.as_ref().to_string());
7942        }
7943
7944        #[allow(clippy::single_element_loop)]
7945        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7946            url = params.uri_replacement(url, param_name, find_this, true);
7947        }
7948        {
7949            let to_remove = ["resource"];
7950            params.remove_params(&to_remove);
7951        }
7952
7953        let url = params.parse_with_url(&url);
7954
7955        let mut json_mime_type = mime::APPLICATION_JSON;
7956        let mut request_value_reader = {
7957            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7958            common::remove_json_null_values(&mut value);
7959            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7960            serde_json::to_writer(&mut dst, &value).unwrap();
7961            dst
7962        };
7963        let request_size = request_value_reader
7964            .seek(std::io::SeekFrom::End(0))
7965            .unwrap();
7966        request_value_reader
7967            .seek(std::io::SeekFrom::Start(0))
7968            .unwrap();
7969
7970        loop {
7971            let token = match self
7972                .hub
7973                .auth
7974                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7975                .await
7976            {
7977                Ok(token) => token,
7978                Err(e) => match dlg.token(e) {
7979                    Ok(token) => token,
7980                    Err(e) => {
7981                        dlg.finished(false);
7982                        return Err(common::Error::MissingToken(e));
7983                    }
7984                },
7985            };
7986            request_value_reader
7987                .seek(std::io::SeekFrom::Start(0))
7988                .unwrap();
7989            let mut req_result = {
7990                let client = &self.hub.client;
7991                dlg.pre_request();
7992                let mut req_builder = hyper::Request::builder()
7993                    .method(hyper::Method::POST)
7994                    .uri(url.as_str())
7995                    .header(USER_AGENT, self.hub._user_agent.clone());
7996
7997                if let Some(token) = token.as_ref() {
7998                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7999                }
8000
8001                let request = req_builder
8002                    .header(CONTENT_TYPE, json_mime_type.to_string())
8003                    .header(CONTENT_LENGTH, request_size as u64)
8004                    .body(common::to_body(
8005                        request_value_reader.get_ref().clone().into(),
8006                    ));
8007
8008                client.request(request.unwrap()).await
8009            };
8010
8011            match req_result {
8012                Err(err) => {
8013                    if let common::Retry::After(d) = dlg.http_error(&err) {
8014                        sleep(d).await;
8015                        continue;
8016                    }
8017                    dlg.finished(false);
8018                    return Err(common::Error::HttpError(err));
8019                }
8020                Ok(res) => {
8021                    let (mut parts, body) = res.into_parts();
8022                    let mut body = common::Body::new(body);
8023                    if !parts.status.is_success() {
8024                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8025                        let error = serde_json::from_str(&common::to_string(&bytes));
8026                        let response = common::to_response(parts, bytes.into());
8027
8028                        if let common::Retry::After(d) =
8029                            dlg.http_failure(&response, error.as_ref().ok())
8030                        {
8031                            sleep(d).await;
8032                            continue;
8033                        }
8034
8035                        dlg.finished(false);
8036
8037                        return Err(match error {
8038                            Ok(value) => common::Error::BadRequest(value),
8039                            _ => common::Error::Failure(response),
8040                        });
8041                    }
8042                    let response = {
8043                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8044                        let encoded = common::to_string(&bytes);
8045                        match serde_json::from_str(&encoded) {
8046                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8047                            Err(error) => {
8048                                dlg.response_json_decode_error(&encoded, &error);
8049                                return Err(common::Error::JsonDecodeError(
8050                                    encoded.to_string(),
8051                                    error,
8052                                ));
8053                            }
8054                        }
8055                    };
8056
8057                    dlg.finished(true);
8058                    return Ok(response);
8059                }
8060            }
8061        }
8062    }
8063
8064    ///
8065    /// Sets the *request* property to the given value.
8066    ///
8067    /// Even though the property as already been set when instantiating this call,
8068    /// we provide this method for API completeness.
8069    pub fn request(
8070        mut self,
8071        new_value: TestIamPermissionsRequest,
8072    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
8073        self._request = new_value;
8074        self
8075    }
8076    /// REQUIRED: The resource for which the policy detail is being requested.
8077    /// See the operation documentation for the appropriate value for this field.
8078    ///
8079    /// Sets the *resource* path property to the given value.
8080    ///
8081    /// Even though the property as already been set when instantiating this call,
8082    /// we provide this method for API completeness.
8083    pub fn resource(
8084        mut self,
8085        new_value: &str,
8086    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
8087        self._resource = new_value.to_string();
8088        self
8089    }
8090    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8091    /// while executing the actual API request.
8092    ///
8093    /// ````text
8094    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8095    /// ````
8096    ///
8097    /// Sets the *delegate* property to the given value.
8098    pub fn delegate(
8099        mut self,
8100        new_value: &'a mut dyn common::Delegate,
8101    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
8102        self._delegate = Some(new_value);
8103        self
8104    }
8105
8106    /// Set any additional parameter of the query string used in the request.
8107    /// It should be used to set parameters which are not yet available through their own
8108    /// setters.
8109    ///
8110    /// Please note that this method must not be used to set any of the known parameters
8111    /// which have their own setter method. If done anyway, the request will fail.
8112    ///
8113    /// # Additional Parameters
8114    ///
8115    /// * *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.
8116    /// * *access_token* (query-string) - OAuth access token.
8117    /// * *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.
8118    /// * *pp* (query-boolean) - Pretty-print response.
8119    /// * *bearer_token* (query-string) - OAuth bearer token.
8120    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8121    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8122    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8123    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8124    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8125    /// * *callback* (query-string) - JSONP
8126    /// * *$.xgafv* (query-string) - V1 error format.
8127    /// * *alt* (query-string) - Data format for response.
8128    pub fn param<T>(
8129        mut self,
8130        name: T,
8131        value: T,
8132    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
8133    where
8134        T: AsRef<str>,
8135    {
8136        self._additional_params
8137            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8138        self
8139    }
8140
8141    /// Identifies the authorization scope for the method you are building.
8142    ///
8143    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8144    /// [`Scope::CloudPlatform`].
8145    ///
8146    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8147    /// tokens for more than one scope.
8148    ///
8149    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8150    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8151    /// sufficient, a read-write scope will do as well.
8152    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
8153    where
8154        St: AsRef<str>,
8155    {
8156        self._scopes.insert(String::from(scope.as_ref()));
8157        self
8158    }
8159    /// Identifies the authorization scope(s) for the method you are building.
8160    ///
8161    /// See [`Self::add_scope()`] for details.
8162    pub fn add_scopes<I, St>(
8163        mut self,
8164        scopes: I,
8165    ) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C>
8166    where
8167        I: IntoIterator<Item = St>,
8168        St: AsRef<str>,
8169    {
8170        self._scopes
8171            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8172        self
8173    }
8174
8175    /// Removes all scopes, and no default scope will be used either.
8176    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8177    /// for details).
8178    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C> {
8179        self._scopes.clear();
8180        self
8181    }
8182}
8183
8184/// Lists KeyRings.
8185///
8186/// A builder for the *locations.keyRings.list* method supported by a *project* resource.
8187/// It is not used directly, but through a [`ProjectMethods`] instance.
8188///
8189/// # Example
8190///
8191/// Instantiate a resource method builder
8192///
8193/// ```test_harness,no_run
8194/// # extern crate hyper;
8195/// # extern crate hyper_rustls;
8196/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
8197/// # async fn dox() {
8198/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8199///
8200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8201/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8202/// #     .with_native_roots()
8203/// #     .unwrap()
8204/// #     .https_only()
8205/// #     .enable_http2()
8206/// #     .build();
8207///
8208/// # let executor = hyper_util::rt::TokioExecutor::new();
8209/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8210/// #     secret,
8211/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8212/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8213/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8214/// #     ),
8215/// # ).build().await.unwrap();
8216///
8217/// # let client = hyper_util::client::legacy::Client::builder(
8218/// #     hyper_util::rt::TokioExecutor::new()
8219/// # )
8220/// # .build(
8221/// #     hyper_rustls::HttpsConnectorBuilder::new()
8222/// #         .with_native_roots()
8223/// #         .unwrap()
8224/// #         .https_or_http()
8225/// #         .enable_http2()
8226/// #         .build()
8227/// # );
8228/// # let mut hub = CloudKMS::new(client, auth);
8229/// // You can configure optional parameters by calling the respective setters at will, and
8230/// // execute the final call using `doit()`.
8231/// // Values shown here are possibly random and not representative !
8232/// let result = hub.projects().locations_key_rings_list("parent")
8233///              .page_token("est")
8234///              .page_size(-50)
8235///              .doit().await;
8236/// # }
8237/// ```
8238pub struct ProjectLocationKeyRingListCall<'a, C>
8239where
8240    C: 'a,
8241{
8242    hub: &'a CloudKMS<C>,
8243    _parent: String,
8244    _page_token: Option<String>,
8245    _page_size: Option<i32>,
8246    _delegate: Option<&'a mut dyn common::Delegate>,
8247    _additional_params: HashMap<String, String>,
8248    _scopes: BTreeSet<String>,
8249}
8250
8251impl<'a, C> common::CallBuilder for ProjectLocationKeyRingListCall<'a, C> {}
8252
8253impl<'a, C> ProjectLocationKeyRingListCall<'a, C>
8254where
8255    C: common::Connector,
8256{
8257    /// Perform the operation you have build so far.
8258    pub async fn doit(mut self) -> common::Result<(common::Response, ListKeyRingsResponse)> {
8259        use std::borrow::Cow;
8260        use std::io::{Read, Seek};
8261
8262        use common::{url::Params, ToParts};
8263        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8264
8265        let mut dd = common::DefaultDelegate;
8266        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8267        dlg.begin(common::MethodInfo {
8268            id: "cloudkms.projects.locations.keyRings.list",
8269            http_method: hyper::Method::GET,
8270        });
8271
8272        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8273            if self._additional_params.contains_key(field) {
8274                dlg.finished(false);
8275                return Err(common::Error::FieldClash(field));
8276            }
8277        }
8278
8279        let mut params = Params::with_capacity(5 + self._additional_params.len());
8280        params.push("parent", self._parent);
8281        if let Some(value) = self._page_token.as_ref() {
8282            params.push("pageToken", value);
8283        }
8284        if let Some(value) = self._page_size.as_ref() {
8285            params.push("pageSize", value.to_string());
8286        }
8287
8288        params.extend(self._additional_params.iter());
8289
8290        params.push("alt", "json");
8291        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/keyRings";
8292        if self._scopes.is_empty() {
8293            self._scopes
8294                .insert(Scope::CloudPlatform.as_ref().to_string());
8295        }
8296
8297        #[allow(clippy::single_element_loop)]
8298        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8299            url = params.uri_replacement(url, param_name, find_this, true);
8300        }
8301        {
8302            let to_remove = ["parent"];
8303            params.remove_params(&to_remove);
8304        }
8305
8306        let url = params.parse_with_url(&url);
8307
8308        loop {
8309            let token = match self
8310                .hub
8311                .auth
8312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8313                .await
8314            {
8315                Ok(token) => token,
8316                Err(e) => match dlg.token(e) {
8317                    Ok(token) => token,
8318                    Err(e) => {
8319                        dlg.finished(false);
8320                        return Err(common::Error::MissingToken(e));
8321                    }
8322                },
8323            };
8324            let mut req_result = {
8325                let client = &self.hub.client;
8326                dlg.pre_request();
8327                let mut req_builder = hyper::Request::builder()
8328                    .method(hyper::Method::GET)
8329                    .uri(url.as_str())
8330                    .header(USER_AGENT, self.hub._user_agent.clone());
8331
8332                if let Some(token) = token.as_ref() {
8333                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8334                }
8335
8336                let request = req_builder
8337                    .header(CONTENT_LENGTH, 0_u64)
8338                    .body(common::to_body::<String>(None));
8339
8340                client.request(request.unwrap()).await
8341            };
8342
8343            match req_result {
8344                Err(err) => {
8345                    if let common::Retry::After(d) = dlg.http_error(&err) {
8346                        sleep(d).await;
8347                        continue;
8348                    }
8349                    dlg.finished(false);
8350                    return Err(common::Error::HttpError(err));
8351                }
8352                Ok(res) => {
8353                    let (mut parts, body) = res.into_parts();
8354                    let mut body = common::Body::new(body);
8355                    if !parts.status.is_success() {
8356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8357                        let error = serde_json::from_str(&common::to_string(&bytes));
8358                        let response = common::to_response(parts, bytes.into());
8359
8360                        if let common::Retry::After(d) =
8361                            dlg.http_failure(&response, error.as_ref().ok())
8362                        {
8363                            sleep(d).await;
8364                            continue;
8365                        }
8366
8367                        dlg.finished(false);
8368
8369                        return Err(match error {
8370                            Ok(value) => common::Error::BadRequest(value),
8371                            _ => common::Error::Failure(response),
8372                        });
8373                    }
8374                    let response = {
8375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8376                        let encoded = common::to_string(&bytes);
8377                        match serde_json::from_str(&encoded) {
8378                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8379                            Err(error) => {
8380                                dlg.response_json_decode_error(&encoded, &error);
8381                                return Err(common::Error::JsonDecodeError(
8382                                    encoded.to_string(),
8383                                    error,
8384                                ));
8385                            }
8386                        }
8387                    };
8388
8389                    dlg.finished(true);
8390                    return Ok(response);
8391                }
8392            }
8393        }
8394    }
8395
8396    /// Required. The resource name of the location associated with the
8397    /// KeyRings, in the format `projects/*/locations/*`.
8398    ///
8399    /// Sets the *parent* path property to the given value.
8400    ///
8401    /// Even though the property as already been set when instantiating this call,
8402    /// we provide this method for API completeness.
8403    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
8404        self._parent = new_value.to_string();
8405        self
8406    }
8407    /// Optional pagination token, returned earlier via
8408    /// ListKeyRingsResponse.next_page_token.
8409    ///
8410    /// Sets the *page token* query property to the given value.
8411    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C> {
8412        self._page_token = Some(new_value.to_string());
8413        self
8414    }
8415    /// Optional limit on the number of KeyRings to include in the
8416    /// response.  Further KeyRings can subsequently be obtained by
8417    /// including the ListKeyRingsResponse.next_page_token in a subsequent
8418    /// request.  If unspecified, the server will pick an appropriate default.
8419    ///
8420    /// Sets the *page size* query property to the given value.
8421    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingListCall<'a, C> {
8422        self._page_size = Some(new_value);
8423        self
8424    }
8425    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8426    /// while executing the actual API request.
8427    ///
8428    /// ````text
8429    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8430    /// ````
8431    ///
8432    /// Sets the *delegate* property to the given value.
8433    pub fn delegate(
8434        mut self,
8435        new_value: &'a mut dyn common::Delegate,
8436    ) -> ProjectLocationKeyRingListCall<'a, C> {
8437        self._delegate = Some(new_value);
8438        self
8439    }
8440
8441    /// Set any additional parameter of the query string used in the request.
8442    /// It should be used to set parameters which are not yet available through their own
8443    /// setters.
8444    ///
8445    /// Please note that this method must not be used to set any of the known parameters
8446    /// which have their own setter method. If done anyway, the request will fail.
8447    ///
8448    /// # Additional Parameters
8449    ///
8450    /// * *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.
8451    /// * *access_token* (query-string) - OAuth access token.
8452    /// * *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.
8453    /// * *pp* (query-boolean) - Pretty-print response.
8454    /// * *bearer_token* (query-string) - OAuth bearer token.
8455    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8456    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8457    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8458    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8459    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8460    /// * *callback* (query-string) - JSONP
8461    /// * *$.xgafv* (query-string) - V1 error format.
8462    /// * *alt* (query-string) - Data format for response.
8463    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingListCall<'a, C>
8464    where
8465        T: AsRef<str>,
8466    {
8467        self._additional_params
8468            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8469        self
8470    }
8471
8472    /// Identifies the authorization scope for the method you are building.
8473    ///
8474    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8475    /// [`Scope::CloudPlatform`].
8476    ///
8477    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8478    /// tokens for more than one scope.
8479    ///
8480    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8481    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8482    /// sufficient, a read-write scope will do as well.
8483    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingListCall<'a, C>
8484    where
8485        St: AsRef<str>,
8486    {
8487        self._scopes.insert(String::from(scope.as_ref()));
8488        self
8489    }
8490    /// Identifies the authorization scope(s) for the method you are building.
8491    ///
8492    /// See [`Self::add_scope()`] for details.
8493    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingListCall<'a, C>
8494    where
8495        I: IntoIterator<Item = St>,
8496        St: AsRef<str>,
8497    {
8498        self._scopes
8499            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8500        self
8501    }
8502
8503    /// Removes all scopes, and no default scope will be used either.
8504    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8505    /// for details).
8506    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingListCall<'a, C> {
8507        self._scopes.clear();
8508        self
8509    }
8510}
8511
8512/// Sets the access control policy on the specified resource. Replaces any
8513/// existing policy.
8514///
8515/// A builder for the *locations.keyRings.setIamPolicy* method supported by a *project* resource.
8516/// It is not used directly, but through a [`ProjectMethods`] instance.
8517///
8518/// # Example
8519///
8520/// Instantiate a resource method builder
8521///
8522/// ```test_harness,no_run
8523/// # extern crate hyper;
8524/// # extern crate hyper_rustls;
8525/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
8526/// use cloudkms1_beta1::api::SetIamPolicyRequest;
8527/// # async fn dox() {
8528/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8529///
8530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8531/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8532/// #     .with_native_roots()
8533/// #     .unwrap()
8534/// #     .https_only()
8535/// #     .enable_http2()
8536/// #     .build();
8537///
8538/// # let executor = hyper_util::rt::TokioExecutor::new();
8539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8540/// #     secret,
8541/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8542/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8543/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8544/// #     ),
8545/// # ).build().await.unwrap();
8546///
8547/// # let client = hyper_util::client::legacy::Client::builder(
8548/// #     hyper_util::rt::TokioExecutor::new()
8549/// # )
8550/// # .build(
8551/// #     hyper_rustls::HttpsConnectorBuilder::new()
8552/// #         .with_native_roots()
8553/// #         .unwrap()
8554/// #         .https_or_http()
8555/// #         .enable_http2()
8556/// #         .build()
8557/// # );
8558/// # let mut hub = CloudKMS::new(client, auth);
8559/// // As the method needs a request, you would usually fill it with the desired information
8560/// // into the respective structure. Some of the parts shown here might not be applicable !
8561/// // Values shown here are possibly random and not representative !
8562/// let mut req = SetIamPolicyRequest::default();
8563///
8564/// // You can configure optional parameters by calling the respective setters at will, and
8565/// // execute the final call using `doit()`.
8566/// // Values shown here are possibly random and not representative !
8567/// let result = hub.projects().locations_key_rings_set_iam_policy(req, "resource")
8568///              .doit().await;
8569/// # }
8570/// ```
8571pub struct ProjectLocationKeyRingSetIamPolicyCall<'a, C>
8572where
8573    C: 'a,
8574{
8575    hub: &'a CloudKMS<C>,
8576    _request: SetIamPolicyRequest,
8577    _resource: String,
8578    _delegate: Option<&'a mut dyn common::Delegate>,
8579    _additional_params: HashMap<String, String>,
8580    _scopes: BTreeSet<String>,
8581}
8582
8583impl<'a, C> common::CallBuilder for ProjectLocationKeyRingSetIamPolicyCall<'a, C> {}
8584
8585impl<'a, C> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
8586where
8587    C: common::Connector,
8588{
8589    /// Perform the operation you have build so far.
8590    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8591        use std::borrow::Cow;
8592        use std::io::{Read, Seek};
8593
8594        use common::{url::Params, ToParts};
8595        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8596
8597        let mut dd = common::DefaultDelegate;
8598        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8599        dlg.begin(common::MethodInfo {
8600            id: "cloudkms.projects.locations.keyRings.setIamPolicy",
8601            http_method: hyper::Method::POST,
8602        });
8603
8604        for &field in ["alt", "resource"].iter() {
8605            if self._additional_params.contains_key(field) {
8606                dlg.finished(false);
8607                return Err(common::Error::FieldClash(field));
8608            }
8609        }
8610
8611        let mut params = Params::with_capacity(4 + self._additional_params.len());
8612        params.push("resource", self._resource);
8613
8614        params.extend(self._additional_params.iter());
8615
8616        params.push("alt", "json");
8617        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
8618        if self._scopes.is_empty() {
8619            self._scopes
8620                .insert(Scope::CloudPlatform.as_ref().to_string());
8621        }
8622
8623        #[allow(clippy::single_element_loop)]
8624        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8625            url = params.uri_replacement(url, param_name, find_this, true);
8626        }
8627        {
8628            let to_remove = ["resource"];
8629            params.remove_params(&to_remove);
8630        }
8631
8632        let url = params.parse_with_url(&url);
8633
8634        let mut json_mime_type = mime::APPLICATION_JSON;
8635        let mut request_value_reader = {
8636            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8637            common::remove_json_null_values(&mut value);
8638            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8639            serde_json::to_writer(&mut dst, &value).unwrap();
8640            dst
8641        };
8642        let request_size = request_value_reader
8643            .seek(std::io::SeekFrom::End(0))
8644            .unwrap();
8645        request_value_reader
8646            .seek(std::io::SeekFrom::Start(0))
8647            .unwrap();
8648
8649        loop {
8650            let token = match self
8651                .hub
8652                .auth
8653                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8654                .await
8655            {
8656                Ok(token) => token,
8657                Err(e) => match dlg.token(e) {
8658                    Ok(token) => token,
8659                    Err(e) => {
8660                        dlg.finished(false);
8661                        return Err(common::Error::MissingToken(e));
8662                    }
8663                },
8664            };
8665            request_value_reader
8666                .seek(std::io::SeekFrom::Start(0))
8667                .unwrap();
8668            let mut req_result = {
8669                let client = &self.hub.client;
8670                dlg.pre_request();
8671                let mut req_builder = hyper::Request::builder()
8672                    .method(hyper::Method::POST)
8673                    .uri(url.as_str())
8674                    .header(USER_AGENT, self.hub._user_agent.clone());
8675
8676                if let Some(token) = token.as_ref() {
8677                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8678                }
8679
8680                let request = req_builder
8681                    .header(CONTENT_TYPE, json_mime_type.to_string())
8682                    .header(CONTENT_LENGTH, request_size as u64)
8683                    .body(common::to_body(
8684                        request_value_reader.get_ref().clone().into(),
8685                    ));
8686
8687                client.request(request.unwrap()).await
8688            };
8689
8690            match req_result {
8691                Err(err) => {
8692                    if let common::Retry::After(d) = dlg.http_error(&err) {
8693                        sleep(d).await;
8694                        continue;
8695                    }
8696                    dlg.finished(false);
8697                    return Err(common::Error::HttpError(err));
8698                }
8699                Ok(res) => {
8700                    let (mut parts, body) = res.into_parts();
8701                    let mut body = common::Body::new(body);
8702                    if !parts.status.is_success() {
8703                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8704                        let error = serde_json::from_str(&common::to_string(&bytes));
8705                        let response = common::to_response(parts, bytes.into());
8706
8707                        if let common::Retry::After(d) =
8708                            dlg.http_failure(&response, error.as_ref().ok())
8709                        {
8710                            sleep(d).await;
8711                            continue;
8712                        }
8713
8714                        dlg.finished(false);
8715
8716                        return Err(match error {
8717                            Ok(value) => common::Error::BadRequest(value),
8718                            _ => common::Error::Failure(response),
8719                        });
8720                    }
8721                    let response = {
8722                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8723                        let encoded = common::to_string(&bytes);
8724                        match serde_json::from_str(&encoded) {
8725                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8726                            Err(error) => {
8727                                dlg.response_json_decode_error(&encoded, &error);
8728                                return Err(common::Error::JsonDecodeError(
8729                                    encoded.to_string(),
8730                                    error,
8731                                ));
8732                            }
8733                        }
8734                    };
8735
8736                    dlg.finished(true);
8737                    return Ok(response);
8738                }
8739            }
8740        }
8741    }
8742
8743    ///
8744    /// Sets the *request* property to the given value.
8745    ///
8746    /// Even though the property as already been set when instantiating this call,
8747    /// we provide this method for API completeness.
8748    pub fn request(
8749        mut self,
8750        new_value: SetIamPolicyRequest,
8751    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
8752        self._request = new_value;
8753        self
8754    }
8755    /// REQUIRED: The resource for which the policy is being specified.
8756    /// See the operation documentation for the appropriate value for this field.
8757    ///
8758    /// Sets the *resource* path property to the given value.
8759    ///
8760    /// Even though the property as already been set when instantiating this call,
8761    /// we provide this method for API completeness.
8762    pub fn resource(mut self, new_value: &str) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
8763        self._resource = new_value.to_string();
8764        self
8765    }
8766    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8767    /// while executing the actual API request.
8768    ///
8769    /// ````text
8770    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8771    /// ````
8772    ///
8773    /// Sets the *delegate* property to the given value.
8774    pub fn delegate(
8775        mut self,
8776        new_value: &'a mut dyn common::Delegate,
8777    ) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
8778        self._delegate = Some(new_value);
8779        self
8780    }
8781
8782    /// Set any additional parameter of the query string used in the request.
8783    /// It should be used to set parameters which are not yet available through their own
8784    /// setters.
8785    ///
8786    /// Please note that this method must not be used to set any of the known parameters
8787    /// which have their own setter method. If done anyway, the request will fail.
8788    ///
8789    /// # Additional Parameters
8790    ///
8791    /// * *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.
8792    /// * *access_token* (query-string) - OAuth access token.
8793    /// * *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.
8794    /// * *pp* (query-boolean) - Pretty-print response.
8795    /// * *bearer_token* (query-string) - OAuth bearer token.
8796    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8797    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8798    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8799    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8800    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8801    /// * *callback* (query-string) - JSONP
8802    /// * *$.xgafv* (query-string) - V1 error format.
8803    /// * *alt* (query-string) - Data format for response.
8804    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
8805    where
8806        T: AsRef<str>,
8807    {
8808        self._additional_params
8809            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8810        self
8811    }
8812
8813    /// Identifies the authorization scope for the method you are building.
8814    ///
8815    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8816    /// [`Scope::CloudPlatform`].
8817    ///
8818    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8819    /// tokens for more than one scope.
8820    ///
8821    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8822    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8823    /// sufficient, a read-write scope will do as well.
8824    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
8825    where
8826        St: AsRef<str>,
8827    {
8828        self._scopes.insert(String::from(scope.as_ref()));
8829        self
8830    }
8831    /// Identifies the authorization scope(s) for the method you are building.
8832    ///
8833    /// See [`Self::add_scope()`] for details.
8834    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C>
8835    where
8836        I: IntoIterator<Item = St>,
8837        St: AsRef<str>,
8838    {
8839        self._scopes
8840            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8841        self
8842    }
8843
8844    /// Removes all scopes, and no default scope will be used either.
8845    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8846    /// for details).
8847    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C> {
8848        self._scopes.clear();
8849        self
8850    }
8851}
8852
8853/// Create a new KeyRing in a given Project and Location.
8854///
8855/// A builder for the *locations.keyRings.create* method supported by a *project* resource.
8856/// It is not used directly, but through a [`ProjectMethods`] instance.
8857///
8858/// # Example
8859///
8860/// Instantiate a resource method builder
8861///
8862/// ```test_harness,no_run
8863/// # extern crate hyper;
8864/// # extern crate hyper_rustls;
8865/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
8866/// use cloudkms1_beta1::api::KeyRing;
8867/// # async fn dox() {
8868/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8869///
8870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8871/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8872/// #     .with_native_roots()
8873/// #     .unwrap()
8874/// #     .https_only()
8875/// #     .enable_http2()
8876/// #     .build();
8877///
8878/// # let executor = hyper_util::rt::TokioExecutor::new();
8879/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8880/// #     secret,
8881/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8882/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8883/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8884/// #     ),
8885/// # ).build().await.unwrap();
8886///
8887/// # let client = hyper_util::client::legacy::Client::builder(
8888/// #     hyper_util::rt::TokioExecutor::new()
8889/// # )
8890/// # .build(
8891/// #     hyper_rustls::HttpsConnectorBuilder::new()
8892/// #         .with_native_roots()
8893/// #         .unwrap()
8894/// #         .https_or_http()
8895/// #         .enable_http2()
8896/// #         .build()
8897/// # );
8898/// # let mut hub = CloudKMS::new(client, auth);
8899/// // As the method needs a request, you would usually fill it with the desired information
8900/// // into the respective structure. Some of the parts shown here might not be applicable !
8901/// // Values shown here are possibly random and not representative !
8902/// let mut req = KeyRing::default();
8903///
8904/// // You can configure optional parameters by calling the respective setters at will, and
8905/// // execute the final call using `doit()`.
8906/// // Values shown here are possibly random and not representative !
8907/// let result = hub.projects().locations_key_rings_create(req, "parent")
8908///              .key_ring_id("gubergren")
8909///              .doit().await;
8910/// # }
8911/// ```
8912pub struct ProjectLocationKeyRingCreateCall<'a, C>
8913where
8914    C: 'a,
8915{
8916    hub: &'a CloudKMS<C>,
8917    _request: KeyRing,
8918    _parent: String,
8919    _key_ring_id: Option<String>,
8920    _delegate: Option<&'a mut dyn common::Delegate>,
8921    _additional_params: HashMap<String, String>,
8922    _scopes: BTreeSet<String>,
8923}
8924
8925impl<'a, C> common::CallBuilder for ProjectLocationKeyRingCreateCall<'a, C> {}
8926
8927impl<'a, C> ProjectLocationKeyRingCreateCall<'a, C>
8928where
8929    C: common::Connector,
8930{
8931    /// Perform the operation you have build so far.
8932    pub async fn doit(mut self) -> common::Result<(common::Response, KeyRing)> {
8933        use std::borrow::Cow;
8934        use std::io::{Read, Seek};
8935
8936        use common::{url::Params, ToParts};
8937        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8938
8939        let mut dd = common::DefaultDelegate;
8940        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8941        dlg.begin(common::MethodInfo {
8942            id: "cloudkms.projects.locations.keyRings.create",
8943            http_method: hyper::Method::POST,
8944        });
8945
8946        for &field in ["alt", "parent", "keyRingId"].iter() {
8947            if self._additional_params.contains_key(field) {
8948                dlg.finished(false);
8949                return Err(common::Error::FieldClash(field));
8950            }
8951        }
8952
8953        let mut params = Params::with_capacity(5 + self._additional_params.len());
8954        params.push("parent", self._parent);
8955        if let Some(value) = self._key_ring_id.as_ref() {
8956            params.push("keyRingId", value);
8957        }
8958
8959        params.extend(self._additional_params.iter());
8960
8961        params.push("alt", "json");
8962        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/keyRings";
8963        if self._scopes.is_empty() {
8964            self._scopes
8965                .insert(Scope::CloudPlatform.as_ref().to_string());
8966        }
8967
8968        #[allow(clippy::single_element_loop)]
8969        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8970            url = params.uri_replacement(url, param_name, find_this, true);
8971        }
8972        {
8973            let to_remove = ["parent"];
8974            params.remove_params(&to_remove);
8975        }
8976
8977        let url = params.parse_with_url(&url);
8978
8979        let mut json_mime_type = mime::APPLICATION_JSON;
8980        let mut request_value_reader = {
8981            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8982            common::remove_json_null_values(&mut value);
8983            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8984            serde_json::to_writer(&mut dst, &value).unwrap();
8985            dst
8986        };
8987        let request_size = request_value_reader
8988            .seek(std::io::SeekFrom::End(0))
8989            .unwrap();
8990        request_value_reader
8991            .seek(std::io::SeekFrom::Start(0))
8992            .unwrap();
8993
8994        loop {
8995            let token = match self
8996                .hub
8997                .auth
8998                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8999                .await
9000            {
9001                Ok(token) => token,
9002                Err(e) => match dlg.token(e) {
9003                    Ok(token) => token,
9004                    Err(e) => {
9005                        dlg.finished(false);
9006                        return Err(common::Error::MissingToken(e));
9007                    }
9008                },
9009            };
9010            request_value_reader
9011                .seek(std::io::SeekFrom::Start(0))
9012                .unwrap();
9013            let mut req_result = {
9014                let client = &self.hub.client;
9015                dlg.pre_request();
9016                let mut req_builder = hyper::Request::builder()
9017                    .method(hyper::Method::POST)
9018                    .uri(url.as_str())
9019                    .header(USER_AGENT, self.hub._user_agent.clone());
9020
9021                if let Some(token) = token.as_ref() {
9022                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9023                }
9024
9025                let request = req_builder
9026                    .header(CONTENT_TYPE, json_mime_type.to_string())
9027                    .header(CONTENT_LENGTH, request_size as u64)
9028                    .body(common::to_body(
9029                        request_value_reader.get_ref().clone().into(),
9030                    ));
9031
9032                client.request(request.unwrap()).await
9033            };
9034
9035            match req_result {
9036                Err(err) => {
9037                    if let common::Retry::After(d) = dlg.http_error(&err) {
9038                        sleep(d).await;
9039                        continue;
9040                    }
9041                    dlg.finished(false);
9042                    return Err(common::Error::HttpError(err));
9043                }
9044                Ok(res) => {
9045                    let (mut parts, body) = res.into_parts();
9046                    let mut body = common::Body::new(body);
9047                    if !parts.status.is_success() {
9048                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9049                        let error = serde_json::from_str(&common::to_string(&bytes));
9050                        let response = common::to_response(parts, bytes.into());
9051
9052                        if let common::Retry::After(d) =
9053                            dlg.http_failure(&response, error.as_ref().ok())
9054                        {
9055                            sleep(d).await;
9056                            continue;
9057                        }
9058
9059                        dlg.finished(false);
9060
9061                        return Err(match error {
9062                            Ok(value) => common::Error::BadRequest(value),
9063                            _ => common::Error::Failure(response),
9064                        });
9065                    }
9066                    let response = {
9067                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9068                        let encoded = common::to_string(&bytes);
9069                        match serde_json::from_str(&encoded) {
9070                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9071                            Err(error) => {
9072                                dlg.response_json_decode_error(&encoded, &error);
9073                                return Err(common::Error::JsonDecodeError(
9074                                    encoded.to_string(),
9075                                    error,
9076                                ));
9077                            }
9078                        }
9079                    };
9080
9081                    dlg.finished(true);
9082                    return Ok(response);
9083                }
9084            }
9085        }
9086    }
9087
9088    ///
9089    /// Sets the *request* property to the given value.
9090    ///
9091    /// Even though the property as already been set when instantiating this call,
9092    /// we provide this method for API completeness.
9093    pub fn request(mut self, new_value: KeyRing) -> ProjectLocationKeyRingCreateCall<'a, C> {
9094        self._request = new_value;
9095        self
9096    }
9097    /// Required. The resource name of the location associated with the
9098    /// KeyRings, in the format `projects/*/locations/*`.
9099    ///
9100    /// Sets the *parent* path property to the given value.
9101    ///
9102    /// Even though the property as already been set when instantiating this call,
9103    /// we provide this method for API completeness.
9104    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
9105        self._parent = new_value.to_string();
9106        self
9107    }
9108    /// Required. It must be unique within a location and match the regular
9109    /// expression `[a-zA-Z0-9_-]{1,63}`
9110    ///
9111    /// Sets the *key ring id* query property to the given value.
9112    pub fn key_ring_id(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C> {
9113        self._key_ring_id = Some(new_value.to_string());
9114        self
9115    }
9116    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9117    /// while executing the actual API request.
9118    ///
9119    /// ````text
9120    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9121    /// ````
9122    ///
9123    /// Sets the *delegate* property to the given value.
9124    pub fn delegate(
9125        mut self,
9126        new_value: &'a mut dyn common::Delegate,
9127    ) -> ProjectLocationKeyRingCreateCall<'a, C> {
9128        self._delegate = Some(new_value);
9129        self
9130    }
9131
9132    /// Set any additional parameter of the query string used in the request.
9133    /// It should be used to set parameters which are not yet available through their own
9134    /// setters.
9135    ///
9136    /// Please note that this method must not be used to set any of the known parameters
9137    /// which have their own setter method. If done anyway, the request will fail.
9138    ///
9139    /// # Additional Parameters
9140    ///
9141    /// * *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.
9142    /// * *access_token* (query-string) - OAuth access token.
9143    /// * *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.
9144    /// * *pp* (query-boolean) - Pretty-print response.
9145    /// * *bearer_token* (query-string) - OAuth bearer token.
9146    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9147    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9148    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9149    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9150    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9151    /// * *callback* (query-string) - JSONP
9152    /// * *$.xgafv* (query-string) - V1 error format.
9153    /// * *alt* (query-string) - Data format for response.
9154    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyRingCreateCall<'a, C>
9155    where
9156        T: AsRef<str>,
9157    {
9158        self._additional_params
9159            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9160        self
9161    }
9162
9163    /// Identifies the authorization scope for the method you are building.
9164    ///
9165    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9166    /// [`Scope::CloudPlatform`].
9167    ///
9168    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9169    /// tokens for more than one scope.
9170    ///
9171    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9172    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9173    /// sufficient, a read-write scope will do as well.
9174    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyRingCreateCall<'a, C>
9175    where
9176        St: AsRef<str>,
9177    {
9178        self._scopes.insert(String::from(scope.as_ref()));
9179        self
9180    }
9181    /// Identifies the authorization scope(s) for the method you are building.
9182    ///
9183    /// See [`Self::add_scope()`] for details.
9184    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyRingCreateCall<'a, C>
9185    where
9186        I: IntoIterator<Item = St>,
9187        St: AsRef<str>,
9188    {
9189        self._scopes
9190            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9191        self
9192    }
9193
9194    /// Removes all scopes, and no default scope will be used either.
9195    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9196    /// for details).
9197    pub fn clear_scopes(mut self) -> ProjectLocationKeyRingCreateCall<'a, C> {
9198        self._scopes.clear();
9199        self
9200    }
9201}
9202
9203/// Lists information about the supported locations for this service.
9204///
9205/// A builder for the *locations.list* method supported by a *project* resource.
9206/// It is not used directly, but through a [`ProjectMethods`] instance.
9207///
9208/// # Example
9209///
9210/// Instantiate a resource method builder
9211///
9212/// ```test_harness,no_run
9213/// # extern crate hyper;
9214/// # extern crate hyper_rustls;
9215/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
9216/// # async fn dox() {
9217/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9218///
9219/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9220/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9221/// #     .with_native_roots()
9222/// #     .unwrap()
9223/// #     .https_only()
9224/// #     .enable_http2()
9225/// #     .build();
9226///
9227/// # let executor = hyper_util::rt::TokioExecutor::new();
9228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9229/// #     secret,
9230/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9231/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9232/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9233/// #     ),
9234/// # ).build().await.unwrap();
9235///
9236/// # let client = hyper_util::client::legacy::Client::builder(
9237/// #     hyper_util::rt::TokioExecutor::new()
9238/// # )
9239/// # .build(
9240/// #     hyper_rustls::HttpsConnectorBuilder::new()
9241/// #         .with_native_roots()
9242/// #         .unwrap()
9243/// #         .https_or_http()
9244/// #         .enable_http2()
9245/// #         .build()
9246/// # );
9247/// # let mut hub = CloudKMS::new(client, auth);
9248/// // You can configure optional parameters by calling the respective setters at will, and
9249/// // execute the final call using `doit()`.
9250/// // Values shown here are possibly random and not representative !
9251/// let result = hub.projects().locations_list("name")
9252///              .page_token("dolor")
9253///              .page_size(-56)
9254///              .filter("eos")
9255///              .doit().await;
9256/// # }
9257/// ```
9258pub struct ProjectLocationListCall<'a, C>
9259where
9260    C: 'a,
9261{
9262    hub: &'a CloudKMS<C>,
9263    _name: String,
9264    _page_token: Option<String>,
9265    _page_size: Option<i32>,
9266    _filter: Option<String>,
9267    _delegate: Option<&'a mut dyn common::Delegate>,
9268    _additional_params: HashMap<String, String>,
9269    _scopes: BTreeSet<String>,
9270}
9271
9272impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
9273
9274impl<'a, C> ProjectLocationListCall<'a, C>
9275where
9276    C: common::Connector,
9277{
9278    /// Perform the operation you have build so far.
9279    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
9280        use std::borrow::Cow;
9281        use std::io::{Read, Seek};
9282
9283        use common::{url::Params, ToParts};
9284        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9285
9286        let mut dd = common::DefaultDelegate;
9287        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9288        dlg.begin(common::MethodInfo {
9289            id: "cloudkms.projects.locations.list",
9290            http_method: hyper::Method::GET,
9291        });
9292
9293        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
9294            if self._additional_params.contains_key(field) {
9295                dlg.finished(false);
9296                return Err(common::Error::FieldClash(field));
9297            }
9298        }
9299
9300        let mut params = Params::with_capacity(6 + self._additional_params.len());
9301        params.push("name", self._name);
9302        if let Some(value) = self._page_token.as_ref() {
9303            params.push("pageToken", value);
9304        }
9305        if let Some(value) = self._page_size.as_ref() {
9306            params.push("pageSize", value.to_string());
9307        }
9308        if let Some(value) = self._filter.as_ref() {
9309            params.push("filter", value);
9310        }
9311
9312        params.extend(self._additional_params.iter());
9313
9314        params.push("alt", "json");
9315        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
9316        if self._scopes.is_empty() {
9317            self._scopes
9318                .insert(Scope::CloudPlatform.as_ref().to_string());
9319        }
9320
9321        #[allow(clippy::single_element_loop)]
9322        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9323            url = params.uri_replacement(url, param_name, find_this, true);
9324        }
9325        {
9326            let to_remove = ["name"];
9327            params.remove_params(&to_remove);
9328        }
9329
9330        let url = params.parse_with_url(&url);
9331
9332        loop {
9333            let token = match self
9334                .hub
9335                .auth
9336                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9337                .await
9338            {
9339                Ok(token) => token,
9340                Err(e) => match dlg.token(e) {
9341                    Ok(token) => token,
9342                    Err(e) => {
9343                        dlg.finished(false);
9344                        return Err(common::Error::MissingToken(e));
9345                    }
9346                },
9347            };
9348            let mut req_result = {
9349                let client = &self.hub.client;
9350                dlg.pre_request();
9351                let mut req_builder = hyper::Request::builder()
9352                    .method(hyper::Method::GET)
9353                    .uri(url.as_str())
9354                    .header(USER_AGENT, self.hub._user_agent.clone());
9355
9356                if let Some(token) = token.as_ref() {
9357                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9358                }
9359
9360                let request = req_builder
9361                    .header(CONTENT_LENGTH, 0_u64)
9362                    .body(common::to_body::<String>(None));
9363
9364                client.request(request.unwrap()).await
9365            };
9366
9367            match req_result {
9368                Err(err) => {
9369                    if let common::Retry::After(d) = dlg.http_error(&err) {
9370                        sleep(d).await;
9371                        continue;
9372                    }
9373                    dlg.finished(false);
9374                    return Err(common::Error::HttpError(err));
9375                }
9376                Ok(res) => {
9377                    let (mut parts, body) = res.into_parts();
9378                    let mut body = common::Body::new(body);
9379                    if !parts.status.is_success() {
9380                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9381                        let error = serde_json::from_str(&common::to_string(&bytes));
9382                        let response = common::to_response(parts, bytes.into());
9383
9384                        if let common::Retry::After(d) =
9385                            dlg.http_failure(&response, error.as_ref().ok())
9386                        {
9387                            sleep(d).await;
9388                            continue;
9389                        }
9390
9391                        dlg.finished(false);
9392
9393                        return Err(match error {
9394                            Ok(value) => common::Error::BadRequest(value),
9395                            _ => common::Error::Failure(response),
9396                        });
9397                    }
9398                    let response = {
9399                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9400                        let encoded = common::to_string(&bytes);
9401                        match serde_json::from_str(&encoded) {
9402                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9403                            Err(error) => {
9404                                dlg.response_json_decode_error(&encoded, &error);
9405                                return Err(common::Error::JsonDecodeError(
9406                                    encoded.to_string(),
9407                                    error,
9408                                ));
9409                            }
9410                        }
9411                    };
9412
9413                    dlg.finished(true);
9414                    return Ok(response);
9415                }
9416            }
9417        }
9418    }
9419
9420    /// The resource that owns the locations collection, if applicable.
9421    ///
9422    /// Sets the *name* path property to the given value.
9423    ///
9424    /// Even though the property as already been set when instantiating this call,
9425    /// we provide this method for API completeness.
9426    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9427        self._name = new_value.to_string();
9428        self
9429    }
9430    /// The standard list page token.
9431    ///
9432    /// Sets the *page token* query property to the given value.
9433    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9434        self._page_token = Some(new_value.to_string());
9435        self
9436    }
9437    /// The standard list page size.
9438    ///
9439    /// Sets the *page size* query property to the given value.
9440    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
9441        self._page_size = Some(new_value);
9442        self
9443    }
9444    /// The standard list filter.
9445    ///
9446    /// Sets the *filter* query property to the given value.
9447    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
9448        self._filter = Some(new_value.to_string());
9449        self
9450    }
9451    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9452    /// while executing the actual API request.
9453    ///
9454    /// ````text
9455    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9456    /// ````
9457    ///
9458    /// Sets the *delegate* property to the given value.
9459    pub fn delegate(
9460        mut self,
9461        new_value: &'a mut dyn common::Delegate,
9462    ) -> ProjectLocationListCall<'a, C> {
9463        self._delegate = Some(new_value);
9464        self
9465    }
9466
9467    /// Set any additional parameter of the query string used in the request.
9468    /// It should be used to set parameters which are not yet available through their own
9469    /// setters.
9470    ///
9471    /// Please note that this method must not be used to set any of the known parameters
9472    /// which have their own setter method. If done anyway, the request will fail.
9473    ///
9474    /// # Additional Parameters
9475    ///
9476    /// * *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.
9477    /// * *access_token* (query-string) - OAuth access token.
9478    /// * *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.
9479    /// * *pp* (query-boolean) - Pretty-print response.
9480    /// * *bearer_token* (query-string) - OAuth bearer token.
9481    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9482    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9483    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9484    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9485    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9486    /// * *callback* (query-string) - JSONP
9487    /// * *$.xgafv* (query-string) - V1 error format.
9488    /// * *alt* (query-string) - Data format for response.
9489    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
9490    where
9491        T: AsRef<str>,
9492    {
9493        self._additional_params
9494            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9495        self
9496    }
9497
9498    /// Identifies the authorization scope for the method you are building.
9499    ///
9500    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9501    /// [`Scope::CloudPlatform`].
9502    ///
9503    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9504    /// tokens for more than one scope.
9505    ///
9506    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9507    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9508    /// sufficient, a read-write scope will do as well.
9509    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
9510    where
9511        St: AsRef<str>,
9512    {
9513        self._scopes.insert(String::from(scope.as_ref()));
9514        self
9515    }
9516    /// Identifies the authorization scope(s) for the method you are building.
9517    ///
9518    /// See [`Self::add_scope()`] for details.
9519    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
9520    where
9521        I: IntoIterator<Item = St>,
9522        St: AsRef<str>,
9523    {
9524        self._scopes
9525            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9526        self
9527    }
9528
9529    /// Removes all scopes, and no default scope will be used either.
9530    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9531    /// for details).
9532    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
9533        self._scopes.clear();
9534        self
9535    }
9536}
9537
9538/// Get information about a location.
9539///
9540/// A builder for the *locations.get* method supported by a *project* resource.
9541/// It is not used directly, but through a [`ProjectMethods`] instance.
9542///
9543/// # Example
9544///
9545/// Instantiate a resource method builder
9546///
9547/// ```test_harness,no_run
9548/// # extern crate hyper;
9549/// # extern crate hyper_rustls;
9550/// # extern crate google_cloudkms1_beta1 as cloudkms1_beta1;
9551/// # async fn dox() {
9552/// # use cloudkms1_beta1::{CloudKMS, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9553///
9554/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9555/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9556/// #     .with_native_roots()
9557/// #     .unwrap()
9558/// #     .https_only()
9559/// #     .enable_http2()
9560/// #     .build();
9561///
9562/// # let executor = hyper_util::rt::TokioExecutor::new();
9563/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9564/// #     secret,
9565/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9566/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9567/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9568/// #     ),
9569/// # ).build().await.unwrap();
9570///
9571/// # let client = hyper_util::client::legacy::Client::builder(
9572/// #     hyper_util::rt::TokioExecutor::new()
9573/// # )
9574/// # .build(
9575/// #     hyper_rustls::HttpsConnectorBuilder::new()
9576/// #         .with_native_roots()
9577/// #         .unwrap()
9578/// #         .https_or_http()
9579/// #         .enable_http2()
9580/// #         .build()
9581/// # );
9582/// # let mut hub = CloudKMS::new(client, auth);
9583/// // You can configure optional parameters by calling the respective setters at will, and
9584/// // execute the final call using `doit()`.
9585/// // Values shown here are possibly random and not representative !
9586/// let result = hub.projects().locations_get("name")
9587///              .doit().await;
9588/// # }
9589/// ```
9590pub struct ProjectLocationGetCall<'a, C>
9591where
9592    C: 'a,
9593{
9594    hub: &'a CloudKMS<C>,
9595    _name: String,
9596    _delegate: Option<&'a mut dyn common::Delegate>,
9597    _additional_params: HashMap<String, String>,
9598    _scopes: BTreeSet<String>,
9599}
9600
9601impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
9602
9603impl<'a, C> ProjectLocationGetCall<'a, C>
9604where
9605    C: common::Connector,
9606{
9607    /// Perform the operation you have build so far.
9608    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
9609        use std::borrow::Cow;
9610        use std::io::{Read, Seek};
9611
9612        use common::{url::Params, ToParts};
9613        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9614
9615        let mut dd = common::DefaultDelegate;
9616        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9617        dlg.begin(common::MethodInfo {
9618            id: "cloudkms.projects.locations.get",
9619            http_method: hyper::Method::GET,
9620        });
9621
9622        for &field in ["alt", "name"].iter() {
9623            if self._additional_params.contains_key(field) {
9624                dlg.finished(false);
9625                return Err(common::Error::FieldClash(field));
9626            }
9627        }
9628
9629        let mut params = Params::with_capacity(3 + self._additional_params.len());
9630        params.push("name", self._name);
9631
9632        params.extend(self._additional_params.iter());
9633
9634        params.push("alt", "json");
9635        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
9636        if self._scopes.is_empty() {
9637            self._scopes
9638                .insert(Scope::CloudPlatform.as_ref().to_string());
9639        }
9640
9641        #[allow(clippy::single_element_loop)]
9642        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9643            url = params.uri_replacement(url, param_name, find_this, true);
9644        }
9645        {
9646            let to_remove = ["name"];
9647            params.remove_params(&to_remove);
9648        }
9649
9650        let url = params.parse_with_url(&url);
9651
9652        loop {
9653            let token = match self
9654                .hub
9655                .auth
9656                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9657                .await
9658            {
9659                Ok(token) => token,
9660                Err(e) => match dlg.token(e) {
9661                    Ok(token) => token,
9662                    Err(e) => {
9663                        dlg.finished(false);
9664                        return Err(common::Error::MissingToken(e));
9665                    }
9666                },
9667            };
9668            let mut req_result = {
9669                let client = &self.hub.client;
9670                dlg.pre_request();
9671                let mut req_builder = hyper::Request::builder()
9672                    .method(hyper::Method::GET)
9673                    .uri(url.as_str())
9674                    .header(USER_AGENT, self.hub._user_agent.clone());
9675
9676                if let Some(token) = token.as_ref() {
9677                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9678                }
9679
9680                let request = req_builder
9681                    .header(CONTENT_LENGTH, 0_u64)
9682                    .body(common::to_body::<String>(None));
9683
9684                client.request(request.unwrap()).await
9685            };
9686
9687            match req_result {
9688                Err(err) => {
9689                    if let common::Retry::After(d) = dlg.http_error(&err) {
9690                        sleep(d).await;
9691                        continue;
9692                    }
9693                    dlg.finished(false);
9694                    return Err(common::Error::HttpError(err));
9695                }
9696                Ok(res) => {
9697                    let (mut parts, body) = res.into_parts();
9698                    let mut body = common::Body::new(body);
9699                    if !parts.status.is_success() {
9700                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9701                        let error = serde_json::from_str(&common::to_string(&bytes));
9702                        let response = common::to_response(parts, bytes.into());
9703
9704                        if let common::Retry::After(d) =
9705                            dlg.http_failure(&response, error.as_ref().ok())
9706                        {
9707                            sleep(d).await;
9708                            continue;
9709                        }
9710
9711                        dlg.finished(false);
9712
9713                        return Err(match error {
9714                            Ok(value) => common::Error::BadRequest(value),
9715                            _ => common::Error::Failure(response),
9716                        });
9717                    }
9718                    let response = {
9719                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9720                        let encoded = common::to_string(&bytes);
9721                        match serde_json::from_str(&encoded) {
9722                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9723                            Err(error) => {
9724                                dlg.response_json_decode_error(&encoded, &error);
9725                                return Err(common::Error::JsonDecodeError(
9726                                    encoded.to_string(),
9727                                    error,
9728                                ));
9729                            }
9730                        }
9731                    };
9732
9733                    dlg.finished(true);
9734                    return Ok(response);
9735                }
9736            }
9737        }
9738    }
9739
9740    /// Resource name for the location.
9741    ///
9742    /// Sets the *name* path property to the given value.
9743    ///
9744    /// Even though the property as already been set when instantiating this call,
9745    /// we provide this method for API completeness.
9746    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
9747        self._name = new_value.to_string();
9748        self
9749    }
9750    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9751    /// while executing the actual API request.
9752    ///
9753    /// ````text
9754    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9755    /// ````
9756    ///
9757    /// Sets the *delegate* property to the given value.
9758    pub fn delegate(
9759        mut self,
9760        new_value: &'a mut dyn common::Delegate,
9761    ) -> ProjectLocationGetCall<'a, C> {
9762        self._delegate = Some(new_value);
9763        self
9764    }
9765
9766    /// Set any additional parameter of the query string used in the request.
9767    /// It should be used to set parameters which are not yet available through their own
9768    /// setters.
9769    ///
9770    /// Please note that this method must not be used to set any of the known parameters
9771    /// which have their own setter method. If done anyway, the request will fail.
9772    ///
9773    /// # Additional Parameters
9774    ///
9775    /// * *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.
9776    /// * *access_token* (query-string) - OAuth access token.
9777    /// * *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.
9778    /// * *pp* (query-boolean) - Pretty-print response.
9779    /// * *bearer_token* (query-string) - OAuth bearer token.
9780    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9781    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9782    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9783    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9784    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9785    /// * *callback* (query-string) - JSONP
9786    /// * *$.xgafv* (query-string) - V1 error format.
9787    /// * *alt* (query-string) - Data format for response.
9788    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
9789    where
9790        T: AsRef<str>,
9791    {
9792        self._additional_params
9793            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9794        self
9795    }
9796
9797    /// Identifies the authorization scope for the method you are building.
9798    ///
9799    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9800    /// [`Scope::CloudPlatform`].
9801    ///
9802    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9803    /// tokens for more than one scope.
9804    ///
9805    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9806    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9807    /// sufficient, a read-write scope will do as well.
9808    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
9809    where
9810        St: AsRef<str>,
9811    {
9812        self._scopes.insert(String::from(scope.as_ref()));
9813        self
9814    }
9815    /// Identifies the authorization scope(s) for the method you are building.
9816    ///
9817    /// See [`Self::add_scope()`] for details.
9818    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
9819    where
9820        I: IntoIterator<Item = St>,
9821        St: AsRef<str>,
9822    {
9823        self._scopes
9824            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9825        self
9826    }
9827
9828    /// Removes all scopes, and no default scope will be used either.
9829    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9830    /// for details).
9831    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
9832        self._scopes.clear();
9833        self
9834    }
9835}