google_secretmanager1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all SecretManager 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_secretmanager1 as secretmanager1;
49/// use secretmanager1::api::DestroySecretVersionRequest;
50/// use secretmanager1::{Result, Error};
51/// # async fn dox() {
52/// use secretmanager1::{SecretManager, 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 = SecretManager::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 = DestroySecretVersionRequest::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_secrets_versions_destroy(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct SecretManager<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for SecretManager<C> {}
130
131impl<'a, C> SecretManager<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> SecretManager<C> {
136        SecretManager {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://secretmanager.googleapis.com/".to_string(),
141            _root_url: "https://secretmanager.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146        ProjectMethods { hub: self }
147    }
148
149    /// Set the user-agent header field to use in all requests to the server.
150    /// It defaults to `google-api-rust-client/7.0.0`.
151    ///
152    /// Returns the previously set user-agent.
153    pub fn user_agent(&mut self, agent_name: String) -> String {
154        std::mem::replace(&mut self._user_agent, agent_name)
155    }
156
157    /// Set the base url to use in all requests to the server.
158    /// It defaults to `https://secretmanager.googleapis.com/`.
159    ///
160    /// Returns the previously set base url.
161    pub fn base_url(&mut self, new_base_url: String) -> String {
162        std::mem::replace(&mut self._base_url, new_base_url)
163    }
164
165    /// Set the root url to use in all requests to the server.
166    /// It defaults to `https://secretmanager.googleapis.com/`.
167    ///
168    /// Returns the previously set root url.
169    pub fn root_url(&mut self, new_root_url: String) -> String {
170        std::mem::replace(&mut self._root_url, new_root_url)
171    }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// Response message for SecretManagerService.AccessSecretVersion.
178///
179/// # Activities
180///
181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
183///
184/// * [locations secrets versions access projects](ProjectLocationSecretVersionAccesCall) (response)
185/// * [secrets versions access projects](ProjectSecretVersionAccesCall) (response)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AccessSecretVersionResponse {
190    /// The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
191    pub name: Option<String>,
192    /// Secret payload
193    pub payload: Option<SecretPayload>,
194}
195
196impl common::ResponseResult for AccessSecretVersionResponse {}
197
198/// Request message for SecretManagerService.AddSecretVersion.
199///
200/// # Activities
201///
202/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
203/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
204///
205/// * [locations secrets add version projects](ProjectLocationSecretAddVersionCall) (request)
206/// * [secrets add version projects](ProjectSecretAddVersionCall) (request)
207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
208#[serde_with::serde_as]
209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
210pub struct AddSecretVersionRequest {
211    /// Required. The secret payload of the SecretVersion.
212    pub payload: Option<SecretPayload>,
213}
214
215impl common::RequestValue for AddSecretVersionRequest {}
216
217/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
218///
219/// This type is not used in any activity, and only used as *part* of another schema.
220///
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct AuditConfig {
225    /// The configuration for logging of each type of permission.
226    #[serde(rename = "auditLogConfigs")]
227    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
228    /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
229    pub service: Option<String>,
230}
231
232impl common::Part for AuditConfig {}
233
234/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
235///
236/// This type is not used in any activity, and only used as *part* of another schema.
237///
238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
239#[serde_with::serde_as]
240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
241pub struct AuditLogConfig {
242    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
243    #[serde(rename = "exemptedMembers")]
244    pub exempted_members: Option<Vec<String>>,
245    /// The log type that this config enables.
246    #[serde(rename = "logType")]
247    pub log_type: Option<String>,
248}
249
250impl common::Part for AuditLogConfig {}
251
252/// A replication policy that replicates the Secret payload without any restrictions.
253///
254/// This type is not used in any activity, and only used as *part* of another schema.
255///
256#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
257#[serde_with::serde_as]
258#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
259pub struct Automatic {
260    /// Optional. The customer-managed encryption configuration of the Secret. If no configuration is provided, Google-managed default encryption is used. Updates to the Secret encryption configuration only apply to SecretVersions added afterwards. They do not apply retroactively to existing SecretVersions.
261    #[serde(rename = "customerManagedEncryption")]
262    pub customer_managed_encryption: Option<CustomerManagedEncryption>,
263}
264
265impl common::Part for Automatic {}
266
267/// The replication status of a SecretVersion using automatic replication. Only populated if the parent Secret has an automatic replication policy.
268///
269/// This type is not used in any activity, and only used as *part* of another schema.
270///
271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
272#[serde_with::serde_as]
273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
274pub struct AutomaticStatus {
275    /// Output only. The customer-managed encryption status of the SecretVersion. Only populated if customer-managed encryption is used.
276    #[serde(rename = "customerManagedEncryption")]
277    pub customer_managed_encryption: Option<CustomerManagedEncryptionStatus>,
278}
279
280impl common::Part for AutomaticStatus {}
281
282/// Associates `members`, or principals, with a `role`.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct Binding {
290    /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
291    pub condition: Option<Expr>,
292    /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
293    pub members: Option<Vec<String>>,
294    /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
295    pub role: Option<String>,
296}
297
298impl common::Part for Binding {}
299
300/// Configuration for encrypting secret payloads using customer-managed encryption keys (CMEK).
301///
302/// This type is not used in any activity, and only used as *part* of another schema.
303///
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct CustomerManagedEncryption {
308    /// Required. The resource name of the Cloud KMS CryptoKey used to encrypt secret payloads. For secrets using the UserManaged replication policy type, Cloud KMS CryptoKeys must reside in the same location as the replica location. For secrets using the Automatic replication policy type, Cloud KMS CryptoKeys must reside in `global`. The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
309    #[serde(rename = "kmsKeyName")]
310    pub kms_key_name: Option<String>,
311}
312
313impl common::Part for CustomerManagedEncryption {}
314
315/// Describes the status of customer-managed encryption.
316///
317/// This type is not used in any activity, and only used as *part* of another schema.
318///
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct CustomerManagedEncryptionStatus {
323    /// Required. The resource name of the Cloud KMS CryptoKeyVersion used to encrypt the secret payload, in the following format: `projects/*/locations/*/keyRings/*/cryptoKeys/*/versions/*`.
324    #[serde(rename = "kmsKeyVersionName")]
325    pub kms_key_version_name: Option<String>,
326}
327
328impl common::Part for CustomerManagedEncryptionStatus {}
329
330/// Request message for SecretManagerService.DestroySecretVersion.
331///
332/// # Activities
333///
334/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
335/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
336///
337/// * [locations secrets versions destroy projects](ProjectLocationSecretVersionDestroyCall) (request)
338/// * [secrets versions destroy projects](ProjectSecretVersionDestroyCall) (request)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct DestroySecretVersionRequest {
343    /// Optional. Etag of the SecretVersion. The request succeeds if it matches the etag of the currently stored secret version object. If the etag is omitted, the request succeeds.
344    pub etag: Option<String>,
345}
346
347impl common::RequestValue for DestroySecretVersionRequest {}
348
349/// Request message for SecretManagerService.DisableSecretVersion.
350///
351/// # Activities
352///
353/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
354/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
355///
356/// * [locations secrets versions disable projects](ProjectLocationSecretVersionDisableCall) (request)
357/// * [secrets versions disable projects](ProjectSecretVersionDisableCall) (request)
358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
359#[serde_with::serde_as]
360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
361pub struct DisableSecretVersionRequest {
362    /// Optional. Etag of the SecretVersion. The request succeeds if it matches the etag of the currently stored secret version object. If the etag is omitted, the request succeeds.
363    pub etag: Option<String>,
364}
365
366impl common::RequestValue for DisableSecretVersionRequest {}
367
368/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [locations secrets delete projects](ProjectLocationSecretDeleteCall) (response)
376/// * [secrets delete projects](ProjectSecretDeleteCall) (response)
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct Empty {
381    _never_set: Option<bool>,
382}
383
384impl common::ResponseResult for Empty {}
385
386/// Request message for SecretManagerService.EnableSecretVersion.
387///
388/// # Activities
389///
390/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
391/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
392///
393/// * [locations secrets versions enable projects](ProjectLocationSecretVersionEnableCall) (request)
394/// * [secrets versions enable projects](ProjectSecretVersionEnableCall) (request)
395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
396#[serde_with::serde_as]
397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
398pub struct EnableSecretVersionRequest {
399    /// Optional. Etag of the SecretVersion. The request succeeds if it matches the etag of the currently stored secret version object. If the etag is omitted, the request succeeds.
400    pub etag: Option<String>,
401}
402
403impl common::RequestValue for EnableSecretVersionRequest {}
404
405/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
406///
407/// This type is not used in any activity, and only used as *part* of another schema.
408///
409#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
410#[serde_with::serde_as]
411#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
412pub struct Expr {
413    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
414    pub description: Option<String>,
415    /// Textual representation of an expression in Common Expression Language syntax.
416    pub expression: Option<String>,
417    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
418    pub location: Option<String>,
419    /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
420    pub title: Option<String>,
421}
422
423impl common::Part for Expr {}
424
425/// The response message for Locations.ListLocations.
426///
427/// # Activities
428///
429/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
430/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
431///
432/// * [locations list projects](ProjectLocationListCall) (response)
433#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
434#[serde_with::serde_as]
435#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
436pub struct ListLocationsResponse {
437    /// A list of locations that matches the specified filter in the request.
438    pub locations: Option<Vec<Location>>,
439    /// The standard List next-page token.
440    #[serde(rename = "nextPageToken")]
441    pub next_page_token: Option<String>,
442}
443
444impl common::ResponseResult for ListLocationsResponse {}
445
446/// Response message for SecretManagerService.ListSecretVersions.
447///
448/// # Activities
449///
450/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
451/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
452///
453/// * [locations secrets versions list projects](ProjectLocationSecretVersionListCall) (response)
454/// * [secrets versions list projects](ProjectSecretVersionListCall) (response)
455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
456#[serde_with::serde_as]
457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
458pub struct ListSecretVersionsResponse {
459    /// A token to retrieve the next page of results. Pass this value in ListSecretVersionsRequest.page_token to retrieve the next page.
460    #[serde(rename = "nextPageToken")]
461    pub next_page_token: Option<String>,
462    /// The total number of SecretVersions but 0 when the ListSecretsRequest.filter field is set.
463    #[serde(rename = "totalSize")]
464    pub total_size: Option<i32>,
465    /// The list of SecretVersions sorted in reverse by create_time (newest first).
466    pub versions: Option<Vec<SecretVersion>>,
467}
468
469impl common::ResponseResult for ListSecretVersionsResponse {}
470
471/// Response message for SecretManagerService.ListSecrets.
472///
473/// # Activities
474///
475/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
476/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
477///
478/// * [locations secrets list projects](ProjectLocationSecretListCall) (response)
479/// * [secrets list projects](ProjectSecretListCall) (response)
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct ListSecretsResponse {
484    /// A token to retrieve the next page of results. Pass this value in ListSecretsRequest.page_token to retrieve the next page.
485    #[serde(rename = "nextPageToken")]
486    pub next_page_token: Option<String>,
487    /// The list of Secrets sorted in reverse by create_time (newest first).
488    pub secrets: Option<Vec<Secret>>,
489    /// The total number of Secrets but 0 when the ListSecretsRequest.filter field is set.
490    #[serde(rename = "totalSize")]
491    pub total_size: Option<i32>,
492}
493
494impl common::ResponseResult for ListSecretsResponse {}
495
496/// A resource that represents a Google Cloud location.
497///
498/// # Activities
499///
500/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
501/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
502///
503/// * [locations get projects](ProjectLocationGetCall) (response)
504#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
505#[serde_with::serde_as]
506#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
507pub struct Location {
508    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
509    #[serde(rename = "displayName")]
510    pub display_name: Option<String>,
511    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
512    pub labels: Option<HashMap<String, String>>,
513    /// The canonical id for this location. For example: `"us-east1"`.
514    #[serde(rename = "locationId")]
515    pub location_id: Option<String>,
516    /// Service-specific metadata. For example the available capacity at the given location.
517    pub metadata: Option<HashMap<String, serde_json::Value>>,
518    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
519    pub name: Option<String>,
520}
521
522impl common::ResponseResult for Location {}
523
524/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
525///
526/// # Activities
527///
528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
530///
531/// * [locations secrets get iam policy projects](ProjectLocationSecretGetIamPolicyCall) (response)
532/// * [locations secrets set iam policy projects](ProjectLocationSecretSetIamPolicyCall) (response)
533/// * [secrets get iam policy projects](ProjectSecretGetIamPolicyCall) (response)
534/// * [secrets set iam policy projects](ProjectSecretSetIamPolicyCall) (response)
535#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
536#[serde_with::serde_as]
537#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
538pub struct Policy {
539    /// Specifies cloud audit logging configuration for this policy.
540    #[serde(rename = "auditConfigs")]
541    pub audit_configs: Option<Vec<AuditConfig>>,
542    /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
543    pub bindings: Option<Vec<Binding>>,
544    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
545    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
546    pub etag: Option<Vec<u8>>,
547    /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
548    pub version: Option<i32>,
549}
550
551impl common::ResponseResult for Policy {}
552
553/// Represents a Replica for this Secret.
554///
555/// This type is not used in any activity, and only used as *part* of another schema.
556///
557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
558#[serde_with::serde_as]
559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
560pub struct Replica {
561    /// Optional. The customer-managed encryption configuration of the User-Managed Replica. If no configuration is provided, Google-managed default encryption is used. Updates to the Secret encryption configuration only apply to SecretVersions added afterwards. They do not apply retroactively to existing SecretVersions.
562    #[serde(rename = "customerManagedEncryption")]
563    pub customer_managed_encryption: Option<CustomerManagedEncryption>,
564    /// The canonical IDs of the location to replicate data. For example: `"us-east1"`.
565    pub location: Option<String>,
566}
567
568impl common::Part for Replica {}
569
570/// Describes the status of a user-managed replica for the SecretVersion.
571///
572/// This type is not used in any activity, and only used as *part* of another schema.
573///
574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
575#[serde_with::serde_as]
576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
577pub struct ReplicaStatus {
578    /// Output only. The customer-managed encryption status of the SecretVersion. Only populated if customer-managed encryption is used.
579    #[serde(rename = "customerManagedEncryption")]
580    pub customer_managed_encryption: Option<CustomerManagedEncryptionStatus>,
581    /// Output only. The canonical ID of the replica location. For example: `"us-east1"`.
582    pub location: Option<String>,
583}
584
585impl common::Part for ReplicaStatus {}
586
587/// A policy that defines the replication and encryption configuration of data.
588///
589/// This type is not used in any activity, and only used as *part* of another schema.
590///
591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
592#[serde_with::serde_as]
593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
594pub struct Replication {
595    /// The Secret will automatically be replicated without any restrictions.
596    pub automatic: Option<Automatic>,
597    /// The Secret will only be replicated into the locations specified.
598    #[serde(rename = "userManaged")]
599    pub user_managed: Option<UserManaged>,
600}
601
602impl common::Part for Replication {}
603
604/// The replication status of a SecretVersion.
605///
606/// This type is not used in any activity, and only used as *part* of another schema.
607///
608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
609#[serde_with::serde_as]
610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
611pub struct ReplicationStatus {
612    /// Describes the replication status of a SecretVersion with automatic replication. Only populated if the parent Secret has an automatic replication policy.
613    pub automatic: Option<AutomaticStatus>,
614    /// Describes the replication status of a SecretVersion with user-managed replication. Only populated if the parent Secret has a user-managed replication policy.
615    #[serde(rename = "userManaged")]
616    pub user_managed: Option<UserManagedStatus>,
617}
618
619impl common::Part for ReplicationStatus {}
620
621/// The rotation time and period for a Secret. At next_rotation_time, Secret Manager will send a Pub/Sub notification to the topics configured on the Secret. Secret.topics must be set to configure rotation.
622///
623/// This type is not used in any activity, and only used as *part* of another schema.
624///
625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
626#[serde_with::serde_as]
627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
628pub struct Rotation {
629    /// Optional. Timestamp in UTC at which the Secret is scheduled to rotate. Cannot be set to less than 300s (5 min) in the future and at most 3153600000s (100 years). next_rotation_time MUST be set if rotation_period is set.
630    #[serde(rename = "nextRotationTime")]
631    pub next_rotation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
632    /// Input only. The Duration between rotation notifications. Must be in seconds and at least 3600s (1h) and at most 3153600000s (100 years). If rotation_period is set, next_rotation_time must be set. next_rotation_time will be advanced by this period when the service automatically sends rotation notifications.
633    #[serde(rename = "rotationPeriod")]
634    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
635    pub rotation_period: Option<chrono::Duration>,
636}
637
638impl common::Part for Rotation {}
639
640/// A Secret is a logical secret whose value and versions can be accessed. A Secret is made up of zero or more SecretVersions that represent the secret data.
641///
642/// # Activities
643///
644/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
645/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
646///
647/// * [locations secrets create projects](ProjectLocationSecretCreateCall) (request|response)
648/// * [locations secrets get projects](ProjectLocationSecretGetCall) (response)
649/// * [locations secrets patch projects](ProjectLocationSecretPatchCall) (request|response)
650/// * [secrets create projects](ProjectSecretCreateCall) (request|response)
651/// * [secrets get projects](ProjectSecretGetCall) (response)
652/// * [secrets patch projects](ProjectSecretPatchCall) (request|response)
653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
654#[serde_with::serde_as]
655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
656pub struct Secret {
657    /// Optional. Custom metadata about the secret. Annotations are distinct from various forms of labels. Annotations exist to allow client tools to store their own state information without requiring a database. Annotation keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, begin and end with an alphanumeric character ([a-z0-9A-Z]), and may have dashes (-), underscores (_), dots (.), and alphanumerics in between these symbols. The total size of annotation keys and values must be less than 16KiB.
658    pub annotations: Option<HashMap<String, String>>,
659    /// Output only. The time at which the Secret was created.
660    #[serde(rename = "createTime")]
661    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
662    /// Optional. The customer-managed encryption configuration of the regionalized secrets. If no configuration is provided, Google-managed default encryption is used. Updates to the Secret encryption configuration only apply to SecretVersions added afterwards. They do not apply retroactively to existing SecretVersions.
663    #[serde(rename = "customerManagedEncryption")]
664    pub customer_managed_encryption: Option<CustomerManagedEncryption>,
665    /// Optional. Etag of the currently stored Secret.
666    pub etag: Option<String>,
667    /// Optional. Timestamp in UTC when the Secret is scheduled to expire. This is always provided on output, regardless of what was sent on input.
668    #[serde(rename = "expireTime")]
669    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
670    /// The labels assigned to this Secret. Label keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: `\p{Ll}\p{Lo}{0,62}` Label values must be between 0 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}` No more than 64 labels can be assigned to a given resource.
671    pub labels: Option<HashMap<String, String>>,
672    /// Output only. The resource name of the Secret in the format `projects/*/secrets/*`.
673    pub name: Option<String>,
674    /// Optional. Immutable. The replication policy of the secret data attached to the Secret. The replication policy cannot be changed after the Secret has been created.
675    pub replication: Option<Replication>,
676    /// Optional. Rotation policy attached to the Secret. May be excluded if there is no rotation policy.
677    pub rotation: Option<Rotation>,
678    /// Optional. Input only. Immutable. Mapping of Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing" Tags are used to organize and group resources. Tags can be used to control policy evaluation for the resource.
679    pub tags: Option<HashMap<String, String>>,
680    /// Optional. A list of up to 10 Pub/Sub topics to which messages are published when control plane operations are called on the secret or its versions.
681    pub topics: Option<Vec<Topic>>,
682    /// Input only. The TTL for the Secret.
683    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
684    pub ttl: Option<chrono::Duration>,
685    /// Optional. Mapping from version alias to version name. A version alias is a string with a maximum length of 63 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore ('_') characters. An alias string must start with a letter and cannot be the string 'latest' or 'NEW'. No more than 50 aliases can be assigned to a given secret. Version-Alias pairs will be viewable via GetSecret and modifiable via UpdateSecret. Access by alias is only be supported on GetSecretVersion and AccessSecretVersion.
686    #[serde(rename = "versionAliases")]
687    #[serde_as(as = "Option<HashMap<_, serde_with::DisplayFromStr>>")]
688    pub version_aliases: Option<HashMap<String, i64>>,
689    /// Optional. Secret Version TTL after destruction request This is a part of the Delayed secret version destroy feature. For secret with TTL>0, version destruction doesn't happen immediately on calling destroy instead the version goes to a disabled state and destruction happens after the TTL expires.
690    #[serde(rename = "versionDestroyTtl")]
691    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
692    pub version_destroy_ttl: Option<chrono::Duration>,
693}
694
695impl common::RequestValue for Secret {}
696impl common::ResponseResult for Secret {}
697
698/// A secret payload resource in the Secret Manager API. This contains the sensitive secret payload that is associated with a SecretVersion.
699///
700/// This type is not used in any activity, and only used as *part* of another schema.
701///
702#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
703#[serde_with::serde_as]
704#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
705pub struct SecretPayload {
706    /// The secret data. Must be no larger than 64KiB.
707    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
708    pub data: Option<Vec<u8>>,
709    /// Optional. If specified, SecretManagerService will verify the integrity of the received data on SecretManagerService.AddSecretVersion calls using the crc32c checksum and store it to include in future SecretManagerService.AccessSecretVersion responses. If a checksum is not provided in the SecretManagerService.AddSecretVersion request, the SecretManagerService will generate and store one for you. The CRC32C value is encoded as a Int64 for compatibility, and can be safely downconverted to uint32 in languages that support this type. https://cloud.google.com/apis/design/design_patterns#integer_types
710    #[serde(rename = "dataCrc32c")]
711    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
712    pub data_crc32c: Option<i64>,
713}
714
715impl common::Part for SecretPayload {}
716
717/// A secret version resource in the Secret Manager API.
718///
719/// # Activities
720///
721/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
722/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
723///
724/// * [locations secrets versions destroy projects](ProjectLocationSecretVersionDestroyCall) (response)
725/// * [locations secrets versions disable projects](ProjectLocationSecretVersionDisableCall) (response)
726/// * [locations secrets versions enable projects](ProjectLocationSecretVersionEnableCall) (response)
727/// * [locations secrets versions get projects](ProjectLocationSecretVersionGetCall) (response)
728/// * [locations secrets add version projects](ProjectLocationSecretAddVersionCall) (response)
729/// * [secrets versions destroy projects](ProjectSecretVersionDestroyCall) (response)
730/// * [secrets versions disable projects](ProjectSecretVersionDisableCall) (response)
731/// * [secrets versions enable projects](ProjectSecretVersionEnableCall) (response)
732/// * [secrets versions get projects](ProjectSecretVersionGetCall) (response)
733/// * [secrets add version projects](ProjectSecretAddVersionCall) (response)
734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
735#[serde_with::serde_as]
736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
737pub struct SecretVersion {
738    /// Output only. True if payload checksum specified in SecretPayload object has been received by SecretManagerService on SecretManagerService.AddSecretVersion.
739    #[serde(rename = "clientSpecifiedPayloadChecksum")]
740    pub client_specified_payload_checksum: Option<bool>,
741    /// Output only. The time at which the SecretVersion was created.
742    #[serde(rename = "createTime")]
743    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
744    /// Output only. The customer-managed encryption status of the SecretVersion. Only populated if customer-managed encryption is used and Secret is a regionalized secret.
745    #[serde(rename = "customerManagedEncryption")]
746    pub customer_managed_encryption: Option<CustomerManagedEncryptionStatus>,
747    /// Output only. The time this SecretVersion was destroyed. Only present if state is DESTROYED.
748    #[serde(rename = "destroyTime")]
749    pub destroy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
750    /// Output only. Etag of the currently stored SecretVersion.
751    pub etag: Option<String>,
752    /// Output only. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*`. SecretVersion IDs in a Secret start at 1 and are incremented for each subsequent version of the secret.
753    pub name: Option<String>,
754    /// The replication status of the SecretVersion.
755    #[serde(rename = "replicationStatus")]
756    pub replication_status: Option<ReplicationStatus>,
757    /// Optional. Output only. Scheduled destroy time for secret version. This is a part of the Delayed secret version destroy feature. For a Secret with a valid version destroy TTL, when a secert version is destroyed, version is moved to disabled state and it is scheduled for destruction Version is destroyed only after the scheduled_destroy_time.
758    #[serde(rename = "scheduledDestroyTime")]
759    pub scheduled_destroy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
760    /// Output only. The current state of the SecretVersion.
761    pub state: Option<String>,
762}
763
764impl common::ResponseResult for SecretVersion {}
765
766/// Request message for `SetIamPolicy` method.
767///
768/// # Activities
769///
770/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
771/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
772///
773/// * [locations secrets set iam policy projects](ProjectLocationSecretSetIamPolicyCall) (request)
774/// * [secrets set iam policy projects](ProjectSecretSetIamPolicyCall) (request)
775#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
776#[serde_with::serde_as]
777#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
778pub struct SetIamPolicyRequest {
779    /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
780    pub policy: Option<Policy>,
781    /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
782    #[serde(rename = "updateMask")]
783    pub update_mask: Option<common::FieldMask>,
784}
785
786impl common::RequestValue for SetIamPolicyRequest {}
787
788/// Request message for `TestIamPermissions` method.
789///
790/// # Activities
791///
792/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
793/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
794///
795/// * [locations secrets test iam permissions projects](ProjectLocationSecretTestIamPermissionCall) (request)
796/// * [secrets test iam permissions projects](ProjectSecretTestIamPermissionCall) (request)
797#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
798#[serde_with::serde_as]
799#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
800pub struct TestIamPermissionsRequest {
801    /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
802    pub permissions: Option<Vec<String>>,
803}
804
805impl common::RequestValue for TestIamPermissionsRequest {}
806
807/// Response message for `TestIamPermissions` method.
808///
809/// # Activities
810///
811/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
812/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
813///
814/// * [locations secrets test iam permissions projects](ProjectLocationSecretTestIamPermissionCall) (response)
815/// * [secrets test iam permissions projects](ProjectSecretTestIamPermissionCall) (response)
816#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
817#[serde_with::serde_as]
818#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
819pub struct TestIamPermissionsResponse {
820    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
821    pub permissions: Option<Vec<String>>,
822}
823
824impl common::ResponseResult for TestIamPermissionsResponse {}
825
826/// A Pub/Sub topic which Secret Manager will publish to when control plane events occur on this secret.
827///
828/// This type is not used in any activity, and only used as *part* of another schema.
829///
830#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
831#[serde_with::serde_as]
832#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
833pub struct Topic {
834    /// Identifier. The resource name of the Pub/Sub topic that will be published to, in the following format: `projects/*/topics/*`. For publication to succeed, the Secret Manager service agent must have the `pubsub.topic.publish` permission on the topic. The Pub/Sub Publisher role (`roles/pubsub.publisher`) includes this permission.
835    pub name: Option<String>,
836}
837
838impl common::Part for Topic {}
839
840/// A replication policy that replicates the Secret payload into the locations specified in Replication.UserManaged.replicas
841///
842/// This type is not used in any activity, and only used as *part* of another schema.
843///
844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
845#[serde_with::serde_as]
846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
847pub struct UserManaged {
848    /// Required. The list of Replicas for this Secret. Cannot be empty.
849    pub replicas: Option<Vec<Replica>>,
850}
851
852impl common::Part for UserManaged {}
853
854/// The replication status of a SecretVersion using user-managed replication. Only populated if the parent Secret has a user-managed replication policy.
855///
856/// This type is not used in any activity, and only used as *part* of another schema.
857///
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct UserManagedStatus {
862    /// Output only. The list of replica statuses for the SecretVersion.
863    pub replicas: Option<Vec<ReplicaStatus>>,
864}
865
866impl common::Part for UserManagedStatus {}
867
868// ###################
869// MethodBuilders ###
870// #################
871
872/// A builder providing access to all methods supported on *project* resources.
873/// It is not used directly, but through the [`SecretManager`] hub.
874///
875/// # Example
876///
877/// Instantiate a resource builder
878///
879/// ```test_harness,no_run
880/// extern crate hyper;
881/// extern crate hyper_rustls;
882/// extern crate google_secretmanager1 as secretmanager1;
883///
884/// # async fn dox() {
885/// use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
886///
887/// let secret: yup_oauth2::ApplicationSecret = Default::default();
888/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
889///     .with_native_roots()
890///     .unwrap()
891///     .https_only()
892///     .enable_http2()
893///     .build();
894///
895/// let executor = hyper_util::rt::TokioExecutor::new();
896/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
897///     secret,
898///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
899///     yup_oauth2::client::CustomHyperClientBuilder::from(
900///         hyper_util::client::legacy::Client::builder(executor).build(connector),
901///     ),
902/// ).build().await.unwrap();
903///
904/// let client = hyper_util::client::legacy::Client::builder(
905///     hyper_util::rt::TokioExecutor::new()
906/// )
907/// .build(
908///     hyper_rustls::HttpsConnectorBuilder::new()
909///         .with_native_roots()
910///         .unwrap()
911///         .https_or_http()
912///         .enable_http2()
913///         .build()
914/// );
915/// let mut hub = SecretManager::new(client, auth);
916/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
917/// // like `locations_get(...)`, `locations_list(...)`, `locations_secrets_add_version(...)`, `locations_secrets_create(...)`, `locations_secrets_delete(...)`, `locations_secrets_get(...)`, `locations_secrets_get_iam_policy(...)`, `locations_secrets_list(...)`, `locations_secrets_patch(...)`, `locations_secrets_set_iam_policy(...)`, `locations_secrets_test_iam_permissions(...)`, `locations_secrets_versions_access(...)`, `locations_secrets_versions_destroy(...)`, `locations_secrets_versions_disable(...)`, `locations_secrets_versions_enable(...)`, `locations_secrets_versions_get(...)`, `locations_secrets_versions_list(...)`, `secrets_add_version(...)`, `secrets_create(...)`, `secrets_delete(...)`, `secrets_get(...)`, `secrets_get_iam_policy(...)`, `secrets_list(...)`, `secrets_patch(...)`, `secrets_set_iam_policy(...)`, `secrets_test_iam_permissions(...)`, `secrets_versions_access(...)`, `secrets_versions_destroy(...)`, `secrets_versions_disable(...)`, `secrets_versions_enable(...)`, `secrets_versions_get(...)` and `secrets_versions_list(...)`
918/// // to build up your call.
919/// let rb = hub.projects();
920/// # }
921/// ```
922pub struct ProjectMethods<'a, C>
923where
924    C: 'a,
925{
926    hub: &'a SecretManager<C>,
927}
928
929impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
930
931impl<'a, C> ProjectMethods<'a, C> {
932    /// Create a builder to help you perform the following task:
933    ///
934    /// Accesses a SecretVersion. This call returns the secret data. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
935    ///
936    /// # Arguments
937    ///
938    /// * `name` - Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
939    pub fn locations_secrets_versions_access(
940        &self,
941        name: &str,
942    ) -> ProjectLocationSecretVersionAccesCall<'a, C> {
943        ProjectLocationSecretVersionAccesCall {
944            hub: self.hub,
945            _name: name.to_string(),
946            _delegate: Default::default(),
947            _additional_params: Default::default(),
948            _scopes: Default::default(),
949        }
950    }
951
952    /// Create a builder to help you perform the following task:
953    ///
954    /// Destroys a SecretVersion. Sets the state of the SecretVersion to DESTROYED and irrevocably destroys the secret data.
955    ///
956    /// # Arguments
957    ///
958    /// * `request` - No description provided.
959    /// * `name` - Required. The resource name of the SecretVersion to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
960    pub fn locations_secrets_versions_destroy(
961        &self,
962        request: DestroySecretVersionRequest,
963        name: &str,
964    ) -> ProjectLocationSecretVersionDestroyCall<'a, C> {
965        ProjectLocationSecretVersionDestroyCall {
966            hub: self.hub,
967            _request: request,
968            _name: name.to_string(),
969            _delegate: Default::default(),
970            _additional_params: Default::default(),
971            _scopes: Default::default(),
972        }
973    }
974
975    /// Create a builder to help you perform the following task:
976    ///
977    /// Disables a SecretVersion. Sets the state of the SecretVersion to DISABLED.
978    ///
979    /// # Arguments
980    ///
981    /// * `request` - No description provided.
982    /// * `name` - Required. The resource name of the SecretVersion to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
983    pub fn locations_secrets_versions_disable(
984        &self,
985        request: DisableSecretVersionRequest,
986        name: &str,
987    ) -> ProjectLocationSecretVersionDisableCall<'a, C> {
988        ProjectLocationSecretVersionDisableCall {
989            hub: self.hub,
990            _request: request,
991            _name: name.to_string(),
992            _delegate: Default::default(),
993            _additional_params: Default::default(),
994            _scopes: Default::default(),
995        }
996    }
997
998    /// Create a builder to help you perform the following task:
999    ///
1000    /// Enables a SecretVersion. Sets the state of the SecretVersion to ENABLED.
1001    ///
1002    /// # Arguments
1003    ///
1004    /// * `request` - No description provided.
1005    /// * `name` - Required. The resource name of the SecretVersion to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
1006    pub fn locations_secrets_versions_enable(
1007        &self,
1008        request: EnableSecretVersionRequest,
1009        name: &str,
1010    ) -> ProjectLocationSecretVersionEnableCall<'a, C> {
1011        ProjectLocationSecretVersionEnableCall {
1012            hub: self.hub,
1013            _request: request,
1014            _name: name.to_string(),
1015            _delegate: Default::default(),
1016            _additional_params: Default::default(),
1017            _scopes: Default::default(),
1018        }
1019    }
1020
1021    /// Create a builder to help you perform the following task:
1022    ///
1023    /// Gets metadata for a SecretVersion. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1024    ///
1025    /// # Arguments
1026    ///
1027    /// * `name` - Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1028    pub fn locations_secrets_versions_get(
1029        &self,
1030        name: &str,
1031    ) -> ProjectLocationSecretVersionGetCall<'a, C> {
1032        ProjectLocationSecretVersionGetCall {
1033            hub: self.hub,
1034            _name: name.to_string(),
1035            _delegate: Default::default(),
1036            _additional_params: Default::default(),
1037            _scopes: Default::default(),
1038        }
1039    }
1040
1041    /// Create a builder to help you perform the following task:
1042    ///
1043    /// Lists SecretVersions. This call does not return secret data.
1044    ///
1045    /// # Arguments
1046    ///
1047    /// * `parent` - Required. The resource name of the Secret associated with the SecretVersions to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1048    pub fn locations_secrets_versions_list(
1049        &self,
1050        parent: &str,
1051    ) -> ProjectLocationSecretVersionListCall<'a, C> {
1052        ProjectLocationSecretVersionListCall {
1053            hub: self.hub,
1054            _parent: parent.to_string(),
1055            _page_token: Default::default(),
1056            _page_size: Default::default(),
1057            _filter: Default::default(),
1058            _delegate: Default::default(),
1059            _additional_params: Default::default(),
1060            _scopes: Default::default(),
1061        }
1062    }
1063
1064    /// Create a builder to help you perform the following task:
1065    ///
1066    /// Creates a new SecretVersion containing secret data and attaches it to an existing Secret.
1067    ///
1068    /// # Arguments
1069    ///
1070    /// * `request` - No description provided.
1071    /// * `parent` - Required. The resource name of the Secret to associate with the SecretVersion in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1072    pub fn locations_secrets_add_version(
1073        &self,
1074        request: AddSecretVersionRequest,
1075        parent: &str,
1076    ) -> ProjectLocationSecretAddVersionCall<'a, C> {
1077        ProjectLocationSecretAddVersionCall {
1078            hub: self.hub,
1079            _request: request,
1080            _parent: parent.to_string(),
1081            _delegate: Default::default(),
1082            _additional_params: Default::default(),
1083            _scopes: Default::default(),
1084        }
1085    }
1086
1087    /// Create a builder to help you perform the following task:
1088    ///
1089    /// Creates a new Secret containing no SecretVersions.
1090    ///
1091    /// # Arguments
1092    ///
1093    /// * `request` - No description provided.
1094    /// * `parent` - Required. The resource name of the project to associate with the Secret, in the format `projects/*` or `projects/*/locations/*`.
1095    pub fn locations_secrets_create(
1096        &self,
1097        request: Secret,
1098        parent: &str,
1099    ) -> ProjectLocationSecretCreateCall<'a, C> {
1100        ProjectLocationSecretCreateCall {
1101            hub: self.hub,
1102            _request: request,
1103            _parent: parent.to_string(),
1104            _secret_id: Default::default(),
1105            _delegate: Default::default(),
1106            _additional_params: Default::default(),
1107            _scopes: Default::default(),
1108        }
1109    }
1110
1111    /// Create a builder to help you perform the following task:
1112    ///
1113    /// Deletes a Secret.
1114    ///
1115    /// # Arguments
1116    ///
1117    /// * `name` - Required. The resource name of the Secret to delete in the format `projects/*/secrets/*`.
1118    pub fn locations_secrets_delete(&self, name: &str) -> ProjectLocationSecretDeleteCall<'a, C> {
1119        ProjectLocationSecretDeleteCall {
1120            hub: self.hub,
1121            _name: name.to_string(),
1122            _etag: Default::default(),
1123            _delegate: Default::default(),
1124            _additional_params: Default::default(),
1125            _scopes: Default::default(),
1126        }
1127    }
1128
1129    /// Create a builder to help you perform the following task:
1130    ///
1131    /// Gets metadata for a given Secret.
1132    ///
1133    /// # Arguments
1134    ///
1135    /// * `name` - Required. The resource name of the Secret, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1136    pub fn locations_secrets_get(&self, name: &str) -> ProjectLocationSecretGetCall<'a, C> {
1137        ProjectLocationSecretGetCall {
1138            hub: self.hub,
1139            _name: name.to_string(),
1140            _delegate: Default::default(),
1141            _additional_params: Default::default(),
1142            _scopes: Default::default(),
1143        }
1144    }
1145
1146    /// Create a builder to help you perform the following task:
1147    ///
1148    /// Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.
1149    ///
1150    /// # Arguments
1151    ///
1152    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1153    pub fn locations_secrets_get_iam_policy(
1154        &self,
1155        resource: &str,
1156    ) -> ProjectLocationSecretGetIamPolicyCall<'a, C> {
1157        ProjectLocationSecretGetIamPolicyCall {
1158            hub: self.hub,
1159            _resource: resource.to_string(),
1160            _options_requested_policy_version: Default::default(),
1161            _delegate: Default::default(),
1162            _additional_params: Default::default(),
1163            _scopes: Default::default(),
1164        }
1165    }
1166
1167    /// Create a builder to help you perform the following task:
1168    ///
1169    /// Lists Secrets.
1170    ///
1171    /// # Arguments
1172    ///
1173    /// * `parent` - Required. The resource name of the project associated with the Secrets, in the format `projects/*` or `projects/*/locations/*`
1174    pub fn locations_secrets_list(&self, parent: &str) -> ProjectLocationSecretListCall<'a, C> {
1175        ProjectLocationSecretListCall {
1176            hub: self.hub,
1177            _parent: parent.to_string(),
1178            _page_token: Default::default(),
1179            _page_size: Default::default(),
1180            _filter: Default::default(),
1181            _delegate: Default::default(),
1182            _additional_params: Default::default(),
1183            _scopes: Default::default(),
1184        }
1185    }
1186
1187    /// Create a builder to help you perform the following task:
1188    ///
1189    /// Updates metadata of an existing Secret.
1190    ///
1191    /// # Arguments
1192    ///
1193    /// * `request` - No description provided.
1194    /// * `name` - Output only. The resource name of the Secret in the format `projects/*/secrets/*`.
1195    pub fn locations_secrets_patch(
1196        &self,
1197        request: Secret,
1198        name: &str,
1199    ) -> ProjectLocationSecretPatchCall<'a, C> {
1200        ProjectLocationSecretPatchCall {
1201            hub: self.hub,
1202            _request: request,
1203            _name: name.to_string(),
1204            _update_mask: Default::default(),
1205            _delegate: Default::default(),
1206            _additional_params: Default::default(),
1207            _scopes: Default::default(),
1208        }
1209    }
1210
1211    /// Create a builder to help you perform the following task:
1212    ///
1213    /// Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on SecretVersions are enforced according to the policy set on the associated Secret.
1214    ///
1215    /// # Arguments
1216    ///
1217    /// * `request` - No description provided.
1218    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1219    pub fn locations_secrets_set_iam_policy(
1220        &self,
1221        request: SetIamPolicyRequest,
1222        resource: &str,
1223    ) -> ProjectLocationSecretSetIamPolicyCall<'a, C> {
1224        ProjectLocationSecretSetIamPolicyCall {
1225            hub: self.hub,
1226            _request: request,
1227            _resource: resource.to_string(),
1228            _delegate: Default::default(),
1229            _additional_params: Default::default(),
1230            _scopes: Default::default(),
1231        }
1232    }
1233
1234    /// Create a builder to help you perform the following task:
1235    ///
1236    /// Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
1237    ///
1238    /// # Arguments
1239    ///
1240    /// * `request` - No description provided.
1241    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1242    pub fn locations_secrets_test_iam_permissions(
1243        &self,
1244        request: TestIamPermissionsRequest,
1245        resource: &str,
1246    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C> {
1247        ProjectLocationSecretTestIamPermissionCall {
1248            hub: self.hub,
1249            _request: request,
1250            _resource: resource.to_string(),
1251            _delegate: Default::default(),
1252            _additional_params: Default::default(),
1253            _scopes: Default::default(),
1254        }
1255    }
1256
1257    /// Create a builder to help you perform the following task:
1258    ///
1259    /// Gets information about a location.
1260    ///
1261    /// # Arguments
1262    ///
1263    /// * `name` - Resource name for the location.
1264    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1265        ProjectLocationGetCall {
1266            hub: self.hub,
1267            _name: name.to_string(),
1268            _delegate: Default::default(),
1269            _additional_params: Default::default(),
1270            _scopes: Default::default(),
1271        }
1272    }
1273
1274    /// Create a builder to help you perform the following task:
1275    ///
1276    /// Lists information about the supported locations for this service.
1277    ///
1278    /// # Arguments
1279    ///
1280    /// * `name` - The resource that owns the locations collection, if applicable.
1281    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1282        ProjectLocationListCall {
1283            hub: self.hub,
1284            _name: name.to_string(),
1285            _page_token: Default::default(),
1286            _page_size: Default::default(),
1287            _filter: Default::default(),
1288            _extra_location_types: Default::default(),
1289            _delegate: Default::default(),
1290            _additional_params: Default::default(),
1291            _scopes: Default::default(),
1292        }
1293    }
1294
1295    /// Create a builder to help you perform the following task:
1296    ///
1297    /// Accesses a SecretVersion. This call returns the secret data. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1298    ///
1299    /// # Arguments
1300    ///
1301    /// * `name` - Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1302    pub fn secrets_versions_access(&self, name: &str) -> ProjectSecretVersionAccesCall<'a, C> {
1303        ProjectSecretVersionAccesCall {
1304            hub: self.hub,
1305            _name: name.to_string(),
1306            _delegate: Default::default(),
1307            _additional_params: Default::default(),
1308            _scopes: Default::default(),
1309        }
1310    }
1311
1312    /// Create a builder to help you perform the following task:
1313    ///
1314    /// Destroys a SecretVersion. Sets the state of the SecretVersion to DESTROYED and irrevocably destroys the secret data.
1315    ///
1316    /// # Arguments
1317    ///
1318    /// * `request` - No description provided.
1319    /// * `name` - Required. The resource name of the SecretVersion to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
1320    pub fn secrets_versions_destroy(
1321        &self,
1322        request: DestroySecretVersionRequest,
1323        name: &str,
1324    ) -> ProjectSecretVersionDestroyCall<'a, C> {
1325        ProjectSecretVersionDestroyCall {
1326            hub: self.hub,
1327            _request: request,
1328            _name: name.to_string(),
1329            _delegate: Default::default(),
1330            _additional_params: Default::default(),
1331            _scopes: Default::default(),
1332        }
1333    }
1334
1335    /// Create a builder to help you perform the following task:
1336    ///
1337    /// Disables a SecretVersion. Sets the state of the SecretVersion to DISABLED.
1338    ///
1339    /// # Arguments
1340    ///
1341    /// * `request` - No description provided.
1342    /// * `name` - Required. The resource name of the SecretVersion to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
1343    pub fn secrets_versions_disable(
1344        &self,
1345        request: DisableSecretVersionRequest,
1346        name: &str,
1347    ) -> ProjectSecretVersionDisableCall<'a, C> {
1348        ProjectSecretVersionDisableCall {
1349            hub: self.hub,
1350            _request: request,
1351            _name: name.to_string(),
1352            _delegate: Default::default(),
1353            _additional_params: Default::default(),
1354            _scopes: Default::default(),
1355        }
1356    }
1357
1358    /// Create a builder to help you perform the following task:
1359    ///
1360    /// Enables a SecretVersion. Sets the state of the SecretVersion to ENABLED.
1361    ///
1362    /// # Arguments
1363    ///
1364    /// * `request` - No description provided.
1365    /// * `name` - Required. The resource name of the SecretVersion to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
1366    pub fn secrets_versions_enable(
1367        &self,
1368        request: EnableSecretVersionRequest,
1369        name: &str,
1370    ) -> ProjectSecretVersionEnableCall<'a, C> {
1371        ProjectSecretVersionEnableCall {
1372            hub: self.hub,
1373            _request: request,
1374            _name: name.to_string(),
1375            _delegate: Default::default(),
1376            _additional_params: Default::default(),
1377            _scopes: Default::default(),
1378        }
1379    }
1380
1381    /// Create a builder to help you perform the following task:
1382    ///
1383    /// Gets metadata for a SecretVersion. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1384    ///
1385    /// # Arguments
1386    ///
1387    /// * `name` - Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1388    pub fn secrets_versions_get(&self, name: &str) -> ProjectSecretVersionGetCall<'a, C> {
1389        ProjectSecretVersionGetCall {
1390            hub: self.hub,
1391            _name: name.to_string(),
1392            _delegate: Default::default(),
1393            _additional_params: Default::default(),
1394            _scopes: Default::default(),
1395        }
1396    }
1397
1398    /// Create a builder to help you perform the following task:
1399    ///
1400    /// Lists SecretVersions. This call does not return secret data.
1401    ///
1402    /// # Arguments
1403    ///
1404    /// * `parent` - Required. The resource name of the Secret associated with the SecretVersions to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1405    pub fn secrets_versions_list(&self, parent: &str) -> ProjectSecretVersionListCall<'a, C> {
1406        ProjectSecretVersionListCall {
1407            hub: self.hub,
1408            _parent: parent.to_string(),
1409            _page_token: Default::default(),
1410            _page_size: Default::default(),
1411            _filter: Default::default(),
1412            _delegate: Default::default(),
1413            _additional_params: Default::default(),
1414            _scopes: Default::default(),
1415        }
1416    }
1417
1418    /// Create a builder to help you perform the following task:
1419    ///
1420    /// Creates a new SecretVersion containing secret data and attaches it to an existing Secret.
1421    ///
1422    /// # Arguments
1423    ///
1424    /// * `request` - No description provided.
1425    /// * `parent` - Required. The resource name of the Secret to associate with the SecretVersion in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1426    pub fn secrets_add_version(
1427        &self,
1428        request: AddSecretVersionRequest,
1429        parent: &str,
1430    ) -> ProjectSecretAddVersionCall<'a, C> {
1431        ProjectSecretAddVersionCall {
1432            hub: self.hub,
1433            _request: request,
1434            _parent: parent.to_string(),
1435            _delegate: Default::default(),
1436            _additional_params: Default::default(),
1437            _scopes: Default::default(),
1438        }
1439    }
1440
1441    /// Create a builder to help you perform the following task:
1442    ///
1443    /// Creates a new Secret containing no SecretVersions.
1444    ///
1445    /// # Arguments
1446    ///
1447    /// * `request` - No description provided.
1448    /// * `parent` - Required. The resource name of the project to associate with the Secret, in the format `projects/*` or `projects/*/locations/*`.
1449    pub fn secrets_create(&self, request: Secret, parent: &str) -> ProjectSecretCreateCall<'a, C> {
1450        ProjectSecretCreateCall {
1451            hub: self.hub,
1452            _request: request,
1453            _parent: parent.to_string(),
1454            _secret_id: Default::default(),
1455            _delegate: Default::default(),
1456            _additional_params: Default::default(),
1457            _scopes: Default::default(),
1458        }
1459    }
1460
1461    /// Create a builder to help you perform the following task:
1462    ///
1463    /// Deletes a Secret.
1464    ///
1465    /// # Arguments
1466    ///
1467    /// * `name` - Required. The resource name of the Secret to delete in the format `projects/*/secrets/*`.
1468    pub fn secrets_delete(&self, name: &str) -> ProjectSecretDeleteCall<'a, C> {
1469        ProjectSecretDeleteCall {
1470            hub: self.hub,
1471            _name: name.to_string(),
1472            _etag: Default::default(),
1473            _delegate: Default::default(),
1474            _additional_params: Default::default(),
1475            _scopes: Default::default(),
1476        }
1477    }
1478
1479    /// Create a builder to help you perform the following task:
1480    ///
1481    /// Gets metadata for a given Secret.
1482    ///
1483    /// # Arguments
1484    ///
1485    /// * `name` - Required. The resource name of the Secret, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
1486    pub fn secrets_get(&self, name: &str) -> ProjectSecretGetCall<'a, C> {
1487        ProjectSecretGetCall {
1488            hub: self.hub,
1489            _name: name.to_string(),
1490            _delegate: Default::default(),
1491            _additional_params: Default::default(),
1492            _scopes: Default::default(),
1493        }
1494    }
1495
1496    /// Create a builder to help you perform the following task:
1497    ///
1498    /// Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.
1499    ///
1500    /// # Arguments
1501    ///
1502    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1503    pub fn secrets_get_iam_policy(&self, resource: &str) -> ProjectSecretGetIamPolicyCall<'a, C> {
1504        ProjectSecretGetIamPolicyCall {
1505            hub: self.hub,
1506            _resource: resource.to_string(),
1507            _options_requested_policy_version: Default::default(),
1508            _delegate: Default::default(),
1509            _additional_params: Default::default(),
1510            _scopes: Default::default(),
1511        }
1512    }
1513
1514    /// Create a builder to help you perform the following task:
1515    ///
1516    /// Lists Secrets.
1517    ///
1518    /// # Arguments
1519    ///
1520    /// * `parent` - Required. The resource name of the project associated with the Secrets, in the format `projects/*` or `projects/*/locations/*`
1521    pub fn secrets_list(&self, parent: &str) -> ProjectSecretListCall<'a, C> {
1522        ProjectSecretListCall {
1523            hub: self.hub,
1524            _parent: parent.to_string(),
1525            _page_token: Default::default(),
1526            _page_size: Default::default(),
1527            _filter: Default::default(),
1528            _delegate: Default::default(),
1529            _additional_params: Default::default(),
1530            _scopes: Default::default(),
1531        }
1532    }
1533
1534    /// Create a builder to help you perform the following task:
1535    ///
1536    /// Updates metadata of an existing Secret.
1537    ///
1538    /// # Arguments
1539    ///
1540    /// * `request` - No description provided.
1541    /// * `name` - Output only. The resource name of the Secret in the format `projects/*/secrets/*`.
1542    pub fn secrets_patch(&self, request: Secret, name: &str) -> ProjectSecretPatchCall<'a, C> {
1543        ProjectSecretPatchCall {
1544            hub: self.hub,
1545            _request: request,
1546            _name: name.to_string(),
1547            _update_mask: Default::default(),
1548            _delegate: Default::default(),
1549            _additional_params: Default::default(),
1550            _scopes: Default::default(),
1551        }
1552    }
1553
1554    /// Create a builder to help you perform the following task:
1555    ///
1556    /// Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on SecretVersions are enforced according to the policy set on the associated Secret.
1557    ///
1558    /// # Arguments
1559    ///
1560    /// * `request` - No description provided.
1561    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1562    pub fn secrets_set_iam_policy(
1563        &self,
1564        request: SetIamPolicyRequest,
1565        resource: &str,
1566    ) -> ProjectSecretSetIamPolicyCall<'a, C> {
1567        ProjectSecretSetIamPolicyCall {
1568            hub: self.hub,
1569            _request: request,
1570            _resource: resource.to_string(),
1571            _delegate: Default::default(),
1572            _additional_params: Default::default(),
1573            _scopes: Default::default(),
1574        }
1575    }
1576
1577    /// Create a builder to help you perform the following task:
1578    ///
1579    /// Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
1580    ///
1581    /// # Arguments
1582    ///
1583    /// * `request` - No description provided.
1584    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1585    pub fn secrets_test_iam_permissions(
1586        &self,
1587        request: TestIamPermissionsRequest,
1588        resource: &str,
1589    ) -> ProjectSecretTestIamPermissionCall<'a, C> {
1590        ProjectSecretTestIamPermissionCall {
1591            hub: self.hub,
1592            _request: request,
1593            _resource: resource.to_string(),
1594            _delegate: Default::default(),
1595            _additional_params: Default::default(),
1596            _scopes: Default::default(),
1597        }
1598    }
1599}
1600
1601// ###################
1602// CallBuilders   ###
1603// #################
1604
1605/// Accesses a SecretVersion. This call returns the secret data. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1606///
1607/// A builder for the *locations.secrets.versions.access* method supported by a *project* resource.
1608/// It is not used directly, but through a [`ProjectMethods`] instance.
1609///
1610/// # Example
1611///
1612/// Instantiate a resource method builder
1613///
1614/// ```test_harness,no_run
1615/// # extern crate hyper;
1616/// # extern crate hyper_rustls;
1617/// # extern crate google_secretmanager1 as secretmanager1;
1618/// # async fn dox() {
1619/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1620///
1621/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1622/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1623/// #     .with_native_roots()
1624/// #     .unwrap()
1625/// #     .https_only()
1626/// #     .enable_http2()
1627/// #     .build();
1628///
1629/// # let executor = hyper_util::rt::TokioExecutor::new();
1630/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1631/// #     secret,
1632/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1633/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1634/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1635/// #     ),
1636/// # ).build().await.unwrap();
1637///
1638/// # let client = hyper_util::client::legacy::Client::builder(
1639/// #     hyper_util::rt::TokioExecutor::new()
1640/// # )
1641/// # .build(
1642/// #     hyper_rustls::HttpsConnectorBuilder::new()
1643/// #         .with_native_roots()
1644/// #         .unwrap()
1645/// #         .https_or_http()
1646/// #         .enable_http2()
1647/// #         .build()
1648/// # );
1649/// # let mut hub = SecretManager::new(client, auth);
1650/// // You can configure optional parameters by calling the respective setters at will, and
1651/// // execute the final call using `doit()`.
1652/// // Values shown here are possibly random and not representative !
1653/// let result = hub.projects().locations_secrets_versions_access("name")
1654///              .doit().await;
1655/// # }
1656/// ```
1657pub struct ProjectLocationSecretVersionAccesCall<'a, C>
1658where
1659    C: 'a,
1660{
1661    hub: &'a SecretManager<C>,
1662    _name: String,
1663    _delegate: Option<&'a mut dyn common::Delegate>,
1664    _additional_params: HashMap<String, String>,
1665    _scopes: BTreeSet<String>,
1666}
1667
1668impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionAccesCall<'a, C> {}
1669
1670impl<'a, C> ProjectLocationSecretVersionAccesCall<'a, C>
1671where
1672    C: common::Connector,
1673{
1674    /// Perform the operation you have build so far.
1675    pub async fn doit(mut self) -> common::Result<(common::Response, AccessSecretVersionResponse)> {
1676        use std::borrow::Cow;
1677        use std::io::{Read, Seek};
1678
1679        use common::{url::Params, ToParts};
1680        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1681
1682        let mut dd = common::DefaultDelegate;
1683        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1684        dlg.begin(common::MethodInfo {
1685            id: "secretmanager.projects.locations.secrets.versions.access",
1686            http_method: hyper::Method::GET,
1687        });
1688
1689        for &field in ["alt", "name"].iter() {
1690            if self._additional_params.contains_key(field) {
1691                dlg.finished(false);
1692                return Err(common::Error::FieldClash(field));
1693            }
1694        }
1695
1696        let mut params = Params::with_capacity(3 + self._additional_params.len());
1697        params.push("name", self._name);
1698
1699        params.extend(self._additional_params.iter());
1700
1701        params.push("alt", "json");
1702        let mut url = self.hub._base_url.clone() + "v1/{+name}:access";
1703        if self._scopes.is_empty() {
1704            self._scopes
1705                .insert(Scope::CloudPlatform.as_ref().to_string());
1706        }
1707
1708        #[allow(clippy::single_element_loop)]
1709        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1710            url = params.uri_replacement(url, param_name, find_this, true);
1711        }
1712        {
1713            let to_remove = ["name"];
1714            params.remove_params(&to_remove);
1715        }
1716
1717        let url = params.parse_with_url(&url);
1718
1719        loop {
1720            let token = match self
1721                .hub
1722                .auth
1723                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1724                .await
1725            {
1726                Ok(token) => token,
1727                Err(e) => match dlg.token(e) {
1728                    Ok(token) => token,
1729                    Err(e) => {
1730                        dlg.finished(false);
1731                        return Err(common::Error::MissingToken(e));
1732                    }
1733                },
1734            };
1735            let mut req_result = {
1736                let client = &self.hub.client;
1737                dlg.pre_request();
1738                let mut req_builder = hyper::Request::builder()
1739                    .method(hyper::Method::GET)
1740                    .uri(url.as_str())
1741                    .header(USER_AGENT, self.hub._user_agent.clone());
1742
1743                if let Some(token) = token.as_ref() {
1744                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1745                }
1746
1747                let request = req_builder
1748                    .header(CONTENT_LENGTH, 0_u64)
1749                    .body(common::to_body::<String>(None));
1750
1751                client.request(request.unwrap()).await
1752            };
1753
1754            match req_result {
1755                Err(err) => {
1756                    if let common::Retry::After(d) = dlg.http_error(&err) {
1757                        sleep(d).await;
1758                        continue;
1759                    }
1760                    dlg.finished(false);
1761                    return Err(common::Error::HttpError(err));
1762                }
1763                Ok(res) => {
1764                    let (mut parts, body) = res.into_parts();
1765                    let mut body = common::Body::new(body);
1766                    if !parts.status.is_success() {
1767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1768                        let error = serde_json::from_str(&common::to_string(&bytes));
1769                        let response = common::to_response(parts, bytes.into());
1770
1771                        if let common::Retry::After(d) =
1772                            dlg.http_failure(&response, error.as_ref().ok())
1773                        {
1774                            sleep(d).await;
1775                            continue;
1776                        }
1777
1778                        dlg.finished(false);
1779
1780                        return Err(match error {
1781                            Ok(value) => common::Error::BadRequest(value),
1782                            _ => common::Error::Failure(response),
1783                        });
1784                    }
1785                    let response = {
1786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1787                        let encoded = common::to_string(&bytes);
1788                        match serde_json::from_str(&encoded) {
1789                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1790                            Err(error) => {
1791                                dlg.response_json_decode_error(&encoded, &error);
1792                                return Err(common::Error::JsonDecodeError(
1793                                    encoded.to_string(),
1794                                    error,
1795                                ));
1796                            }
1797                        }
1798                    };
1799
1800                    dlg.finished(true);
1801                    return Ok(response);
1802                }
1803            }
1804        }
1805    }
1806
1807    /// Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
1808    ///
1809    /// Sets the *name* path property to the given value.
1810    ///
1811    /// Even though the property as already been set when instantiating this call,
1812    /// we provide this method for API completeness.
1813    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretVersionAccesCall<'a, C> {
1814        self._name = new_value.to_string();
1815        self
1816    }
1817    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1818    /// while executing the actual API request.
1819    ///
1820    /// ````text
1821    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1822    /// ````
1823    ///
1824    /// Sets the *delegate* property to the given value.
1825    pub fn delegate(
1826        mut self,
1827        new_value: &'a mut dyn common::Delegate,
1828    ) -> ProjectLocationSecretVersionAccesCall<'a, C> {
1829        self._delegate = Some(new_value);
1830        self
1831    }
1832
1833    /// Set any additional parameter of the query string used in the request.
1834    /// It should be used to set parameters which are not yet available through their own
1835    /// setters.
1836    ///
1837    /// Please note that this method must not be used to set any of the known parameters
1838    /// which have their own setter method. If done anyway, the request will fail.
1839    ///
1840    /// # Additional Parameters
1841    ///
1842    /// * *$.xgafv* (query-string) - V1 error format.
1843    /// * *access_token* (query-string) - OAuth access token.
1844    /// * *alt* (query-string) - Data format for response.
1845    /// * *callback* (query-string) - JSONP
1846    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1847    /// * *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.
1848    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1849    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1850    /// * *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.
1851    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1852    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1853    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionAccesCall<'a, C>
1854    where
1855        T: AsRef<str>,
1856    {
1857        self._additional_params
1858            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1859        self
1860    }
1861
1862    /// Identifies the authorization scope for the method you are building.
1863    ///
1864    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1865    /// [`Scope::CloudPlatform`].
1866    ///
1867    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1868    /// tokens for more than one scope.
1869    ///
1870    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1871    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1872    /// sufficient, a read-write scope will do as well.
1873    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionAccesCall<'a, C>
1874    where
1875        St: AsRef<str>,
1876    {
1877        self._scopes.insert(String::from(scope.as_ref()));
1878        self
1879    }
1880    /// Identifies the authorization scope(s) for the method you are building.
1881    ///
1882    /// See [`Self::add_scope()`] for details.
1883    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionAccesCall<'a, C>
1884    where
1885        I: IntoIterator<Item = St>,
1886        St: AsRef<str>,
1887    {
1888        self._scopes
1889            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1890        self
1891    }
1892
1893    /// Removes all scopes, and no default scope will be used either.
1894    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1895    /// for details).
1896    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionAccesCall<'a, C> {
1897        self._scopes.clear();
1898        self
1899    }
1900}
1901
1902/// Destroys a SecretVersion. Sets the state of the SecretVersion to DESTROYED and irrevocably destroys the secret data.
1903///
1904/// A builder for the *locations.secrets.versions.destroy* method supported by a *project* resource.
1905/// It is not used directly, but through a [`ProjectMethods`] instance.
1906///
1907/// # Example
1908///
1909/// Instantiate a resource method builder
1910///
1911/// ```test_harness,no_run
1912/// # extern crate hyper;
1913/// # extern crate hyper_rustls;
1914/// # extern crate google_secretmanager1 as secretmanager1;
1915/// use secretmanager1::api::DestroySecretVersionRequest;
1916/// # async fn dox() {
1917/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1918///
1919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1920/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1921/// #     .with_native_roots()
1922/// #     .unwrap()
1923/// #     .https_only()
1924/// #     .enable_http2()
1925/// #     .build();
1926///
1927/// # let executor = hyper_util::rt::TokioExecutor::new();
1928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1929/// #     secret,
1930/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1931/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1932/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1933/// #     ),
1934/// # ).build().await.unwrap();
1935///
1936/// # let client = hyper_util::client::legacy::Client::builder(
1937/// #     hyper_util::rt::TokioExecutor::new()
1938/// # )
1939/// # .build(
1940/// #     hyper_rustls::HttpsConnectorBuilder::new()
1941/// #         .with_native_roots()
1942/// #         .unwrap()
1943/// #         .https_or_http()
1944/// #         .enable_http2()
1945/// #         .build()
1946/// # );
1947/// # let mut hub = SecretManager::new(client, auth);
1948/// // As the method needs a request, you would usually fill it with the desired information
1949/// // into the respective structure. Some of the parts shown here might not be applicable !
1950/// // Values shown here are possibly random and not representative !
1951/// let mut req = DestroySecretVersionRequest::default();
1952///
1953/// // You can configure optional parameters by calling the respective setters at will, and
1954/// // execute the final call using `doit()`.
1955/// // Values shown here are possibly random and not representative !
1956/// let result = hub.projects().locations_secrets_versions_destroy(req, "name")
1957///              .doit().await;
1958/// # }
1959/// ```
1960pub struct ProjectLocationSecretVersionDestroyCall<'a, C>
1961where
1962    C: 'a,
1963{
1964    hub: &'a SecretManager<C>,
1965    _request: DestroySecretVersionRequest,
1966    _name: String,
1967    _delegate: Option<&'a mut dyn common::Delegate>,
1968    _additional_params: HashMap<String, String>,
1969    _scopes: BTreeSet<String>,
1970}
1971
1972impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionDestroyCall<'a, C> {}
1973
1974impl<'a, C> ProjectLocationSecretVersionDestroyCall<'a, C>
1975where
1976    C: common::Connector,
1977{
1978    /// Perform the operation you have build so far.
1979    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
1980        use std::borrow::Cow;
1981        use std::io::{Read, Seek};
1982
1983        use common::{url::Params, ToParts};
1984        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1985
1986        let mut dd = common::DefaultDelegate;
1987        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1988        dlg.begin(common::MethodInfo {
1989            id: "secretmanager.projects.locations.secrets.versions.destroy",
1990            http_method: hyper::Method::POST,
1991        });
1992
1993        for &field in ["alt", "name"].iter() {
1994            if self._additional_params.contains_key(field) {
1995                dlg.finished(false);
1996                return Err(common::Error::FieldClash(field));
1997            }
1998        }
1999
2000        let mut params = Params::with_capacity(4 + self._additional_params.len());
2001        params.push("name", self._name);
2002
2003        params.extend(self._additional_params.iter());
2004
2005        params.push("alt", "json");
2006        let mut url = self.hub._base_url.clone() + "v1/{+name}:destroy";
2007        if self._scopes.is_empty() {
2008            self._scopes
2009                .insert(Scope::CloudPlatform.as_ref().to_string());
2010        }
2011
2012        #[allow(clippy::single_element_loop)]
2013        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2014            url = params.uri_replacement(url, param_name, find_this, true);
2015        }
2016        {
2017            let to_remove = ["name"];
2018            params.remove_params(&to_remove);
2019        }
2020
2021        let url = params.parse_with_url(&url);
2022
2023        let mut json_mime_type = mime::APPLICATION_JSON;
2024        let mut request_value_reader = {
2025            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2026            common::remove_json_null_values(&mut value);
2027            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2028            serde_json::to_writer(&mut dst, &value).unwrap();
2029            dst
2030        };
2031        let request_size = request_value_reader
2032            .seek(std::io::SeekFrom::End(0))
2033            .unwrap();
2034        request_value_reader
2035            .seek(std::io::SeekFrom::Start(0))
2036            .unwrap();
2037
2038        loop {
2039            let token = match self
2040                .hub
2041                .auth
2042                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2043                .await
2044            {
2045                Ok(token) => token,
2046                Err(e) => match dlg.token(e) {
2047                    Ok(token) => token,
2048                    Err(e) => {
2049                        dlg.finished(false);
2050                        return Err(common::Error::MissingToken(e));
2051                    }
2052                },
2053            };
2054            request_value_reader
2055                .seek(std::io::SeekFrom::Start(0))
2056                .unwrap();
2057            let mut req_result = {
2058                let client = &self.hub.client;
2059                dlg.pre_request();
2060                let mut req_builder = hyper::Request::builder()
2061                    .method(hyper::Method::POST)
2062                    .uri(url.as_str())
2063                    .header(USER_AGENT, self.hub._user_agent.clone());
2064
2065                if let Some(token) = token.as_ref() {
2066                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2067                }
2068
2069                let request = req_builder
2070                    .header(CONTENT_TYPE, json_mime_type.to_string())
2071                    .header(CONTENT_LENGTH, request_size as u64)
2072                    .body(common::to_body(
2073                        request_value_reader.get_ref().clone().into(),
2074                    ));
2075
2076                client.request(request.unwrap()).await
2077            };
2078
2079            match req_result {
2080                Err(err) => {
2081                    if let common::Retry::After(d) = dlg.http_error(&err) {
2082                        sleep(d).await;
2083                        continue;
2084                    }
2085                    dlg.finished(false);
2086                    return Err(common::Error::HttpError(err));
2087                }
2088                Ok(res) => {
2089                    let (mut parts, body) = res.into_parts();
2090                    let mut body = common::Body::new(body);
2091                    if !parts.status.is_success() {
2092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2093                        let error = serde_json::from_str(&common::to_string(&bytes));
2094                        let response = common::to_response(parts, bytes.into());
2095
2096                        if let common::Retry::After(d) =
2097                            dlg.http_failure(&response, error.as_ref().ok())
2098                        {
2099                            sleep(d).await;
2100                            continue;
2101                        }
2102
2103                        dlg.finished(false);
2104
2105                        return Err(match error {
2106                            Ok(value) => common::Error::BadRequest(value),
2107                            _ => common::Error::Failure(response),
2108                        });
2109                    }
2110                    let response = {
2111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2112                        let encoded = common::to_string(&bytes);
2113                        match serde_json::from_str(&encoded) {
2114                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2115                            Err(error) => {
2116                                dlg.response_json_decode_error(&encoded, &error);
2117                                return Err(common::Error::JsonDecodeError(
2118                                    encoded.to_string(),
2119                                    error,
2120                                ));
2121                            }
2122                        }
2123                    };
2124
2125                    dlg.finished(true);
2126                    return Ok(response);
2127                }
2128            }
2129        }
2130    }
2131
2132    ///
2133    /// Sets the *request* property to the given value.
2134    ///
2135    /// Even though the property as already been set when instantiating this call,
2136    /// we provide this method for API completeness.
2137    pub fn request(
2138        mut self,
2139        new_value: DestroySecretVersionRequest,
2140    ) -> ProjectLocationSecretVersionDestroyCall<'a, C> {
2141        self._request = new_value;
2142        self
2143    }
2144    /// Required. The resource name of the SecretVersion to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
2145    ///
2146    /// Sets the *name* path property to the given value.
2147    ///
2148    /// Even though the property as already been set when instantiating this call,
2149    /// we provide this method for API completeness.
2150    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretVersionDestroyCall<'a, C> {
2151        self._name = new_value.to_string();
2152        self
2153    }
2154    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2155    /// while executing the actual API request.
2156    ///
2157    /// ````text
2158    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2159    /// ````
2160    ///
2161    /// Sets the *delegate* property to the given value.
2162    pub fn delegate(
2163        mut self,
2164        new_value: &'a mut dyn common::Delegate,
2165    ) -> ProjectLocationSecretVersionDestroyCall<'a, C> {
2166        self._delegate = Some(new_value);
2167        self
2168    }
2169
2170    /// Set any additional parameter of the query string used in the request.
2171    /// It should be used to set parameters which are not yet available through their own
2172    /// setters.
2173    ///
2174    /// Please note that this method must not be used to set any of the known parameters
2175    /// which have their own setter method. If done anyway, the request will fail.
2176    ///
2177    /// # Additional Parameters
2178    ///
2179    /// * *$.xgafv* (query-string) - V1 error format.
2180    /// * *access_token* (query-string) - OAuth access token.
2181    /// * *alt* (query-string) - Data format for response.
2182    /// * *callback* (query-string) - JSONP
2183    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2184    /// * *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.
2185    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2186    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2187    /// * *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.
2188    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2189    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2190    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionDestroyCall<'a, C>
2191    where
2192        T: AsRef<str>,
2193    {
2194        self._additional_params
2195            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2196        self
2197    }
2198
2199    /// Identifies the authorization scope for the method you are building.
2200    ///
2201    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2202    /// [`Scope::CloudPlatform`].
2203    ///
2204    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2205    /// tokens for more than one scope.
2206    ///
2207    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2208    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2209    /// sufficient, a read-write scope will do as well.
2210    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionDestroyCall<'a, C>
2211    where
2212        St: AsRef<str>,
2213    {
2214        self._scopes.insert(String::from(scope.as_ref()));
2215        self
2216    }
2217    /// Identifies the authorization scope(s) for the method you are building.
2218    ///
2219    /// See [`Self::add_scope()`] for details.
2220    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionDestroyCall<'a, C>
2221    where
2222        I: IntoIterator<Item = St>,
2223        St: AsRef<str>,
2224    {
2225        self._scopes
2226            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2227        self
2228    }
2229
2230    /// Removes all scopes, and no default scope will be used either.
2231    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2232    /// for details).
2233    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionDestroyCall<'a, C> {
2234        self._scopes.clear();
2235        self
2236    }
2237}
2238
2239/// Disables a SecretVersion. Sets the state of the SecretVersion to DISABLED.
2240///
2241/// A builder for the *locations.secrets.versions.disable* method supported by a *project* resource.
2242/// It is not used directly, but through a [`ProjectMethods`] instance.
2243///
2244/// # Example
2245///
2246/// Instantiate a resource method builder
2247///
2248/// ```test_harness,no_run
2249/// # extern crate hyper;
2250/// # extern crate hyper_rustls;
2251/// # extern crate google_secretmanager1 as secretmanager1;
2252/// use secretmanager1::api::DisableSecretVersionRequest;
2253/// # async fn dox() {
2254/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2255///
2256/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2257/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2258/// #     .with_native_roots()
2259/// #     .unwrap()
2260/// #     .https_only()
2261/// #     .enable_http2()
2262/// #     .build();
2263///
2264/// # let executor = hyper_util::rt::TokioExecutor::new();
2265/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2266/// #     secret,
2267/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2268/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2269/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2270/// #     ),
2271/// # ).build().await.unwrap();
2272///
2273/// # let client = hyper_util::client::legacy::Client::builder(
2274/// #     hyper_util::rt::TokioExecutor::new()
2275/// # )
2276/// # .build(
2277/// #     hyper_rustls::HttpsConnectorBuilder::new()
2278/// #         .with_native_roots()
2279/// #         .unwrap()
2280/// #         .https_or_http()
2281/// #         .enable_http2()
2282/// #         .build()
2283/// # );
2284/// # let mut hub = SecretManager::new(client, auth);
2285/// // As the method needs a request, you would usually fill it with the desired information
2286/// // into the respective structure. Some of the parts shown here might not be applicable !
2287/// // Values shown here are possibly random and not representative !
2288/// let mut req = DisableSecretVersionRequest::default();
2289///
2290/// // You can configure optional parameters by calling the respective setters at will, and
2291/// // execute the final call using `doit()`.
2292/// // Values shown here are possibly random and not representative !
2293/// let result = hub.projects().locations_secrets_versions_disable(req, "name")
2294///              .doit().await;
2295/// # }
2296/// ```
2297pub struct ProjectLocationSecretVersionDisableCall<'a, C>
2298where
2299    C: 'a,
2300{
2301    hub: &'a SecretManager<C>,
2302    _request: DisableSecretVersionRequest,
2303    _name: String,
2304    _delegate: Option<&'a mut dyn common::Delegate>,
2305    _additional_params: HashMap<String, String>,
2306    _scopes: BTreeSet<String>,
2307}
2308
2309impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionDisableCall<'a, C> {}
2310
2311impl<'a, C> ProjectLocationSecretVersionDisableCall<'a, C>
2312where
2313    C: common::Connector,
2314{
2315    /// Perform the operation you have build so far.
2316    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
2317        use std::borrow::Cow;
2318        use std::io::{Read, Seek};
2319
2320        use common::{url::Params, ToParts};
2321        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2322
2323        let mut dd = common::DefaultDelegate;
2324        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2325        dlg.begin(common::MethodInfo {
2326            id: "secretmanager.projects.locations.secrets.versions.disable",
2327            http_method: hyper::Method::POST,
2328        });
2329
2330        for &field in ["alt", "name"].iter() {
2331            if self._additional_params.contains_key(field) {
2332                dlg.finished(false);
2333                return Err(common::Error::FieldClash(field));
2334            }
2335        }
2336
2337        let mut params = Params::with_capacity(4 + self._additional_params.len());
2338        params.push("name", self._name);
2339
2340        params.extend(self._additional_params.iter());
2341
2342        params.push("alt", "json");
2343        let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
2344        if self._scopes.is_empty() {
2345            self._scopes
2346                .insert(Scope::CloudPlatform.as_ref().to_string());
2347        }
2348
2349        #[allow(clippy::single_element_loop)]
2350        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2351            url = params.uri_replacement(url, param_name, find_this, true);
2352        }
2353        {
2354            let to_remove = ["name"];
2355            params.remove_params(&to_remove);
2356        }
2357
2358        let url = params.parse_with_url(&url);
2359
2360        let mut json_mime_type = mime::APPLICATION_JSON;
2361        let mut request_value_reader = {
2362            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2363            common::remove_json_null_values(&mut value);
2364            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2365            serde_json::to_writer(&mut dst, &value).unwrap();
2366            dst
2367        };
2368        let request_size = request_value_reader
2369            .seek(std::io::SeekFrom::End(0))
2370            .unwrap();
2371        request_value_reader
2372            .seek(std::io::SeekFrom::Start(0))
2373            .unwrap();
2374
2375        loop {
2376            let token = match self
2377                .hub
2378                .auth
2379                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2380                .await
2381            {
2382                Ok(token) => token,
2383                Err(e) => match dlg.token(e) {
2384                    Ok(token) => token,
2385                    Err(e) => {
2386                        dlg.finished(false);
2387                        return Err(common::Error::MissingToken(e));
2388                    }
2389                },
2390            };
2391            request_value_reader
2392                .seek(std::io::SeekFrom::Start(0))
2393                .unwrap();
2394            let mut req_result = {
2395                let client = &self.hub.client;
2396                dlg.pre_request();
2397                let mut req_builder = hyper::Request::builder()
2398                    .method(hyper::Method::POST)
2399                    .uri(url.as_str())
2400                    .header(USER_AGENT, self.hub._user_agent.clone());
2401
2402                if let Some(token) = token.as_ref() {
2403                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2404                }
2405
2406                let request = req_builder
2407                    .header(CONTENT_TYPE, json_mime_type.to_string())
2408                    .header(CONTENT_LENGTH, request_size as u64)
2409                    .body(common::to_body(
2410                        request_value_reader.get_ref().clone().into(),
2411                    ));
2412
2413                client.request(request.unwrap()).await
2414            };
2415
2416            match req_result {
2417                Err(err) => {
2418                    if let common::Retry::After(d) = dlg.http_error(&err) {
2419                        sleep(d).await;
2420                        continue;
2421                    }
2422                    dlg.finished(false);
2423                    return Err(common::Error::HttpError(err));
2424                }
2425                Ok(res) => {
2426                    let (mut parts, body) = res.into_parts();
2427                    let mut body = common::Body::new(body);
2428                    if !parts.status.is_success() {
2429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2430                        let error = serde_json::from_str(&common::to_string(&bytes));
2431                        let response = common::to_response(parts, bytes.into());
2432
2433                        if let common::Retry::After(d) =
2434                            dlg.http_failure(&response, error.as_ref().ok())
2435                        {
2436                            sleep(d).await;
2437                            continue;
2438                        }
2439
2440                        dlg.finished(false);
2441
2442                        return Err(match error {
2443                            Ok(value) => common::Error::BadRequest(value),
2444                            _ => common::Error::Failure(response),
2445                        });
2446                    }
2447                    let response = {
2448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2449                        let encoded = common::to_string(&bytes);
2450                        match serde_json::from_str(&encoded) {
2451                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2452                            Err(error) => {
2453                                dlg.response_json_decode_error(&encoded, &error);
2454                                return Err(common::Error::JsonDecodeError(
2455                                    encoded.to_string(),
2456                                    error,
2457                                ));
2458                            }
2459                        }
2460                    };
2461
2462                    dlg.finished(true);
2463                    return Ok(response);
2464                }
2465            }
2466        }
2467    }
2468
2469    ///
2470    /// Sets the *request* property to the given value.
2471    ///
2472    /// Even though the property as already been set when instantiating this call,
2473    /// we provide this method for API completeness.
2474    pub fn request(
2475        mut self,
2476        new_value: DisableSecretVersionRequest,
2477    ) -> ProjectLocationSecretVersionDisableCall<'a, C> {
2478        self._request = new_value;
2479        self
2480    }
2481    /// Required. The resource name of the SecretVersion to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
2482    ///
2483    /// Sets the *name* path property to the given value.
2484    ///
2485    /// Even though the property as already been set when instantiating this call,
2486    /// we provide this method for API completeness.
2487    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretVersionDisableCall<'a, C> {
2488        self._name = new_value.to_string();
2489        self
2490    }
2491    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2492    /// while executing the actual API request.
2493    ///
2494    /// ````text
2495    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2496    /// ````
2497    ///
2498    /// Sets the *delegate* property to the given value.
2499    pub fn delegate(
2500        mut self,
2501        new_value: &'a mut dyn common::Delegate,
2502    ) -> ProjectLocationSecretVersionDisableCall<'a, C> {
2503        self._delegate = Some(new_value);
2504        self
2505    }
2506
2507    /// Set any additional parameter of the query string used in the request.
2508    /// It should be used to set parameters which are not yet available through their own
2509    /// setters.
2510    ///
2511    /// Please note that this method must not be used to set any of the known parameters
2512    /// which have their own setter method. If done anyway, the request will fail.
2513    ///
2514    /// # Additional Parameters
2515    ///
2516    /// * *$.xgafv* (query-string) - V1 error format.
2517    /// * *access_token* (query-string) - OAuth access token.
2518    /// * *alt* (query-string) - Data format for response.
2519    /// * *callback* (query-string) - JSONP
2520    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2521    /// * *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.
2522    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2523    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2524    /// * *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.
2525    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2526    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2527    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionDisableCall<'a, C>
2528    where
2529        T: AsRef<str>,
2530    {
2531        self._additional_params
2532            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2533        self
2534    }
2535
2536    /// Identifies the authorization scope for the method you are building.
2537    ///
2538    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2539    /// [`Scope::CloudPlatform`].
2540    ///
2541    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2542    /// tokens for more than one scope.
2543    ///
2544    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2545    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2546    /// sufficient, a read-write scope will do as well.
2547    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionDisableCall<'a, C>
2548    where
2549        St: AsRef<str>,
2550    {
2551        self._scopes.insert(String::from(scope.as_ref()));
2552        self
2553    }
2554    /// Identifies the authorization scope(s) for the method you are building.
2555    ///
2556    /// See [`Self::add_scope()`] for details.
2557    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionDisableCall<'a, C>
2558    where
2559        I: IntoIterator<Item = St>,
2560        St: AsRef<str>,
2561    {
2562        self._scopes
2563            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2564        self
2565    }
2566
2567    /// Removes all scopes, and no default scope will be used either.
2568    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2569    /// for details).
2570    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionDisableCall<'a, C> {
2571        self._scopes.clear();
2572        self
2573    }
2574}
2575
2576/// Enables a SecretVersion. Sets the state of the SecretVersion to ENABLED.
2577///
2578/// A builder for the *locations.secrets.versions.enable* method supported by a *project* resource.
2579/// It is not used directly, but through a [`ProjectMethods`] instance.
2580///
2581/// # Example
2582///
2583/// Instantiate a resource method builder
2584///
2585/// ```test_harness,no_run
2586/// # extern crate hyper;
2587/// # extern crate hyper_rustls;
2588/// # extern crate google_secretmanager1 as secretmanager1;
2589/// use secretmanager1::api::EnableSecretVersionRequest;
2590/// # async fn dox() {
2591/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2592///
2593/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2594/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2595/// #     .with_native_roots()
2596/// #     .unwrap()
2597/// #     .https_only()
2598/// #     .enable_http2()
2599/// #     .build();
2600///
2601/// # let executor = hyper_util::rt::TokioExecutor::new();
2602/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2603/// #     secret,
2604/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2605/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2606/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2607/// #     ),
2608/// # ).build().await.unwrap();
2609///
2610/// # let client = hyper_util::client::legacy::Client::builder(
2611/// #     hyper_util::rt::TokioExecutor::new()
2612/// # )
2613/// # .build(
2614/// #     hyper_rustls::HttpsConnectorBuilder::new()
2615/// #         .with_native_roots()
2616/// #         .unwrap()
2617/// #         .https_or_http()
2618/// #         .enable_http2()
2619/// #         .build()
2620/// # );
2621/// # let mut hub = SecretManager::new(client, auth);
2622/// // As the method needs a request, you would usually fill it with the desired information
2623/// // into the respective structure. Some of the parts shown here might not be applicable !
2624/// // Values shown here are possibly random and not representative !
2625/// let mut req = EnableSecretVersionRequest::default();
2626///
2627/// // You can configure optional parameters by calling the respective setters at will, and
2628/// // execute the final call using `doit()`.
2629/// // Values shown here are possibly random and not representative !
2630/// let result = hub.projects().locations_secrets_versions_enable(req, "name")
2631///              .doit().await;
2632/// # }
2633/// ```
2634pub struct ProjectLocationSecretVersionEnableCall<'a, C>
2635where
2636    C: 'a,
2637{
2638    hub: &'a SecretManager<C>,
2639    _request: EnableSecretVersionRequest,
2640    _name: String,
2641    _delegate: Option<&'a mut dyn common::Delegate>,
2642    _additional_params: HashMap<String, String>,
2643    _scopes: BTreeSet<String>,
2644}
2645
2646impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionEnableCall<'a, C> {}
2647
2648impl<'a, C> ProjectLocationSecretVersionEnableCall<'a, C>
2649where
2650    C: common::Connector,
2651{
2652    /// Perform the operation you have build so far.
2653    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
2654        use std::borrow::Cow;
2655        use std::io::{Read, Seek};
2656
2657        use common::{url::Params, ToParts};
2658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2659
2660        let mut dd = common::DefaultDelegate;
2661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2662        dlg.begin(common::MethodInfo {
2663            id: "secretmanager.projects.locations.secrets.versions.enable",
2664            http_method: hyper::Method::POST,
2665        });
2666
2667        for &field in ["alt", "name"].iter() {
2668            if self._additional_params.contains_key(field) {
2669                dlg.finished(false);
2670                return Err(common::Error::FieldClash(field));
2671            }
2672        }
2673
2674        let mut params = Params::with_capacity(4 + self._additional_params.len());
2675        params.push("name", self._name);
2676
2677        params.extend(self._additional_params.iter());
2678
2679        params.push("alt", "json");
2680        let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
2681        if self._scopes.is_empty() {
2682            self._scopes
2683                .insert(Scope::CloudPlatform.as_ref().to_string());
2684        }
2685
2686        #[allow(clippy::single_element_loop)]
2687        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2688            url = params.uri_replacement(url, param_name, find_this, true);
2689        }
2690        {
2691            let to_remove = ["name"];
2692            params.remove_params(&to_remove);
2693        }
2694
2695        let url = params.parse_with_url(&url);
2696
2697        let mut json_mime_type = mime::APPLICATION_JSON;
2698        let mut request_value_reader = {
2699            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2700            common::remove_json_null_values(&mut value);
2701            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2702            serde_json::to_writer(&mut dst, &value).unwrap();
2703            dst
2704        };
2705        let request_size = request_value_reader
2706            .seek(std::io::SeekFrom::End(0))
2707            .unwrap();
2708        request_value_reader
2709            .seek(std::io::SeekFrom::Start(0))
2710            .unwrap();
2711
2712        loop {
2713            let token = match self
2714                .hub
2715                .auth
2716                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2717                .await
2718            {
2719                Ok(token) => token,
2720                Err(e) => match dlg.token(e) {
2721                    Ok(token) => token,
2722                    Err(e) => {
2723                        dlg.finished(false);
2724                        return Err(common::Error::MissingToken(e));
2725                    }
2726                },
2727            };
2728            request_value_reader
2729                .seek(std::io::SeekFrom::Start(0))
2730                .unwrap();
2731            let mut req_result = {
2732                let client = &self.hub.client;
2733                dlg.pre_request();
2734                let mut req_builder = hyper::Request::builder()
2735                    .method(hyper::Method::POST)
2736                    .uri(url.as_str())
2737                    .header(USER_AGENT, self.hub._user_agent.clone());
2738
2739                if let Some(token) = token.as_ref() {
2740                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2741                }
2742
2743                let request = req_builder
2744                    .header(CONTENT_TYPE, json_mime_type.to_string())
2745                    .header(CONTENT_LENGTH, request_size as u64)
2746                    .body(common::to_body(
2747                        request_value_reader.get_ref().clone().into(),
2748                    ));
2749
2750                client.request(request.unwrap()).await
2751            };
2752
2753            match req_result {
2754                Err(err) => {
2755                    if let common::Retry::After(d) = dlg.http_error(&err) {
2756                        sleep(d).await;
2757                        continue;
2758                    }
2759                    dlg.finished(false);
2760                    return Err(common::Error::HttpError(err));
2761                }
2762                Ok(res) => {
2763                    let (mut parts, body) = res.into_parts();
2764                    let mut body = common::Body::new(body);
2765                    if !parts.status.is_success() {
2766                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2767                        let error = serde_json::from_str(&common::to_string(&bytes));
2768                        let response = common::to_response(parts, bytes.into());
2769
2770                        if let common::Retry::After(d) =
2771                            dlg.http_failure(&response, error.as_ref().ok())
2772                        {
2773                            sleep(d).await;
2774                            continue;
2775                        }
2776
2777                        dlg.finished(false);
2778
2779                        return Err(match error {
2780                            Ok(value) => common::Error::BadRequest(value),
2781                            _ => common::Error::Failure(response),
2782                        });
2783                    }
2784                    let response = {
2785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2786                        let encoded = common::to_string(&bytes);
2787                        match serde_json::from_str(&encoded) {
2788                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2789                            Err(error) => {
2790                                dlg.response_json_decode_error(&encoded, &error);
2791                                return Err(common::Error::JsonDecodeError(
2792                                    encoded.to_string(),
2793                                    error,
2794                                ));
2795                            }
2796                        }
2797                    };
2798
2799                    dlg.finished(true);
2800                    return Ok(response);
2801                }
2802            }
2803        }
2804    }
2805
2806    ///
2807    /// Sets the *request* property to the given value.
2808    ///
2809    /// Even though the property as already been set when instantiating this call,
2810    /// we provide this method for API completeness.
2811    pub fn request(
2812        mut self,
2813        new_value: EnableSecretVersionRequest,
2814    ) -> ProjectLocationSecretVersionEnableCall<'a, C> {
2815        self._request = new_value;
2816        self
2817    }
2818    /// Required. The resource name of the SecretVersion to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
2819    ///
2820    /// Sets the *name* path property to the given value.
2821    ///
2822    /// Even though the property as already been set when instantiating this call,
2823    /// we provide this method for API completeness.
2824    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretVersionEnableCall<'a, C> {
2825        self._name = new_value.to_string();
2826        self
2827    }
2828    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2829    /// while executing the actual API request.
2830    ///
2831    /// ````text
2832    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2833    /// ````
2834    ///
2835    /// Sets the *delegate* property to the given value.
2836    pub fn delegate(
2837        mut self,
2838        new_value: &'a mut dyn common::Delegate,
2839    ) -> ProjectLocationSecretVersionEnableCall<'a, C> {
2840        self._delegate = Some(new_value);
2841        self
2842    }
2843
2844    /// Set any additional parameter of the query string used in the request.
2845    /// It should be used to set parameters which are not yet available through their own
2846    /// setters.
2847    ///
2848    /// Please note that this method must not be used to set any of the known parameters
2849    /// which have their own setter method. If done anyway, the request will fail.
2850    ///
2851    /// # Additional Parameters
2852    ///
2853    /// * *$.xgafv* (query-string) - V1 error format.
2854    /// * *access_token* (query-string) - OAuth access token.
2855    /// * *alt* (query-string) - Data format for response.
2856    /// * *callback* (query-string) - JSONP
2857    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2858    /// * *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.
2859    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2860    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2861    /// * *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.
2862    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2863    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2864    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionEnableCall<'a, C>
2865    where
2866        T: AsRef<str>,
2867    {
2868        self._additional_params
2869            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2870        self
2871    }
2872
2873    /// Identifies the authorization scope for the method you are building.
2874    ///
2875    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2876    /// [`Scope::CloudPlatform`].
2877    ///
2878    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2879    /// tokens for more than one scope.
2880    ///
2881    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2882    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2883    /// sufficient, a read-write scope will do as well.
2884    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionEnableCall<'a, C>
2885    where
2886        St: AsRef<str>,
2887    {
2888        self._scopes.insert(String::from(scope.as_ref()));
2889        self
2890    }
2891    /// Identifies the authorization scope(s) for the method you are building.
2892    ///
2893    /// See [`Self::add_scope()`] for details.
2894    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionEnableCall<'a, C>
2895    where
2896        I: IntoIterator<Item = St>,
2897        St: AsRef<str>,
2898    {
2899        self._scopes
2900            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2901        self
2902    }
2903
2904    /// Removes all scopes, and no default scope will be used either.
2905    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2906    /// for details).
2907    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionEnableCall<'a, C> {
2908        self._scopes.clear();
2909        self
2910    }
2911}
2912
2913/// Gets metadata for a SecretVersion. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
2914///
2915/// A builder for the *locations.secrets.versions.get* method supported by a *project* resource.
2916/// It is not used directly, but through a [`ProjectMethods`] instance.
2917///
2918/// # Example
2919///
2920/// Instantiate a resource method builder
2921///
2922/// ```test_harness,no_run
2923/// # extern crate hyper;
2924/// # extern crate hyper_rustls;
2925/// # extern crate google_secretmanager1 as secretmanager1;
2926/// # async fn dox() {
2927/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2928///
2929/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2930/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2931/// #     .with_native_roots()
2932/// #     .unwrap()
2933/// #     .https_only()
2934/// #     .enable_http2()
2935/// #     .build();
2936///
2937/// # let executor = hyper_util::rt::TokioExecutor::new();
2938/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2939/// #     secret,
2940/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2941/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2942/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2943/// #     ),
2944/// # ).build().await.unwrap();
2945///
2946/// # let client = hyper_util::client::legacy::Client::builder(
2947/// #     hyper_util::rt::TokioExecutor::new()
2948/// # )
2949/// # .build(
2950/// #     hyper_rustls::HttpsConnectorBuilder::new()
2951/// #         .with_native_roots()
2952/// #         .unwrap()
2953/// #         .https_or_http()
2954/// #         .enable_http2()
2955/// #         .build()
2956/// # );
2957/// # let mut hub = SecretManager::new(client, auth);
2958/// // You can configure optional parameters by calling the respective setters at will, and
2959/// // execute the final call using `doit()`.
2960/// // Values shown here are possibly random and not representative !
2961/// let result = hub.projects().locations_secrets_versions_get("name")
2962///              .doit().await;
2963/// # }
2964/// ```
2965pub struct ProjectLocationSecretVersionGetCall<'a, C>
2966where
2967    C: 'a,
2968{
2969    hub: &'a SecretManager<C>,
2970    _name: String,
2971    _delegate: Option<&'a mut dyn common::Delegate>,
2972    _additional_params: HashMap<String, String>,
2973    _scopes: BTreeSet<String>,
2974}
2975
2976impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionGetCall<'a, C> {}
2977
2978impl<'a, C> ProjectLocationSecretVersionGetCall<'a, C>
2979where
2980    C: common::Connector,
2981{
2982    /// Perform the operation you have build so far.
2983    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
2984        use std::borrow::Cow;
2985        use std::io::{Read, Seek};
2986
2987        use common::{url::Params, ToParts};
2988        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2989
2990        let mut dd = common::DefaultDelegate;
2991        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2992        dlg.begin(common::MethodInfo {
2993            id: "secretmanager.projects.locations.secrets.versions.get",
2994            http_method: hyper::Method::GET,
2995        });
2996
2997        for &field in ["alt", "name"].iter() {
2998            if self._additional_params.contains_key(field) {
2999                dlg.finished(false);
3000                return Err(common::Error::FieldClash(field));
3001            }
3002        }
3003
3004        let mut params = Params::with_capacity(3 + self._additional_params.len());
3005        params.push("name", self._name);
3006
3007        params.extend(self._additional_params.iter());
3008
3009        params.push("alt", "json");
3010        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3011        if self._scopes.is_empty() {
3012            self._scopes
3013                .insert(Scope::CloudPlatform.as_ref().to_string());
3014        }
3015
3016        #[allow(clippy::single_element_loop)]
3017        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3018            url = params.uri_replacement(url, param_name, find_this, true);
3019        }
3020        {
3021            let to_remove = ["name"];
3022            params.remove_params(&to_remove);
3023        }
3024
3025        let url = params.parse_with_url(&url);
3026
3027        loop {
3028            let token = match self
3029                .hub
3030                .auth
3031                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3032                .await
3033            {
3034                Ok(token) => token,
3035                Err(e) => match dlg.token(e) {
3036                    Ok(token) => token,
3037                    Err(e) => {
3038                        dlg.finished(false);
3039                        return Err(common::Error::MissingToken(e));
3040                    }
3041                },
3042            };
3043            let mut req_result = {
3044                let client = &self.hub.client;
3045                dlg.pre_request();
3046                let mut req_builder = hyper::Request::builder()
3047                    .method(hyper::Method::GET)
3048                    .uri(url.as_str())
3049                    .header(USER_AGENT, self.hub._user_agent.clone());
3050
3051                if let Some(token) = token.as_ref() {
3052                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3053                }
3054
3055                let request = req_builder
3056                    .header(CONTENT_LENGTH, 0_u64)
3057                    .body(common::to_body::<String>(None));
3058
3059                client.request(request.unwrap()).await
3060            };
3061
3062            match req_result {
3063                Err(err) => {
3064                    if let common::Retry::After(d) = dlg.http_error(&err) {
3065                        sleep(d).await;
3066                        continue;
3067                    }
3068                    dlg.finished(false);
3069                    return Err(common::Error::HttpError(err));
3070                }
3071                Ok(res) => {
3072                    let (mut parts, body) = res.into_parts();
3073                    let mut body = common::Body::new(body);
3074                    if !parts.status.is_success() {
3075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3076                        let error = serde_json::from_str(&common::to_string(&bytes));
3077                        let response = common::to_response(parts, bytes.into());
3078
3079                        if let common::Retry::After(d) =
3080                            dlg.http_failure(&response, error.as_ref().ok())
3081                        {
3082                            sleep(d).await;
3083                            continue;
3084                        }
3085
3086                        dlg.finished(false);
3087
3088                        return Err(match error {
3089                            Ok(value) => common::Error::BadRequest(value),
3090                            _ => common::Error::Failure(response),
3091                        });
3092                    }
3093                    let response = {
3094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3095                        let encoded = common::to_string(&bytes);
3096                        match serde_json::from_str(&encoded) {
3097                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3098                            Err(error) => {
3099                                dlg.response_json_decode_error(&encoded, &error);
3100                                return Err(common::Error::JsonDecodeError(
3101                                    encoded.to_string(),
3102                                    error,
3103                                ));
3104                            }
3105                        }
3106                    };
3107
3108                    dlg.finished(true);
3109                    return Ok(response);
3110                }
3111            }
3112        }
3113    }
3114
3115    /// Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
3116    ///
3117    /// Sets the *name* path property to the given value.
3118    ///
3119    /// Even though the property as already been set when instantiating this call,
3120    /// we provide this method for API completeness.
3121    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretVersionGetCall<'a, C> {
3122        self._name = new_value.to_string();
3123        self
3124    }
3125    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3126    /// while executing the actual API request.
3127    ///
3128    /// ````text
3129    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3130    /// ````
3131    ///
3132    /// Sets the *delegate* property to the given value.
3133    pub fn delegate(
3134        mut self,
3135        new_value: &'a mut dyn common::Delegate,
3136    ) -> ProjectLocationSecretVersionGetCall<'a, C> {
3137        self._delegate = Some(new_value);
3138        self
3139    }
3140
3141    /// Set any additional parameter of the query string used in the request.
3142    /// It should be used to set parameters which are not yet available through their own
3143    /// setters.
3144    ///
3145    /// Please note that this method must not be used to set any of the known parameters
3146    /// which have their own setter method. If done anyway, the request will fail.
3147    ///
3148    /// # Additional Parameters
3149    ///
3150    /// * *$.xgafv* (query-string) - V1 error format.
3151    /// * *access_token* (query-string) - OAuth access token.
3152    /// * *alt* (query-string) - Data format for response.
3153    /// * *callback* (query-string) - JSONP
3154    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3155    /// * *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.
3156    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3157    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3158    /// * *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.
3159    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3160    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3161    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionGetCall<'a, C>
3162    where
3163        T: AsRef<str>,
3164    {
3165        self._additional_params
3166            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3167        self
3168    }
3169
3170    /// Identifies the authorization scope for the method you are building.
3171    ///
3172    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3173    /// [`Scope::CloudPlatform`].
3174    ///
3175    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3176    /// tokens for more than one scope.
3177    ///
3178    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3179    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3180    /// sufficient, a read-write scope will do as well.
3181    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionGetCall<'a, C>
3182    where
3183        St: AsRef<str>,
3184    {
3185        self._scopes.insert(String::from(scope.as_ref()));
3186        self
3187    }
3188    /// Identifies the authorization scope(s) for the method you are building.
3189    ///
3190    /// See [`Self::add_scope()`] for details.
3191    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionGetCall<'a, C>
3192    where
3193        I: IntoIterator<Item = St>,
3194        St: AsRef<str>,
3195    {
3196        self._scopes
3197            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3198        self
3199    }
3200
3201    /// Removes all scopes, and no default scope will be used either.
3202    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3203    /// for details).
3204    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionGetCall<'a, C> {
3205        self._scopes.clear();
3206        self
3207    }
3208}
3209
3210/// Lists SecretVersions. This call does not return secret data.
3211///
3212/// A builder for the *locations.secrets.versions.list* method supported by a *project* resource.
3213/// It is not used directly, but through a [`ProjectMethods`] instance.
3214///
3215/// # Example
3216///
3217/// Instantiate a resource method builder
3218///
3219/// ```test_harness,no_run
3220/// # extern crate hyper;
3221/// # extern crate hyper_rustls;
3222/// # extern crate google_secretmanager1 as secretmanager1;
3223/// # async fn dox() {
3224/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3225///
3226/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3227/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3228/// #     .with_native_roots()
3229/// #     .unwrap()
3230/// #     .https_only()
3231/// #     .enable_http2()
3232/// #     .build();
3233///
3234/// # let executor = hyper_util::rt::TokioExecutor::new();
3235/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3236/// #     secret,
3237/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3238/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3239/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3240/// #     ),
3241/// # ).build().await.unwrap();
3242///
3243/// # let client = hyper_util::client::legacy::Client::builder(
3244/// #     hyper_util::rt::TokioExecutor::new()
3245/// # )
3246/// # .build(
3247/// #     hyper_rustls::HttpsConnectorBuilder::new()
3248/// #         .with_native_roots()
3249/// #         .unwrap()
3250/// #         .https_or_http()
3251/// #         .enable_http2()
3252/// #         .build()
3253/// # );
3254/// # let mut hub = SecretManager::new(client, auth);
3255/// // You can configure optional parameters by calling the respective setters at will, and
3256/// // execute the final call using `doit()`.
3257/// // Values shown here are possibly random and not representative !
3258/// let result = hub.projects().locations_secrets_versions_list("parent")
3259///              .page_token("takimata")
3260///              .page_size(-52)
3261///              .filter("duo")
3262///              .doit().await;
3263/// # }
3264/// ```
3265pub struct ProjectLocationSecretVersionListCall<'a, C>
3266where
3267    C: 'a,
3268{
3269    hub: &'a SecretManager<C>,
3270    _parent: String,
3271    _page_token: Option<String>,
3272    _page_size: Option<i32>,
3273    _filter: Option<String>,
3274    _delegate: Option<&'a mut dyn common::Delegate>,
3275    _additional_params: HashMap<String, String>,
3276    _scopes: BTreeSet<String>,
3277}
3278
3279impl<'a, C> common::CallBuilder for ProjectLocationSecretVersionListCall<'a, C> {}
3280
3281impl<'a, C> ProjectLocationSecretVersionListCall<'a, C>
3282where
3283    C: common::Connector,
3284{
3285    /// Perform the operation you have build so far.
3286    pub async fn doit(mut self) -> common::Result<(common::Response, ListSecretVersionsResponse)> {
3287        use std::borrow::Cow;
3288        use std::io::{Read, Seek};
3289
3290        use common::{url::Params, ToParts};
3291        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3292
3293        let mut dd = common::DefaultDelegate;
3294        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3295        dlg.begin(common::MethodInfo {
3296            id: "secretmanager.projects.locations.secrets.versions.list",
3297            http_method: hyper::Method::GET,
3298        });
3299
3300        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
3301            if self._additional_params.contains_key(field) {
3302                dlg.finished(false);
3303                return Err(common::Error::FieldClash(field));
3304            }
3305        }
3306
3307        let mut params = Params::with_capacity(6 + self._additional_params.len());
3308        params.push("parent", self._parent);
3309        if let Some(value) = self._page_token.as_ref() {
3310            params.push("pageToken", value);
3311        }
3312        if let Some(value) = self._page_size.as_ref() {
3313            params.push("pageSize", value.to_string());
3314        }
3315        if let Some(value) = self._filter.as_ref() {
3316            params.push("filter", value);
3317        }
3318
3319        params.extend(self._additional_params.iter());
3320
3321        params.push("alt", "json");
3322        let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
3323        if self._scopes.is_empty() {
3324            self._scopes
3325                .insert(Scope::CloudPlatform.as_ref().to_string());
3326        }
3327
3328        #[allow(clippy::single_element_loop)]
3329        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3330            url = params.uri_replacement(url, param_name, find_this, true);
3331        }
3332        {
3333            let to_remove = ["parent"];
3334            params.remove_params(&to_remove);
3335        }
3336
3337        let url = params.parse_with_url(&url);
3338
3339        loop {
3340            let token = match self
3341                .hub
3342                .auth
3343                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3344                .await
3345            {
3346                Ok(token) => token,
3347                Err(e) => match dlg.token(e) {
3348                    Ok(token) => token,
3349                    Err(e) => {
3350                        dlg.finished(false);
3351                        return Err(common::Error::MissingToken(e));
3352                    }
3353                },
3354            };
3355            let mut req_result = {
3356                let client = &self.hub.client;
3357                dlg.pre_request();
3358                let mut req_builder = hyper::Request::builder()
3359                    .method(hyper::Method::GET)
3360                    .uri(url.as_str())
3361                    .header(USER_AGENT, self.hub._user_agent.clone());
3362
3363                if let Some(token) = token.as_ref() {
3364                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3365                }
3366
3367                let request = req_builder
3368                    .header(CONTENT_LENGTH, 0_u64)
3369                    .body(common::to_body::<String>(None));
3370
3371                client.request(request.unwrap()).await
3372            };
3373
3374            match req_result {
3375                Err(err) => {
3376                    if let common::Retry::After(d) = dlg.http_error(&err) {
3377                        sleep(d).await;
3378                        continue;
3379                    }
3380                    dlg.finished(false);
3381                    return Err(common::Error::HttpError(err));
3382                }
3383                Ok(res) => {
3384                    let (mut parts, body) = res.into_parts();
3385                    let mut body = common::Body::new(body);
3386                    if !parts.status.is_success() {
3387                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3388                        let error = serde_json::from_str(&common::to_string(&bytes));
3389                        let response = common::to_response(parts, bytes.into());
3390
3391                        if let common::Retry::After(d) =
3392                            dlg.http_failure(&response, error.as_ref().ok())
3393                        {
3394                            sleep(d).await;
3395                            continue;
3396                        }
3397
3398                        dlg.finished(false);
3399
3400                        return Err(match error {
3401                            Ok(value) => common::Error::BadRequest(value),
3402                            _ => common::Error::Failure(response),
3403                        });
3404                    }
3405                    let response = {
3406                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3407                        let encoded = common::to_string(&bytes);
3408                        match serde_json::from_str(&encoded) {
3409                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3410                            Err(error) => {
3411                                dlg.response_json_decode_error(&encoded, &error);
3412                                return Err(common::Error::JsonDecodeError(
3413                                    encoded.to_string(),
3414                                    error,
3415                                ));
3416                            }
3417                        }
3418                    };
3419
3420                    dlg.finished(true);
3421                    return Ok(response);
3422                }
3423            }
3424        }
3425    }
3426
3427    /// Required. The resource name of the Secret associated with the SecretVersions to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
3428    ///
3429    /// Sets the *parent* path property to the given value.
3430    ///
3431    /// Even though the property as already been set when instantiating this call,
3432    /// we provide this method for API completeness.
3433    pub fn parent(mut self, new_value: &str) -> ProjectLocationSecretVersionListCall<'a, C> {
3434        self._parent = new_value.to_string();
3435        self
3436    }
3437    /// Optional. Pagination token, returned earlier via ListSecretVersionsResponse.next_page_token][].
3438    ///
3439    /// Sets the *page token* query property to the given value.
3440    pub fn page_token(mut self, new_value: &str) -> ProjectLocationSecretVersionListCall<'a, C> {
3441        self._page_token = Some(new_value.to_string());
3442        self
3443    }
3444    /// Optional. The maximum number of results to be returned in a single page. If set to 0, the server decides the number of results to return. If the number is greater than 25000, it is capped at 25000.
3445    ///
3446    /// Sets the *page size* query property to the given value.
3447    pub fn page_size(mut self, new_value: i32) -> ProjectLocationSecretVersionListCall<'a, C> {
3448        self._page_size = Some(new_value);
3449        self
3450    }
3451    /// Optional. Filter string, adhering to the rules in [List-operation filtering](https://cloud.google.com/secret-manager/docs/filtering). List only secret versions matching the filter. If filter is empty, all secret versions are listed.
3452    ///
3453    /// Sets the *filter* query property to the given value.
3454    pub fn filter(mut self, new_value: &str) -> ProjectLocationSecretVersionListCall<'a, C> {
3455        self._filter = Some(new_value.to_string());
3456        self
3457    }
3458    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3459    /// while executing the actual API request.
3460    ///
3461    /// ````text
3462    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3463    /// ````
3464    ///
3465    /// Sets the *delegate* property to the given value.
3466    pub fn delegate(
3467        mut self,
3468        new_value: &'a mut dyn common::Delegate,
3469    ) -> ProjectLocationSecretVersionListCall<'a, C> {
3470        self._delegate = Some(new_value);
3471        self
3472    }
3473
3474    /// Set any additional parameter of the query string used in the request.
3475    /// It should be used to set parameters which are not yet available through their own
3476    /// setters.
3477    ///
3478    /// Please note that this method must not be used to set any of the known parameters
3479    /// which have their own setter method. If done anyway, the request will fail.
3480    ///
3481    /// # Additional Parameters
3482    ///
3483    /// * *$.xgafv* (query-string) - V1 error format.
3484    /// * *access_token* (query-string) - OAuth access token.
3485    /// * *alt* (query-string) - Data format for response.
3486    /// * *callback* (query-string) - JSONP
3487    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3488    /// * *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.
3489    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3490    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3491    /// * *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.
3492    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3493    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3494    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretVersionListCall<'a, C>
3495    where
3496        T: AsRef<str>,
3497    {
3498        self._additional_params
3499            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3500        self
3501    }
3502
3503    /// Identifies the authorization scope for the method you are building.
3504    ///
3505    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3506    /// [`Scope::CloudPlatform`].
3507    ///
3508    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3509    /// tokens for more than one scope.
3510    ///
3511    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3512    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3513    /// sufficient, a read-write scope will do as well.
3514    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretVersionListCall<'a, C>
3515    where
3516        St: AsRef<str>,
3517    {
3518        self._scopes.insert(String::from(scope.as_ref()));
3519        self
3520    }
3521    /// Identifies the authorization scope(s) for the method you are building.
3522    ///
3523    /// See [`Self::add_scope()`] for details.
3524    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretVersionListCall<'a, C>
3525    where
3526        I: IntoIterator<Item = St>,
3527        St: AsRef<str>,
3528    {
3529        self._scopes
3530            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3531        self
3532    }
3533
3534    /// Removes all scopes, and no default scope will be used either.
3535    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3536    /// for details).
3537    pub fn clear_scopes(mut self) -> ProjectLocationSecretVersionListCall<'a, C> {
3538        self._scopes.clear();
3539        self
3540    }
3541}
3542
3543/// Creates a new SecretVersion containing secret data and attaches it to an existing Secret.
3544///
3545/// A builder for the *locations.secrets.addVersion* method supported by a *project* resource.
3546/// It is not used directly, but through a [`ProjectMethods`] instance.
3547///
3548/// # Example
3549///
3550/// Instantiate a resource method builder
3551///
3552/// ```test_harness,no_run
3553/// # extern crate hyper;
3554/// # extern crate hyper_rustls;
3555/// # extern crate google_secretmanager1 as secretmanager1;
3556/// use secretmanager1::api::AddSecretVersionRequest;
3557/// # async fn dox() {
3558/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3559///
3560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3561/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3562/// #     .with_native_roots()
3563/// #     .unwrap()
3564/// #     .https_only()
3565/// #     .enable_http2()
3566/// #     .build();
3567///
3568/// # let executor = hyper_util::rt::TokioExecutor::new();
3569/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3570/// #     secret,
3571/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3572/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3573/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3574/// #     ),
3575/// # ).build().await.unwrap();
3576///
3577/// # let client = hyper_util::client::legacy::Client::builder(
3578/// #     hyper_util::rt::TokioExecutor::new()
3579/// # )
3580/// # .build(
3581/// #     hyper_rustls::HttpsConnectorBuilder::new()
3582/// #         .with_native_roots()
3583/// #         .unwrap()
3584/// #         .https_or_http()
3585/// #         .enable_http2()
3586/// #         .build()
3587/// # );
3588/// # let mut hub = SecretManager::new(client, auth);
3589/// // As the method needs a request, you would usually fill it with the desired information
3590/// // into the respective structure. Some of the parts shown here might not be applicable !
3591/// // Values shown here are possibly random and not representative !
3592/// let mut req = AddSecretVersionRequest::default();
3593///
3594/// // You can configure optional parameters by calling the respective setters at will, and
3595/// // execute the final call using `doit()`.
3596/// // Values shown here are possibly random and not representative !
3597/// let result = hub.projects().locations_secrets_add_version(req, "parent")
3598///              .doit().await;
3599/// # }
3600/// ```
3601pub struct ProjectLocationSecretAddVersionCall<'a, C>
3602where
3603    C: 'a,
3604{
3605    hub: &'a SecretManager<C>,
3606    _request: AddSecretVersionRequest,
3607    _parent: String,
3608    _delegate: Option<&'a mut dyn common::Delegate>,
3609    _additional_params: HashMap<String, String>,
3610    _scopes: BTreeSet<String>,
3611}
3612
3613impl<'a, C> common::CallBuilder for ProjectLocationSecretAddVersionCall<'a, C> {}
3614
3615impl<'a, C> ProjectLocationSecretAddVersionCall<'a, C>
3616where
3617    C: common::Connector,
3618{
3619    /// Perform the operation you have build so far.
3620    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
3621        use std::borrow::Cow;
3622        use std::io::{Read, Seek};
3623
3624        use common::{url::Params, ToParts};
3625        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3626
3627        let mut dd = common::DefaultDelegate;
3628        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3629        dlg.begin(common::MethodInfo {
3630            id: "secretmanager.projects.locations.secrets.addVersion",
3631            http_method: hyper::Method::POST,
3632        });
3633
3634        for &field in ["alt", "parent"].iter() {
3635            if self._additional_params.contains_key(field) {
3636                dlg.finished(false);
3637                return Err(common::Error::FieldClash(field));
3638            }
3639        }
3640
3641        let mut params = Params::with_capacity(4 + self._additional_params.len());
3642        params.push("parent", self._parent);
3643
3644        params.extend(self._additional_params.iter());
3645
3646        params.push("alt", "json");
3647        let mut url = self.hub._base_url.clone() + "v1/{+parent}:addVersion";
3648        if self._scopes.is_empty() {
3649            self._scopes
3650                .insert(Scope::CloudPlatform.as_ref().to_string());
3651        }
3652
3653        #[allow(clippy::single_element_loop)]
3654        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3655            url = params.uri_replacement(url, param_name, find_this, true);
3656        }
3657        {
3658            let to_remove = ["parent"];
3659            params.remove_params(&to_remove);
3660        }
3661
3662        let url = params.parse_with_url(&url);
3663
3664        let mut json_mime_type = mime::APPLICATION_JSON;
3665        let mut request_value_reader = {
3666            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3667            common::remove_json_null_values(&mut value);
3668            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3669            serde_json::to_writer(&mut dst, &value).unwrap();
3670            dst
3671        };
3672        let request_size = request_value_reader
3673            .seek(std::io::SeekFrom::End(0))
3674            .unwrap();
3675        request_value_reader
3676            .seek(std::io::SeekFrom::Start(0))
3677            .unwrap();
3678
3679        loop {
3680            let token = match self
3681                .hub
3682                .auth
3683                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3684                .await
3685            {
3686                Ok(token) => token,
3687                Err(e) => match dlg.token(e) {
3688                    Ok(token) => token,
3689                    Err(e) => {
3690                        dlg.finished(false);
3691                        return Err(common::Error::MissingToken(e));
3692                    }
3693                },
3694            };
3695            request_value_reader
3696                .seek(std::io::SeekFrom::Start(0))
3697                .unwrap();
3698            let mut req_result = {
3699                let client = &self.hub.client;
3700                dlg.pre_request();
3701                let mut req_builder = hyper::Request::builder()
3702                    .method(hyper::Method::POST)
3703                    .uri(url.as_str())
3704                    .header(USER_AGENT, self.hub._user_agent.clone());
3705
3706                if let Some(token) = token.as_ref() {
3707                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3708                }
3709
3710                let request = req_builder
3711                    .header(CONTENT_TYPE, json_mime_type.to_string())
3712                    .header(CONTENT_LENGTH, request_size as u64)
3713                    .body(common::to_body(
3714                        request_value_reader.get_ref().clone().into(),
3715                    ));
3716
3717                client.request(request.unwrap()).await
3718            };
3719
3720            match req_result {
3721                Err(err) => {
3722                    if let common::Retry::After(d) = dlg.http_error(&err) {
3723                        sleep(d).await;
3724                        continue;
3725                    }
3726                    dlg.finished(false);
3727                    return Err(common::Error::HttpError(err));
3728                }
3729                Ok(res) => {
3730                    let (mut parts, body) = res.into_parts();
3731                    let mut body = common::Body::new(body);
3732                    if !parts.status.is_success() {
3733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3734                        let error = serde_json::from_str(&common::to_string(&bytes));
3735                        let response = common::to_response(parts, bytes.into());
3736
3737                        if let common::Retry::After(d) =
3738                            dlg.http_failure(&response, error.as_ref().ok())
3739                        {
3740                            sleep(d).await;
3741                            continue;
3742                        }
3743
3744                        dlg.finished(false);
3745
3746                        return Err(match error {
3747                            Ok(value) => common::Error::BadRequest(value),
3748                            _ => common::Error::Failure(response),
3749                        });
3750                    }
3751                    let response = {
3752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3753                        let encoded = common::to_string(&bytes);
3754                        match serde_json::from_str(&encoded) {
3755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3756                            Err(error) => {
3757                                dlg.response_json_decode_error(&encoded, &error);
3758                                return Err(common::Error::JsonDecodeError(
3759                                    encoded.to_string(),
3760                                    error,
3761                                ));
3762                            }
3763                        }
3764                    };
3765
3766                    dlg.finished(true);
3767                    return Ok(response);
3768                }
3769            }
3770        }
3771    }
3772
3773    ///
3774    /// Sets the *request* property to the given value.
3775    ///
3776    /// Even though the property as already been set when instantiating this call,
3777    /// we provide this method for API completeness.
3778    pub fn request(
3779        mut self,
3780        new_value: AddSecretVersionRequest,
3781    ) -> ProjectLocationSecretAddVersionCall<'a, C> {
3782        self._request = new_value;
3783        self
3784    }
3785    /// Required. The resource name of the Secret to associate with the SecretVersion in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
3786    ///
3787    /// Sets the *parent* path property to the given value.
3788    ///
3789    /// Even though the property as already been set when instantiating this call,
3790    /// we provide this method for API completeness.
3791    pub fn parent(mut self, new_value: &str) -> ProjectLocationSecretAddVersionCall<'a, C> {
3792        self._parent = new_value.to_string();
3793        self
3794    }
3795    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3796    /// while executing the actual API request.
3797    ///
3798    /// ````text
3799    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3800    /// ````
3801    ///
3802    /// Sets the *delegate* property to the given value.
3803    pub fn delegate(
3804        mut self,
3805        new_value: &'a mut dyn common::Delegate,
3806    ) -> ProjectLocationSecretAddVersionCall<'a, C> {
3807        self._delegate = Some(new_value);
3808        self
3809    }
3810
3811    /// Set any additional parameter of the query string used in the request.
3812    /// It should be used to set parameters which are not yet available through their own
3813    /// setters.
3814    ///
3815    /// Please note that this method must not be used to set any of the known parameters
3816    /// which have their own setter method. If done anyway, the request will fail.
3817    ///
3818    /// # Additional Parameters
3819    ///
3820    /// * *$.xgafv* (query-string) - V1 error format.
3821    /// * *access_token* (query-string) - OAuth access token.
3822    /// * *alt* (query-string) - Data format for response.
3823    /// * *callback* (query-string) - JSONP
3824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3825    /// * *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.
3826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3828    /// * *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.
3829    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3830    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3831    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretAddVersionCall<'a, C>
3832    where
3833        T: AsRef<str>,
3834    {
3835        self._additional_params
3836            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3837        self
3838    }
3839
3840    /// Identifies the authorization scope for the method you are building.
3841    ///
3842    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3843    /// [`Scope::CloudPlatform`].
3844    ///
3845    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3846    /// tokens for more than one scope.
3847    ///
3848    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3849    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3850    /// sufficient, a read-write scope will do as well.
3851    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretAddVersionCall<'a, C>
3852    where
3853        St: AsRef<str>,
3854    {
3855        self._scopes.insert(String::from(scope.as_ref()));
3856        self
3857    }
3858    /// Identifies the authorization scope(s) for the method you are building.
3859    ///
3860    /// See [`Self::add_scope()`] for details.
3861    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretAddVersionCall<'a, C>
3862    where
3863        I: IntoIterator<Item = St>,
3864        St: AsRef<str>,
3865    {
3866        self._scopes
3867            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3868        self
3869    }
3870
3871    /// Removes all scopes, and no default scope will be used either.
3872    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3873    /// for details).
3874    pub fn clear_scopes(mut self) -> ProjectLocationSecretAddVersionCall<'a, C> {
3875        self._scopes.clear();
3876        self
3877    }
3878}
3879
3880/// Creates a new Secret containing no SecretVersions.
3881///
3882/// A builder for the *locations.secrets.create* method supported by a *project* resource.
3883/// It is not used directly, but through a [`ProjectMethods`] instance.
3884///
3885/// # Example
3886///
3887/// Instantiate a resource method builder
3888///
3889/// ```test_harness,no_run
3890/// # extern crate hyper;
3891/// # extern crate hyper_rustls;
3892/// # extern crate google_secretmanager1 as secretmanager1;
3893/// use secretmanager1::api::Secret;
3894/// # async fn dox() {
3895/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3896///
3897/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3898/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3899/// #     .with_native_roots()
3900/// #     .unwrap()
3901/// #     .https_only()
3902/// #     .enable_http2()
3903/// #     .build();
3904///
3905/// # let executor = hyper_util::rt::TokioExecutor::new();
3906/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3907/// #     secret,
3908/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3909/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3910/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3911/// #     ),
3912/// # ).build().await.unwrap();
3913///
3914/// # let client = hyper_util::client::legacy::Client::builder(
3915/// #     hyper_util::rt::TokioExecutor::new()
3916/// # )
3917/// # .build(
3918/// #     hyper_rustls::HttpsConnectorBuilder::new()
3919/// #         .with_native_roots()
3920/// #         .unwrap()
3921/// #         .https_or_http()
3922/// #         .enable_http2()
3923/// #         .build()
3924/// # );
3925/// # let mut hub = SecretManager::new(client, auth);
3926/// // As the method needs a request, you would usually fill it with the desired information
3927/// // into the respective structure. Some of the parts shown here might not be applicable !
3928/// // Values shown here are possibly random and not representative !
3929/// let mut req = Secret::default();
3930///
3931/// // You can configure optional parameters by calling the respective setters at will, and
3932/// // execute the final call using `doit()`.
3933/// // Values shown here are possibly random and not representative !
3934/// let result = hub.projects().locations_secrets_create(req, "parent")
3935///              .secret_id("Lorem")
3936///              .doit().await;
3937/// # }
3938/// ```
3939pub struct ProjectLocationSecretCreateCall<'a, C>
3940where
3941    C: 'a,
3942{
3943    hub: &'a SecretManager<C>,
3944    _request: Secret,
3945    _parent: String,
3946    _secret_id: Option<String>,
3947    _delegate: Option<&'a mut dyn common::Delegate>,
3948    _additional_params: HashMap<String, String>,
3949    _scopes: BTreeSet<String>,
3950}
3951
3952impl<'a, C> common::CallBuilder for ProjectLocationSecretCreateCall<'a, C> {}
3953
3954impl<'a, C> ProjectLocationSecretCreateCall<'a, C>
3955where
3956    C: common::Connector,
3957{
3958    /// Perform the operation you have build so far.
3959    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
3960        use std::borrow::Cow;
3961        use std::io::{Read, Seek};
3962
3963        use common::{url::Params, ToParts};
3964        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3965
3966        let mut dd = common::DefaultDelegate;
3967        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3968        dlg.begin(common::MethodInfo {
3969            id: "secretmanager.projects.locations.secrets.create",
3970            http_method: hyper::Method::POST,
3971        });
3972
3973        for &field in ["alt", "parent", "secretId"].iter() {
3974            if self._additional_params.contains_key(field) {
3975                dlg.finished(false);
3976                return Err(common::Error::FieldClash(field));
3977            }
3978        }
3979
3980        let mut params = Params::with_capacity(5 + self._additional_params.len());
3981        params.push("parent", self._parent);
3982        if let Some(value) = self._secret_id.as_ref() {
3983            params.push("secretId", value);
3984        }
3985
3986        params.extend(self._additional_params.iter());
3987
3988        params.push("alt", "json");
3989        let mut url = self.hub._base_url.clone() + "v1/{+parent}/secrets";
3990        if self._scopes.is_empty() {
3991            self._scopes
3992                .insert(Scope::CloudPlatform.as_ref().to_string());
3993        }
3994
3995        #[allow(clippy::single_element_loop)]
3996        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3997            url = params.uri_replacement(url, param_name, find_this, true);
3998        }
3999        {
4000            let to_remove = ["parent"];
4001            params.remove_params(&to_remove);
4002        }
4003
4004        let url = params.parse_with_url(&url);
4005
4006        let mut json_mime_type = mime::APPLICATION_JSON;
4007        let mut request_value_reader = {
4008            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4009            common::remove_json_null_values(&mut value);
4010            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4011            serde_json::to_writer(&mut dst, &value).unwrap();
4012            dst
4013        };
4014        let request_size = request_value_reader
4015            .seek(std::io::SeekFrom::End(0))
4016            .unwrap();
4017        request_value_reader
4018            .seek(std::io::SeekFrom::Start(0))
4019            .unwrap();
4020
4021        loop {
4022            let token = match self
4023                .hub
4024                .auth
4025                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4026                .await
4027            {
4028                Ok(token) => token,
4029                Err(e) => match dlg.token(e) {
4030                    Ok(token) => token,
4031                    Err(e) => {
4032                        dlg.finished(false);
4033                        return Err(common::Error::MissingToken(e));
4034                    }
4035                },
4036            };
4037            request_value_reader
4038                .seek(std::io::SeekFrom::Start(0))
4039                .unwrap();
4040            let mut req_result = {
4041                let client = &self.hub.client;
4042                dlg.pre_request();
4043                let mut req_builder = hyper::Request::builder()
4044                    .method(hyper::Method::POST)
4045                    .uri(url.as_str())
4046                    .header(USER_AGENT, self.hub._user_agent.clone());
4047
4048                if let Some(token) = token.as_ref() {
4049                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4050                }
4051
4052                let request = req_builder
4053                    .header(CONTENT_TYPE, json_mime_type.to_string())
4054                    .header(CONTENT_LENGTH, request_size as u64)
4055                    .body(common::to_body(
4056                        request_value_reader.get_ref().clone().into(),
4057                    ));
4058
4059                client.request(request.unwrap()).await
4060            };
4061
4062            match req_result {
4063                Err(err) => {
4064                    if let common::Retry::After(d) = dlg.http_error(&err) {
4065                        sleep(d).await;
4066                        continue;
4067                    }
4068                    dlg.finished(false);
4069                    return Err(common::Error::HttpError(err));
4070                }
4071                Ok(res) => {
4072                    let (mut parts, body) = res.into_parts();
4073                    let mut body = common::Body::new(body);
4074                    if !parts.status.is_success() {
4075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4076                        let error = serde_json::from_str(&common::to_string(&bytes));
4077                        let response = common::to_response(parts, bytes.into());
4078
4079                        if let common::Retry::After(d) =
4080                            dlg.http_failure(&response, error.as_ref().ok())
4081                        {
4082                            sleep(d).await;
4083                            continue;
4084                        }
4085
4086                        dlg.finished(false);
4087
4088                        return Err(match error {
4089                            Ok(value) => common::Error::BadRequest(value),
4090                            _ => common::Error::Failure(response),
4091                        });
4092                    }
4093                    let response = {
4094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4095                        let encoded = common::to_string(&bytes);
4096                        match serde_json::from_str(&encoded) {
4097                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4098                            Err(error) => {
4099                                dlg.response_json_decode_error(&encoded, &error);
4100                                return Err(common::Error::JsonDecodeError(
4101                                    encoded.to_string(),
4102                                    error,
4103                                ));
4104                            }
4105                        }
4106                    };
4107
4108                    dlg.finished(true);
4109                    return Ok(response);
4110                }
4111            }
4112        }
4113    }
4114
4115    ///
4116    /// Sets the *request* property to the given value.
4117    ///
4118    /// Even though the property as already been set when instantiating this call,
4119    /// we provide this method for API completeness.
4120    pub fn request(mut self, new_value: Secret) -> ProjectLocationSecretCreateCall<'a, C> {
4121        self._request = new_value;
4122        self
4123    }
4124    /// Required. The resource name of the project to associate with the Secret, in the format `projects/*` or `projects/*/locations/*`.
4125    ///
4126    /// Sets the *parent* path property to the given value.
4127    ///
4128    /// Even though the property as already been set when instantiating this call,
4129    /// we provide this method for API completeness.
4130    pub fn parent(mut self, new_value: &str) -> ProjectLocationSecretCreateCall<'a, C> {
4131        self._parent = new_value.to_string();
4132        self
4133    }
4134    /// Required. This must be unique within the project. A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
4135    ///
4136    /// Sets the *secret id* query property to the given value.
4137    pub fn secret_id(mut self, new_value: &str) -> ProjectLocationSecretCreateCall<'a, C> {
4138        self._secret_id = Some(new_value.to_string());
4139        self
4140    }
4141    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4142    /// while executing the actual API request.
4143    ///
4144    /// ````text
4145    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4146    /// ````
4147    ///
4148    /// Sets the *delegate* property to the given value.
4149    pub fn delegate(
4150        mut self,
4151        new_value: &'a mut dyn common::Delegate,
4152    ) -> ProjectLocationSecretCreateCall<'a, C> {
4153        self._delegate = Some(new_value);
4154        self
4155    }
4156
4157    /// Set any additional parameter of the query string used in the request.
4158    /// It should be used to set parameters which are not yet available through their own
4159    /// setters.
4160    ///
4161    /// Please note that this method must not be used to set any of the known parameters
4162    /// which have their own setter method. If done anyway, the request will fail.
4163    ///
4164    /// # Additional Parameters
4165    ///
4166    /// * *$.xgafv* (query-string) - V1 error format.
4167    /// * *access_token* (query-string) - OAuth access token.
4168    /// * *alt* (query-string) - Data format for response.
4169    /// * *callback* (query-string) - JSONP
4170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4171    /// * *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.
4172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4174    /// * *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.
4175    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4176    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4177    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretCreateCall<'a, C>
4178    where
4179        T: AsRef<str>,
4180    {
4181        self._additional_params
4182            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4183        self
4184    }
4185
4186    /// Identifies the authorization scope for the method you are building.
4187    ///
4188    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4189    /// [`Scope::CloudPlatform`].
4190    ///
4191    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4192    /// tokens for more than one scope.
4193    ///
4194    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4195    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4196    /// sufficient, a read-write scope will do as well.
4197    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretCreateCall<'a, C>
4198    where
4199        St: AsRef<str>,
4200    {
4201        self._scopes.insert(String::from(scope.as_ref()));
4202        self
4203    }
4204    /// Identifies the authorization scope(s) for the method you are building.
4205    ///
4206    /// See [`Self::add_scope()`] for details.
4207    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretCreateCall<'a, C>
4208    where
4209        I: IntoIterator<Item = St>,
4210        St: AsRef<str>,
4211    {
4212        self._scopes
4213            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4214        self
4215    }
4216
4217    /// Removes all scopes, and no default scope will be used either.
4218    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4219    /// for details).
4220    pub fn clear_scopes(mut self) -> ProjectLocationSecretCreateCall<'a, C> {
4221        self._scopes.clear();
4222        self
4223    }
4224}
4225
4226/// Deletes a Secret.
4227///
4228/// A builder for the *locations.secrets.delete* method supported by a *project* resource.
4229/// It is not used directly, but through a [`ProjectMethods`] instance.
4230///
4231/// # Example
4232///
4233/// Instantiate a resource method builder
4234///
4235/// ```test_harness,no_run
4236/// # extern crate hyper;
4237/// # extern crate hyper_rustls;
4238/// # extern crate google_secretmanager1 as secretmanager1;
4239/// # async fn dox() {
4240/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4241///
4242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4244/// #     .with_native_roots()
4245/// #     .unwrap()
4246/// #     .https_only()
4247/// #     .enable_http2()
4248/// #     .build();
4249///
4250/// # let executor = hyper_util::rt::TokioExecutor::new();
4251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4252/// #     secret,
4253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4254/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4255/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4256/// #     ),
4257/// # ).build().await.unwrap();
4258///
4259/// # let client = hyper_util::client::legacy::Client::builder(
4260/// #     hyper_util::rt::TokioExecutor::new()
4261/// # )
4262/// # .build(
4263/// #     hyper_rustls::HttpsConnectorBuilder::new()
4264/// #         .with_native_roots()
4265/// #         .unwrap()
4266/// #         .https_or_http()
4267/// #         .enable_http2()
4268/// #         .build()
4269/// # );
4270/// # let mut hub = SecretManager::new(client, auth);
4271/// // You can configure optional parameters by calling the respective setters at will, and
4272/// // execute the final call using `doit()`.
4273/// // Values shown here are possibly random and not representative !
4274/// let result = hub.projects().locations_secrets_delete("name")
4275///              .etag("eos")
4276///              .doit().await;
4277/// # }
4278/// ```
4279pub struct ProjectLocationSecretDeleteCall<'a, C>
4280where
4281    C: 'a,
4282{
4283    hub: &'a SecretManager<C>,
4284    _name: String,
4285    _etag: Option<String>,
4286    _delegate: Option<&'a mut dyn common::Delegate>,
4287    _additional_params: HashMap<String, String>,
4288    _scopes: BTreeSet<String>,
4289}
4290
4291impl<'a, C> common::CallBuilder for ProjectLocationSecretDeleteCall<'a, C> {}
4292
4293impl<'a, C> ProjectLocationSecretDeleteCall<'a, C>
4294where
4295    C: common::Connector,
4296{
4297    /// Perform the operation you have build so far.
4298    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4299        use std::borrow::Cow;
4300        use std::io::{Read, Seek};
4301
4302        use common::{url::Params, ToParts};
4303        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4304
4305        let mut dd = common::DefaultDelegate;
4306        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4307        dlg.begin(common::MethodInfo {
4308            id: "secretmanager.projects.locations.secrets.delete",
4309            http_method: hyper::Method::DELETE,
4310        });
4311
4312        for &field in ["alt", "name", "etag"].iter() {
4313            if self._additional_params.contains_key(field) {
4314                dlg.finished(false);
4315                return Err(common::Error::FieldClash(field));
4316            }
4317        }
4318
4319        let mut params = Params::with_capacity(4 + self._additional_params.len());
4320        params.push("name", self._name);
4321        if let Some(value) = self._etag.as_ref() {
4322            params.push("etag", value);
4323        }
4324
4325        params.extend(self._additional_params.iter());
4326
4327        params.push("alt", "json");
4328        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4329        if self._scopes.is_empty() {
4330            self._scopes
4331                .insert(Scope::CloudPlatform.as_ref().to_string());
4332        }
4333
4334        #[allow(clippy::single_element_loop)]
4335        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4336            url = params.uri_replacement(url, param_name, find_this, true);
4337        }
4338        {
4339            let to_remove = ["name"];
4340            params.remove_params(&to_remove);
4341        }
4342
4343        let url = params.parse_with_url(&url);
4344
4345        loop {
4346            let token = match self
4347                .hub
4348                .auth
4349                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4350                .await
4351            {
4352                Ok(token) => token,
4353                Err(e) => match dlg.token(e) {
4354                    Ok(token) => token,
4355                    Err(e) => {
4356                        dlg.finished(false);
4357                        return Err(common::Error::MissingToken(e));
4358                    }
4359                },
4360            };
4361            let mut req_result = {
4362                let client = &self.hub.client;
4363                dlg.pre_request();
4364                let mut req_builder = hyper::Request::builder()
4365                    .method(hyper::Method::DELETE)
4366                    .uri(url.as_str())
4367                    .header(USER_AGENT, self.hub._user_agent.clone());
4368
4369                if let Some(token) = token.as_ref() {
4370                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4371                }
4372
4373                let request = req_builder
4374                    .header(CONTENT_LENGTH, 0_u64)
4375                    .body(common::to_body::<String>(None));
4376
4377                client.request(request.unwrap()).await
4378            };
4379
4380            match req_result {
4381                Err(err) => {
4382                    if let common::Retry::After(d) = dlg.http_error(&err) {
4383                        sleep(d).await;
4384                        continue;
4385                    }
4386                    dlg.finished(false);
4387                    return Err(common::Error::HttpError(err));
4388                }
4389                Ok(res) => {
4390                    let (mut parts, body) = res.into_parts();
4391                    let mut body = common::Body::new(body);
4392                    if !parts.status.is_success() {
4393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4394                        let error = serde_json::from_str(&common::to_string(&bytes));
4395                        let response = common::to_response(parts, bytes.into());
4396
4397                        if let common::Retry::After(d) =
4398                            dlg.http_failure(&response, error.as_ref().ok())
4399                        {
4400                            sleep(d).await;
4401                            continue;
4402                        }
4403
4404                        dlg.finished(false);
4405
4406                        return Err(match error {
4407                            Ok(value) => common::Error::BadRequest(value),
4408                            _ => common::Error::Failure(response),
4409                        });
4410                    }
4411                    let response = {
4412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4413                        let encoded = common::to_string(&bytes);
4414                        match serde_json::from_str(&encoded) {
4415                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4416                            Err(error) => {
4417                                dlg.response_json_decode_error(&encoded, &error);
4418                                return Err(common::Error::JsonDecodeError(
4419                                    encoded.to_string(),
4420                                    error,
4421                                ));
4422                            }
4423                        }
4424                    };
4425
4426                    dlg.finished(true);
4427                    return Ok(response);
4428                }
4429            }
4430        }
4431    }
4432
4433    /// Required. The resource name of the Secret to delete in the format `projects/*/secrets/*`.
4434    ///
4435    /// Sets the *name* path property to the given value.
4436    ///
4437    /// Even though the property as already been set when instantiating this call,
4438    /// we provide this method for API completeness.
4439    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretDeleteCall<'a, C> {
4440        self._name = new_value.to_string();
4441        self
4442    }
4443    /// Optional. Etag of the Secret. The request succeeds if it matches the etag of the currently stored secret object. If the etag is omitted, the request succeeds.
4444    ///
4445    /// Sets the *etag* query property to the given value.
4446    pub fn etag(mut self, new_value: &str) -> ProjectLocationSecretDeleteCall<'a, C> {
4447        self._etag = Some(new_value.to_string());
4448        self
4449    }
4450    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4451    /// while executing the actual API request.
4452    ///
4453    /// ````text
4454    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4455    /// ````
4456    ///
4457    /// Sets the *delegate* property to the given value.
4458    pub fn delegate(
4459        mut self,
4460        new_value: &'a mut dyn common::Delegate,
4461    ) -> ProjectLocationSecretDeleteCall<'a, C> {
4462        self._delegate = Some(new_value);
4463        self
4464    }
4465
4466    /// Set any additional parameter of the query string used in the request.
4467    /// It should be used to set parameters which are not yet available through their own
4468    /// setters.
4469    ///
4470    /// Please note that this method must not be used to set any of the known parameters
4471    /// which have their own setter method. If done anyway, the request will fail.
4472    ///
4473    /// # Additional Parameters
4474    ///
4475    /// * *$.xgafv* (query-string) - V1 error format.
4476    /// * *access_token* (query-string) - OAuth access token.
4477    /// * *alt* (query-string) - Data format for response.
4478    /// * *callback* (query-string) - JSONP
4479    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4480    /// * *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.
4481    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4482    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4483    /// * *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.
4484    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4485    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4486    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretDeleteCall<'a, C>
4487    where
4488        T: AsRef<str>,
4489    {
4490        self._additional_params
4491            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4492        self
4493    }
4494
4495    /// Identifies the authorization scope for the method you are building.
4496    ///
4497    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4498    /// [`Scope::CloudPlatform`].
4499    ///
4500    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4501    /// tokens for more than one scope.
4502    ///
4503    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4504    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4505    /// sufficient, a read-write scope will do as well.
4506    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretDeleteCall<'a, C>
4507    where
4508        St: AsRef<str>,
4509    {
4510        self._scopes.insert(String::from(scope.as_ref()));
4511        self
4512    }
4513    /// Identifies the authorization scope(s) for the method you are building.
4514    ///
4515    /// See [`Self::add_scope()`] for details.
4516    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretDeleteCall<'a, C>
4517    where
4518        I: IntoIterator<Item = St>,
4519        St: AsRef<str>,
4520    {
4521        self._scopes
4522            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4523        self
4524    }
4525
4526    /// Removes all scopes, and no default scope will be used either.
4527    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4528    /// for details).
4529    pub fn clear_scopes(mut self) -> ProjectLocationSecretDeleteCall<'a, C> {
4530        self._scopes.clear();
4531        self
4532    }
4533}
4534
4535/// Gets metadata for a given Secret.
4536///
4537/// A builder for the *locations.secrets.get* method supported by a *project* resource.
4538/// It is not used directly, but through a [`ProjectMethods`] instance.
4539///
4540/// # Example
4541///
4542/// Instantiate a resource method builder
4543///
4544/// ```test_harness,no_run
4545/// # extern crate hyper;
4546/// # extern crate hyper_rustls;
4547/// # extern crate google_secretmanager1 as secretmanager1;
4548/// # async fn dox() {
4549/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4550///
4551/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4552/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4553/// #     .with_native_roots()
4554/// #     .unwrap()
4555/// #     .https_only()
4556/// #     .enable_http2()
4557/// #     .build();
4558///
4559/// # let executor = hyper_util::rt::TokioExecutor::new();
4560/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4561/// #     secret,
4562/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4563/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4564/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4565/// #     ),
4566/// # ).build().await.unwrap();
4567///
4568/// # let client = hyper_util::client::legacy::Client::builder(
4569/// #     hyper_util::rt::TokioExecutor::new()
4570/// # )
4571/// # .build(
4572/// #     hyper_rustls::HttpsConnectorBuilder::new()
4573/// #         .with_native_roots()
4574/// #         .unwrap()
4575/// #         .https_or_http()
4576/// #         .enable_http2()
4577/// #         .build()
4578/// # );
4579/// # let mut hub = SecretManager::new(client, auth);
4580/// // You can configure optional parameters by calling the respective setters at will, and
4581/// // execute the final call using `doit()`.
4582/// // Values shown here are possibly random and not representative !
4583/// let result = hub.projects().locations_secrets_get("name")
4584///              .doit().await;
4585/// # }
4586/// ```
4587pub struct ProjectLocationSecretGetCall<'a, C>
4588where
4589    C: 'a,
4590{
4591    hub: &'a SecretManager<C>,
4592    _name: String,
4593    _delegate: Option<&'a mut dyn common::Delegate>,
4594    _additional_params: HashMap<String, String>,
4595    _scopes: BTreeSet<String>,
4596}
4597
4598impl<'a, C> common::CallBuilder for ProjectLocationSecretGetCall<'a, C> {}
4599
4600impl<'a, C> ProjectLocationSecretGetCall<'a, C>
4601where
4602    C: common::Connector,
4603{
4604    /// Perform the operation you have build so far.
4605    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
4606        use std::borrow::Cow;
4607        use std::io::{Read, Seek};
4608
4609        use common::{url::Params, ToParts};
4610        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4611
4612        let mut dd = common::DefaultDelegate;
4613        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4614        dlg.begin(common::MethodInfo {
4615            id: "secretmanager.projects.locations.secrets.get",
4616            http_method: hyper::Method::GET,
4617        });
4618
4619        for &field in ["alt", "name"].iter() {
4620            if self._additional_params.contains_key(field) {
4621                dlg.finished(false);
4622                return Err(common::Error::FieldClash(field));
4623            }
4624        }
4625
4626        let mut params = Params::with_capacity(3 + self._additional_params.len());
4627        params.push("name", self._name);
4628
4629        params.extend(self._additional_params.iter());
4630
4631        params.push("alt", "json");
4632        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4633        if self._scopes.is_empty() {
4634            self._scopes
4635                .insert(Scope::CloudPlatform.as_ref().to_string());
4636        }
4637
4638        #[allow(clippy::single_element_loop)]
4639        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4640            url = params.uri_replacement(url, param_name, find_this, true);
4641        }
4642        {
4643            let to_remove = ["name"];
4644            params.remove_params(&to_remove);
4645        }
4646
4647        let url = params.parse_with_url(&url);
4648
4649        loop {
4650            let token = match self
4651                .hub
4652                .auth
4653                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4654                .await
4655            {
4656                Ok(token) => token,
4657                Err(e) => match dlg.token(e) {
4658                    Ok(token) => token,
4659                    Err(e) => {
4660                        dlg.finished(false);
4661                        return Err(common::Error::MissingToken(e));
4662                    }
4663                },
4664            };
4665            let mut req_result = {
4666                let client = &self.hub.client;
4667                dlg.pre_request();
4668                let mut req_builder = hyper::Request::builder()
4669                    .method(hyper::Method::GET)
4670                    .uri(url.as_str())
4671                    .header(USER_AGENT, self.hub._user_agent.clone());
4672
4673                if let Some(token) = token.as_ref() {
4674                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4675                }
4676
4677                let request = req_builder
4678                    .header(CONTENT_LENGTH, 0_u64)
4679                    .body(common::to_body::<String>(None));
4680
4681                client.request(request.unwrap()).await
4682            };
4683
4684            match req_result {
4685                Err(err) => {
4686                    if let common::Retry::After(d) = dlg.http_error(&err) {
4687                        sleep(d).await;
4688                        continue;
4689                    }
4690                    dlg.finished(false);
4691                    return Err(common::Error::HttpError(err));
4692                }
4693                Ok(res) => {
4694                    let (mut parts, body) = res.into_parts();
4695                    let mut body = common::Body::new(body);
4696                    if !parts.status.is_success() {
4697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4698                        let error = serde_json::from_str(&common::to_string(&bytes));
4699                        let response = common::to_response(parts, bytes.into());
4700
4701                        if let common::Retry::After(d) =
4702                            dlg.http_failure(&response, error.as_ref().ok())
4703                        {
4704                            sleep(d).await;
4705                            continue;
4706                        }
4707
4708                        dlg.finished(false);
4709
4710                        return Err(match error {
4711                            Ok(value) => common::Error::BadRequest(value),
4712                            _ => common::Error::Failure(response),
4713                        });
4714                    }
4715                    let response = {
4716                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4717                        let encoded = common::to_string(&bytes);
4718                        match serde_json::from_str(&encoded) {
4719                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4720                            Err(error) => {
4721                                dlg.response_json_decode_error(&encoded, &error);
4722                                return Err(common::Error::JsonDecodeError(
4723                                    encoded.to_string(),
4724                                    error,
4725                                ));
4726                            }
4727                        }
4728                    };
4729
4730                    dlg.finished(true);
4731                    return Ok(response);
4732                }
4733            }
4734        }
4735    }
4736
4737    /// Required. The resource name of the Secret, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
4738    ///
4739    /// Sets the *name* path property to the given value.
4740    ///
4741    /// Even though the property as already been set when instantiating this call,
4742    /// we provide this method for API completeness.
4743    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretGetCall<'a, C> {
4744        self._name = new_value.to_string();
4745        self
4746    }
4747    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4748    /// while executing the actual API request.
4749    ///
4750    /// ````text
4751    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4752    /// ````
4753    ///
4754    /// Sets the *delegate* property to the given value.
4755    pub fn delegate(
4756        mut self,
4757        new_value: &'a mut dyn common::Delegate,
4758    ) -> ProjectLocationSecretGetCall<'a, C> {
4759        self._delegate = Some(new_value);
4760        self
4761    }
4762
4763    /// Set any additional parameter of the query string used in the request.
4764    /// It should be used to set parameters which are not yet available through their own
4765    /// setters.
4766    ///
4767    /// Please note that this method must not be used to set any of the known parameters
4768    /// which have their own setter method. If done anyway, the request will fail.
4769    ///
4770    /// # Additional Parameters
4771    ///
4772    /// * *$.xgafv* (query-string) - V1 error format.
4773    /// * *access_token* (query-string) - OAuth access token.
4774    /// * *alt* (query-string) - Data format for response.
4775    /// * *callback* (query-string) - JSONP
4776    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4777    /// * *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.
4778    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4779    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4780    /// * *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.
4781    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4782    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4783    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretGetCall<'a, C>
4784    where
4785        T: AsRef<str>,
4786    {
4787        self._additional_params
4788            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4789        self
4790    }
4791
4792    /// Identifies the authorization scope for the method you are building.
4793    ///
4794    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4795    /// [`Scope::CloudPlatform`].
4796    ///
4797    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4798    /// tokens for more than one scope.
4799    ///
4800    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4801    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4802    /// sufficient, a read-write scope will do as well.
4803    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretGetCall<'a, C>
4804    where
4805        St: AsRef<str>,
4806    {
4807        self._scopes.insert(String::from(scope.as_ref()));
4808        self
4809    }
4810    /// Identifies the authorization scope(s) for the method you are building.
4811    ///
4812    /// See [`Self::add_scope()`] for details.
4813    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretGetCall<'a, C>
4814    where
4815        I: IntoIterator<Item = St>,
4816        St: AsRef<str>,
4817    {
4818        self._scopes
4819            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4820        self
4821    }
4822
4823    /// Removes all scopes, and no default scope will be used either.
4824    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4825    /// for details).
4826    pub fn clear_scopes(mut self) -> ProjectLocationSecretGetCall<'a, C> {
4827        self._scopes.clear();
4828        self
4829    }
4830}
4831
4832/// Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.
4833///
4834/// A builder for the *locations.secrets.getIamPolicy* method supported by a *project* resource.
4835/// It is not used directly, but through a [`ProjectMethods`] instance.
4836///
4837/// # Example
4838///
4839/// Instantiate a resource method builder
4840///
4841/// ```test_harness,no_run
4842/// # extern crate hyper;
4843/// # extern crate hyper_rustls;
4844/// # extern crate google_secretmanager1 as secretmanager1;
4845/// # async fn dox() {
4846/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4847///
4848/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4849/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4850/// #     .with_native_roots()
4851/// #     .unwrap()
4852/// #     .https_only()
4853/// #     .enable_http2()
4854/// #     .build();
4855///
4856/// # let executor = hyper_util::rt::TokioExecutor::new();
4857/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4858/// #     secret,
4859/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4860/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4861/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4862/// #     ),
4863/// # ).build().await.unwrap();
4864///
4865/// # let client = hyper_util::client::legacy::Client::builder(
4866/// #     hyper_util::rt::TokioExecutor::new()
4867/// # )
4868/// # .build(
4869/// #     hyper_rustls::HttpsConnectorBuilder::new()
4870/// #         .with_native_roots()
4871/// #         .unwrap()
4872/// #         .https_or_http()
4873/// #         .enable_http2()
4874/// #         .build()
4875/// # );
4876/// # let mut hub = SecretManager::new(client, auth);
4877/// // You can configure optional parameters by calling the respective setters at will, and
4878/// // execute the final call using `doit()`.
4879/// // Values shown here are possibly random and not representative !
4880/// let result = hub.projects().locations_secrets_get_iam_policy("resource")
4881///              .options_requested_policy_version(-55)
4882///              .doit().await;
4883/// # }
4884/// ```
4885pub struct ProjectLocationSecretGetIamPolicyCall<'a, C>
4886where
4887    C: 'a,
4888{
4889    hub: &'a SecretManager<C>,
4890    _resource: String,
4891    _options_requested_policy_version: Option<i32>,
4892    _delegate: Option<&'a mut dyn common::Delegate>,
4893    _additional_params: HashMap<String, String>,
4894    _scopes: BTreeSet<String>,
4895}
4896
4897impl<'a, C> common::CallBuilder for ProjectLocationSecretGetIamPolicyCall<'a, C> {}
4898
4899impl<'a, C> ProjectLocationSecretGetIamPolicyCall<'a, C>
4900where
4901    C: common::Connector,
4902{
4903    /// Perform the operation you have build so far.
4904    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4905        use std::borrow::Cow;
4906        use std::io::{Read, Seek};
4907
4908        use common::{url::Params, ToParts};
4909        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4910
4911        let mut dd = common::DefaultDelegate;
4912        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4913        dlg.begin(common::MethodInfo {
4914            id: "secretmanager.projects.locations.secrets.getIamPolicy",
4915            http_method: hyper::Method::GET,
4916        });
4917
4918        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
4919            if self._additional_params.contains_key(field) {
4920                dlg.finished(false);
4921                return Err(common::Error::FieldClash(field));
4922            }
4923        }
4924
4925        let mut params = Params::with_capacity(4 + self._additional_params.len());
4926        params.push("resource", self._resource);
4927        if let Some(value) = self._options_requested_policy_version.as_ref() {
4928            params.push("options.requestedPolicyVersion", value.to_string());
4929        }
4930
4931        params.extend(self._additional_params.iter());
4932
4933        params.push("alt", "json");
4934        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
4935        if self._scopes.is_empty() {
4936            self._scopes
4937                .insert(Scope::CloudPlatform.as_ref().to_string());
4938        }
4939
4940        #[allow(clippy::single_element_loop)]
4941        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4942            url = params.uri_replacement(url, param_name, find_this, true);
4943        }
4944        {
4945            let to_remove = ["resource"];
4946            params.remove_params(&to_remove);
4947        }
4948
4949        let url = params.parse_with_url(&url);
4950
4951        loop {
4952            let token = match self
4953                .hub
4954                .auth
4955                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4956                .await
4957            {
4958                Ok(token) => token,
4959                Err(e) => match dlg.token(e) {
4960                    Ok(token) => token,
4961                    Err(e) => {
4962                        dlg.finished(false);
4963                        return Err(common::Error::MissingToken(e));
4964                    }
4965                },
4966            };
4967            let mut req_result = {
4968                let client = &self.hub.client;
4969                dlg.pre_request();
4970                let mut req_builder = hyper::Request::builder()
4971                    .method(hyper::Method::GET)
4972                    .uri(url.as_str())
4973                    .header(USER_AGENT, self.hub._user_agent.clone());
4974
4975                if let Some(token) = token.as_ref() {
4976                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4977                }
4978
4979                let request = req_builder
4980                    .header(CONTENT_LENGTH, 0_u64)
4981                    .body(common::to_body::<String>(None));
4982
4983                client.request(request.unwrap()).await
4984            };
4985
4986            match req_result {
4987                Err(err) => {
4988                    if let common::Retry::After(d) = dlg.http_error(&err) {
4989                        sleep(d).await;
4990                        continue;
4991                    }
4992                    dlg.finished(false);
4993                    return Err(common::Error::HttpError(err));
4994                }
4995                Ok(res) => {
4996                    let (mut parts, body) = res.into_parts();
4997                    let mut body = common::Body::new(body);
4998                    if !parts.status.is_success() {
4999                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5000                        let error = serde_json::from_str(&common::to_string(&bytes));
5001                        let response = common::to_response(parts, bytes.into());
5002
5003                        if let common::Retry::After(d) =
5004                            dlg.http_failure(&response, error.as_ref().ok())
5005                        {
5006                            sleep(d).await;
5007                            continue;
5008                        }
5009
5010                        dlg.finished(false);
5011
5012                        return Err(match error {
5013                            Ok(value) => common::Error::BadRequest(value),
5014                            _ => common::Error::Failure(response),
5015                        });
5016                    }
5017                    let response = {
5018                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5019                        let encoded = common::to_string(&bytes);
5020                        match serde_json::from_str(&encoded) {
5021                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5022                            Err(error) => {
5023                                dlg.response_json_decode_error(&encoded, &error);
5024                                return Err(common::Error::JsonDecodeError(
5025                                    encoded.to_string(),
5026                                    error,
5027                                ));
5028                            }
5029                        }
5030                    };
5031
5032                    dlg.finished(true);
5033                    return Ok(response);
5034                }
5035            }
5036        }
5037    }
5038
5039    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5040    ///
5041    /// Sets the *resource* path property to the given value.
5042    ///
5043    /// Even though the property as already been set when instantiating this call,
5044    /// we provide this method for API completeness.
5045    pub fn resource(mut self, new_value: &str) -> ProjectLocationSecretGetIamPolicyCall<'a, C> {
5046        self._resource = new_value.to_string();
5047        self
5048    }
5049    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
5050    ///
5051    /// Sets the *options.requested policy version* query property to the given value.
5052    pub fn options_requested_policy_version(
5053        mut self,
5054        new_value: i32,
5055    ) -> ProjectLocationSecretGetIamPolicyCall<'a, C> {
5056        self._options_requested_policy_version = Some(new_value);
5057        self
5058    }
5059    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5060    /// while executing the actual API request.
5061    ///
5062    /// ````text
5063    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5064    /// ````
5065    ///
5066    /// Sets the *delegate* property to the given value.
5067    pub fn delegate(
5068        mut self,
5069        new_value: &'a mut dyn common::Delegate,
5070    ) -> ProjectLocationSecretGetIamPolicyCall<'a, C> {
5071        self._delegate = Some(new_value);
5072        self
5073    }
5074
5075    /// Set any additional parameter of the query string used in the request.
5076    /// It should be used to set parameters which are not yet available through their own
5077    /// setters.
5078    ///
5079    /// Please note that this method must not be used to set any of the known parameters
5080    /// which have their own setter method. If done anyway, the request will fail.
5081    ///
5082    /// # Additional Parameters
5083    ///
5084    /// * *$.xgafv* (query-string) - V1 error format.
5085    /// * *access_token* (query-string) - OAuth access token.
5086    /// * *alt* (query-string) - Data format for response.
5087    /// * *callback* (query-string) - JSONP
5088    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5089    /// * *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.
5090    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5091    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5092    /// * *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.
5093    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5094    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5095    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretGetIamPolicyCall<'a, C>
5096    where
5097        T: AsRef<str>,
5098    {
5099        self._additional_params
5100            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5101        self
5102    }
5103
5104    /// Identifies the authorization scope for the method you are building.
5105    ///
5106    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5107    /// [`Scope::CloudPlatform`].
5108    ///
5109    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5110    /// tokens for more than one scope.
5111    ///
5112    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5113    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5114    /// sufficient, a read-write scope will do as well.
5115    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretGetIamPolicyCall<'a, C>
5116    where
5117        St: AsRef<str>,
5118    {
5119        self._scopes.insert(String::from(scope.as_ref()));
5120        self
5121    }
5122    /// Identifies the authorization scope(s) for the method you are building.
5123    ///
5124    /// See [`Self::add_scope()`] for details.
5125    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretGetIamPolicyCall<'a, C>
5126    where
5127        I: IntoIterator<Item = St>,
5128        St: AsRef<str>,
5129    {
5130        self._scopes
5131            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5132        self
5133    }
5134
5135    /// Removes all scopes, and no default scope will be used either.
5136    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5137    /// for details).
5138    pub fn clear_scopes(mut self) -> ProjectLocationSecretGetIamPolicyCall<'a, C> {
5139        self._scopes.clear();
5140        self
5141    }
5142}
5143
5144/// Lists Secrets.
5145///
5146/// A builder for the *locations.secrets.list* method supported by a *project* resource.
5147/// It is not used directly, but through a [`ProjectMethods`] instance.
5148///
5149/// # Example
5150///
5151/// Instantiate a resource method builder
5152///
5153/// ```test_harness,no_run
5154/// # extern crate hyper;
5155/// # extern crate hyper_rustls;
5156/// # extern crate google_secretmanager1 as secretmanager1;
5157/// # async fn dox() {
5158/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5159///
5160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5161/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5162/// #     .with_native_roots()
5163/// #     .unwrap()
5164/// #     .https_only()
5165/// #     .enable_http2()
5166/// #     .build();
5167///
5168/// # let executor = hyper_util::rt::TokioExecutor::new();
5169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5170/// #     secret,
5171/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5172/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5173/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5174/// #     ),
5175/// # ).build().await.unwrap();
5176///
5177/// # let client = hyper_util::client::legacy::Client::builder(
5178/// #     hyper_util::rt::TokioExecutor::new()
5179/// # )
5180/// # .build(
5181/// #     hyper_rustls::HttpsConnectorBuilder::new()
5182/// #         .with_native_roots()
5183/// #         .unwrap()
5184/// #         .https_or_http()
5185/// #         .enable_http2()
5186/// #         .build()
5187/// # );
5188/// # let mut hub = SecretManager::new(client, auth);
5189/// // You can configure optional parameters by calling the respective setters at will, and
5190/// // execute the final call using `doit()`.
5191/// // Values shown here are possibly random and not representative !
5192/// let result = hub.projects().locations_secrets_list("parent")
5193///              .page_token("amet")
5194///              .page_size(-20)
5195///              .filter("ipsum")
5196///              .doit().await;
5197/// # }
5198/// ```
5199pub struct ProjectLocationSecretListCall<'a, C>
5200where
5201    C: 'a,
5202{
5203    hub: &'a SecretManager<C>,
5204    _parent: String,
5205    _page_token: Option<String>,
5206    _page_size: Option<i32>,
5207    _filter: Option<String>,
5208    _delegate: Option<&'a mut dyn common::Delegate>,
5209    _additional_params: HashMap<String, String>,
5210    _scopes: BTreeSet<String>,
5211}
5212
5213impl<'a, C> common::CallBuilder for ProjectLocationSecretListCall<'a, C> {}
5214
5215impl<'a, C> ProjectLocationSecretListCall<'a, C>
5216where
5217    C: common::Connector,
5218{
5219    /// Perform the operation you have build so far.
5220    pub async fn doit(mut self) -> common::Result<(common::Response, ListSecretsResponse)> {
5221        use std::borrow::Cow;
5222        use std::io::{Read, Seek};
5223
5224        use common::{url::Params, ToParts};
5225        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5226
5227        let mut dd = common::DefaultDelegate;
5228        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5229        dlg.begin(common::MethodInfo {
5230            id: "secretmanager.projects.locations.secrets.list",
5231            http_method: hyper::Method::GET,
5232        });
5233
5234        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5235            if self._additional_params.contains_key(field) {
5236                dlg.finished(false);
5237                return Err(common::Error::FieldClash(field));
5238            }
5239        }
5240
5241        let mut params = Params::with_capacity(6 + self._additional_params.len());
5242        params.push("parent", self._parent);
5243        if let Some(value) = self._page_token.as_ref() {
5244            params.push("pageToken", value);
5245        }
5246        if let Some(value) = self._page_size.as_ref() {
5247            params.push("pageSize", value.to_string());
5248        }
5249        if let Some(value) = self._filter.as_ref() {
5250            params.push("filter", value);
5251        }
5252
5253        params.extend(self._additional_params.iter());
5254
5255        params.push("alt", "json");
5256        let mut url = self.hub._base_url.clone() + "v1/{+parent}/secrets";
5257        if self._scopes.is_empty() {
5258            self._scopes
5259                .insert(Scope::CloudPlatform.as_ref().to_string());
5260        }
5261
5262        #[allow(clippy::single_element_loop)]
5263        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5264            url = params.uri_replacement(url, param_name, find_this, true);
5265        }
5266        {
5267            let to_remove = ["parent"];
5268            params.remove_params(&to_remove);
5269        }
5270
5271        let url = params.parse_with_url(&url);
5272
5273        loop {
5274            let token = match self
5275                .hub
5276                .auth
5277                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5278                .await
5279            {
5280                Ok(token) => token,
5281                Err(e) => match dlg.token(e) {
5282                    Ok(token) => token,
5283                    Err(e) => {
5284                        dlg.finished(false);
5285                        return Err(common::Error::MissingToken(e));
5286                    }
5287                },
5288            };
5289            let mut req_result = {
5290                let client = &self.hub.client;
5291                dlg.pre_request();
5292                let mut req_builder = hyper::Request::builder()
5293                    .method(hyper::Method::GET)
5294                    .uri(url.as_str())
5295                    .header(USER_AGENT, self.hub._user_agent.clone());
5296
5297                if let Some(token) = token.as_ref() {
5298                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5299                }
5300
5301                let request = req_builder
5302                    .header(CONTENT_LENGTH, 0_u64)
5303                    .body(common::to_body::<String>(None));
5304
5305                client.request(request.unwrap()).await
5306            };
5307
5308            match req_result {
5309                Err(err) => {
5310                    if let common::Retry::After(d) = dlg.http_error(&err) {
5311                        sleep(d).await;
5312                        continue;
5313                    }
5314                    dlg.finished(false);
5315                    return Err(common::Error::HttpError(err));
5316                }
5317                Ok(res) => {
5318                    let (mut parts, body) = res.into_parts();
5319                    let mut body = common::Body::new(body);
5320                    if !parts.status.is_success() {
5321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5322                        let error = serde_json::from_str(&common::to_string(&bytes));
5323                        let response = common::to_response(parts, bytes.into());
5324
5325                        if let common::Retry::After(d) =
5326                            dlg.http_failure(&response, error.as_ref().ok())
5327                        {
5328                            sleep(d).await;
5329                            continue;
5330                        }
5331
5332                        dlg.finished(false);
5333
5334                        return Err(match error {
5335                            Ok(value) => common::Error::BadRequest(value),
5336                            _ => common::Error::Failure(response),
5337                        });
5338                    }
5339                    let response = {
5340                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5341                        let encoded = common::to_string(&bytes);
5342                        match serde_json::from_str(&encoded) {
5343                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5344                            Err(error) => {
5345                                dlg.response_json_decode_error(&encoded, &error);
5346                                return Err(common::Error::JsonDecodeError(
5347                                    encoded.to_string(),
5348                                    error,
5349                                ));
5350                            }
5351                        }
5352                    };
5353
5354                    dlg.finished(true);
5355                    return Ok(response);
5356                }
5357            }
5358        }
5359    }
5360
5361    /// Required. The resource name of the project associated with the Secrets, in the format `projects/*` or `projects/*/locations/*`
5362    ///
5363    /// Sets the *parent* path property to the given value.
5364    ///
5365    /// Even though the property as already been set when instantiating this call,
5366    /// we provide this method for API completeness.
5367    pub fn parent(mut self, new_value: &str) -> ProjectLocationSecretListCall<'a, C> {
5368        self._parent = new_value.to_string();
5369        self
5370    }
5371    /// Optional. Pagination token, returned earlier via ListSecretsResponse.next_page_token.
5372    ///
5373    /// Sets the *page token* query property to the given value.
5374    pub fn page_token(mut self, new_value: &str) -> ProjectLocationSecretListCall<'a, C> {
5375        self._page_token = Some(new_value.to_string());
5376        self
5377    }
5378    /// Optional. The maximum number of results to be returned in a single page. If set to 0, the server decides the number of results to return. If the number is greater than 25000, it is capped at 25000.
5379    ///
5380    /// Sets the *page size* query property to the given value.
5381    pub fn page_size(mut self, new_value: i32) -> ProjectLocationSecretListCall<'a, C> {
5382        self._page_size = Some(new_value);
5383        self
5384    }
5385    /// Optional. Filter string, adhering to the rules in [List-operation filtering](https://cloud.google.com/secret-manager/docs/filtering). List only secrets matching the filter. If filter is empty, all secrets are listed.
5386    ///
5387    /// Sets the *filter* query property to the given value.
5388    pub fn filter(mut self, new_value: &str) -> ProjectLocationSecretListCall<'a, C> {
5389        self._filter = Some(new_value.to_string());
5390        self
5391    }
5392    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5393    /// while executing the actual API request.
5394    ///
5395    /// ````text
5396    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5397    /// ````
5398    ///
5399    /// Sets the *delegate* property to the given value.
5400    pub fn delegate(
5401        mut self,
5402        new_value: &'a mut dyn common::Delegate,
5403    ) -> ProjectLocationSecretListCall<'a, C> {
5404        self._delegate = Some(new_value);
5405        self
5406    }
5407
5408    /// Set any additional parameter of the query string used in the request.
5409    /// It should be used to set parameters which are not yet available through their own
5410    /// setters.
5411    ///
5412    /// Please note that this method must not be used to set any of the known parameters
5413    /// which have their own setter method. If done anyway, the request will fail.
5414    ///
5415    /// # Additional Parameters
5416    ///
5417    /// * *$.xgafv* (query-string) - V1 error format.
5418    /// * *access_token* (query-string) - OAuth access token.
5419    /// * *alt* (query-string) - Data format for response.
5420    /// * *callback* (query-string) - JSONP
5421    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5422    /// * *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.
5423    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5424    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5425    /// * *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.
5426    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5427    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5428    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretListCall<'a, C>
5429    where
5430        T: AsRef<str>,
5431    {
5432        self._additional_params
5433            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5434        self
5435    }
5436
5437    /// Identifies the authorization scope for the method you are building.
5438    ///
5439    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5440    /// [`Scope::CloudPlatform`].
5441    ///
5442    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5443    /// tokens for more than one scope.
5444    ///
5445    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5446    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5447    /// sufficient, a read-write scope will do as well.
5448    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretListCall<'a, C>
5449    where
5450        St: AsRef<str>,
5451    {
5452        self._scopes.insert(String::from(scope.as_ref()));
5453        self
5454    }
5455    /// Identifies the authorization scope(s) for the method you are building.
5456    ///
5457    /// See [`Self::add_scope()`] for details.
5458    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretListCall<'a, C>
5459    where
5460        I: IntoIterator<Item = St>,
5461        St: AsRef<str>,
5462    {
5463        self._scopes
5464            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5465        self
5466    }
5467
5468    /// Removes all scopes, and no default scope will be used either.
5469    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5470    /// for details).
5471    pub fn clear_scopes(mut self) -> ProjectLocationSecretListCall<'a, C> {
5472        self._scopes.clear();
5473        self
5474    }
5475}
5476
5477/// Updates metadata of an existing Secret.
5478///
5479/// A builder for the *locations.secrets.patch* method supported by a *project* resource.
5480/// It is not used directly, but through a [`ProjectMethods`] instance.
5481///
5482/// # Example
5483///
5484/// Instantiate a resource method builder
5485///
5486/// ```test_harness,no_run
5487/// # extern crate hyper;
5488/// # extern crate hyper_rustls;
5489/// # extern crate google_secretmanager1 as secretmanager1;
5490/// use secretmanager1::api::Secret;
5491/// # async fn dox() {
5492/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5493///
5494/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5495/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5496/// #     .with_native_roots()
5497/// #     .unwrap()
5498/// #     .https_only()
5499/// #     .enable_http2()
5500/// #     .build();
5501///
5502/// # let executor = hyper_util::rt::TokioExecutor::new();
5503/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5504/// #     secret,
5505/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5506/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5507/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5508/// #     ),
5509/// # ).build().await.unwrap();
5510///
5511/// # let client = hyper_util::client::legacy::Client::builder(
5512/// #     hyper_util::rt::TokioExecutor::new()
5513/// # )
5514/// # .build(
5515/// #     hyper_rustls::HttpsConnectorBuilder::new()
5516/// #         .with_native_roots()
5517/// #         .unwrap()
5518/// #         .https_or_http()
5519/// #         .enable_http2()
5520/// #         .build()
5521/// # );
5522/// # let mut hub = SecretManager::new(client, auth);
5523/// // As the method needs a request, you would usually fill it with the desired information
5524/// // into the respective structure. Some of the parts shown here might not be applicable !
5525/// // Values shown here are possibly random and not representative !
5526/// let mut req = Secret::default();
5527///
5528/// // You can configure optional parameters by calling the respective setters at will, and
5529/// // execute the final call using `doit()`.
5530/// // Values shown here are possibly random and not representative !
5531/// let result = hub.projects().locations_secrets_patch(req, "name")
5532///              .update_mask(FieldMask::new::<&str>(&[]))
5533///              .doit().await;
5534/// # }
5535/// ```
5536pub struct ProjectLocationSecretPatchCall<'a, C>
5537where
5538    C: 'a,
5539{
5540    hub: &'a SecretManager<C>,
5541    _request: Secret,
5542    _name: String,
5543    _update_mask: Option<common::FieldMask>,
5544    _delegate: Option<&'a mut dyn common::Delegate>,
5545    _additional_params: HashMap<String, String>,
5546    _scopes: BTreeSet<String>,
5547}
5548
5549impl<'a, C> common::CallBuilder for ProjectLocationSecretPatchCall<'a, C> {}
5550
5551impl<'a, C> ProjectLocationSecretPatchCall<'a, C>
5552where
5553    C: common::Connector,
5554{
5555    /// Perform the operation you have build so far.
5556    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
5557        use std::borrow::Cow;
5558        use std::io::{Read, Seek};
5559
5560        use common::{url::Params, ToParts};
5561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5562
5563        let mut dd = common::DefaultDelegate;
5564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5565        dlg.begin(common::MethodInfo {
5566            id: "secretmanager.projects.locations.secrets.patch",
5567            http_method: hyper::Method::PATCH,
5568        });
5569
5570        for &field in ["alt", "name", "updateMask"].iter() {
5571            if self._additional_params.contains_key(field) {
5572                dlg.finished(false);
5573                return Err(common::Error::FieldClash(field));
5574            }
5575        }
5576
5577        let mut params = Params::with_capacity(5 + self._additional_params.len());
5578        params.push("name", self._name);
5579        if let Some(value) = self._update_mask.as_ref() {
5580            params.push("updateMask", value.to_string());
5581        }
5582
5583        params.extend(self._additional_params.iter());
5584
5585        params.push("alt", "json");
5586        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5587        if self._scopes.is_empty() {
5588            self._scopes
5589                .insert(Scope::CloudPlatform.as_ref().to_string());
5590        }
5591
5592        #[allow(clippy::single_element_loop)]
5593        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5594            url = params.uri_replacement(url, param_name, find_this, true);
5595        }
5596        {
5597            let to_remove = ["name"];
5598            params.remove_params(&to_remove);
5599        }
5600
5601        let url = params.parse_with_url(&url);
5602
5603        let mut json_mime_type = mime::APPLICATION_JSON;
5604        let mut request_value_reader = {
5605            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5606            common::remove_json_null_values(&mut value);
5607            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5608            serde_json::to_writer(&mut dst, &value).unwrap();
5609            dst
5610        };
5611        let request_size = request_value_reader
5612            .seek(std::io::SeekFrom::End(0))
5613            .unwrap();
5614        request_value_reader
5615            .seek(std::io::SeekFrom::Start(0))
5616            .unwrap();
5617
5618        loop {
5619            let token = match self
5620                .hub
5621                .auth
5622                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5623                .await
5624            {
5625                Ok(token) => token,
5626                Err(e) => match dlg.token(e) {
5627                    Ok(token) => token,
5628                    Err(e) => {
5629                        dlg.finished(false);
5630                        return Err(common::Error::MissingToken(e));
5631                    }
5632                },
5633            };
5634            request_value_reader
5635                .seek(std::io::SeekFrom::Start(0))
5636                .unwrap();
5637            let mut req_result = {
5638                let client = &self.hub.client;
5639                dlg.pre_request();
5640                let mut req_builder = hyper::Request::builder()
5641                    .method(hyper::Method::PATCH)
5642                    .uri(url.as_str())
5643                    .header(USER_AGENT, self.hub._user_agent.clone());
5644
5645                if let Some(token) = token.as_ref() {
5646                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5647                }
5648
5649                let request = req_builder
5650                    .header(CONTENT_TYPE, json_mime_type.to_string())
5651                    .header(CONTENT_LENGTH, request_size as u64)
5652                    .body(common::to_body(
5653                        request_value_reader.get_ref().clone().into(),
5654                    ));
5655
5656                client.request(request.unwrap()).await
5657            };
5658
5659            match req_result {
5660                Err(err) => {
5661                    if let common::Retry::After(d) = dlg.http_error(&err) {
5662                        sleep(d).await;
5663                        continue;
5664                    }
5665                    dlg.finished(false);
5666                    return Err(common::Error::HttpError(err));
5667                }
5668                Ok(res) => {
5669                    let (mut parts, body) = res.into_parts();
5670                    let mut body = common::Body::new(body);
5671                    if !parts.status.is_success() {
5672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5673                        let error = serde_json::from_str(&common::to_string(&bytes));
5674                        let response = common::to_response(parts, bytes.into());
5675
5676                        if let common::Retry::After(d) =
5677                            dlg.http_failure(&response, error.as_ref().ok())
5678                        {
5679                            sleep(d).await;
5680                            continue;
5681                        }
5682
5683                        dlg.finished(false);
5684
5685                        return Err(match error {
5686                            Ok(value) => common::Error::BadRequest(value),
5687                            _ => common::Error::Failure(response),
5688                        });
5689                    }
5690                    let response = {
5691                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5692                        let encoded = common::to_string(&bytes);
5693                        match serde_json::from_str(&encoded) {
5694                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5695                            Err(error) => {
5696                                dlg.response_json_decode_error(&encoded, &error);
5697                                return Err(common::Error::JsonDecodeError(
5698                                    encoded.to_string(),
5699                                    error,
5700                                ));
5701                            }
5702                        }
5703                    };
5704
5705                    dlg.finished(true);
5706                    return Ok(response);
5707                }
5708            }
5709        }
5710    }
5711
5712    ///
5713    /// Sets the *request* property to the given value.
5714    ///
5715    /// Even though the property as already been set when instantiating this call,
5716    /// we provide this method for API completeness.
5717    pub fn request(mut self, new_value: Secret) -> ProjectLocationSecretPatchCall<'a, C> {
5718        self._request = new_value;
5719        self
5720    }
5721    /// Output only. The resource name of the Secret in the format `projects/*/secrets/*`.
5722    ///
5723    /// Sets the *name* path property to the given value.
5724    ///
5725    /// Even though the property as already been set when instantiating this call,
5726    /// we provide this method for API completeness.
5727    pub fn name(mut self, new_value: &str) -> ProjectLocationSecretPatchCall<'a, C> {
5728        self._name = new_value.to_string();
5729        self
5730    }
5731    /// Required. Specifies the fields to be updated.
5732    ///
5733    /// Sets the *update mask* query property to the given value.
5734    pub fn update_mask(
5735        mut self,
5736        new_value: common::FieldMask,
5737    ) -> ProjectLocationSecretPatchCall<'a, C> {
5738        self._update_mask = Some(new_value);
5739        self
5740    }
5741    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5742    /// while executing the actual API request.
5743    ///
5744    /// ````text
5745    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5746    /// ````
5747    ///
5748    /// Sets the *delegate* property to the given value.
5749    pub fn delegate(
5750        mut self,
5751        new_value: &'a mut dyn common::Delegate,
5752    ) -> ProjectLocationSecretPatchCall<'a, C> {
5753        self._delegate = Some(new_value);
5754        self
5755    }
5756
5757    /// Set any additional parameter of the query string used in the request.
5758    /// It should be used to set parameters which are not yet available through their own
5759    /// setters.
5760    ///
5761    /// Please note that this method must not be used to set any of the known parameters
5762    /// which have their own setter method. If done anyway, the request will fail.
5763    ///
5764    /// # Additional Parameters
5765    ///
5766    /// * *$.xgafv* (query-string) - V1 error format.
5767    /// * *access_token* (query-string) - OAuth access token.
5768    /// * *alt* (query-string) - Data format for response.
5769    /// * *callback* (query-string) - JSONP
5770    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5771    /// * *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.
5772    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5774    /// * *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.
5775    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5776    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5777    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretPatchCall<'a, C>
5778    where
5779        T: AsRef<str>,
5780    {
5781        self._additional_params
5782            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5783        self
5784    }
5785
5786    /// Identifies the authorization scope for the method you are building.
5787    ///
5788    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5789    /// [`Scope::CloudPlatform`].
5790    ///
5791    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5792    /// tokens for more than one scope.
5793    ///
5794    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5795    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5796    /// sufficient, a read-write scope will do as well.
5797    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretPatchCall<'a, C>
5798    where
5799        St: AsRef<str>,
5800    {
5801        self._scopes.insert(String::from(scope.as_ref()));
5802        self
5803    }
5804    /// Identifies the authorization scope(s) for the method you are building.
5805    ///
5806    /// See [`Self::add_scope()`] for details.
5807    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretPatchCall<'a, C>
5808    where
5809        I: IntoIterator<Item = St>,
5810        St: AsRef<str>,
5811    {
5812        self._scopes
5813            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5814        self
5815    }
5816
5817    /// Removes all scopes, and no default scope will be used either.
5818    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5819    /// for details).
5820    pub fn clear_scopes(mut self) -> ProjectLocationSecretPatchCall<'a, C> {
5821        self._scopes.clear();
5822        self
5823    }
5824}
5825
5826/// Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on SecretVersions are enforced according to the policy set on the associated Secret.
5827///
5828/// A builder for the *locations.secrets.setIamPolicy* method supported by a *project* resource.
5829/// It is not used directly, but through a [`ProjectMethods`] instance.
5830///
5831/// # Example
5832///
5833/// Instantiate a resource method builder
5834///
5835/// ```test_harness,no_run
5836/// # extern crate hyper;
5837/// # extern crate hyper_rustls;
5838/// # extern crate google_secretmanager1 as secretmanager1;
5839/// use secretmanager1::api::SetIamPolicyRequest;
5840/// # async fn dox() {
5841/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5842///
5843/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5844/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5845/// #     .with_native_roots()
5846/// #     .unwrap()
5847/// #     .https_only()
5848/// #     .enable_http2()
5849/// #     .build();
5850///
5851/// # let executor = hyper_util::rt::TokioExecutor::new();
5852/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5853/// #     secret,
5854/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5855/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5856/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5857/// #     ),
5858/// # ).build().await.unwrap();
5859///
5860/// # let client = hyper_util::client::legacy::Client::builder(
5861/// #     hyper_util::rt::TokioExecutor::new()
5862/// # )
5863/// # .build(
5864/// #     hyper_rustls::HttpsConnectorBuilder::new()
5865/// #         .with_native_roots()
5866/// #         .unwrap()
5867/// #         .https_or_http()
5868/// #         .enable_http2()
5869/// #         .build()
5870/// # );
5871/// # let mut hub = SecretManager::new(client, auth);
5872/// // As the method needs a request, you would usually fill it with the desired information
5873/// // into the respective structure. Some of the parts shown here might not be applicable !
5874/// // Values shown here are possibly random and not representative !
5875/// let mut req = SetIamPolicyRequest::default();
5876///
5877/// // You can configure optional parameters by calling the respective setters at will, and
5878/// // execute the final call using `doit()`.
5879/// // Values shown here are possibly random and not representative !
5880/// let result = hub.projects().locations_secrets_set_iam_policy(req, "resource")
5881///              .doit().await;
5882/// # }
5883/// ```
5884pub struct ProjectLocationSecretSetIamPolicyCall<'a, C>
5885where
5886    C: 'a,
5887{
5888    hub: &'a SecretManager<C>,
5889    _request: SetIamPolicyRequest,
5890    _resource: String,
5891    _delegate: Option<&'a mut dyn common::Delegate>,
5892    _additional_params: HashMap<String, String>,
5893    _scopes: BTreeSet<String>,
5894}
5895
5896impl<'a, C> common::CallBuilder for ProjectLocationSecretSetIamPolicyCall<'a, C> {}
5897
5898impl<'a, C> ProjectLocationSecretSetIamPolicyCall<'a, C>
5899where
5900    C: common::Connector,
5901{
5902    /// Perform the operation you have build so far.
5903    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5904        use std::borrow::Cow;
5905        use std::io::{Read, Seek};
5906
5907        use common::{url::Params, ToParts};
5908        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5909
5910        let mut dd = common::DefaultDelegate;
5911        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5912        dlg.begin(common::MethodInfo {
5913            id: "secretmanager.projects.locations.secrets.setIamPolicy",
5914            http_method: hyper::Method::POST,
5915        });
5916
5917        for &field in ["alt", "resource"].iter() {
5918            if self._additional_params.contains_key(field) {
5919                dlg.finished(false);
5920                return Err(common::Error::FieldClash(field));
5921            }
5922        }
5923
5924        let mut params = Params::with_capacity(4 + self._additional_params.len());
5925        params.push("resource", self._resource);
5926
5927        params.extend(self._additional_params.iter());
5928
5929        params.push("alt", "json");
5930        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5931        if self._scopes.is_empty() {
5932            self._scopes
5933                .insert(Scope::CloudPlatform.as_ref().to_string());
5934        }
5935
5936        #[allow(clippy::single_element_loop)]
5937        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5938            url = params.uri_replacement(url, param_name, find_this, true);
5939        }
5940        {
5941            let to_remove = ["resource"];
5942            params.remove_params(&to_remove);
5943        }
5944
5945        let url = params.parse_with_url(&url);
5946
5947        let mut json_mime_type = mime::APPLICATION_JSON;
5948        let mut request_value_reader = {
5949            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5950            common::remove_json_null_values(&mut value);
5951            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5952            serde_json::to_writer(&mut dst, &value).unwrap();
5953            dst
5954        };
5955        let request_size = request_value_reader
5956            .seek(std::io::SeekFrom::End(0))
5957            .unwrap();
5958        request_value_reader
5959            .seek(std::io::SeekFrom::Start(0))
5960            .unwrap();
5961
5962        loop {
5963            let token = match self
5964                .hub
5965                .auth
5966                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5967                .await
5968            {
5969                Ok(token) => token,
5970                Err(e) => match dlg.token(e) {
5971                    Ok(token) => token,
5972                    Err(e) => {
5973                        dlg.finished(false);
5974                        return Err(common::Error::MissingToken(e));
5975                    }
5976                },
5977            };
5978            request_value_reader
5979                .seek(std::io::SeekFrom::Start(0))
5980                .unwrap();
5981            let mut req_result = {
5982                let client = &self.hub.client;
5983                dlg.pre_request();
5984                let mut req_builder = hyper::Request::builder()
5985                    .method(hyper::Method::POST)
5986                    .uri(url.as_str())
5987                    .header(USER_AGENT, self.hub._user_agent.clone());
5988
5989                if let Some(token) = token.as_ref() {
5990                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5991                }
5992
5993                let request = req_builder
5994                    .header(CONTENT_TYPE, json_mime_type.to_string())
5995                    .header(CONTENT_LENGTH, request_size as u64)
5996                    .body(common::to_body(
5997                        request_value_reader.get_ref().clone().into(),
5998                    ));
5999
6000                client.request(request.unwrap()).await
6001            };
6002
6003            match req_result {
6004                Err(err) => {
6005                    if let common::Retry::After(d) = dlg.http_error(&err) {
6006                        sleep(d).await;
6007                        continue;
6008                    }
6009                    dlg.finished(false);
6010                    return Err(common::Error::HttpError(err));
6011                }
6012                Ok(res) => {
6013                    let (mut parts, body) = res.into_parts();
6014                    let mut body = common::Body::new(body);
6015                    if !parts.status.is_success() {
6016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6017                        let error = serde_json::from_str(&common::to_string(&bytes));
6018                        let response = common::to_response(parts, bytes.into());
6019
6020                        if let common::Retry::After(d) =
6021                            dlg.http_failure(&response, error.as_ref().ok())
6022                        {
6023                            sleep(d).await;
6024                            continue;
6025                        }
6026
6027                        dlg.finished(false);
6028
6029                        return Err(match error {
6030                            Ok(value) => common::Error::BadRequest(value),
6031                            _ => common::Error::Failure(response),
6032                        });
6033                    }
6034                    let response = {
6035                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6036                        let encoded = common::to_string(&bytes);
6037                        match serde_json::from_str(&encoded) {
6038                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6039                            Err(error) => {
6040                                dlg.response_json_decode_error(&encoded, &error);
6041                                return Err(common::Error::JsonDecodeError(
6042                                    encoded.to_string(),
6043                                    error,
6044                                ));
6045                            }
6046                        }
6047                    };
6048
6049                    dlg.finished(true);
6050                    return Ok(response);
6051                }
6052            }
6053        }
6054    }
6055
6056    ///
6057    /// Sets the *request* property to the given value.
6058    ///
6059    /// Even though the property as already been set when instantiating this call,
6060    /// we provide this method for API completeness.
6061    pub fn request(
6062        mut self,
6063        new_value: SetIamPolicyRequest,
6064    ) -> ProjectLocationSecretSetIamPolicyCall<'a, C> {
6065        self._request = new_value;
6066        self
6067    }
6068    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6069    ///
6070    /// Sets the *resource* path property to the given value.
6071    ///
6072    /// Even though the property as already been set when instantiating this call,
6073    /// we provide this method for API completeness.
6074    pub fn resource(mut self, new_value: &str) -> ProjectLocationSecretSetIamPolicyCall<'a, C> {
6075        self._resource = new_value.to_string();
6076        self
6077    }
6078    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6079    /// while executing the actual API request.
6080    ///
6081    /// ````text
6082    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6083    /// ````
6084    ///
6085    /// Sets the *delegate* property to the given value.
6086    pub fn delegate(
6087        mut self,
6088        new_value: &'a mut dyn common::Delegate,
6089    ) -> ProjectLocationSecretSetIamPolicyCall<'a, C> {
6090        self._delegate = Some(new_value);
6091        self
6092    }
6093
6094    /// Set any additional parameter of the query string used in the request.
6095    /// It should be used to set parameters which are not yet available through their own
6096    /// setters.
6097    ///
6098    /// Please note that this method must not be used to set any of the known parameters
6099    /// which have their own setter method. If done anyway, the request will fail.
6100    ///
6101    /// # Additional Parameters
6102    ///
6103    /// * *$.xgafv* (query-string) - V1 error format.
6104    /// * *access_token* (query-string) - OAuth access token.
6105    /// * *alt* (query-string) - Data format for response.
6106    /// * *callback* (query-string) - JSONP
6107    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6108    /// * *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.
6109    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6110    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6111    /// * *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.
6112    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6113    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6114    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSecretSetIamPolicyCall<'a, C>
6115    where
6116        T: AsRef<str>,
6117    {
6118        self._additional_params
6119            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6120        self
6121    }
6122
6123    /// Identifies the authorization scope for the method you are building.
6124    ///
6125    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6126    /// [`Scope::CloudPlatform`].
6127    ///
6128    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6129    /// tokens for more than one scope.
6130    ///
6131    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6132    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6133    /// sufficient, a read-write scope will do as well.
6134    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretSetIamPolicyCall<'a, C>
6135    where
6136        St: AsRef<str>,
6137    {
6138        self._scopes.insert(String::from(scope.as_ref()));
6139        self
6140    }
6141    /// Identifies the authorization scope(s) for the method you are building.
6142    ///
6143    /// See [`Self::add_scope()`] for details.
6144    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSecretSetIamPolicyCall<'a, C>
6145    where
6146        I: IntoIterator<Item = St>,
6147        St: AsRef<str>,
6148    {
6149        self._scopes
6150            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6151        self
6152    }
6153
6154    /// Removes all scopes, and no default scope will be used either.
6155    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6156    /// for details).
6157    pub fn clear_scopes(mut self) -> ProjectLocationSecretSetIamPolicyCall<'a, C> {
6158        self._scopes.clear();
6159        self
6160    }
6161}
6162
6163/// Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
6164///
6165/// A builder for the *locations.secrets.testIamPermissions* method supported by a *project* resource.
6166/// It is not used directly, but through a [`ProjectMethods`] instance.
6167///
6168/// # Example
6169///
6170/// Instantiate a resource method builder
6171///
6172/// ```test_harness,no_run
6173/// # extern crate hyper;
6174/// # extern crate hyper_rustls;
6175/// # extern crate google_secretmanager1 as secretmanager1;
6176/// use secretmanager1::api::TestIamPermissionsRequest;
6177/// # async fn dox() {
6178/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6179///
6180/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6181/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6182/// #     .with_native_roots()
6183/// #     .unwrap()
6184/// #     .https_only()
6185/// #     .enable_http2()
6186/// #     .build();
6187///
6188/// # let executor = hyper_util::rt::TokioExecutor::new();
6189/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6190/// #     secret,
6191/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6192/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6193/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6194/// #     ),
6195/// # ).build().await.unwrap();
6196///
6197/// # let client = hyper_util::client::legacy::Client::builder(
6198/// #     hyper_util::rt::TokioExecutor::new()
6199/// # )
6200/// # .build(
6201/// #     hyper_rustls::HttpsConnectorBuilder::new()
6202/// #         .with_native_roots()
6203/// #         .unwrap()
6204/// #         .https_or_http()
6205/// #         .enable_http2()
6206/// #         .build()
6207/// # );
6208/// # let mut hub = SecretManager::new(client, auth);
6209/// // As the method needs a request, you would usually fill it with the desired information
6210/// // into the respective structure. Some of the parts shown here might not be applicable !
6211/// // Values shown here are possibly random and not representative !
6212/// let mut req = TestIamPermissionsRequest::default();
6213///
6214/// // You can configure optional parameters by calling the respective setters at will, and
6215/// // execute the final call using `doit()`.
6216/// // Values shown here are possibly random and not representative !
6217/// let result = hub.projects().locations_secrets_test_iam_permissions(req, "resource")
6218///              .doit().await;
6219/// # }
6220/// ```
6221pub struct ProjectLocationSecretTestIamPermissionCall<'a, C>
6222where
6223    C: 'a,
6224{
6225    hub: &'a SecretManager<C>,
6226    _request: TestIamPermissionsRequest,
6227    _resource: String,
6228    _delegate: Option<&'a mut dyn common::Delegate>,
6229    _additional_params: HashMap<String, String>,
6230    _scopes: BTreeSet<String>,
6231}
6232
6233impl<'a, C> common::CallBuilder for ProjectLocationSecretTestIamPermissionCall<'a, C> {}
6234
6235impl<'a, C> ProjectLocationSecretTestIamPermissionCall<'a, C>
6236where
6237    C: common::Connector,
6238{
6239    /// Perform the operation you have build so far.
6240    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
6241        use std::borrow::Cow;
6242        use std::io::{Read, Seek};
6243
6244        use common::{url::Params, ToParts};
6245        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6246
6247        let mut dd = common::DefaultDelegate;
6248        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6249        dlg.begin(common::MethodInfo {
6250            id: "secretmanager.projects.locations.secrets.testIamPermissions",
6251            http_method: hyper::Method::POST,
6252        });
6253
6254        for &field in ["alt", "resource"].iter() {
6255            if self._additional_params.contains_key(field) {
6256                dlg.finished(false);
6257                return Err(common::Error::FieldClash(field));
6258            }
6259        }
6260
6261        let mut params = Params::with_capacity(4 + self._additional_params.len());
6262        params.push("resource", self._resource);
6263
6264        params.extend(self._additional_params.iter());
6265
6266        params.push("alt", "json");
6267        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
6268        if self._scopes.is_empty() {
6269            self._scopes
6270                .insert(Scope::CloudPlatform.as_ref().to_string());
6271        }
6272
6273        #[allow(clippy::single_element_loop)]
6274        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6275            url = params.uri_replacement(url, param_name, find_this, true);
6276        }
6277        {
6278            let to_remove = ["resource"];
6279            params.remove_params(&to_remove);
6280        }
6281
6282        let url = params.parse_with_url(&url);
6283
6284        let mut json_mime_type = mime::APPLICATION_JSON;
6285        let mut request_value_reader = {
6286            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6287            common::remove_json_null_values(&mut value);
6288            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6289            serde_json::to_writer(&mut dst, &value).unwrap();
6290            dst
6291        };
6292        let request_size = request_value_reader
6293            .seek(std::io::SeekFrom::End(0))
6294            .unwrap();
6295        request_value_reader
6296            .seek(std::io::SeekFrom::Start(0))
6297            .unwrap();
6298
6299        loop {
6300            let token = match self
6301                .hub
6302                .auth
6303                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6304                .await
6305            {
6306                Ok(token) => token,
6307                Err(e) => match dlg.token(e) {
6308                    Ok(token) => token,
6309                    Err(e) => {
6310                        dlg.finished(false);
6311                        return Err(common::Error::MissingToken(e));
6312                    }
6313                },
6314            };
6315            request_value_reader
6316                .seek(std::io::SeekFrom::Start(0))
6317                .unwrap();
6318            let mut req_result = {
6319                let client = &self.hub.client;
6320                dlg.pre_request();
6321                let mut req_builder = hyper::Request::builder()
6322                    .method(hyper::Method::POST)
6323                    .uri(url.as_str())
6324                    .header(USER_AGENT, self.hub._user_agent.clone());
6325
6326                if let Some(token) = token.as_ref() {
6327                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6328                }
6329
6330                let request = req_builder
6331                    .header(CONTENT_TYPE, json_mime_type.to_string())
6332                    .header(CONTENT_LENGTH, request_size as u64)
6333                    .body(common::to_body(
6334                        request_value_reader.get_ref().clone().into(),
6335                    ));
6336
6337                client.request(request.unwrap()).await
6338            };
6339
6340            match req_result {
6341                Err(err) => {
6342                    if let common::Retry::After(d) = dlg.http_error(&err) {
6343                        sleep(d).await;
6344                        continue;
6345                    }
6346                    dlg.finished(false);
6347                    return Err(common::Error::HttpError(err));
6348                }
6349                Ok(res) => {
6350                    let (mut parts, body) = res.into_parts();
6351                    let mut body = common::Body::new(body);
6352                    if !parts.status.is_success() {
6353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6354                        let error = serde_json::from_str(&common::to_string(&bytes));
6355                        let response = common::to_response(parts, bytes.into());
6356
6357                        if let common::Retry::After(d) =
6358                            dlg.http_failure(&response, error.as_ref().ok())
6359                        {
6360                            sleep(d).await;
6361                            continue;
6362                        }
6363
6364                        dlg.finished(false);
6365
6366                        return Err(match error {
6367                            Ok(value) => common::Error::BadRequest(value),
6368                            _ => common::Error::Failure(response),
6369                        });
6370                    }
6371                    let response = {
6372                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6373                        let encoded = common::to_string(&bytes);
6374                        match serde_json::from_str(&encoded) {
6375                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6376                            Err(error) => {
6377                                dlg.response_json_decode_error(&encoded, &error);
6378                                return Err(common::Error::JsonDecodeError(
6379                                    encoded.to_string(),
6380                                    error,
6381                                ));
6382                            }
6383                        }
6384                    };
6385
6386                    dlg.finished(true);
6387                    return Ok(response);
6388                }
6389            }
6390        }
6391    }
6392
6393    ///
6394    /// Sets the *request* property to the given value.
6395    ///
6396    /// Even though the property as already been set when instantiating this call,
6397    /// we provide this method for API completeness.
6398    pub fn request(
6399        mut self,
6400        new_value: TestIamPermissionsRequest,
6401    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C> {
6402        self._request = new_value;
6403        self
6404    }
6405    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6406    ///
6407    /// Sets the *resource* path property to the given value.
6408    ///
6409    /// Even though the property as already been set when instantiating this call,
6410    /// we provide this method for API completeness.
6411    pub fn resource(
6412        mut self,
6413        new_value: &str,
6414    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C> {
6415        self._resource = new_value.to_string();
6416        self
6417    }
6418    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6419    /// while executing the actual API request.
6420    ///
6421    /// ````text
6422    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6423    /// ````
6424    ///
6425    /// Sets the *delegate* property to the given value.
6426    pub fn delegate(
6427        mut self,
6428        new_value: &'a mut dyn common::Delegate,
6429    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C> {
6430        self._delegate = Some(new_value);
6431        self
6432    }
6433
6434    /// Set any additional parameter of the query string used in the request.
6435    /// It should be used to set parameters which are not yet available through their own
6436    /// setters.
6437    ///
6438    /// Please note that this method must not be used to set any of the known parameters
6439    /// which have their own setter method. If done anyway, the request will fail.
6440    ///
6441    /// # Additional Parameters
6442    ///
6443    /// * *$.xgafv* (query-string) - V1 error format.
6444    /// * *access_token* (query-string) - OAuth access token.
6445    /// * *alt* (query-string) - Data format for response.
6446    /// * *callback* (query-string) - JSONP
6447    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6448    /// * *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.
6449    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6450    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6451    /// * *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.
6452    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6453    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6454    pub fn param<T>(
6455        mut self,
6456        name: T,
6457        value: T,
6458    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C>
6459    where
6460        T: AsRef<str>,
6461    {
6462        self._additional_params
6463            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6464        self
6465    }
6466
6467    /// Identifies the authorization scope for the method you are building.
6468    ///
6469    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6470    /// [`Scope::CloudPlatform`].
6471    ///
6472    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6473    /// tokens for more than one scope.
6474    ///
6475    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6476    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6477    /// sufficient, a read-write scope will do as well.
6478    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSecretTestIamPermissionCall<'a, C>
6479    where
6480        St: AsRef<str>,
6481    {
6482        self._scopes.insert(String::from(scope.as_ref()));
6483        self
6484    }
6485    /// Identifies the authorization scope(s) for the method you are building.
6486    ///
6487    /// See [`Self::add_scope()`] for details.
6488    pub fn add_scopes<I, St>(
6489        mut self,
6490        scopes: I,
6491    ) -> ProjectLocationSecretTestIamPermissionCall<'a, C>
6492    where
6493        I: IntoIterator<Item = St>,
6494        St: AsRef<str>,
6495    {
6496        self._scopes
6497            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6498        self
6499    }
6500
6501    /// Removes all scopes, and no default scope will be used either.
6502    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6503    /// for details).
6504    pub fn clear_scopes(mut self) -> ProjectLocationSecretTestIamPermissionCall<'a, C> {
6505        self._scopes.clear();
6506        self
6507    }
6508}
6509
6510/// Gets information about a location.
6511///
6512/// A builder for the *locations.get* method supported by a *project* resource.
6513/// It is not used directly, but through a [`ProjectMethods`] instance.
6514///
6515/// # Example
6516///
6517/// Instantiate a resource method builder
6518///
6519/// ```test_harness,no_run
6520/// # extern crate hyper;
6521/// # extern crate hyper_rustls;
6522/// # extern crate google_secretmanager1 as secretmanager1;
6523/// # async fn dox() {
6524/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6525///
6526/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6527/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6528/// #     .with_native_roots()
6529/// #     .unwrap()
6530/// #     .https_only()
6531/// #     .enable_http2()
6532/// #     .build();
6533///
6534/// # let executor = hyper_util::rt::TokioExecutor::new();
6535/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6536/// #     secret,
6537/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6538/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6539/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6540/// #     ),
6541/// # ).build().await.unwrap();
6542///
6543/// # let client = hyper_util::client::legacy::Client::builder(
6544/// #     hyper_util::rt::TokioExecutor::new()
6545/// # )
6546/// # .build(
6547/// #     hyper_rustls::HttpsConnectorBuilder::new()
6548/// #         .with_native_roots()
6549/// #         .unwrap()
6550/// #         .https_or_http()
6551/// #         .enable_http2()
6552/// #         .build()
6553/// # );
6554/// # let mut hub = SecretManager::new(client, auth);
6555/// // You can configure optional parameters by calling the respective setters at will, and
6556/// // execute the final call using `doit()`.
6557/// // Values shown here are possibly random and not representative !
6558/// let result = hub.projects().locations_get("name")
6559///              .doit().await;
6560/// # }
6561/// ```
6562pub struct ProjectLocationGetCall<'a, C>
6563where
6564    C: 'a,
6565{
6566    hub: &'a SecretManager<C>,
6567    _name: String,
6568    _delegate: Option<&'a mut dyn common::Delegate>,
6569    _additional_params: HashMap<String, String>,
6570    _scopes: BTreeSet<String>,
6571}
6572
6573impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
6574
6575impl<'a, C> ProjectLocationGetCall<'a, C>
6576where
6577    C: common::Connector,
6578{
6579    /// Perform the operation you have build so far.
6580    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
6581        use std::borrow::Cow;
6582        use std::io::{Read, Seek};
6583
6584        use common::{url::Params, ToParts};
6585        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6586
6587        let mut dd = common::DefaultDelegate;
6588        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6589        dlg.begin(common::MethodInfo {
6590            id: "secretmanager.projects.locations.get",
6591            http_method: hyper::Method::GET,
6592        });
6593
6594        for &field in ["alt", "name"].iter() {
6595            if self._additional_params.contains_key(field) {
6596                dlg.finished(false);
6597                return Err(common::Error::FieldClash(field));
6598            }
6599        }
6600
6601        let mut params = Params::with_capacity(3 + self._additional_params.len());
6602        params.push("name", self._name);
6603
6604        params.extend(self._additional_params.iter());
6605
6606        params.push("alt", "json");
6607        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6608        if self._scopes.is_empty() {
6609            self._scopes
6610                .insert(Scope::CloudPlatform.as_ref().to_string());
6611        }
6612
6613        #[allow(clippy::single_element_loop)]
6614        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6615            url = params.uri_replacement(url, param_name, find_this, true);
6616        }
6617        {
6618            let to_remove = ["name"];
6619            params.remove_params(&to_remove);
6620        }
6621
6622        let url = params.parse_with_url(&url);
6623
6624        loop {
6625            let token = match self
6626                .hub
6627                .auth
6628                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6629                .await
6630            {
6631                Ok(token) => token,
6632                Err(e) => match dlg.token(e) {
6633                    Ok(token) => token,
6634                    Err(e) => {
6635                        dlg.finished(false);
6636                        return Err(common::Error::MissingToken(e));
6637                    }
6638                },
6639            };
6640            let mut req_result = {
6641                let client = &self.hub.client;
6642                dlg.pre_request();
6643                let mut req_builder = hyper::Request::builder()
6644                    .method(hyper::Method::GET)
6645                    .uri(url.as_str())
6646                    .header(USER_AGENT, self.hub._user_agent.clone());
6647
6648                if let Some(token) = token.as_ref() {
6649                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6650                }
6651
6652                let request = req_builder
6653                    .header(CONTENT_LENGTH, 0_u64)
6654                    .body(common::to_body::<String>(None));
6655
6656                client.request(request.unwrap()).await
6657            };
6658
6659            match req_result {
6660                Err(err) => {
6661                    if let common::Retry::After(d) = dlg.http_error(&err) {
6662                        sleep(d).await;
6663                        continue;
6664                    }
6665                    dlg.finished(false);
6666                    return Err(common::Error::HttpError(err));
6667                }
6668                Ok(res) => {
6669                    let (mut parts, body) = res.into_parts();
6670                    let mut body = common::Body::new(body);
6671                    if !parts.status.is_success() {
6672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6673                        let error = serde_json::from_str(&common::to_string(&bytes));
6674                        let response = common::to_response(parts, bytes.into());
6675
6676                        if let common::Retry::After(d) =
6677                            dlg.http_failure(&response, error.as_ref().ok())
6678                        {
6679                            sleep(d).await;
6680                            continue;
6681                        }
6682
6683                        dlg.finished(false);
6684
6685                        return Err(match error {
6686                            Ok(value) => common::Error::BadRequest(value),
6687                            _ => common::Error::Failure(response),
6688                        });
6689                    }
6690                    let response = {
6691                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6692                        let encoded = common::to_string(&bytes);
6693                        match serde_json::from_str(&encoded) {
6694                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6695                            Err(error) => {
6696                                dlg.response_json_decode_error(&encoded, &error);
6697                                return Err(common::Error::JsonDecodeError(
6698                                    encoded.to_string(),
6699                                    error,
6700                                ));
6701                            }
6702                        }
6703                    };
6704
6705                    dlg.finished(true);
6706                    return Ok(response);
6707                }
6708            }
6709        }
6710    }
6711
6712    /// Resource name for the location.
6713    ///
6714    /// Sets the *name* path property to the given value.
6715    ///
6716    /// Even though the property as already been set when instantiating this call,
6717    /// we provide this method for API completeness.
6718    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
6719        self._name = new_value.to_string();
6720        self
6721    }
6722    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6723    /// while executing the actual API request.
6724    ///
6725    /// ````text
6726    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6727    /// ````
6728    ///
6729    /// Sets the *delegate* property to the given value.
6730    pub fn delegate(
6731        mut self,
6732        new_value: &'a mut dyn common::Delegate,
6733    ) -> ProjectLocationGetCall<'a, C> {
6734        self._delegate = Some(new_value);
6735        self
6736    }
6737
6738    /// Set any additional parameter of the query string used in the request.
6739    /// It should be used to set parameters which are not yet available through their own
6740    /// setters.
6741    ///
6742    /// Please note that this method must not be used to set any of the known parameters
6743    /// which have their own setter method. If done anyway, the request will fail.
6744    ///
6745    /// # Additional Parameters
6746    ///
6747    /// * *$.xgafv* (query-string) - V1 error format.
6748    /// * *access_token* (query-string) - OAuth access token.
6749    /// * *alt* (query-string) - Data format for response.
6750    /// * *callback* (query-string) - JSONP
6751    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6752    /// * *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.
6753    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6754    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6755    /// * *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.
6756    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6757    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6758    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
6759    where
6760        T: AsRef<str>,
6761    {
6762        self._additional_params
6763            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6764        self
6765    }
6766
6767    /// Identifies the authorization scope for the method you are building.
6768    ///
6769    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6770    /// [`Scope::CloudPlatform`].
6771    ///
6772    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6773    /// tokens for more than one scope.
6774    ///
6775    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6776    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6777    /// sufficient, a read-write scope will do as well.
6778    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
6779    where
6780        St: AsRef<str>,
6781    {
6782        self._scopes.insert(String::from(scope.as_ref()));
6783        self
6784    }
6785    /// Identifies the authorization scope(s) for the method you are building.
6786    ///
6787    /// See [`Self::add_scope()`] for details.
6788    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
6789    where
6790        I: IntoIterator<Item = St>,
6791        St: AsRef<str>,
6792    {
6793        self._scopes
6794            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6795        self
6796    }
6797
6798    /// Removes all scopes, and no default scope will be used either.
6799    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6800    /// for details).
6801    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
6802        self._scopes.clear();
6803        self
6804    }
6805}
6806
6807/// Lists information about the supported locations for this service.
6808///
6809/// A builder for the *locations.list* method supported by a *project* resource.
6810/// It is not used directly, but through a [`ProjectMethods`] instance.
6811///
6812/// # Example
6813///
6814/// Instantiate a resource method builder
6815///
6816/// ```test_harness,no_run
6817/// # extern crate hyper;
6818/// # extern crate hyper_rustls;
6819/// # extern crate google_secretmanager1 as secretmanager1;
6820/// # async fn dox() {
6821/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6822///
6823/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6824/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6825/// #     .with_native_roots()
6826/// #     .unwrap()
6827/// #     .https_only()
6828/// #     .enable_http2()
6829/// #     .build();
6830///
6831/// # let executor = hyper_util::rt::TokioExecutor::new();
6832/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6833/// #     secret,
6834/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6835/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6836/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6837/// #     ),
6838/// # ).build().await.unwrap();
6839///
6840/// # let client = hyper_util::client::legacy::Client::builder(
6841/// #     hyper_util::rt::TokioExecutor::new()
6842/// # )
6843/// # .build(
6844/// #     hyper_rustls::HttpsConnectorBuilder::new()
6845/// #         .with_native_roots()
6846/// #         .unwrap()
6847/// #         .https_or_http()
6848/// #         .enable_http2()
6849/// #         .build()
6850/// # );
6851/// # let mut hub = SecretManager::new(client, auth);
6852/// // You can configure optional parameters by calling the respective setters at will, and
6853/// // execute the final call using `doit()`.
6854/// // Values shown here are possibly random and not representative !
6855/// let result = hub.projects().locations_list("name")
6856///              .page_token("ipsum")
6857///              .page_size(-50)
6858///              .filter("est")
6859///              .add_extra_location_types("gubergren")
6860///              .doit().await;
6861/// # }
6862/// ```
6863pub struct ProjectLocationListCall<'a, C>
6864where
6865    C: 'a,
6866{
6867    hub: &'a SecretManager<C>,
6868    _name: String,
6869    _page_token: Option<String>,
6870    _page_size: Option<i32>,
6871    _filter: Option<String>,
6872    _extra_location_types: Vec<String>,
6873    _delegate: Option<&'a mut dyn common::Delegate>,
6874    _additional_params: HashMap<String, String>,
6875    _scopes: BTreeSet<String>,
6876}
6877
6878impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
6879
6880impl<'a, C> ProjectLocationListCall<'a, C>
6881where
6882    C: common::Connector,
6883{
6884    /// Perform the operation you have build so far.
6885    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
6886        use std::borrow::Cow;
6887        use std::io::{Read, Seek};
6888
6889        use common::{url::Params, ToParts};
6890        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6891
6892        let mut dd = common::DefaultDelegate;
6893        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6894        dlg.begin(common::MethodInfo {
6895            id: "secretmanager.projects.locations.list",
6896            http_method: hyper::Method::GET,
6897        });
6898
6899        for &field in [
6900            "alt",
6901            "name",
6902            "pageToken",
6903            "pageSize",
6904            "filter",
6905            "extraLocationTypes",
6906        ]
6907        .iter()
6908        {
6909            if self._additional_params.contains_key(field) {
6910                dlg.finished(false);
6911                return Err(common::Error::FieldClash(field));
6912            }
6913        }
6914
6915        let mut params = Params::with_capacity(7 + self._additional_params.len());
6916        params.push("name", self._name);
6917        if let Some(value) = self._page_token.as_ref() {
6918            params.push("pageToken", value);
6919        }
6920        if let Some(value) = self._page_size.as_ref() {
6921            params.push("pageSize", value.to_string());
6922        }
6923        if let Some(value) = self._filter.as_ref() {
6924            params.push("filter", value);
6925        }
6926        if !self._extra_location_types.is_empty() {
6927            for f in self._extra_location_types.iter() {
6928                params.push("extraLocationTypes", f);
6929            }
6930        }
6931
6932        params.extend(self._additional_params.iter());
6933
6934        params.push("alt", "json");
6935        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
6936        if self._scopes.is_empty() {
6937            self._scopes
6938                .insert(Scope::CloudPlatform.as_ref().to_string());
6939        }
6940
6941        #[allow(clippy::single_element_loop)]
6942        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6943            url = params.uri_replacement(url, param_name, find_this, true);
6944        }
6945        {
6946            let to_remove = ["name"];
6947            params.remove_params(&to_remove);
6948        }
6949
6950        let url = params.parse_with_url(&url);
6951
6952        loop {
6953            let token = match self
6954                .hub
6955                .auth
6956                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6957                .await
6958            {
6959                Ok(token) => token,
6960                Err(e) => match dlg.token(e) {
6961                    Ok(token) => token,
6962                    Err(e) => {
6963                        dlg.finished(false);
6964                        return Err(common::Error::MissingToken(e));
6965                    }
6966                },
6967            };
6968            let mut req_result = {
6969                let client = &self.hub.client;
6970                dlg.pre_request();
6971                let mut req_builder = hyper::Request::builder()
6972                    .method(hyper::Method::GET)
6973                    .uri(url.as_str())
6974                    .header(USER_AGENT, self.hub._user_agent.clone());
6975
6976                if let Some(token) = token.as_ref() {
6977                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6978                }
6979
6980                let request = req_builder
6981                    .header(CONTENT_LENGTH, 0_u64)
6982                    .body(common::to_body::<String>(None));
6983
6984                client.request(request.unwrap()).await
6985            };
6986
6987            match req_result {
6988                Err(err) => {
6989                    if let common::Retry::After(d) = dlg.http_error(&err) {
6990                        sleep(d).await;
6991                        continue;
6992                    }
6993                    dlg.finished(false);
6994                    return Err(common::Error::HttpError(err));
6995                }
6996                Ok(res) => {
6997                    let (mut parts, body) = res.into_parts();
6998                    let mut body = common::Body::new(body);
6999                    if !parts.status.is_success() {
7000                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7001                        let error = serde_json::from_str(&common::to_string(&bytes));
7002                        let response = common::to_response(parts, bytes.into());
7003
7004                        if let common::Retry::After(d) =
7005                            dlg.http_failure(&response, error.as_ref().ok())
7006                        {
7007                            sleep(d).await;
7008                            continue;
7009                        }
7010
7011                        dlg.finished(false);
7012
7013                        return Err(match error {
7014                            Ok(value) => common::Error::BadRequest(value),
7015                            _ => common::Error::Failure(response),
7016                        });
7017                    }
7018                    let response = {
7019                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7020                        let encoded = common::to_string(&bytes);
7021                        match serde_json::from_str(&encoded) {
7022                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7023                            Err(error) => {
7024                                dlg.response_json_decode_error(&encoded, &error);
7025                                return Err(common::Error::JsonDecodeError(
7026                                    encoded.to_string(),
7027                                    error,
7028                                ));
7029                            }
7030                        }
7031                    };
7032
7033                    dlg.finished(true);
7034                    return Ok(response);
7035                }
7036            }
7037        }
7038    }
7039
7040    /// The resource that owns the locations collection, if applicable.
7041    ///
7042    /// Sets the *name* path property to the given value.
7043    ///
7044    /// Even though the property as already been set when instantiating this call,
7045    /// we provide this method for API completeness.
7046    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7047        self._name = new_value.to_string();
7048        self
7049    }
7050    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
7051    ///
7052    /// Sets the *page token* query property to the given value.
7053    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7054        self._page_token = Some(new_value.to_string());
7055        self
7056    }
7057    /// The maximum number of results to return. If not set, the service selects a default.
7058    ///
7059    /// Sets the *page size* query property to the given value.
7060    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
7061        self._page_size = Some(new_value);
7062        self
7063    }
7064    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
7065    ///
7066    /// Sets the *filter* query property to the given value.
7067    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7068        self._filter = Some(new_value.to_string());
7069        self
7070    }
7071    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
7072    ///
7073    /// Append the given value to the *extra location types* query property.
7074    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7075    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
7076        self._extra_location_types.push(new_value.to_string());
7077        self
7078    }
7079    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7080    /// while executing the actual API request.
7081    ///
7082    /// ````text
7083    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7084    /// ````
7085    ///
7086    /// Sets the *delegate* property to the given value.
7087    pub fn delegate(
7088        mut self,
7089        new_value: &'a mut dyn common::Delegate,
7090    ) -> ProjectLocationListCall<'a, C> {
7091        self._delegate = Some(new_value);
7092        self
7093    }
7094
7095    /// Set any additional parameter of the query string used in the request.
7096    /// It should be used to set parameters which are not yet available through their own
7097    /// setters.
7098    ///
7099    /// Please note that this method must not be used to set any of the known parameters
7100    /// which have their own setter method. If done anyway, the request will fail.
7101    ///
7102    /// # Additional Parameters
7103    ///
7104    /// * *$.xgafv* (query-string) - V1 error format.
7105    /// * *access_token* (query-string) - OAuth access token.
7106    /// * *alt* (query-string) - Data format for response.
7107    /// * *callback* (query-string) - JSONP
7108    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7109    /// * *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.
7110    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7111    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7112    /// * *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.
7113    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7114    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7115    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
7116    where
7117        T: AsRef<str>,
7118    {
7119        self._additional_params
7120            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7121        self
7122    }
7123
7124    /// Identifies the authorization scope for the method you are building.
7125    ///
7126    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7127    /// [`Scope::CloudPlatform`].
7128    ///
7129    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7130    /// tokens for more than one scope.
7131    ///
7132    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7133    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7134    /// sufficient, a read-write scope will do as well.
7135    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
7136    where
7137        St: AsRef<str>,
7138    {
7139        self._scopes.insert(String::from(scope.as_ref()));
7140        self
7141    }
7142    /// Identifies the authorization scope(s) for the method you are building.
7143    ///
7144    /// See [`Self::add_scope()`] for details.
7145    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
7146    where
7147        I: IntoIterator<Item = St>,
7148        St: AsRef<str>,
7149    {
7150        self._scopes
7151            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7152        self
7153    }
7154
7155    /// Removes all scopes, and no default scope will be used either.
7156    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7157    /// for details).
7158    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
7159        self._scopes.clear();
7160        self
7161    }
7162}
7163
7164/// Accesses a SecretVersion. This call returns the secret data. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
7165///
7166/// A builder for the *secrets.versions.access* method supported by a *project* resource.
7167/// It is not used directly, but through a [`ProjectMethods`] instance.
7168///
7169/// # Example
7170///
7171/// Instantiate a resource method builder
7172///
7173/// ```test_harness,no_run
7174/// # extern crate hyper;
7175/// # extern crate hyper_rustls;
7176/// # extern crate google_secretmanager1 as secretmanager1;
7177/// # async fn dox() {
7178/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7179///
7180/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7181/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7182/// #     .with_native_roots()
7183/// #     .unwrap()
7184/// #     .https_only()
7185/// #     .enable_http2()
7186/// #     .build();
7187///
7188/// # let executor = hyper_util::rt::TokioExecutor::new();
7189/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7190/// #     secret,
7191/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7192/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7193/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7194/// #     ),
7195/// # ).build().await.unwrap();
7196///
7197/// # let client = hyper_util::client::legacy::Client::builder(
7198/// #     hyper_util::rt::TokioExecutor::new()
7199/// # )
7200/// # .build(
7201/// #     hyper_rustls::HttpsConnectorBuilder::new()
7202/// #         .with_native_roots()
7203/// #         .unwrap()
7204/// #         .https_or_http()
7205/// #         .enable_http2()
7206/// #         .build()
7207/// # );
7208/// # let mut hub = SecretManager::new(client, auth);
7209/// // You can configure optional parameters by calling the respective setters at will, and
7210/// // execute the final call using `doit()`.
7211/// // Values shown here are possibly random and not representative !
7212/// let result = hub.projects().secrets_versions_access("name")
7213///              .doit().await;
7214/// # }
7215/// ```
7216pub struct ProjectSecretVersionAccesCall<'a, C>
7217where
7218    C: 'a,
7219{
7220    hub: &'a SecretManager<C>,
7221    _name: String,
7222    _delegate: Option<&'a mut dyn common::Delegate>,
7223    _additional_params: HashMap<String, String>,
7224    _scopes: BTreeSet<String>,
7225}
7226
7227impl<'a, C> common::CallBuilder for ProjectSecretVersionAccesCall<'a, C> {}
7228
7229impl<'a, C> ProjectSecretVersionAccesCall<'a, C>
7230where
7231    C: common::Connector,
7232{
7233    /// Perform the operation you have build so far.
7234    pub async fn doit(mut self) -> common::Result<(common::Response, AccessSecretVersionResponse)> {
7235        use std::borrow::Cow;
7236        use std::io::{Read, Seek};
7237
7238        use common::{url::Params, ToParts};
7239        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7240
7241        let mut dd = common::DefaultDelegate;
7242        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7243        dlg.begin(common::MethodInfo {
7244            id: "secretmanager.projects.secrets.versions.access",
7245            http_method: hyper::Method::GET,
7246        });
7247
7248        for &field in ["alt", "name"].iter() {
7249            if self._additional_params.contains_key(field) {
7250                dlg.finished(false);
7251                return Err(common::Error::FieldClash(field));
7252            }
7253        }
7254
7255        let mut params = Params::with_capacity(3 + self._additional_params.len());
7256        params.push("name", self._name);
7257
7258        params.extend(self._additional_params.iter());
7259
7260        params.push("alt", "json");
7261        let mut url = self.hub._base_url.clone() + "v1/{+name}:access";
7262        if self._scopes.is_empty() {
7263            self._scopes
7264                .insert(Scope::CloudPlatform.as_ref().to_string());
7265        }
7266
7267        #[allow(clippy::single_element_loop)]
7268        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7269            url = params.uri_replacement(url, param_name, find_this, true);
7270        }
7271        {
7272            let to_remove = ["name"];
7273            params.remove_params(&to_remove);
7274        }
7275
7276        let url = params.parse_with_url(&url);
7277
7278        loop {
7279            let token = match self
7280                .hub
7281                .auth
7282                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7283                .await
7284            {
7285                Ok(token) => token,
7286                Err(e) => match dlg.token(e) {
7287                    Ok(token) => token,
7288                    Err(e) => {
7289                        dlg.finished(false);
7290                        return Err(common::Error::MissingToken(e));
7291                    }
7292                },
7293            };
7294            let mut req_result = {
7295                let client = &self.hub.client;
7296                dlg.pre_request();
7297                let mut req_builder = hyper::Request::builder()
7298                    .method(hyper::Method::GET)
7299                    .uri(url.as_str())
7300                    .header(USER_AGENT, self.hub._user_agent.clone());
7301
7302                if let Some(token) = token.as_ref() {
7303                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7304                }
7305
7306                let request = req_builder
7307                    .header(CONTENT_LENGTH, 0_u64)
7308                    .body(common::to_body::<String>(None));
7309
7310                client.request(request.unwrap()).await
7311            };
7312
7313            match req_result {
7314                Err(err) => {
7315                    if let common::Retry::After(d) = dlg.http_error(&err) {
7316                        sleep(d).await;
7317                        continue;
7318                    }
7319                    dlg.finished(false);
7320                    return Err(common::Error::HttpError(err));
7321                }
7322                Ok(res) => {
7323                    let (mut parts, body) = res.into_parts();
7324                    let mut body = common::Body::new(body);
7325                    if !parts.status.is_success() {
7326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7327                        let error = serde_json::from_str(&common::to_string(&bytes));
7328                        let response = common::to_response(parts, bytes.into());
7329
7330                        if let common::Retry::After(d) =
7331                            dlg.http_failure(&response, error.as_ref().ok())
7332                        {
7333                            sleep(d).await;
7334                            continue;
7335                        }
7336
7337                        dlg.finished(false);
7338
7339                        return Err(match error {
7340                            Ok(value) => common::Error::BadRequest(value),
7341                            _ => common::Error::Failure(response),
7342                        });
7343                    }
7344                    let response = {
7345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7346                        let encoded = common::to_string(&bytes);
7347                        match serde_json::from_str(&encoded) {
7348                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7349                            Err(error) => {
7350                                dlg.response_json_decode_error(&encoded, &error);
7351                                return Err(common::Error::JsonDecodeError(
7352                                    encoded.to_string(),
7353                                    error,
7354                                ));
7355                            }
7356                        }
7357                    };
7358
7359                    dlg.finished(true);
7360                    return Ok(response);
7361                }
7362            }
7363        }
7364    }
7365
7366    /// Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
7367    ///
7368    /// Sets the *name* path property to the given value.
7369    ///
7370    /// Even though the property as already been set when instantiating this call,
7371    /// we provide this method for API completeness.
7372    pub fn name(mut self, new_value: &str) -> ProjectSecretVersionAccesCall<'a, C> {
7373        self._name = new_value.to_string();
7374        self
7375    }
7376    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7377    /// while executing the actual API request.
7378    ///
7379    /// ````text
7380    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7381    /// ````
7382    ///
7383    /// Sets the *delegate* property to the given value.
7384    pub fn delegate(
7385        mut self,
7386        new_value: &'a mut dyn common::Delegate,
7387    ) -> ProjectSecretVersionAccesCall<'a, C> {
7388        self._delegate = Some(new_value);
7389        self
7390    }
7391
7392    /// Set any additional parameter of the query string used in the request.
7393    /// It should be used to set parameters which are not yet available through their own
7394    /// setters.
7395    ///
7396    /// Please note that this method must not be used to set any of the known parameters
7397    /// which have their own setter method. If done anyway, the request will fail.
7398    ///
7399    /// # Additional Parameters
7400    ///
7401    /// * *$.xgafv* (query-string) - V1 error format.
7402    /// * *access_token* (query-string) - OAuth access token.
7403    /// * *alt* (query-string) - Data format for response.
7404    /// * *callback* (query-string) - JSONP
7405    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7406    /// * *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.
7407    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7408    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7409    /// * *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.
7410    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7411    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7412    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionAccesCall<'a, C>
7413    where
7414        T: AsRef<str>,
7415    {
7416        self._additional_params
7417            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7418        self
7419    }
7420
7421    /// Identifies the authorization scope for the method you are building.
7422    ///
7423    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7424    /// [`Scope::CloudPlatform`].
7425    ///
7426    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7427    /// tokens for more than one scope.
7428    ///
7429    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7430    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7431    /// sufficient, a read-write scope will do as well.
7432    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionAccesCall<'a, C>
7433    where
7434        St: AsRef<str>,
7435    {
7436        self._scopes.insert(String::from(scope.as_ref()));
7437        self
7438    }
7439    /// Identifies the authorization scope(s) for the method you are building.
7440    ///
7441    /// See [`Self::add_scope()`] for details.
7442    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionAccesCall<'a, C>
7443    where
7444        I: IntoIterator<Item = St>,
7445        St: AsRef<str>,
7446    {
7447        self._scopes
7448            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7449        self
7450    }
7451
7452    /// Removes all scopes, and no default scope will be used either.
7453    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7454    /// for details).
7455    pub fn clear_scopes(mut self) -> ProjectSecretVersionAccesCall<'a, C> {
7456        self._scopes.clear();
7457        self
7458    }
7459}
7460
7461/// Destroys a SecretVersion. Sets the state of the SecretVersion to DESTROYED and irrevocably destroys the secret data.
7462///
7463/// A builder for the *secrets.versions.destroy* method supported by a *project* resource.
7464/// It is not used directly, but through a [`ProjectMethods`] instance.
7465///
7466/// # Example
7467///
7468/// Instantiate a resource method builder
7469///
7470/// ```test_harness,no_run
7471/// # extern crate hyper;
7472/// # extern crate hyper_rustls;
7473/// # extern crate google_secretmanager1 as secretmanager1;
7474/// use secretmanager1::api::DestroySecretVersionRequest;
7475/// # async fn dox() {
7476/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7477///
7478/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7479/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7480/// #     .with_native_roots()
7481/// #     .unwrap()
7482/// #     .https_only()
7483/// #     .enable_http2()
7484/// #     .build();
7485///
7486/// # let executor = hyper_util::rt::TokioExecutor::new();
7487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7488/// #     secret,
7489/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7490/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7491/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7492/// #     ),
7493/// # ).build().await.unwrap();
7494///
7495/// # let client = hyper_util::client::legacy::Client::builder(
7496/// #     hyper_util::rt::TokioExecutor::new()
7497/// # )
7498/// # .build(
7499/// #     hyper_rustls::HttpsConnectorBuilder::new()
7500/// #         .with_native_roots()
7501/// #         .unwrap()
7502/// #         .https_or_http()
7503/// #         .enable_http2()
7504/// #         .build()
7505/// # );
7506/// # let mut hub = SecretManager::new(client, auth);
7507/// // As the method needs a request, you would usually fill it with the desired information
7508/// // into the respective structure. Some of the parts shown here might not be applicable !
7509/// // Values shown here are possibly random and not representative !
7510/// let mut req = DestroySecretVersionRequest::default();
7511///
7512/// // You can configure optional parameters by calling the respective setters at will, and
7513/// // execute the final call using `doit()`.
7514/// // Values shown here are possibly random and not representative !
7515/// let result = hub.projects().secrets_versions_destroy(req, "name")
7516///              .doit().await;
7517/// # }
7518/// ```
7519pub struct ProjectSecretVersionDestroyCall<'a, C>
7520where
7521    C: 'a,
7522{
7523    hub: &'a SecretManager<C>,
7524    _request: DestroySecretVersionRequest,
7525    _name: String,
7526    _delegate: Option<&'a mut dyn common::Delegate>,
7527    _additional_params: HashMap<String, String>,
7528    _scopes: BTreeSet<String>,
7529}
7530
7531impl<'a, C> common::CallBuilder for ProjectSecretVersionDestroyCall<'a, C> {}
7532
7533impl<'a, C> ProjectSecretVersionDestroyCall<'a, C>
7534where
7535    C: common::Connector,
7536{
7537    /// Perform the operation you have build so far.
7538    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
7539        use std::borrow::Cow;
7540        use std::io::{Read, Seek};
7541
7542        use common::{url::Params, ToParts};
7543        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7544
7545        let mut dd = common::DefaultDelegate;
7546        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7547        dlg.begin(common::MethodInfo {
7548            id: "secretmanager.projects.secrets.versions.destroy",
7549            http_method: hyper::Method::POST,
7550        });
7551
7552        for &field in ["alt", "name"].iter() {
7553            if self._additional_params.contains_key(field) {
7554                dlg.finished(false);
7555                return Err(common::Error::FieldClash(field));
7556            }
7557        }
7558
7559        let mut params = Params::with_capacity(4 + self._additional_params.len());
7560        params.push("name", self._name);
7561
7562        params.extend(self._additional_params.iter());
7563
7564        params.push("alt", "json");
7565        let mut url = self.hub._base_url.clone() + "v1/{+name}:destroy";
7566        if self._scopes.is_empty() {
7567            self._scopes
7568                .insert(Scope::CloudPlatform.as_ref().to_string());
7569        }
7570
7571        #[allow(clippy::single_element_loop)]
7572        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7573            url = params.uri_replacement(url, param_name, find_this, true);
7574        }
7575        {
7576            let to_remove = ["name"];
7577            params.remove_params(&to_remove);
7578        }
7579
7580        let url = params.parse_with_url(&url);
7581
7582        let mut json_mime_type = mime::APPLICATION_JSON;
7583        let mut request_value_reader = {
7584            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7585            common::remove_json_null_values(&mut value);
7586            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7587            serde_json::to_writer(&mut dst, &value).unwrap();
7588            dst
7589        };
7590        let request_size = request_value_reader
7591            .seek(std::io::SeekFrom::End(0))
7592            .unwrap();
7593        request_value_reader
7594            .seek(std::io::SeekFrom::Start(0))
7595            .unwrap();
7596
7597        loop {
7598            let token = match self
7599                .hub
7600                .auth
7601                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7602                .await
7603            {
7604                Ok(token) => token,
7605                Err(e) => match dlg.token(e) {
7606                    Ok(token) => token,
7607                    Err(e) => {
7608                        dlg.finished(false);
7609                        return Err(common::Error::MissingToken(e));
7610                    }
7611                },
7612            };
7613            request_value_reader
7614                .seek(std::io::SeekFrom::Start(0))
7615                .unwrap();
7616            let mut req_result = {
7617                let client = &self.hub.client;
7618                dlg.pre_request();
7619                let mut req_builder = hyper::Request::builder()
7620                    .method(hyper::Method::POST)
7621                    .uri(url.as_str())
7622                    .header(USER_AGENT, self.hub._user_agent.clone());
7623
7624                if let Some(token) = token.as_ref() {
7625                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7626                }
7627
7628                let request = req_builder
7629                    .header(CONTENT_TYPE, json_mime_type.to_string())
7630                    .header(CONTENT_LENGTH, request_size as u64)
7631                    .body(common::to_body(
7632                        request_value_reader.get_ref().clone().into(),
7633                    ));
7634
7635                client.request(request.unwrap()).await
7636            };
7637
7638            match req_result {
7639                Err(err) => {
7640                    if let common::Retry::After(d) = dlg.http_error(&err) {
7641                        sleep(d).await;
7642                        continue;
7643                    }
7644                    dlg.finished(false);
7645                    return Err(common::Error::HttpError(err));
7646                }
7647                Ok(res) => {
7648                    let (mut parts, body) = res.into_parts();
7649                    let mut body = common::Body::new(body);
7650                    if !parts.status.is_success() {
7651                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7652                        let error = serde_json::from_str(&common::to_string(&bytes));
7653                        let response = common::to_response(parts, bytes.into());
7654
7655                        if let common::Retry::After(d) =
7656                            dlg.http_failure(&response, error.as_ref().ok())
7657                        {
7658                            sleep(d).await;
7659                            continue;
7660                        }
7661
7662                        dlg.finished(false);
7663
7664                        return Err(match error {
7665                            Ok(value) => common::Error::BadRequest(value),
7666                            _ => common::Error::Failure(response),
7667                        });
7668                    }
7669                    let response = {
7670                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7671                        let encoded = common::to_string(&bytes);
7672                        match serde_json::from_str(&encoded) {
7673                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7674                            Err(error) => {
7675                                dlg.response_json_decode_error(&encoded, &error);
7676                                return Err(common::Error::JsonDecodeError(
7677                                    encoded.to_string(),
7678                                    error,
7679                                ));
7680                            }
7681                        }
7682                    };
7683
7684                    dlg.finished(true);
7685                    return Ok(response);
7686                }
7687            }
7688        }
7689    }
7690
7691    ///
7692    /// Sets the *request* property to the given value.
7693    ///
7694    /// Even though the property as already been set when instantiating this call,
7695    /// we provide this method for API completeness.
7696    pub fn request(
7697        mut self,
7698        new_value: DestroySecretVersionRequest,
7699    ) -> ProjectSecretVersionDestroyCall<'a, C> {
7700        self._request = new_value;
7701        self
7702    }
7703    /// Required. The resource name of the SecretVersion to destroy in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
7704    ///
7705    /// Sets the *name* path property to the given value.
7706    ///
7707    /// Even though the property as already been set when instantiating this call,
7708    /// we provide this method for API completeness.
7709    pub fn name(mut self, new_value: &str) -> ProjectSecretVersionDestroyCall<'a, C> {
7710        self._name = new_value.to_string();
7711        self
7712    }
7713    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7714    /// while executing the actual API request.
7715    ///
7716    /// ````text
7717    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7718    /// ````
7719    ///
7720    /// Sets the *delegate* property to the given value.
7721    pub fn delegate(
7722        mut self,
7723        new_value: &'a mut dyn common::Delegate,
7724    ) -> ProjectSecretVersionDestroyCall<'a, C> {
7725        self._delegate = Some(new_value);
7726        self
7727    }
7728
7729    /// Set any additional parameter of the query string used in the request.
7730    /// It should be used to set parameters which are not yet available through their own
7731    /// setters.
7732    ///
7733    /// Please note that this method must not be used to set any of the known parameters
7734    /// which have their own setter method. If done anyway, the request will fail.
7735    ///
7736    /// # Additional Parameters
7737    ///
7738    /// * *$.xgafv* (query-string) - V1 error format.
7739    /// * *access_token* (query-string) - OAuth access token.
7740    /// * *alt* (query-string) - Data format for response.
7741    /// * *callback* (query-string) - JSONP
7742    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7743    /// * *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.
7744    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7745    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7746    /// * *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.
7747    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7748    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7749    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionDestroyCall<'a, C>
7750    where
7751        T: AsRef<str>,
7752    {
7753        self._additional_params
7754            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7755        self
7756    }
7757
7758    /// Identifies the authorization scope for the method you are building.
7759    ///
7760    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7761    /// [`Scope::CloudPlatform`].
7762    ///
7763    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7764    /// tokens for more than one scope.
7765    ///
7766    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7767    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7768    /// sufficient, a read-write scope will do as well.
7769    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionDestroyCall<'a, C>
7770    where
7771        St: AsRef<str>,
7772    {
7773        self._scopes.insert(String::from(scope.as_ref()));
7774        self
7775    }
7776    /// Identifies the authorization scope(s) for the method you are building.
7777    ///
7778    /// See [`Self::add_scope()`] for details.
7779    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionDestroyCall<'a, C>
7780    where
7781        I: IntoIterator<Item = St>,
7782        St: AsRef<str>,
7783    {
7784        self._scopes
7785            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7786        self
7787    }
7788
7789    /// Removes all scopes, and no default scope will be used either.
7790    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7791    /// for details).
7792    pub fn clear_scopes(mut self) -> ProjectSecretVersionDestroyCall<'a, C> {
7793        self._scopes.clear();
7794        self
7795    }
7796}
7797
7798/// Disables a SecretVersion. Sets the state of the SecretVersion to DISABLED.
7799///
7800/// A builder for the *secrets.versions.disable* method supported by a *project* resource.
7801/// It is not used directly, but through a [`ProjectMethods`] instance.
7802///
7803/// # Example
7804///
7805/// Instantiate a resource method builder
7806///
7807/// ```test_harness,no_run
7808/// # extern crate hyper;
7809/// # extern crate hyper_rustls;
7810/// # extern crate google_secretmanager1 as secretmanager1;
7811/// use secretmanager1::api::DisableSecretVersionRequest;
7812/// # async fn dox() {
7813/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7814///
7815/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7816/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7817/// #     .with_native_roots()
7818/// #     .unwrap()
7819/// #     .https_only()
7820/// #     .enable_http2()
7821/// #     .build();
7822///
7823/// # let executor = hyper_util::rt::TokioExecutor::new();
7824/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7825/// #     secret,
7826/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7827/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7828/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7829/// #     ),
7830/// # ).build().await.unwrap();
7831///
7832/// # let client = hyper_util::client::legacy::Client::builder(
7833/// #     hyper_util::rt::TokioExecutor::new()
7834/// # )
7835/// # .build(
7836/// #     hyper_rustls::HttpsConnectorBuilder::new()
7837/// #         .with_native_roots()
7838/// #         .unwrap()
7839/// #         .https_or_http()
7840/// #         .enable_http2()
7841/// #         .build()
7842/// # );
7843/// # let mut hub = SecretManager::new(client, auth);
7844/// // As the method needs a request, you would usually fill it with the desired information
7845/// // into the respective structure. Some of the parts shown here might not be applicable !
7846/// // Values shown here are possibly random and not representative !
7847/// let mut req = DisableSecretVersionRequest::default();
7848///
7849/// // You can configure optional parameters by calling the respective setters at will, and
7850/// // execute the final call using `doit()`.
7851/// // Values shown here are possibly random and not representative !
7852/// let result = hub.projects().secrets_versions_disable(req, "name")
7853///              .doit().await;
7854/// # }
7855/// ```
7856pub struct ProjectSecretVersionDisableCall<'a, C>
7857where
7858    C: 'a,
7859{
7860    hub: &'a SecretManager<C>,
7861    _request: DisableSecretVersionRequest,
7862    _name: String,
7863    _delegate: Option<&'a mut dyn common::Delegate>,
7864    _additional_params: HashMap<String, String>,
7865    _scopes: BTreeSet<String>,
7866}
7867
7868impl<'a, C> common::CallBuilder for ProjectSecretVersionDisableCall<'a, C> {}
7869
7870impl<'a, C> ProjectSecretVersionDisableCall<'a, C>
7871where
7872    C: common::Connector,
7873{
7874    /// Perform the operation you have build so far.
7875    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
7876        use std::borrow::Cow;
7877        use std::io::{Read, Seek};
7878
7879        use common::{url::Params, ToParts};
7880        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7881
7882        let mut dd = common::DefaultDelegate;
7883        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7884        dlg.begin(common::MethodInfo {
7885            id: "secretmanager.projects.secrets.versions.disable",
7886            http_method: hyper::Method::POST,
7887        });
7888
7889        for &field in ["alt", "name"].iter() {
7890            if self._additional_params.contains_key(field) {
7891                dlg.finished(false);
7892                return Err(common::Error::FieldClash(field));
7893            }
7894        }
7895
7896        let mut params = Params::with_capacity(4 + self._additional_params.len());
7897        params.push("name", self._name);
7898
7899        params.extend(self._additional_params.iter());
7900
7901        params.push("alt", "json");
7902        let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
7903        if self._scopes.is_empty() {
7904            self._scopes
7905                .insert(Scope::CloudPlatform.as_ref().to_string());
7906        }
7907
7908        #[allow(clippy::single_element_loop)]
7909        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7910            url = params.uri_replacement(url, param_name, find_this, true);
7911        }
7912        {
7913            let to_remove = ["name"];
7914            params.remove_params(&to_remove);
7915        }
7916
7917        let url = params.parse_with_url(&url);
7918
7919        let mut json_mime_type = mime::APPLICATION_JSON;
7920        let mut request_value_reader = {
7921            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7922            common::remove_json_null_values(&mut value);
7923            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7924            serde_json::to_writer(&mut dst, &value).unwrap();
7925            dst
7926        };
7927        let request_size = request_value_reader
7928            .seek(std::io::SeekFrom::End(0))
7929            .unwrap();
7930        request_value_reader
7931            .seek(std::io::SeekFrom::Start(0))
7932            .unwrap();
7933
7934        loop {
7935            let token = match self
7936                .hub
7937                .auth
7938                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7939                .await
7940            {
7941                Ok(token) => token,
7942                Err(e) => match dlg.token(e) {
7943                    Ok(token) => token,
7944                    Err(e) => {
7945                        dlg.finished(false);
7946                        return Err(common::Error::MissingToken(e));
7947                    }
7948                },
7949            };
7950            request_value_reader
7951                .seek(std::io::SeekFrom::Start(0))
7952                .unwrap();
7953            let mut req_result = {
7954                let client = &self.hub.client;
7955                dlg.pre_request();
7956                let mut req_builder = hyper::Request::builder()
7957                    .method(hyper::Method::POST)
7958                    .uri(url.as_str())
7959                    .header(USER_AGENT, self.hub._user_agent.clone());
7960
7961                if let Some(token) = token.as_ref() {
7962                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7963                }
7964
7965                let request = req_builder
7966                    .header(CONTENT_TYPE, json_mime_type.to_string())
7967                    .header(CONTENT_LENGTH, request_size as u64)
7968                    .body(common::to_body(
7969                        request_value_reader.get_ref().clone().into(),
7970                    ));
7971
7972                client.request(request.unwrap()).await
7973            };
7974
7975            match req_result {
7976                Err(err) => {
7977                    if let common::Retry::After(d) = dlg.http_error(&err) {
7978                        sleep(d).await;
7979                        continue;
7980                    }
7981                    dlg.finished(false);
7982                    return Err(common::Error::HttpError(err));
7983                }
7984                Ok(res) => {
7985                    let (mut parts, body) = res.into_parts();
7986                    let mut body = common::Body::new(body);
7987                    if !parts.status.is_success() {
7988                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7989                        let error = serde_json::from_str(&common::to_string(&bytes));
7990                        let response = common::to_response(parts, bytes.into());
7991
7992                        if let common::Retry::After(d) =
7993                            dlg.http_failure(&response, error.as_ref().ok())
7994                        {
7995                            sleep(d).await;
7996                            continue;
7997                        }
7998
7999                        dlg.finished(false);
8000
8001                        return Err(match error {
8002                            Ok(value) => common::Error::BadRequest(value),
8003                            _ => common::Error::Failure(response),
8004                        });
8005                    }
8006                    let response = {
8007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8008                        let encoded = common::to_string(&bytes);
8009                        match serde_json::from_str(&encoded) {
8010                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8011                            Err(error) => {
8012                                dlg.response_json_decode_error(&encoded, &error);
8013                                return Err(common::Error::JsonDecodeError(
8014                                    encoded.to_string(),
8015                                    error,
8016                                ));
8017                            }
8018                        }
8019                    };
8020
8021                    dlg.finished(true);
8022                    return Ok(response);
8023                }
8024            }
8025        }
8026    }
8027
8028    ///
8029    /// Sets the *request* property to the given value.
8030    ///
8031    /// Even though the property as already been set when instantiating this call,
8032    /// we provide this method for API completeness.
8033    pub fn request(
8034        mut self,
8035        new_value: DisableSecretVersionRequest,
8036    ) -> ProjectSecretVersionDisableCall<'a, C> {
8037        self._request = new_value;
8038        self
8039    }
8040    /// Required. The resource name of the SecretVersion to disable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
8041    ///
8042    /// Sets the *name* path property to the given value.
8043    ///
8044    /// Even though the property as already been set when instantiating this call,
8045    /// we provide this method for API completeness.
8046    pub fn name(mut self, new_value: &str) -> ProjectSecretVersionDisableCall<'a, C> {
8047        self._name = new_value.to_string();
8048        self
8049    }
8050    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8051    /// while executing the actual API request.
8052    ///
8053    /// ````text
8054    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8055    /// ````
8056    ///
8057    /// Sets the *delegate* property to the given value.
8058    pub fn delegate(
8059        mut self,
8060        new_value: &'a mut dyn common::Delegate,
8061    ) -> ProjectSecretVersionDisableCall<'a, C> {
8062        self._delegate = Some(new_value);
8063        self
8064    }
8065
8066    /// Set any additional parameter of the query string used in the request.
8067    /// It should be used to set parameters which are not yet available through their own
8068    /// setters.
8069    ///
8070    /// Please note that this method must not be used to set any of the known parameters
8071    /// which have their own setter method. If done anyway, the request will fail.
8072    ///
8073    /// # Additional Parameters
8074    ///
8075    /// * *$.xgafv* (query-string) - V1 error format.
8076    /// * *access_token* (query-string) - OAuth access token.
8077    /// * *alt* (query-string) - Data format for response.
8078    /// * *callback* (query-string) - JSONP
8079    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8080    /// * *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.
8081    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8082    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8083    /// * *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.
8084    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8085    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8086    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionDisableCall<'a, C>
8087    where
8088        T: AsRef<str>,
8089    {
8090        self._additional_params
8091            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8092        self
8093    }
8094
8095    /// Identifies the authorization scope for the method you are building.
8096    ///
8097    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8098    /// [`Scope::CloudPlatform`].
8099    ///
8100    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8101    /// tokens for more than one scope.
8102    ///
8103    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8104    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8105    /// sufficient, a read-write scope will do as well.
8106    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionDisableCall<'a, C>
8107    where
8108        St: AsRef<str>,
8109    {
8110        self._scopes.insert(String::from(scope.as_ref()));
8111        self
8112    }
8113    /// Identifies the authorization scope(s) for the method you are building.
8114    ///
8115    /// See [`Self::add_scope()`] for details.
8116    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionDisableCall<'a, C>
8117    where
8118        I: IntoIterator<Item = St>,
8119        St: AsRef<str>,
8120    {
8121        self._scopes
8122            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8123        self
8124    }
8125
8126    /// Removes all scopes, and no default scope will be used either.
8127    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8128    /// for details).
8129    pub fn clear_scopes(mut self) -> ProjectSecretVersionDisableCall<'a, C> {
8130        self._scopes.clear();
8131        self
8132    }
8133}
8134
8135/// Enables a SecretVersion. Sets the state of the SecretVersion to ENABLED.
8136///
8137/// A builder for the *secrets.versions.enable* method supported by a *project* resource.
8138/// It is not used directly, but through a [`ProjectMethods`] instance.
8139///
8140/// # Example
8141///
8142/// Instantiate a resource method builder
8143///
8144/// ```test_harness,no_run
8145/// # extern crate hyper;
8146/// # extern crate hyper_rustls;
8147/// # extern crate google_secretmanager1 as secretmanager1;
8148/// use secretmanager1::api::EnableSecretVersionRequest;
8149/// # async fn dox() {
8150/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8151///
8152/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8153/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8154/// #     .with_native_roots()
8155/// #     .unwrap()
8156/// #     .https_only()
8157/// #     .enable_http2()
8158/// #     .build();
8159///
8160/// # let executor = hyper_util::rt::TokioExecutor::new();
8161/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8162/// #     secret,
8163/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8164/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8165/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8166/// #     ),
8167/// # ).build().await.unwrap();
8168///
8169/// # let client = hyper_util::client::legacy::Client::builder(
8170/// #     hyper_util::rt::TokioExecutor::new()
8171/// # )
8172/// # .build(
8173/// #     hyper_rustls::HttpsConnectorBuilder::new()
8174/// #         .with_native_roots()
8175/// #         .unwrap()
8176/// #         .https_or_http()
8177/// #         .enable_http2()
8178/// #         .build()
8179/// # );
8180/// # let mut hub = SecretManager::new(client, auth);
8181/// // As the method needs a request, you would usually fill it with the desired information
8182/// // into the respective structure. Some of the parts shown here might not be applicable !
8183/// // Values shown here are possibly random and not representative !
8184/// let mut req = EnableSecretVersionRequest::default();
8185///
8186/// // You can configure optional parameters by calling the respective setters at will, and
8187/// // execute the final call using `doit()`.
8188/// // Values shown here are possibly random and not representative !
8189/// let result = hub.projects().secrets_versions_enable(req, "name")
8190///              .doit().await;
8191/// # }
8192/// ```
8193pub struct ProjectSecretVersionEnableCall<'a, C>
8194where
8195    C: 'a,
8196{
8197    hub: &'a SecretManager<C>,
8198    _request: EnableSecretVersionRequest,
8199    _name: String,
8200    _delegate: Option<&'a mut dyn common::Delegate>,
8201    _additional_params: HashMap<String, String>,
8202    _scopes: BTreeSet<String>,
8203}
8204
8205impl<'a, C> common::CallBuilder for ProjectSecretVersionEnableCall<'a, C> {}
8206
8207impl<'a, C> ProjectSecretVersionEnableCall<'a, C>
8208where
8209    C: common::Connector,
8210{
8211    /// Perform the operation you have build so far.
8212    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
8213        use std::borrow::Cow;
8214        use std::io::{Read, Seek};
8215
8216        use common::{url::Params, ToParts};
8217        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8218
8219        let mut dd = common::DefaultDelegate;
8220        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8221        dlg.begin(common::MethodInfo {
8222            id: "secretmanager.projects.secrets.versions.enable",
8223            http_method: hyper::Method::POST,
8224        });
8225
8226        for &field in ["alt", "name"].iter() {
8227            if self._additional_params.contains_key(field) {
8228                dlg.finished(false);
8229                return Err(common::Error::FieldClash(field));
8230            }
8231        }
8232
8233        let mut params = Params::with_capacity(4 + self._additional_params.len());
8234        params.push("name", self._name);
8235
8236        params.extend(self._additional_params.iter());
8237
8238        params.push("alt", "json");
8239        let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
8240        if self._scopes.is_empty() {
8241            self._scopes
8242                .insert(Scope::CloudPlatform.as_ref().to_string());
8243        }
8244
8245        #[allow(clippy::single_element_loop)]
8246        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8247            url = params.uri_replacement(url, param_name, find_this, true);
8248        }
8249        {
8250            let to_remove = ["name"];
8251            params.remove_params(&to_remove);
8252        }
8253
8254        let url = params.parse_with_url(&url);
8255
8256        let mut json_mime_type = mime::APPLICATION_JSON;
8257        let mut request_value_reader = {
8258            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8259            common::remove_json_null_values(&mut value);
8260            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8261            serde_json::to_writer(&mut dst, &value).unwrap();
8262            dst
8263        };
8264        let request_size = request_value_reader
8265            .seek(std::io::SeekFrom::End(0))
8266            .unwrap();
8267        request_value_reader
8268            .seek(std::io::SeekFrom::Start(0))
8269            .unwrap();
8270
8271        loop {
8272            let token = match self
8273                .hub
8274                .auth
8275                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8276                .await
8277            {
8278                Ok(token) => token,
8279                Err(e) => match dlg.token(e) {
8280                    Ok(token) => token,
8281                    Err(e) => {
8282                        dlg.finished(false);
8283                        return Err(common::Error::MissingToken(e));
8284                    }
8285                },
8286            };
8287            request_value_reader
8288                .seek(std::io::SeekFrom::Start(0))
8289                .unwrap();
8290            let mut req_result = {
8291                let client = &self.hub.client;
8292                dlg.pre_request();
8293                let mut req_builder = hyper::Request::builder()
8294                    .method(hyper::Method::POST)
8295                    .uri(url.as_str())
8296                    .header(USER_AGENT, self.hub._user_agent.clone());
8297
8298                if let Some(token) = token.as_ref() {
8299                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8300                }
8301
8302                let request = req_builder
8303                    .header(CONTENT_TYPE, json_mime_type.to_string())
8304                    .header(CONTENT_LENGTH, request_size as u64)
8305                    .body(common::to_body(
8306                        request_value_reader.get_ref().clone().into(),
8307                    ));
8308
8309                client.request(request.unwrap()).await
8310            };
8311
8312            match req_result {
8313                Err(err) => {
8314                    if let common::Retry::After(d) = dlg.http_error(&err) {
8315                        sleep(d).await;
8316                        continue;
8317                    }
8318                    dlg.finished(false);
8319                    return Err(common::Error::HttpError(err));
8320                }
8321                Ok(res) => {
8322                    let (mut parts, body) = res.into_parts();
8323                    let mut body = common::Body::new(body);
8324                    if !parts.status.is_success() {
8325                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8326                        let error = serde_json::from_str(&common::to_string(&bytes));
8327                        let response = common::to_response(parts, bytes.into());
8328
8329                        if let common::Retry::After(d) =
8330                            dlg.http_failure(&response, error.as_ref().ok())
8331                        {
8332                            sleep(d).await;
8333                            continue;
8334                        }
8335
8336                        dlg.finished(false);
8337
8338                        return Err(match error {
8339                            Ok(value) => common::Error::BadRequest(value),
8340                            _ => common::Error::Failure(response),
8341                        });
8342                    }
8343                    let response = {
8344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8345                        let encoded = common::to_string(&bytes);
8346                        match serde_json::from_str(&encoded) {
8347                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8348                            Err(error) => {
8349                                dlg.response_json_decode_error(&encoded, &error);
8350                                return Err(common::Error::JsonDecodeError(
8351                                    encoded.to_string(),
8352                                    error,
8353                                ));
8354                            }
8355                        }
8356                    };
8357
8358                    dlg.finished(true);
8359                    return Ok(response);
8360                }
8361            }
8362        }
8363    }
8364
8365    ///
8366    /// Sets the *request* property to the given value.
8367    ///
8368    /// Even though the property as already been set when instantiating this call,
8369    /// we provide this method for API completeness.
8370    pub fn request(
8371        mut self,
8372        new_value: EnableSecretVersionRequest,
8373    ) -> ProjectSecretVersionEnableCall<'a, C> {
8374        self._request = new_value;
8375        self
8376    }
8377    /// Required. The resource name of the SecretVersion to enable in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`.
8378    ///
8379    /// Sets the *name* path property to the given value.
8380    ///
8381    /// Even though the property as already been set when instantiating this call,
8382    /// we provide this method for API completeness.
8383    pub fn name(mut self, new_value: &str) -> ProjectSecretVersionEnableCall<'a, C> {
8384        self._name = new_value.to_string();
8385        self
8386    }
8387    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8388    /// while executing the actual API request.
8389    ///
8390    /// ````text
8391    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8392    /// ````
8393    ///
8394    /// Sets the *delegate* property to the given value.
8395    pub fn delegate(
8396        mut self,
8397        new_value: &'a mut dyn common::Delegate,
8398    ) -> ProjectSecretVersionEnableCall<'a, C> {
8399        self._delegate = Some(new_value);
8400        self
8401    }
8402
8403    /// Set any additional parameter of the query string used in the request.
8404    /// It should be used to set parameters which are not yet available through their own
8405    /// setters.
8406    ///
8407    /// Please note that this method must not be used to set any of the known parameters
8408    /// which have their own setter method. If done anyway, the request will fail.
8409    ///
8410    /// # Additional Parameters
8411    ///
8412    /// * *$.xgafv* (query-string) - V1 error format.
8413    /// * *access_token* (query-string) - OAuth access token.
8414    /// * *alt* (query-string) - Data format for response.
8415    /// * *callback* (query-string) - JSONP
8416    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8417    /// * *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.
8418    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8419    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8420    /// * *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.
8421    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8422    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8423    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionEnableCall<'a, C>
8424    where
8425        T: AsRef<str>,
8426    {
8427        self._additional_params
8428            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8429        self
8430    }
8431
8432    /// Identifies the authorization scope for the method you are building.
8433    ///
8434    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8435    /// [`Scope::CloudPlatform`].
8436    ///
8437    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8438    /// tokens for more than one scope.
8439    ///
8440    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8441    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8442    /// sufficient, a read-write scope will do as well.
8443    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionEnableCall<'a, C>
8444    where
8445        St: AsRef<str>,
8446    {
8447        self._scopes.insert(String::from(scope.as_ref()));
8448        self
8449    }
8450    /// Identifies the authorization scope(s) for the method you are building.
8451    ///
8452    /// See [`Self::add_scope()`] for details.
8453    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionEnableCall<'a, C>
8454    where
8455        I: IntoIterator<Item = St>,
8456        St: AsRef<str>,
8457    {
8458        self._scopes
8459            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8460        self
8461    }
8462
8463    /// Removes all scopes, and no default scope will be used either.
8464    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8465    /// for details).
8466    pub fn clear_scopes(mut self) -> ProjectSecretVersionEnableCall<'a, C> {
8467        self._scopes.clear();
8468        self
8469    }
8470}
8471
8472/// Gets metadata for a SecretVersion. `projects/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
8473///
8474/// A builder for the *secrets.versions.get* method supported by a *project* resource.
8475/// It is not used directly, but through a [`ProjectMethods`] instance.
8476///
8477/// # Example
8478///
8479/// Instantiate a resource method builder
8480///
8481/// ```test_harness,no_run
8482/// # extern crate hyper;
8483/// # extern crate hyper_rustls;
8484/// # extern crate google_secretmanager1 as secretmanager1;
8485/// # async fn dox() {
8486/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8487///
8488/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8489/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8490/// #     .with_native_roots()
8491/// #     .unwrap()
8492/// #     .https_only()
8493/// #     .enable_http2()
8494/// #     .build();
8495///
8496/// # let executor = hyper_util::rt::TokioExecutor::new();
8497/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8498/// #     secret,
8499/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8500/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8501/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8502/// #     ),
8503/// # ).build().await.unwrap();
8504///
8505/// # let client = hyper_util::client::legacy::Client::builder(
8506/// #     hyper_util::rt::TokioExecutor::new()
8507/// # )
8508/// # .build(
8509/// #     hyper_rustls::HttpsConnectorBuilder::new()
8510/// #         .with_native_roots()
8511/// #         .unwrap()
8512/// #         .https_or_http()
8513/// #         .enable_http2()
8514/// #         .build()
8515/// # );
8516/// # let mut hub = SecretManager::new(client, auth);
8517/// // You can configure optional parameters by calling the respective setters at will, and
8518/// // execute the final call using `doit()`.
8519/// // Values shown here are possibly random and not representative !
8520/// let result = hub.projects().secrets_versions_get("name")
8521///              .doit().await;
8522/// # }
8523/// ```
8524pub struct ProjectSecretVersionGetCall<'a, C>
8525where
8526    C: 'a,
8527{
8528    hub: &'a SecretManager<C>,
8529    _name: String,
8530    _delegate: Option<&'a mut dyn common::Delegate>,
8531    _additional_params: HashMap<String, String>,
8532    _scopes: BTreeSet<String>,
8533}
8534
8535impl<'a, C> common::CallBuilder for ProjectSecretVersionGetCall<'a, C> {}
8536
8537impl<'a, C> ProjectSecretVersionGetCall<'a, C>
8538where
8539    C: common::Connector,
8540{
8541    /// Perform the operation you have build so far.
8542    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
8543        use std::borrow::Cow;
8544        use std::io::{Read, Seek};
8545
8546        use common::{url::Params, ToParts};
8547        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8548
8549        let mut dd = common::DefaultDelegate;
8550        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8551        dlg.begin(common::MethodInfo {
8552            id: "secretmanager.projects.secrets.versions.get",
8553            http_method: hyper::Method::GET,
8554        });
8555
8556        for &field in ["alt", "name"].iter() {
8557            if self._additional_params.contains_key(field) {
8558                dlg.finished(false);
8559                return Err(common::Error::FieldClash(field));
8560            }
8561        }
8562
8563        let mut params = Params::with_capacity(3 + self._additional_params.len());
8564        params.push("name", self._name);
8565
8566        params.extend(self._additional_params.iter());
8567
8568        params.push("alt", "json");
8569        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8570        if self._scopes.is_empty() {
8571            self._scopes
8572                .insert(Scope::CloudPlatform.as_ref().to_string());
8573        }
8574
8575        #[allow(clippy::single_element_loop)]
8576        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8577            url = params.uri_replacement(url, param_name, find_this, true);
8578        }
8579        {
8580            let to_remove = ["name"];
8581            params.remove_params(&to_remove);
8582        }
8583
8584        let url = params.parse_with_url(&url);
8585
8586        loop {
8587            let token = match self
8588                .hub
8589                .auth
8590                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8591                .await
8592            {
8593                Ok(token) => token,
8594                Err(e) => match dlg.token(e) {
8595                    Ok(token) => token,
8596                    Err(e) => {
8597                        dlg.finished(false);
8598                        return Err(common::Error::MissingToken(e));
8599                    }
8600                },
8601            };
8602            let mut req_result = {
8603                let client = &self.hub.client;
8604                dlg.pre_request();
8605                let mut req_builder = hyper::Request::builder()
8606                    .method(hyper::Method::GET)
8607                    .uri(url.as_str())
8608                    .header(USER_AGENT, self.hub._user_agent.clone());
8609
8610                if let Some(token) = token.as_ref() {
8611                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8612                }
8613
8614                let request = req_builder
8615                    .header(CONTENT_LENGTH, 0_u64)
8616                    .body(common::to_body::<String>(None));
8617
8618                client.request(request.unwrap()).await
8619            };
8620
8621            match req_result {
8622                Err(err) => {
8623                    if let common::Retry::After(d) = dlg.http_error(&err) {
8624                        sleep(d).await;
8625                        continue;
8626                    }
8627                    dlg.finished(false);
8628                    return Err(common::Error::HttpError(err));
8629                }
8630                Ok(res) => {
8631                    let (mut parts, body) = res.into_parts();
8632                    let mut body = common::Body::new(body);
8633                    if !parts.status.is_success() {
8634                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8635                        let error = serde_json::from_str(&common::to_string(&bytes));
8636                        let response = common::to_response(parts, bytes.into());
8637
8638                        if let common::Retry::After(d) =
8639                            dlg.http_failure(&response, error.as_ref().ok())
8640                        {
8641                            sleep(d).await;
8642                            continue;
8643                        }
8644
8645                        dlg.finished(false);
8646
8647                        return Err(match error {
8648                            Ok(value) => common::Error::BadRequest(value),
8649                            _ => common::Error::Failure(response),
8650                        });
8651                    }
8652                    let response = {
8653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8654                        let encoded = common::to_string(&bytes);
8655                        match serde_json::from_str(&encoded) {
8656                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8657                            Err(error) => {
8658                                dlg.response_json_decode_error(&encoded, &error);
8659                                return Err(common::Error::JsonDecodeError(
8660                                    encoded.to_string(),
8661                                    error,
8662                                ));
8663                            }
8664                        }
8665                    };
8666
8667                    dlg.finished(true);
8668                    return Ok(response);
8669                }
8670            }
8671        }
8672    }
8673
8674    /// Required. The resource name of the SecretVersion in the format `projects/*/secrets/*/versions/*` or `projects/*/locations/*/secrets/*/versions/*`. `projects/*/secrets/*/versions/latest` or `projects/*/locations/*/secrets/*/versions/latest` is an alias to the most recently created SecretVersion.
8675    ///
8676    /// Sets the *name* path property to the given value.
8677    ///
8678    /// Even though the property as already been set when instantiating this call,
8679    /// we provide this method for API completeness.
8680    pub fn name(mut self, new_value: &str) -> ProjectSecretVersionGetCall<'a, C> {
8681        self._name = new_value.to_string();
8682        self
8683    }
8684    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8685    /// while executing the actual API request.
8686    ///
8687    /// ````text
8688    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8689    /// ````
8690    ///
8691    /// Sets the *delegate* property to the given value.
8692    pub fn delegate(
8693        mut self,
8694        new_value: &'a mut dyn common::Delegate,
8695    ) -> ProjectSecretVersionGetCall<'a, C> {
8696        self._delegate = Some(new_value);
8697        self
8698    }
8699
8700    /// Set any additional parameter of the query string used in the request.
8701    /// It should be used to set parameters which are not yet available through their own
8702    /// setters.
8703    ///
8704    /// Please note that this method must not be used to set any of the known parameters
8705    /// which have their own setter method. If done anyway, the request will fail.
8706    ///
8707    /// # Additional Parameters
8708    ///
8709    /// * *$.xgafv* (query-string) - V1 error format.
8710    /// * *access_token* (query-string) - OAuth access token.
8711    /// * *alt* (query-string) - Data format for response.
8712    /// * *callback* (query-string) - JSONP
8713    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8714    /// * *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.
8715    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8716    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8717    /// * *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.
8718    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8719    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8720    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionGetCall<'a, C>
8721    where
8722        T: AsRef<str>,
8723    {
8724        self._additional_params
8725            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8726        self
8727    }
8728
8729    /// Identifies the authorization scope for the method you are building.
8730    ///
8731    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8732    /// [`Scope::CloudPlatform`].
8733    ///
8734    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8735    /// tokens for more than one scope.
8736    ///
8737    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8738    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8739    /// sufficient, a read-write scope will do as well.
8740    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionGetCall<'a, C>
8741    where
8742        St: AsRef<str>,
8743    {
8744        self._scopes.insert(String::from(scope.as_ref()));
8745        self
8746    }
8747    /// Identifies the authorization scope(s) for the method you are building.
8748    ///
8749    /// See [`Self::add_scope()`] for details.
8750    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionGetCall<'a, C>
8751    where
8752        I: IntoIterator<Item = St>,
8753        St: AsRef<str>,
8754    {
8755        self._scopes
8756            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8757        self
8758    }
8759
8760    /// Removes all scopes, and no default scope will be used either.
8761    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8762    /// for details).
8763    pub fn clear_scopes(mut self) -> ProjectSecretVersionGetCall<'a, C> {
8764        self._scopes.clear();
8765        self
8766    }
8767}
8768
8769/// Lists SecretVersions. This call does not return secret data.
8770///
8771/// A builder for the *secrets.versions.list* method supported by a *project* resource.
8772/// It is not used directly, but through a [`ProjectMethods`] instance.
8773///
8774/// # Example
8775///
8776/// Instantiate a resource method builder
8777///
8778/// ```test_harness,no_run
8779/// # extern crate hyper;
8780/// # extern crate hyper_rustls;
8781/// # extern crate google_secretmanager1 as secretmanager1;
8782/// # async fn dox() {
8783/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8784///
8785/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8786/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8787/// #     .with_native_roots()
8788/// #     .unwrap()
8789/// #     .https_only()
8790/// #     .enable_http2()
8791/// #     .build();
8792///
8793/// # let executor = hyper_util::rt::TokioExecutor::new();
8794/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8795/// #     secret,
8796/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8797/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8798/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8799/// #     ),
8800/// # ).build().await.unwrap();
8801///
8802/// # let client = hyper_util::client::legacy::Client::builder(
8803/// #     hyper_util::rt::TokioExecutor::new()
8804/// # )
8805/// # .build(
8806/// #     hyper_rustls::HttpsConnectorBuilder::new()
8807/// #         .with_native_roots()
8808/// #         .unwrap()
8809/// #         .https_or_http()
8810/// #         .enable_http2()
8811/// #         .build()
8812/// # );
8813/// # let mut hub = SecretManager::new(client, auth);
8814/// // You can configure optional parameters by calling the respective setters at will, and
8815/// // execute the final call using `doit()`.
8816/// // Values shown here are possibly random and not representative !
8817/// let result = hub.projects().secrets_versions_list("parent")
8818///              .page_token("duo")
8819///              .page_size(-80)
8820///              .filter("no")
8821///              .doit().await;
8822/// # }
8823/// ```
8824pub struct ProjectSecretVersionListCall<'a, C>
8825where
8826    C: 'a,
8827{
8828    hub: &'a SecretManager<C>,
8829    _parent: String,
8830    _page_token: Option<String>,
8831    _page_size: Option<i32>,
8832    _filter: Option<String>,
8833    _delegate: Option<&'a mut dyn common::Delegate>,
8834    _additional_params: HashMap<String, String>,
8835    _scopes: BTreeSet<String>,
8836}
8837
8838impl<'a, C> common::CallBuilder for ProjectSecretVersionListCall<'a, C> {}
8839
8840impl<'a, C> ProjectSecretVersionListCall<'a, C>
8841where
8842    C: common::Connector,
8843{
8844    /// Perform the operation you have build so far.
8845    pub async fn doit(mut self) -> common::Result<(common::Response, ListSecretVersionsResponse)> {
8846        use std::borrow::Cow;
8847        use std::io::{Read, Seek};
8848
8849        use common::{url::Params, ToParts};
8850        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8851
8852        let mut dd = common::DefaultDelegate;
8853        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8854        dlg.begin(common::MethodInfo {
8855            id: "secretmanager.projects.secrets.versions.list",
8856            http_method: hyper::Method::GET,
8857        });
8858
8859        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8860            if self._additional_params.contains_key(field) {
8861                dlg.finished(false);
8862                return Err(common::Error::FieldClash(field));
8863            }
8864        }
8865
8866        let mut params = Params::with_capacity(6 + self._additional_params.len());
8867        params.push("parent", self._parent);
8868        if let Some(value) = self._page_token.as_ref() {
8869            params.push("pageToken", value);
8870        }
8871        if let Some(value) = self._page_size.as_ref() {
8872            params.push("pageSize", value.to_string());
8873        }
8874        if let Some(value) = self._filter.as_ref() {
8875            params.push("filter", value);
8876        }
8877
8878        params.extend(self._additional_params.iter());
8879
8880        params.push("alt", "json");
8881        let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
8882        if self._scopes.is_empty() {
8883            self._scopes
8884                .insert(Scope::CloudPlatform.as_ref().to_string());
8885        }
8886
8887        #[allow(clippy::single_element_loop)]
8888        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8889            url = params.uri_replacement(url, param_name, find_this, true);
8890        }
8891        {
8892            let to_remove = ["parent"];
8893            params.remove_params(&to_remove);
8894        }
8895
8896        let url = params.parse_with_url(&url);
8897
8898        loop {
8899            let token = match self
8900                .hub
8901                .auth
8902                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8903                .await
8904            {
8905                Ok(token) => token,
8906                Err(e) => match dlg.token(e) {
8907                    Ok(token) => token,
8908                    Err(e) => {
8909                        dlg.finished(false);
8910                        return Err(common::Error::MissingToken(e));
8911                    }
8912                },
8913            };
8914            let mut req_result = {
8915                let client = &self.hub.client;
8916                dlg.pre_request();
8917                let mut req_builder = hyper::Request::builder()
8918                    .method(hyper::Method::GET)
8919                    .uri(url.as_str())
8920                    .header(USER_AGENT, self.hub._user_agent.clone());
8921
8922                if let Some(token) = token.as_ref() {
8923                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8924                }
8925
8926                let request = req_builder
8927                    .header(CONTENT_LENGTH, 0_u64)
8928                    .body(common::to_body::<String>(None));
8929
8930                client.request(request.unwrap()).await
8931            };
8932
8933            match req_result {
8934                Err(err) => {
8935                    if let common::Retry::After(d) = dlg.http_error(&err) {
8936                        sleep(d).await;
8937                        continue;
8938                    }
8939                    dlg.finished(false);
8940                    return Err(common::Error::HttpError(err));
8941                }
8942                Ok(res) => {
8943                    let (mut parts, body) = res.into_parts();
8944                    let mut body = common::Body::new(body);
8945                    if !parts.status.is_success() {
8946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8947                        let error = serde_json::from_str(&common::to_string(&bytes));
8948                        let response = common::to_response(parts, bytes.into());
8949
8950                        if let common::Retry::After(d) =
8951                            dlg.http_failure(&response, error.as_ref().ok())
8952                        {
8953                            sleep(d).await;
8954                            continue;
8955                        }
8956
8957                        dlg.finished(false);
8958
8959                        return Err(match error {
8960                            Ok(value) => common::Error::BadRequest(value),
8961                            _ => common::Error::Failure(response),
8962                        });
8963                    }
8964                    let response = {
8965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8966                        let encoded = common::to_string(&bytes);
8967                        match serde_json::from_str(&encoded) {
8968                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8969                            Err(error) => {
8970                                dlg.response_json_decode_error(&encoded, &error);
8971                                return Err(common::Error::JsonDecodeError(
8972                                    encoded.to_string(),
8973                                    error,
8974                                ));
8975                            }
8976                        }
8977                    };
8978
8979                    dlg.finished(true);
8980                    return Ok(response);
8981                }
8982            }
8983        }
8984    }
8985
8986    /// Required. The resource name of the Secret associated with the SecretVersions to list, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
8987    ///
8988    /// Sets the *parent* path property to the given value.
8989    ///
8990    /// Even though the property as already been set when instantiating this call,
8991    /// we provide this method for API completeness.
8992    pub fn parent(mut self, new_value: &str) -> ProjectSecretVersionListCall<'a, C> {
8993        self._parent = new_value.to_string();
8994        self
8995    }
8996    /// Optional. Pagination token, returned earlier via ListSecretVersionsResponse.next_page_token][].
8997    ///
8998    /// Sets the *page token* query property to the given value.
8999    pub fn page_token(mut self, new_value: &str) -> ProjectSecretVersionListCall<'a, C> {
9000        self._page_token = Some(new_value.to_string());
9001        self
9002    }
9003    /// Optional. The maximum number of results to be returned in a single page. If set to 0, the server decides the number of results to return. If the number is greater than 25000, it is capped at 25000.
9004    ///
9005    /// Sets the *page size* query property to the given value.
9006    pub fn page_size(mut self, new_value: i32) -> ProjectSecretVersionListCall<'a, C> {
9007        self._page_size = Some(new_value);
9008        self
9009    }
9010    /// Optional. Filter string, adhering to the rules in [List-operation filtering](https://cloud.google.com/secret-manager/docs/filtering). List only secret versions matching the filter. If filter is empty, all secret versions are listed.
9011    ///
9012    /// Sets the *filter* query property to the given value.
9013    pub fn filter(mut self, new_value: &str) -> ProjectSecretVersionListCall<'a, C> {
9014        self._filter = Some(new_value.to_string());
9015        self
9016    }
9017    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9018    /// while executing the actual API request.
9019    ///
9020    /// ````text
9021    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9022    /// ````
9023    ///
9024    /// Sets the *delegate* property to the given value.
9025    pub fn delegate(
9026        mut self,
9027        new_value: &'a mut dyn common::Delegate,
9028    ) -> ProjectSecretVersionListCall<'a, C> {
9029        self._delegate = Some(new_value);
9030        self
9031    }
9032
9033    /// Set any additional parameter of the query string used in the request.
9034    /// It should be used to set parameters which are not yet available through their own
9035    /// setters.
9036    ///
9037    /// Please note that this method must not be used to set any of the known parameters
9038    /// which have their own setter method. If done anyway, the request will fail.
9039    ///
9040    /// # Additional Parameters
9041    ///
9042    /// * *$.xgafv* (query-string) - V1 error format.
9043    /// * *access_token* (query-string) - OAuth access token.
9044    /// * *alt* (query-string) - Data format for response.
9045    /// * *callback* (query-string) - JSONP
9046    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9047    /// * *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.
9048    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9049    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9050    /// * *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.
9051    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9052    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9053    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretVersionListCall<'a, C>
9054    where
9055        T: AsRef<str>,
9056    {
9057        self._additional_params
9058            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9059        self
9060    }
9061
9062    /// Identifies the authorization scope for the method you are building.
9063    ///
9064    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9065    /// [`Scope::CloudPlatform`].
9066    ///
9067    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9068    /// tokens for more than one scope.
9069    ///
9070    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9071    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9072    /// sufficient, a read-write scope will do as well.
9073    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretVersionListCall<'a, C>
9074    where
9075        St: AsRef<str>,
9076    {
9077        self._scopes.insert(String::from(scope.as_ref()));
9078        self
9079    }
9080    /// Identifies the authorization scope(s) for the method you are building.
9081    ///
9082    /// See [`Self::add_scope()`] for details.
9083    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretVersionListCall<'a, C>
9084    where
9085        I: IntoIterator<Item = St>,
9086        St: AsRef<str>,
9087    {
9088        self._scopes
9089            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9090        self
9091    }
9092
9093    /// Removes all scopes, and no default scope will be used either.
9094    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9095    /// for details).
9096    pub fn clear_scopes(mut self) -> ProjectSecretVersionListCall<'a, C> {
9097        self._scopes.clear();
9098        self
9099    }
9100}
9101
9102/// Creates a new SecretVersion containing secret data and attaches it to an existing Secret.
9103///
9104/// A builder for the *secrets.addVersion* method supported by a *project* resource.
9105/// It is not used directly, but through a [`ProjectMethods`] instance.
9106///
9107/// # Example
9108///
9109/// Instantiate a resource method builder
9110///
9111/// ```test_harness,no_run
9112/// # extern crate hyper;
9113/// # extern crate hyper_rustls;
9114/// # extern crate google_secretmanager1 as secretmanager1;
9115/// use secretmanager1::api::AddSecretVersionRequest;
9116/// # async fn dox() {
9117/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9118///
9119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9121/// #     .with_native_roots()
9122/// #     .unwrap()
9123/// #     .https_only()
9124/// #     .enable_http2()
9125/// #     .build();
9126///
9127/// # let executor = hyper_util::rt::TokioExecutor::new();
9128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9129/// #     secret,
9130/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9131/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9132/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9133/// #     ),
9134/// # ).build().await.unwrap();
9135///
9136/// # let client = hyper_util::client::legacy::Client::builder(
9137/// #     hyper_util::rt::TokioExecutor::new()
9138/// # )
9139/// # .build(
9140/// #     hyper_rustls::HttpsConnectorBuilder::new()
9141/// #         .with_native_roots()
9142/// #         .unwrap()
9143/// #         .https_or_http()
9144/// #         .enable_http2()
9145/// #         .build()
9146/// # );
9147/// # let mut hub = SecretManager::new(client, auth);
9148/// // As the method needs a request, you would usually fill it with the desired information
9149/// // into the respective structure. Some of the parts shown here might not be applicable !
9150/// // Values shown here are possibly random and not representative !
9151/// let mut req = AddSecretVersionRequest::default();
9152///
9153/// // You can configure optional parameters by calling the respective setters at will, and
9154/// // execute the final call using `doit()`.
9155/// // Values shown here are possibly random and not representative !
9156/// let result = hub.projects().secrets_add_version(req, "parent")
9157///              .doit().await;
9158/// # }
9159/// ```
9160pub struct ProjectSecretAddVersionCall<'a, C>
9161where
9162    C: 'a,
9163{
9164    hub: &'a SecretManager<C>,
9165    _request: AddSecretVersionRequest,
9166    _parent: String,
9167    _delegate: Option<&'a mut dyn common::Delegate>,
9168    _additional_params: HashMap<String, String>,
9169    _scopes: BTreeSet<String>,
9170}
9171
9172impl<'a, C> common::CallBuilder for ProjectSecretAddVersionCall<'a, C> {}
9173
9174impl<'a, C> ProjectSecretAddVersionCall<'a, C>
9175where
9176    C: common::Connector,
9177{
9178    /// Perform the operation you have build so far.
9179    pub async fn doit(mut self) -> common::Result<(common::Response, SecretVersion)> {
9180        use std::borrow::Cow;
9181        use std::io::{Read, Seek};
9182
9183        use common::{url::Params, ToParts};
9184        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9185
9186        let mut dd = common::DefaultDelegate;
9187        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9188        dlg.begin(common::MethodInfo {
9189            id: "secretmanager.projects.secrets.addVersion",
9190            http_method: hyper::Method::POST,
9191        });
9192
9193        for &field in ["alt", "parent"].iter() {
9194            if self._additional_params.contains_key(field) {
9195                dlg.finished(false);
9196                return Err(common::Error::FieldClash(field));
9197            }
9198        }
9199
9200        let mut params = Params::with_capacity(4 + self._additional_params.len());
9201        params.push("parent", self._parent);
9202
9203        params.extend(self._additional_params.iter());
9204
9205        params.push("alt", "json");
9206        let mut url = self.hub._base_url.clone() + "v1/{+parent}:addVersion";
9207        if self._scopes.is_empty() {
9208            self._scopes
9209                .insert(Scope::CloudPlatform.as_ref().to_string());
9210        }
9211
9212        #[allow(clippy::single_element_loop)]
9213        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9214            url = params.uri_replacement(url, param_name, find_this, true);
9215        }
9216        {
9217            let to_remove = ["parent"];
9218            params.remove_params(&to_remove);
9219        }
9220
9221        let url = params.parse_with_url(&url);
9222
9223        let mut json_mime_type = mime::APPLICATION_JSON;
9224        let mut request_value_reader = {
9225            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9226            common::remove_json_null_values(&mut value);
9227            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9228            serde_json::to_writer(&mut dst, &value).unwrap();
9229            dst
9230        };
9231        let request_size = request_value_reader
9232            .seek(std::io::SeekFrom::End(0))
9233            .unwrap();
9234        request_value_reader
9235            .seek(std::io::SeekFrom::Start(0))
9236            .unwrap();
9237
9238        loop {
9239            let token = match self
9240                .hub
9241                .auth
9242                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9243                .await
9244            {
9245                Ok(token) => token,
9246                Err(e) => match dlg.token(e) {
9247                    Ok(token) => token,
9248                    Err(e) => {
9249                        dlg.finished(false);
9250                        return Err(common::Error::MissingToken(e));
9251                    }
9252                },
9253            };
9254            request_value_reader
9255                .seek(std::io::SeekFrom::Start(0))
9256                .unwrap();
9257            let mut req_result = {
9258                let client = &self.hub.client;
9259                dlg.pre_request();
9260                let mut req_builder = hyper::Request::builder()
9261                    .method(hyper::Method::POST)
9262                    .uri(url.as_str())
9263                    .header(USER_AGENT, self.hub._user_agent.clone());
9264
9265                if let Some(token) = token.as_ref() {
9266                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9267                }
9268
9269                let request = req_builder
9270                    .header(CONTENT_TYPE, json_mime_type.to_string())
9271                    .header(CONTENT_LENGTH, request_size as u64)
9272                    .body(common::to_body(
9273                        request_value_reader.get_ref().clone().into(),
9274                    ));
9275
9276                client.request(request.unwrap()).await
9277            };
9278
9279            match req_result {
9280                Err(err) => {
9281                    if let common::Retry::After(d) = dlg.http_error(&err) {
9282                        sleep(d).await;
9283                        continue;
9284                    }
9285                    dlg.finished(false);
9286                    return Err(common::Error::HttpError(err));
9287                }
9288                Ok(res) => {
9289                    let (mut parts, body) = res.into_parts();
9290                    let mut body = common::Body::new(body);
9291                    if !parts.status.is_success() {
9292                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9293                        let error = serde_json::from_str(&common::to_string(&bytes));
9294                        let response = common::to_response(parts, bytes.into());
9295
9296                        if let common::Retry::After(d) =
9297                            dlg.http_failure(&response, error.as_ref().ok())
9298                        {
9299                            sleep(d).await;
9300                            continue;
9301                        }
9302
9303                        dlg.finished(false);
9304
9305                        return Err(match error {
9306                            Ok(value) => common::Error::BadRequest(value),
9307                            _ => common::Error::Failure(response),
9308                        });
9309                    }
9310                    let response = {
9311                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9312                        let encoded = common::to_string(&bytes);
9313                        match serde_json::from_str(&encoded) {
9314                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9315                            Err(error) => {
9316                                dlg.response_json_decode_error(&encoded, &error);
9317                                return Err(common::Error::JsonDecodeError(
9318                                    encoded.to_string(),
9319                                    error,
9320                                ));
9321                            }
9322                        }
9323                    };
9324
9325                    dlg.finished(true);
9326                    return Ok(response);
9327                }
9328            }
9329        }
9330    }
9331
9332    ///
9333    /// Sets the *request* property to the given value.
9334    ///
9335    /// Even though the property as already been set when instantiating this call,
9336    /// we provide this method for API completeness.
9337    pub fn request(
9338        mut self,
9339        new_value: AddSecretVersionRequest,
9340    ) -> ProjectSecretAddVersionCall<'a, C> {
9341        self._request = new_value;
9342        self
9343    }
9344    /// Required. The resource name of the Secret to associate with the SecretVersion in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
9345    ///
9346    /// Sets the *parent* path property to the given value.
9347    ///
9348    /// Even though the property as already been set when instantiating this call,
9349    /// we provide this method for API completeness.
9350    pub fn parent(mut self, new_value: &str) -> ProjectSecretAddVersionCall<'a, C> {
9351        self._parent = new_value.to_string();
9352        self
9353    }
9354    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9355    /// while executing the actual API request.
9356    ///
9357    /// ````text
9358    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9359    /// ````
9360    ///
9361    /// Sets the *delegate* property to the given value.
9362    pub fn delegate(
9363        mut self,
9364        new_value: &'a mut dyn common::Delegate,
9365    ) -> ProjectSecretAddVersionCall<'a, C> {
9366        self._delegate = Some(new_value);
9367        self
9368    }
9369
9370    /// Set any additional parameter of the query string used in the request.
9371    /// It should be used to set parameters which are not yet available through their own
9372    /// setters.
9373    ///
9374    /// Please note that this method must not be used to set any of the known parameters
9375    /// which have their own setter method. If done anyway, the request will fail.
9376    ///
9377    /// # Additional Parameters
9378    ///
9379    /// * *$.xgafv* (query-string) - V1 error format.
9380    /// * *access_token* (query-string) - OAuth access token.
9381    /// * *alt* (query-string) - Data format for response.
9382    /// * *callback* (query-string) - JSONP
9383    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9384    /// * *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.
9385    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9386    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9387    /// * *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.
9388    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9389    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9390    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretAddVersionCall<'a, C>
9391    where
9392        T: AsRef<str>,
9393    {
9394        self._additional_params
9395            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9396        self
9397    }
9398
9399    /// Identifies the authorization scope for the method you are building.
9400    ///
9401    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9402    /// [`Scope::CloudPlatform`].
9403    ///
9404    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9405    /// tokens for more than one scope.
9406    ///
9407    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9408    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9409    /// sufficient, a read-write scope will do as well.
9410    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretAddVersionCall<'a, C>
9411    where
9412        St: AsRef<str>,
9413    {
9414        self._scopes.insert(String::from(scope.as_ref()));
9415        self
9416    }
9417    /// Identifies the authorization scope(s) for the method you are building.
9418    ///
9419    /// See [`Self::add_scope()`] for details.
9420    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretAddVersionCall<'a, C>
9421    where
9422        I: IntoIterator<Item = St>,
9423        St: AsRef<str>,
9424    {
9425        self._scopes
9426            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9427        self
9428    }
9429
9430    /// Removes all scopes, and no default scope will be used either.
9431    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9432    /// for details).
9433    pub fn clear_scopes(mut self) -> ProjectSecretAddVersionCall<'a, C> {
9434        self._scopes.clear();
9435        self
9436    }
9437}
9438
9439/// Creates a new Secret containing no SecretVersions.
9440///
9441/// A builder for the *secrets.create* method supported by a *project* resource.
9442/// It is not used directly, but through a [`ProjectMethods`] instance.
9443///
9444/// # Example
9445///
9446/// Instantiate a resource method builder
9447///
9448/// ```test_harness,no_run
9449/// # extern crate hyper;
9450/// # extern crate hyper_rustls;
9451/// # extern crate google_secretmanager1 as secretmanager1;
9452/// use secretmanager1::api::Secret;
9453/// # async fn dox() {
9454/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9455///
9456/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9457/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9458/// #     .with_native_roots()
9459/// #     .unwrap()
9460/// #     .https_only()
9461/// #     .enable_http2()
9462/// #     .build();
9463///
9464/// # let executor = hyper_util::rt::TokioExecutor::new();
9465/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9466/// #     secret,
9467/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9468/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9469/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9470/// #     ),
9471/// # ).build().await.unwrap();
9472///
9473/// # let client = hyper_util::client::legacy::Client::builder(
9474/// #     hyper_util::rt::TokioExecutor::new()
9475/// # )
9476/// # .build(
9477/// #     hyper_rustls::HttpsConnectorBuilder::new()
9478/// #         .with_native_roots()
9479/// #         .unwrap()
9480/// #         .https_or_http()
9481/// #         .enable_http2()
9482/// #         .build()
9483/// # );
9484/// # let mut hub = SecretManager::new(client, auth);
9485/// // As the method needs a request, you would usually fill it with the desired information
9486/// // into the respective structure. Some of the parts shown here might not be applicable !
9487/// // Values shown here are possibly random and not representative !
9488/// let mut req = Secret::default();
9489///
9490/// // You can configure optional parameters by calling the respective setters at will, and
9491/// // execute the final call using `doit()`.
9492/// // Values shown here are possibly random and not representative !
9493/// let result = hub.projects().secrets_create(req, "parent")
9494///              .secret_id("et")
9495///              .doit().await;
9496/// # }
9497/// ```
9498pub struct ProjectSecretCreateCall<'a, C>
9499where
9500    C: 'a,
9501{
9502    hub: &'a SecretManager<C>,
9503    _request: Secret,
9504    _parent: String,
9505    _secret_id: Option<String>,
9506    _delegate: Option<&'a mut dyn common::Delegate>,
9507    _additional_params: HashMap<String, String>,
9508    _scopes: BTreeSet<String>,
9509}
9510
9511impl<'a, C> common::CallBuilder for ProjectSecretCreateCall<'a, C> {}
9512
9513impl<'a, C> ProjectSecretCreateCall<'a, C>
9514where
9515    C: common::Connector,
9516{
9517    /// Perform the operation you have build so far.
9518    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
9519        use std::borrow::Cow;
9520        use std::io::{Read, Seek};
9521
9522        use common::{url::Params, ToParts};
9523        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9524
9525        let mut dd = common::DefaultDelegate;
9526        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9527        dlg.begin(common::MethodInfo {
9528            id: "secretmanager.projects.secrets.create",
9529            http_method: hyper::Method::POST,
9530        });
9531
9532        for &field in ["alt", "parent", "secretId"].iter() {
9533            if self._additional_params.contains_key(field) {
9534                dlg.finished(false);
9535                return Err(common::Error::FieldClash(field));
9536            }
9537        }
9538
9539        let mut params = Params::with_capacity(5 + self._additional_params.len());
9540        params.push("parent", self._parent);
9541        if let Some(value) = self._secret_id.as_ref() {
9542            params.push("secretId", value);
9543        }
9544
9545        params.extend(self._additional_params.iter());
9546
9547        params.push("alt", "json");
9548        let mut url = self.hub._base_url.clone() + "v1/{+parent}/secrets";
9549        if self._scopes.is_empty() {
9550            self._scopes
9551                .insert(Scope::CloudPlatform.as_ref().to_string());
9552        }
9553
9554        #[allow(clippy::single_element_loop)]
9555        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9556            url = params.uri_replacement(url, param_name, find_this, true);
9557        }
9558        {
9559            let to_remove = ["parent"];
9560            params.remove_params(&to_remove);
9561        }
9562
9563        let url = params.parse_with_url(&url);
9564
9565        let mut json_mime_type = mime::APPLICATION_JSON;
9566        let mut request_value_reader = {
9567            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9568            common::remove_json_null_values(&mut value);
9569            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9570            serde_json::to_writer(&mut dst, &value).unwrap();
9571            dst
9572        };
9573        let request_size = request_value_reader
9574            .seek(std::io::SeekFrom::End(0))
9575            .unwrap();
9576        request_value_reader
9577            .seek(std::io::SeekFrom::Start(0))
9578            .unwrap();
9579
9580        loop {
9581            let token = match self
9582                .hub
9583                .auth
9584                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9585                .await
9586            {
9587                Ok(token) => token,
9588                Err(e) => match dlg.token(e) {
9589                    Ok(token) => token,
9590                    Err(e) => {
9591                        dlg.finished(false);
9592                        return Err(common::Error::MissingToken(e));
9593                    }
9594                },
9595            };
9596            request_value_reader
9597                .seek(std::io::SeekFrom::Start(0))
9598                .unwrap();
9599            let mut req_result = {
9600                let client = &self.hub.client;
9601                dlg.pre_request();
9602                let mut req_builder = hyper::Request::builder()
9603                    .method(hyper::Method::POST)
9604                    .uri(url.as_str())
9605                    .header(USER_AGENT, self.hub._user_agent.clone());
9606
9607                if let Some(token) = token.as_ref() {
9608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9609                }
9610
9611                let request = req_builder
9612                    .header(CONTENT_TYPE, json_mime_type.to_string())
9613                    .header(CONTENT_LENGTH, request_size as u64)
9614                    .body(common::to_body(
9615                        request_value_reader.get_ref().clone().into(),
9616                    ));
9617
9618                client.request(request.unwrap()).await
9619            };
9620
9621            match req_result {
9622                Err(err) => {
9623                    if let common::Retry::After(d) = dlg.http_error(&err) {
9624                        sleep(d).await;
9625                        continue;
9626                    }
9627                    dlg.finished(false);
9628                    return Err(common::Error::HttpError(err));
9629                }
9630                Ok(res) => {
9631                    let (mut parts, body) = res.into_parts();
9632                    let mut body = common::Body::new(body);
9633                    if !parts.status.is_success() {
9634                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9635                        let error = serde_json::from_str(&common::to_string(&bytes));
9636                        let response = common::to_response(parts, bytes.into());
9637
9638                        if let common::Retry::After(d) =
9639                            dlg.http_failure(&response, error.as_ref().ok())
9640                        {
9641                            sleep(d).await;
9642                            continue;
9643                        }
9644
9645                        dlg.finished(false);
9646
9647                        return Err(match error {
9648                            Ok(value) => common::Error::BadRequest(value),
9649                            _ => common::Error::Failure(response),
9650                        });
9651                    }
9652                    let response = {
9653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9654                        let encoded = common::to_string(&bytes);
9655                        match serde_json::from_str(&encoded) {
9656                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9657                            Err(error) => {
9658                                dlg.response_json_decode_error(&encoded, &error);
9659                                return Err(common::Error::JsonDecodeError(
9660                                    encoded.to_string(),
9661                                    error,
9662                                ));
9663                            }
9664                        }
9665                    };
9666
9667                    dlg.finished(true);
9668                    return Ok(response);
9669                }
9670            }
9671        }
9672    }
9673
9674    ///
9675    /// Sets the *request* property to the given value.
9676    ///
9677    /// Even though the property as already been set when instantiating this call,
9678    /// we provide this method for API completeness.
9679    pub fn request(mut self, new_value: Secret) -> ProjectSecretCreateCall<'a, C> {
9680        self._request = new_value;
9681        self
9682    }
9683    /// Required. The resource name of the project to associate with the Secret, in the format `projects/*` or `projects/*/locations/*`.
9684    ///
9685    /// Sets the *parent* path property to the given value.
9686    ///
9687    /// Even though the property as already been set when instantiating this call,
9688    /// we provide this method for API completeness.
9689    pub fn parent(mut self, new_value: &str) -> ProjectSecretCreateCall<'a, C> {
9690        self._parent = new_value.to_string();
9691        self
9692    }
9693    /// Required. This must be unique within the project. A secret ID is a string with a maximum length of 255 characters and can contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and underscore (`_`) characters.
9694    ///
9695    /// Sets the *secret id* query property to the given value.
9696    pub fn secret_id(mut self, new_value: &str) -> ProjectSecretCreateCall<'a, C> {
9697        self._secret_id = Some(new_value.to_string());
9698        self
9699    }
9700    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9701    /// while executing the actual API request.
9702    ///
9703    /// ````text
9704    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9705    /// ````
9706    ///
9707    /// Sets the *delegate* property to the given value.
9708    pub fn delegate(
9709        mut self,
9710        new_value: &'a mut dyn common::Delegate,
9711    ) -> ProjectSecretCreateCall<'a, C> {
9712        self._delegate = Some(new_value);
9713        self
9714    }
9715
9716    /// Set any additional parameter of the query string used in the request.
9717    /// It should be used to set parameters which are not yet available through their own
9718    /// setters.
9719    ///
9720    /// Please note that this method must not be used to set any of the known parameters
9721    /// which have their own setter method. If done anyway, the request will fail.
9722    ///
9723    /// # Additional Parameters
9724    ///
9725    /// * *$.xgafv* (query-string) - V1 error format.
9726    /// * *access_token* (query-string) - OAuth access token.
9727    /// * *alt* (query-string) - Data format for response.
9728    /// * *callback* (query-string) - JSONP
9729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9730    /// * *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.
9731    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9732    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9733    /// * *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.
9734    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9735    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9736    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretCreateCall<'a, C>
9737    where
9738        T: AsRef<str>,
9739    {
9740        self._additional_params
9741            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9742        self
9743    }
9744
9745    /// Identifies the authorization scope for the method you are building.
9746    ///
9747    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9748    /// [`Scope::CloudPlatform`].
9749    ///
9750    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9751    /// tokens for more than one scope.
9752    ///
9753    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9754    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9755    /// sufficient, a read-write scope will do as well.
9756    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretCreateCall<'a, C>
9757    where
9758        St: AsRef<str>,
9759    {
9760        self._scopes.insert(String::from(scope.as_ref()));
9761        self
9762    }
9763    /// Identifies the authorization scope(s) for the method you are building.
9764    ///
9765    /// See [`Self::add_scope()`] for details.
9766    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretCreateCall<'a, C>
9767    where
9768        I: IntoIterator<Item = St>,
9769        St: AsRef<str>,
9770    {
9771        self._scopes
9772            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9773        self
9774    }
9775
9776    /// Removes all scopes, and no default scope will be used either.
9777    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9778    /// for details).
9779    pub fn clear_scopes(mut self) -> ProjectSecretCreateCall<'a, C> {
9780        self._scopes.clear();
9781        self
9782    }
9783}
9784
9785/// Deletes a Secret.
9786///
9787/// A builder for the *secrets.delete* method supported by a *project* resource.
9788/// It is not used directly, but through a [`ProjectMethods`] instance.
9789///
9790/// # Example
9791///
9792/// Instantiate a resource method builder
9793///
9794/// ```test_harness,no_run
9795/// # extern crate hyper;
9796/// # extern crate hyper_rustls;
9797/// # extern crate google_secretmanager1 as secretmanager1;
9798/// # async fn dox() {
9799/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9800///
9801/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9802/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9803/// #     .with_native_roots()
9804/// #     .unwrap()
9805/// #     .https_only()
9806/// #     .enable_http2()
9807/// #     .build();
9808///
9809/// # let executor = hyper_util::rt::TokioExecutor::new();
9810/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9811/// #     secret,
9812/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9813/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9814/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9815/// #     ),
9816/// # ).build().await.unwrap();
9817///
9818/// # let client = hyper_util::client::legacy::Client::builder(
9819/// #     hyper_util::rt::TokioExecutor::new()
9820/// # )
9821/// # .build(
9822/// #     hyper_rustls::HttpsConnectorBuilder::new()
9823/// #         .with_native_roots()
9824/// #         .unwrap()
9825/// #         .https_or_http()
9826/// #         .enable_http2()
9827/// #         .build()
9828/// # );
9829/// # let mut hub = SecretManager::new(client, auth);
9830/// // You can configure optional parameters by calling the respective setters at will, and
9831/// // execute the final call using `doit()`.
9832/// // Values shown here are possibly random and not representative !
9833/// let result = hub.projects().secrets_delete("name")
9834///              .etag("et")
9835///              .doit().await;
9836/// # }
9837/// ```
9838pub struct ProjectSecretDeleteCall<'a, C>
9839where
9840    C: 'a,
9841{
9842    hub: &'a SecretManager<C>,
9843    _name: String,
9844    _etag: Option<String>,
9845    _delegate: Option<&'a mut dyn common::Delegate>,
9846    _additional_params: HashMap<String, String>,
9847    _scopes: BTreeSet<String>,
9848}
9849
9850impl<'a, C> common::CallBuilder for ProjectSecretDeleteCall<'a, C> {}
9851
9852impl<'a, C> ProjectSecretDeleteCall<'a, C>
9853where
9854    C: common::Connector,
9855{
9856    /// Perform the operation you have build so far.
9857    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9858        use std::borrow::Cow;
9859        use std::io::{Read, Seek};
9860
9861        use common::{url::Params, ToParts};
9862        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9863
9864        let mut dd = common::DefaultDelegate;
9865        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9866        dlg.begin(common::MethodInfo {
9867            id: "secretmanager.projects.secrets.delete",
9868            http_method: hyper::Method::DELETE,
9869        });
9870
9871        for &field in ["alt", "name", "etag"].iter() {
9872            if self._additional_params.contains_key(field) {
9873                dlg.finished(false);
9874                return Err(common::Error::FieldClash(field));
9875            }
9876        }
9877
9878        let mut params = Params::with_capacity(4 + self._additional_params.len());
9879        params.push("name", self._name);
9880        if let Some(value) = self._etag.as_ref() {
9881            params.push("etag", value);
9882        }
9883
9884        params.extend(self._additional_params.iter());
9885
9886        params.push("alt", "json");
9887        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9888        if self._scopes.is_empty() {
9889            self._scopes
9890                .insert(Scope::CloudPlatform.as_ref().to_string());
9891        }
9892
9893        #[allow(clippy::single_element_loop)]
9894        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9895            url = params.uri_replacement(url, param_name, find_this, true);
9896        }
9897        {
9898            let to_remove = ["name"];
9899            params.remove_params(&to_remove);
9900        }
9901
9902        let url = params.parse_with_url(&url);
9903
9904        loop {
9905            let token = match self
9906                .hub
9907                .auth
9908                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9909                .await
9910            {
9911                Ok(token) => token,
9912                Err(e) => match dlg.token(e) {
9913                    Ok(token) => token,
9914                    Err(e) => {
9915                        dlg.finished(false);
9916                        return Err(common::Error::MissingToken(e));
9917                    }
9918                },
9919            };
9920            let mut req_result = {
9921                let client = &self.hub.client;
9922                dlg.pre_request();
9923                let mut req_builder = hyper::Request::builder()
9924                    .method(hyper::Method::DELETE)
9925                    .uri(url.as_str())
9926                    .header(USER_AGENT, self.hub._user_agent.clone());
9927
9928                if let Some(token) = token.as_ref() {
9929                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9930                }
9931
9932                let request = req_builder
9933                    .header(CONTENT_LENGTH, 0_u64)
9934                    .body(common::to_body::<String>(None));
9935
9936                client.request(request.unwrap()).await
9937            };
9938
9939            match req_result {
9940                Err(err) => {
9941                    if let common::Retry::After(d) = dlg.http_error(&err) {
9942                        sleep(d).await;
9943                        continue;
9944                    }
9945                    dlg.finished(false);
9946                    return Err(common::Error::HttpError(err));
9947                }
9948                Ok(res) => {
9949                    let (mut parts, body) = res.into_parts();
9950                    let mut body = common::Body::new(body);
9951                    if !parts.status.is_success() {
9952                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9953                        let error = serde_json::from_str(&common::to_string(&bytes));
9954                        let response = common::to_response(parts, bytes.into());
9955
9956                        if let common::Retry::After(d) =
9957                            dlg.http_failure(&response, error.as_ref().ok())
9958                        {
9959                            sleep(d).await;
9960                            continue;
9961                        }
9962
9963                        dlg.finished(false);
9964
9965                        return Err(match error {
9966                            Ok(value) => common::Error::BadRequest(value),
9967                            _ => common::Error::Failure(response),
9968                        });
9969                    }
9970                    let response = {
9971                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9972                        let encoded = common::to_string(&bytes);
9973                        match serde_json::from_str(&encoded) {
9974                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9975                            Err(error) => {
9976                                dlg.response_json_decode_error(&encoded, &error);
9977                                return Err(common::Error::JsonDecodeError(
9978                                    encoded.to_string(),
9979                                    error,
9980                                ));
9981                            }
9982                        }
9983                    };
9984
9985                    dlg.finished(true);
9986                    return Ok(response);
9987                }
9988            }
9989        }
9990    }
9991
9992    /// Required. The resource name of the Secret to delete in the format `projects/*/secrets/*`.
9993    ///
9994    /// Sets the *name* path property to the given value.
9995    ///
9996    /// Even though the property as already been set when instantiating this call,
9997    /// we provide this method for API completeness.
9998    pub fn name(mut self, new_value: &str) -> ProjectSecretDeleteCall<'a, C> {
9999        self._name = new_value.to_string();
10000        self
10001    }
10002    /// Optional. Etag of the Secret. The request succeeds if it matches the etag of the currently stored secret object. If the etag is omitted, the request succeeds.
10003    ///
10004    /// Sets the *etag* query property to the given value.
10005    pub fn etag(mut self, new_value: &str) -> ProjectSecretDeleteCall<'a, C> {
10006        self._etag = Some(new_value.to_string());
10007        self
10008    }
10009    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10010    /// while executing the actual API request.
10011    ///
10012    /// ````text
10013    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10014    /// ````
10015    ///
10016    /// Sets the *delegate* property to the given value.
10017    pub fn delegate(
10018        mut self,
10019        new_value: &'a mut dyn common::Delegate,
10020    ) -> ProjectSecretDeleteCall<'a, C> {
10021        self._delegate = Some(new_value);
10022        self
10023    }
10024
10025    /// Set any additional parameter of the query string used in the request.
10026    /// It should be used to set parameters which are not yet available through their own
10027    /// setters.
10028    ///
10029    /// Please note that this method must not be used to set any of the known parameters
10030    /// which have their own setter method. If done anyway, the request will fail.
10031    ///
10032    /// # Additional Parameters
10033    ///
10034    /// * *$.xgafv* (query-string) - V1 error format.
10035    /// * *access_token* (query-string) - OAuth access token.
10036    /// * *alt* (query-string) - Data format for response.
10037    /// * *callback* (query-string) - JSONP
10038    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10039    /// * *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.
10040    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10041    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10042    /// * *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.
10043    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10044    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10045    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretDeleteCall<'a, C>
10046    where
10047        T: AsRef<str>,
10048    {
10049        self._additional_params
10050            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10051        self
10052    }
10053
10054    /// Identifies the authorization scope for the method you are building.
10055    ///
10056    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10057    /// [`Scope::CloudPlatform`].
10058    ///
10059    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10060    /// tokens for more than one scope.
10061    ///
10062    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10063    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10064    /// sufficient, a read-write scope will do as well.
10065    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretDeleteCall<'a, C>
10066    where
10067        St: AsRef<str>,
10068    {
10069        self._scopes.insert(String::from(scope.as_ref()));
10070        self
10071    }
10072    /// Identifies the authorization scope(s) for the method you are building.
10073    ///
10074    /// See [`Self::add_scope()`] for details.
10075    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretDeleteCall<'a, C>
10076    where
10077        I: IntoIterator<Item = St>,
10078        St: AsRef<str>,
10079    {
10080        self._scopes
10081            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10082        self
10083    }
10084
10085    /// Removes all scopes, and no default scope will be used either.
10086    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10087    /// for details).
10088    pub fn clear_scopes(mut self) -> ProjectSecretDeleteCall<'a, C> {
10089        self._scopes.clear();
10090        self
10091    }
10092}
10093
10094/// Gets metadata for a given Secret.
10095///
10096/// A builder for the *secrets.get* method supported by a *project* resource.
10097/// It is not used directly, but through a [`ProjectMethods`] instance.
10098///
10099/// # Example
10100///
10101/// Instantiate a resource method builder
10102///
10103/// ```test_harness,no_run
10104/// # extern crate hyper;
10105/// # extern crate hyper_rustls;
10106/// # extern crate google_secretmanager1 as secretmanager1;
10107/// # async fn dox() {
10108/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10109///
10110/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10111/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10112/// #     .with_native_roots()
10113/// #     .unwrap()
10114/// #     .https_only()
10115/// #     .enable_http2()
10116/// #     .build();
10117///
10118/// # let executor = hyper_util::rt::TokioExecutor::new();
10119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10120/// #     secret,
10121/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10122/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10123/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10124/// #     ),
10125/// # ).build().await.unwrap();
10126///
10127/// # let client = hyper_util::client::legacy::Client::builder(
10128/// #     hyper_util::rt::TokioExecutor::new()
10129/// # )
10130/// # .build(
10131/// #     hyper_rustls::HttpsConnectorBuilder::new()
10132/// #         .with_native_roots()
10133/// #         .unwrap()
10134/// #         .https_or_http()
10135/// #         .enable_http2()
10136/// #         .build()
10137/// # );
10138/// # let mut hub = SecretManager::new(client, auth);
10139/// // You can configure optional parameters by calling the respective setters at will, and
10140/// // execute the final call using `doit()`.
10141/// // Values shown here are possibly random and not representative !
10142/// let result = hub.projects().secrets_get("name")
10143///              .doit().await;
10144/// # }
10145/// ```
10146pub struct ProjectSecretGetCall<'a, C>
10147where
10148    C: 'a,
10149{
10150    hub: &'a SecretManager<C>,
10151    _name: String,
10152    _delegate: Option<&'a mut dyn common::Delegate>,
10153    _additional_params: HashMap<String, String>,
10154    _scopes: BTreeSet<String>,
10155}
10156
10157impl<'a, C> common::CallBuilder for ProjectSecretGetCall<'a, C> {}
10158
10159impl<'a, C> ProjectSecretGetCall<'a, C>
10160where
10161    C: common::Connector,
10162{
10163    /// Perform the operation you have build so far.
10164    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
10165        use std::borrow::Cow;
10166        use std::io::{Read, Seek};
10167
10168        use common::{url::Params, ToParts};
10169        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10170
10171        let mut dd = common::DefaultDelegate;
10172        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10173        dlg.begin(common::MethodInfo {
10174            id: "secretmanager.projects.secrets.get",
10175            http_method: hyper::Method::GET,
10176        });
10177
10178        for &field in ["alt", "name"].iter() {
10179            if self._additional_params.contains_key(field) {
10180                dlg.finished(false);
10181                return Err(common::Error::FieldClash(field));
10182            }
10183        }
10184
10185        let mut params = Params::with_capacity(3 + self._additional_params.len());
10186        params.push("name", self._name);
10187
10188        params.extend(self._additional_params.iter());
10189
10190        params.push("alt", "json");
10191        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10192        if self._scopes.is_empty() {
10193            self._scopes
10194                .insert(Scope::CloudPlatform.as_ref().to_string());
10195        }
10196
10197        #[allow(clippy::single_element_loop)]
10198        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10199            url = params.uri_replacement(url, param_name, find_this, true);
10200        }
10201        {
10202            let to_remove = ["name"];
10203            params.remove_params(&to_remove);
10204        }
10205
10206        let url = params.parse_with_url(&url);
10207
10208        loop {
10209            let token = match self
10210                .hub
10211                .auth
10212                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10213                .await
10214            {
10215                Ok(token) => token,
10216                Err(e) => match dlg.token(e) {
10217                    Ok(token) => token,
10218                    Err(e) => {
10219                        dlg.finished(false);
10220                        return Err(common::Error::MissingToken(e));
10221                    }
10222                },
10223            };
10224            let mut req_result = {
10225                let client = &self.hub.client;
10226                dlg.pre_request();
10227                let mut req_builder = hyper::Request::builder()
10228                    .method(hyper::Method::GET)
10229                    .uri(url.as_str())
10230                    .header(USER_AGENT, self.hub._user_agent.clone());
10231
10232                if let Some(token) = token.as_ref() {
10233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10234                }
10235
10236                let request = req_builder
10237                    .header(CONTENT_LENGTH, 0_u64)
10238                    .body(common::to_body::<String>(None));
10239
10240                client.request(request.unwrap()).await
10241            };
10242
10243            match req_result {
10244                Err(err) => {
10245                    if let common::Retry::After(d) = dlg.http_error(&err) {
10246                        sleep(d).await;
10247                        continue;
10248                    }
10249                    dlg.finished(false);
10250                    return Err(common::Error::HttpError(err));
10251                }
10252                Ok(res) => {
10253                    let (mut parts, body) = res.into_parts();
10254                    let mut body = common::Body::new(body);
10255                    if !parts.status.is_success() {
10256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10257                        let error = serde_json::from_str(&common::to_string(&bytes));
10258                        let response = common::to_response(parts, bytes.into());
10259
10260                        if let common::Retry::After(d) =
10261                            dlg.http_failure(&response, error.as_ref().ok())
10262                        {
10263                            sleep(d).await;
10264                            continue;
10265                        }
10266
10267                        dlg.finished(false);
10268
10269                        return Err(match error {
10270                            Ok(value) => common::Error::BadRequest(value),
10271                            _ => common::Error::Failure(response),
10272                        });
10273                    }
10274                    let response = {
10275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10276                        let encoded = common::to_string(&bytes);
10277                        match serde_json::from_str(&encoded) {
10278                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10279                            Err(error) => {
10280                                dlg.response_json_decode_error(&encoded, &error);
10281                                return Err(common::Error::JsonDecodeError(
10282                                    encoded.to_string(),
10283                                    error,
10284                                ));
10285                            }
10286                        }
10287                    };
10288
10289                    dlg.finished(true);
10290                    return Ok(response);
10291                }
10292            }
10293        }
10294    }
10295
10296    /// Required. The resource name of the Secret, in the format `projects/*/secrets/*` or `projects/*/locations/*/secrets/*`.
10297    ///
10298    /// Sets the *name* path property to the given value.
10299    ///
10300    /// Even though the property as already been set when instantiating this call,
10301    /// we provide this method for API completeness.
10302    pub fn name(mut self, new_value: &str) -> ProjectSecretGetCall<'a, C> {
10303        self._name = new_value.to_string();
10304        self
10305    }
10306    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10307    /// while executing the actual API request.
10308    ///
10309    /// ````text
10310    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10311    /// ````
10312    ///
10313    /// Sets the *delegate* property to the given value.
10314    pub fn delegate(
10315        mut self,
10316        new_value: &'a mut dyn common::Delegate,
10317    ) -> ProjectSecretGetCall<'a, C> {
10318        self._delegate = Some(new_value);
10319        self
10320    }
10321
10322    /// Set any additional parameter of the query string used in the request.
10323    /// It should be used to set parameters which are not yet available through their own
10324    /// setters.
10325    ///
10326    /// Please note that this method must not be used to set any of the known parameters
10327    /// which have their own setter method. If done anyway, the request will fail.
10328    ///
10329    /// # Additional Parameters
10330    ///
10331    /// * *$.xgafv* (query-string) - V1 error format.
10332    /// * *access_token* (query-string) - OAuth access token.
10333    /// * *alt* (query-string) - Data format for response.
10334    /// * *callback* (query-string) - JSONP
10335    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10336    /// * *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.
10337    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10338    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10339    /// * *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.
10340    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10341    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10342    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretGetCall<'a, C>
10343    where
10344        T: AsRef<str>,
10345    {
10346        self._additional_params
10347            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10348        self
10349    }
10350
10351    /// Identifies the authorization scope for the method you are building.
10352    ///
10353    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10354    /// [`Scope::CloudPlatform`].
10355    ///
10356    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10357    /// tokens for more than one scope.
10358    ///
10359    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10360    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10361    /// sufficient, a read-write scope will do as well.
10362    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretGetCall<'a, C>
10363    where
10364        St: AsRef<str>,
10365    {
10366        self._scopes.insert(String::from(scope.as_ref()));
10367        self
10368    }
10369    /// Identifies the authorization scope(s) for the method you are building.
10370    ///
10371    /// See [`Self::add_scope()`] for details.
10372    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretGetCall<'a, C>
10373    where
10374        I: IntoIterator<Item = St>,
10375        St: AsRef<str>,
10376    {
10377        self._scopes
10378            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10379        self
10380    }
10381
10382    /// Removes all scopes, and no default scope will be used either.
10383    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10384    /// for details).
10385    pub fn clear_scopes(mut self) -> ProjectSecretGetCall<'a, C> {
10386        self._scopes.clear();
10387        self
10388    }
10389}
10390
10391/// Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.
10392///
10393/// A builder for the *secrets.getIamPolicy* method supported by a *project* resource.
10394/// It is not used directly, but through a [`ProjectMethods`] instance.
10395///
10396/// # Example
10397///
10398/// Instantiate a resource method builder
10399///
10400/// ```test_harness,no_run
10401/// # extern crate hyper;
10402/// # extern crate hyper_rustls;
10403/// # extern crate google_secretmanager1 as secretmanager1;
10404/// # async fn dox() {
10405/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10406///
10407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10408/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10409/// #     .with_native_roots()
10410/// #     .unwrap()
10411/// #     .https_only()
10412/// #     .enable_http2()
10413/// #     .build();
10414///
10415/// # let executor = hyper_util::rt::TokioExecutor::new();
10416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10417/// #     secret,
10418/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10419/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10420/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10421/// #     ),
10422/// # ).build().await.unwrap();
10423///
10424/// # let client = hyper_util::client::legacy::Client::builder(
10425/// #     hyper_util::rt::TokioExecutor::new()
10426/// # )
10427/// # .build(
10428/// #     hyper_rustls::HttpsConnectorBuilder::new()
10429/// #         .with_native_roots()
10430/// #         .unwrap()
10431/// #         .https_or_http()
10432/// #         .enable_http2()
10433/// #         .build()
10434/// # );
10435/// # let mut hub = SecretManager::new(client, auth);
10436/// // You can configure optional parameters by calling the respective setters at will, and
10437/// // execute the final call using `doit()`.
10438/// // Values shown here are possibly random and not representative !
10439/// let result = hub.projects().secrets_get_iam_policy("resource")
10440///              .options_requested_policy_version(-31)
10441///              .doit().await;
10442/// # }
10443/// ```
10444pub struct ProjectSecretGetIamPolicyCall<'a, C>
10445where
10446    C: 'a,
10447{
10448    hub: &'a SecretManager<C>,
10449    _resource: String,
10450    _options_requested_policy_version: Option<i32>,
10451    _delegate: Option<&'a mut dyn common::Delegate>,
10452    _additional_params: HashMap<String, String>,
10453    _scopes: BTreeSet<String>,
10454}
10455
10456impl<'a, C> common::CallBuilder for ProjectSecretGetIamPolicyCall<'a, C> {}
10457
10458impl<'a, C> ProjectSecretGetIamPolicyCall<'a, C>
10459where
10460    C: common::Connector,
10461{
10462    /// Perform the operation you have build so far.
10463    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10464        use std::borrow::Cow;
10465        use std::io::{Read, Seek};
10466
10467        use common::{url::Params, ToParts};
10468        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10469
10470        let mut dd = common::DefaultDelegate;
10471        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10472        dlg.begin(common::MethodInfo {
10473            id: "secretmanager.projects.secrets.getIamPolicy",
10474            http_method: hyper::Method::GET,
10475        });
10476
10477        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
10478            if self._additional_params.contains_key(field) {
10479                dlg.finished(false);
10480                return Err(common::Error::FieldClash(field));
10481            }
10482        }
10483
10484        let mut params = Params::with_capacity(4 + self._additional_params.len());
10485        params.push("resource", self._resource);
10486        if let Some(value) = self._options_requested_policy_version.as_ref() {
10487            params.push("options.requestedPolicyVersion", value.to_string());
10488        }
10489
10490        params.extend(self._additional_params.iter());
10491
10492        params.push("alt", "json");
10493        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
10494        if self._scopes.is_empty() {
10495            self._scopes
10496                .insert(Scope::CloudPlatform.as_ref().to_string());
10497        }
10498
10499        #[allow(clippy::single_element_loop)]
10500        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10501            url = params.uri_replacement(url, param_name, find_this, true);
10502        }
10503        {
10504            let to_remove = ["resource"];
10505            params.remove_params(&to_remove);
10506        }
10507
10508        let url = params.parse_with_url(&url);
10509
10510        loop {
10511            let token = match self
10512                .hub
10513                .auth
10514                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10515                .await
10516            {
10517                Ok(token) => token,
10518                Err(e) => match dlg.token(e) {
10519                    Ok(token) => token,
10520                    Err(e) => {
10521                        dlg.finished(false);
10522                        return Err(common::Error::MissingToken(e));
10523                    }
10524                },
10525            };
10526            let mut req_result = {
10527                let client = &self.hub.client;
10528                dlg.pre_request();
10529                let mut req_builder = hyper::Request::builder()
10530                    .method(hyper::Method::GET)
10531                    .uri(url.as_str())
10532                    .header(USER_AGENT, self.hub._user_agent.clone());
10533
10534                if let Some(token) = token.as_ref() {
10535                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10536                }
10537
10538                let request = req_builder
10539                    .header(CONTENT_LENGTH, 0_u64)
10540                    .body(common::to_body::<String>(None));
10541
10542                client.request(request.unwrap()).await
10543            };
10544
10545            match req_result {
10546                Err(err) => {
10547                    if let common::Retry::After(d) = dlg.http_error(&err) {
10548                        sleep(d).await;
10549                        continue;
10550                    }
10551                    dlg.finished(false);
10552                    return Err(common::Error::HttpError(err));
10553                }
10554                Ok(res) => {
10555                    let (mut parts, body) = res.into_parts();
10556                    let mut body = common::Body::new(body);
10557                    if !parts.status.is_success() {
10558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10559                        let error = serde_json::from_str(&common::to_string(&bytes));
10560                        let response = common::to_response(parts, bytes.into());
10561
10562                        if let common::Retry::After(d) =
10563                            dlg.http_failure(&response, error.as_ref().ok())
10564                        {
10565                            sleep(d).await;
10566                            continue;
10567                        }
10568
10569                        dlg.finished(false);
10570
10571                        return Err(match error {
10572                            Ok(value) => common::Error::BadRequest(value),
10573                            _ => common::Error::Failure(response),
10574                        });
10575                    }
10576                    let response = {
10577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10578                        let encoded = common::to_string(&bytes);
10579                        match serde_json::from_str(&encoded) {
10580                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10581                            Err(error) => {
10582                                dlg.response_json_decode_error(&encoded, &error);
10583                                return Err(common::Error::JsonDecodeError(
10584                                    encoded.to_string(),
10585                                    error,
10586                                ));
10587                            }
10588                        }
10589                    };
10590
10591                    dlg.finished(true);
10592                    return Ok(response);
10593                }
10594            }
10595        }
10596    }
10597
10598    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
10599    ///
10600    /// Sets the *resource* path property to the given value.
10601    ///
10602    /// Even though the property as already been set when instantiating this call,
10603    /// we provide this method for API completeness.
10604    pub fn resource(mut self, new_value: &str) -> ProjectSecretGetIamPolicyCall<'a, C> {
10605        self._resource = new_value.to_string();
10606        self
10607    }
10608    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
10609    ///
10610    /// Sets the *options.requested policy version* query property to the given value.
10611    pub fn options_requested_policy_version(
10612        mut self,
10613        new_value: i32,
10614    ) -> ProjectSecretGetIamPolicyCall<'a, C> {
10615        self._options_requested_policy_version = Some(new_value);
10616        self
10617    }
10618    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10619    /// while executing the actual API request.
10620    ///
10621    /// ````text
10622    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10623    /// ````
10624    ///
10625    /// Sets the *delegate* property to the given value.
10626    pub fn delegate(
10627        mut self,
10628        new_value: &'a mut dyn common::Delegate,
10629    ) -> ProjectSecretGetIamPolicyCall<'a, C> {
10630        self._delegate = Some(new_value);
10631        self
10632    }
10633
10634    /// Set any additional parameter of the query string used in the request.
10635    /// It should be used to set parameters which are not yet available through their own
10636    /// setters.
10637    ///
10638    /// Please note that this method must not be used to set any of the known parameters
10639    /// which have their own setter method. If done anyway, the request will fail.
10640    ///
10641    /// # Additional Parameters
10642    ///
10643    /// * *$.xgafv* (query-string) - V1 error format.
10644    /// * *access_token* (query-string) - OAuth access token.
10645    /// * *alt* (query-string) - Data format for response.
10646    /// * *callback* (query-string) - JSONP
10647    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10648    /// * *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.
10649    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10650    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10651    /// * *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.
10652    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10653    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10654    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretGetIamPolicyCall<'a, C>
10655    where
10656        T: AsRef<str>,
10657    {
10658        self._additional_params
10659            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10660        self
10661    }
10662
10663    /// Identifies the authorization scope for the method you are building.
10664    ///
10665    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10666    /// [`Scope::CloudPlatform`].
10667    ///
10668    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10669    /// tokens for more than one scope.
10670    ///
10671    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10672    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10673    /// sufficient, a read-write scope will do as well.
10674    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretGetIamPolicyCall<'a, C>
10675    where
10676        St: AsRef<str>,
10677    {
10678        self._scopes.insert(String::from(scope.as_ref()));
10679        self
10680    }
10681    /// Identifies the authorization scope(s) for the method you are building.
10682    ///
10683    /// See [`Self::add_scope()`] for details.
10684    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretGetIamPolicyCall<'a, C>
10685    where
10686        I: IntoIterator<Item = St>,
10687        St: AsRef<str>,
10688    {
10689        self._scopes
10690            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10691        self
10692    }
10693
10694    /// Removes all scopes, and no default scope will be used either.
10695    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10696    /// for details).
10697    pub fn clear_scopes(mut self) -> ProjectSecretGetIamPolicyCall<'a, C> {
10698        self._scopes.clear();
10699        self
10700    }
10701}
10702
10703/// Lists Secrets.
10704///
10705/// A builder for the *secrets.list* method supported by a *project* resource.
10706/// It is not used directly, but through a [`ProjectMethods`] instance.
10707///
10708/// # Example
10709///
10710/// Instantiate a resource method builder
10711///
10712/// ```test_harness,no_run
10713/// # extern crate hyper;
10714/// # extern crate hyper_rustls;
10715/// # extern crate google_secretmanager1 as secretmanager1;
10716/// # async fn dox() {
10717/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10718///
10719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10720/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10721/// #     .with_native_roots()
10722/// #     .unwrap()
10723/// #     .https_only()
10724/// #     .enable_http2()
10725/// #     .build();
10726///
10727/// # let executor = hyper_util::rt::TokioExecutor::new();
10728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10729/// #     secret,
10730/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10731/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10732/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10733/// #     ),
10734/// # ).build().await.unwrap();
10735///
10736/// # let client = hyper_util::client::legacy::Client::builder(
10737/// #     hyper_util::rt::TokioExecutor::new()
10738/// # )
10739/// # .build(
10740/// #     hyper_rustls::HttpsConnectorBuilder::new()
10741/// #         .with_native_roots()
10742/// #         .unwrap()
10743/// #         .https_or_http()
10744/// #         .enable_http2()
10745/// #         .build()
10746/// # );
10747/// # let mut hub = SecretManager::new(client, auth);
10748/// // You can configure optional parameters by calling the respective setters at will, and
10749/// // execute the final call using `doit()`.
10750/// // Values shown here are possibly random and not representative !
10751/// let result = hub.projects().secrets_list("parent")
10752///              .page_token("duo")
10753///              .page_size(-34)
10754///              .filter("et")
10755///              .doit().await;
10756/// # }
10757/// ```
10758pub struct ProjectSecretListCall<'a, C>
10759where
10760    C: 'a,
10761{
10762    hub: &'a SecretManager<C>,
10763    _parent: String,
10764    _page_token: Option<String>,
10765    _page_size: Option<i32>,
10766    _filter: Option<String>,
10767    _delegate: Option<&'a mut dyn common::Delegate>,
10768    _additional_params: HashMap<String, String>,
10769    _scopes: BTreeSet<String>,
10770}
10771
10772impl<'a, C> common::CallBuilder for ProjectSecretListCall<'a, C> {}
10773
10774impl<'a, C> ProjectSecretListCall<'a, C>
10775where
10776    C: common::Connector,
10777{
10778    /// Perform the operation you have build so far.
10779    pub async fn doit(mut self) -> common::Result<(common::Response, ListSecretsResponse)> {
10780        use std::borrow::Cow;
10781        use std::io::{Read, Seek};
10782
10783        use common::{url::Params, ToParts};
10784        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10785
10786        let mut dd = common::DefaultDelegate;
10787        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10788        dlg.begin(common::MethodInfo {
10789            id: "secretmanager.projects.secrets.list",
10790            http_method: hyper::Method::GET,
10791        });
10792
10793        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10794            if self._additional_params.contains_key(field) {
10795                dlg.finished(false);
10796                return Err(common::Error::FieldClash(field));
10797            }
10798        }
10799
10800        let mut params = Params::with_capacity(6 + self._additional_params.len());
10801        params.push("parent", self._parent);
10802        if let Some(value) = self._page_token.as_ref() {
10803            params.push("pageToken", value);
10804        }
10805        if let Some(value) = self._page_size.as_ref() {
10806            params.push("pageSize", value.to_string());
10807        }
10808        if let Some(value) = self._filter.as_ref() {
10809            params.push("filter", value);
10810        }
10811
10812        params.extend(self._additional_params.iter());
10813
10814        params.push("alt", "json");
10815        let mut url = self.hub._base_url.clone() + "v1/{+parent}/secrets";
10816        if self._scopes.is_empty() {
10817            self._scopes
10818                .insert(Scope::CloudPlatform.as_ref().to_string());
10819        }
10820
10821        #[allow(clippy::single_element_loop)]
10822        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10823            url = params.uri_replacement(url, param_name, find_this, true);
10824        }
10825        {
10826            let to_remove = ["parent"];
10827            params.remove_params(&to_remove);
10828        }
10829
10830        let url = params.parse_with_url(&url);
10831
10832        loop {
10833            let token = match self
10834                .hub
10835                .auth
10836                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10837                .await
10838            {
10839                Ok(token) => token,
10840                Err(e) => match dlg.token(e) {
10841                    Ok(token) => token,
10842                    Err(e) => {
10843                        dlg.finished(false);
10844                        return Err(common::Error::MissingToken(e));
10845                    }
10846                },
10847            };
10848            let mut req_result = {
10849                let client = &self.hub.client;
10850                dlg.pre_request();
10851                let mut req_builder = hyper::Request::builder()
10852                    .method(hyper::Method::GET)
10853                    .uri(url.as_str())
10854                    .header(USER_AGENT, self.hub._user_agent.clone());
10855
10856                if let Some(token) = token.as_ref() {
10857                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10858                }
10859
10860                let request = req_builder
10861                    .header(CONTENT_LENGTH, 0_u64)
10862                    .body(common::to_body::<String>(None));
10863
10864                client.request(request.unwrap()).await
10865            };
10866
10867            match req_result {
10868                Err(err) => {
10869                    if let common::Retry::After(d) = dlg.http_error(&err) {
10870                        sleep(d).await;
10871                        continue;
10872                    }
10873                    dlg.finished(false);
10874                    return Err(common::Error::HttpError(err));
10875                }
10876                Ok(res) => {
10877                    let (mut parts, body) = res.into_parts();
10878                    let mut body = common::Body::new(body);
10879                    if !parts.status.is_success() {
10880                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10881                        let error = serde_json::from_str(&common::to_string(&bytes));
10882                        let response = common::to_response(parts, bytes.into());
10883
10884                        if let common::Retry::After(d) =
10885                            dlg.http_failure(&response, error.as_ref().ok())
10886                        {
10887                            sleep(d).await;
10888                            continue;
10889                        }
10890
10891                        dlg.finished(false);
10892
10893                        return Err(match error {
10894                            Ok(value) => common::Error::BadRequest(value),
10895                            _ => common::Error::Failure(response),
10896                        });
10897                    }
10898                    let response = {
10899                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10900                        let encoded = common::to_string(&bytes);
10901                        match serde_json::from_str(&encoded) {
10902                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10903                            Err(error) => {
10904                                dlg.response_json_decode_error(&encoded, &error);
10905                                return Err(common::Error::JsonDecodeError(
10906                                    encoded.to_string(),
10907                                    error,
10908                                ));
10909                            }
10910                        }
10911                    };
10912
10913                    dlg.finished(true);
10914                    return Ok(response);
10915                }
10916            }
10917        }
10918    }
10919
10920    /// Required. The resource name of the project associated with the Secrets, in the format `projects/*` or `projects/*/locations/*`
10921    ///
10922    /// Sets the *parent* path property to the given value.
10923    ///
10924    /// Even though the property as already been set when instantiating this call,
10925    /// we provide this method for API completeness.
10926    pub fn parent(mut self, new_value: &str) -> ProjectSecretListCall<'a, C> {
10927        self._parent = new_value.to_string();
10928        self
10929    }
10930    /// Optional. Pagination token, returned earlier via ListSecretsResponse.next_page_token.
10931    ///
10932    /// Sets the *page token* query property to the given value.
10933    pub fn page_token(mut self, new_value: &str) -> ProjectSecretListCall<'a, C> {
10934        self._page_token = Some(new_value.to_string());
10935        self
10936    }
10937    /// Optional. The maximum number of results to be returned in a single page. If set to 0, the server decides the number of results to return. If the number is greater than 25000, it is capped at 25000.
10938    ///
10939    /// Sets the *page size* query property to the given value.
10940    pub fn page_size(mut self, new_value: i32) -> ProjectSecretListCall<'a, C> {
10941        self._page_size = Some(new_value);
10942        self
10943    }
10944    /// Optional. Filter string, adhering to the rules in [List-operation filtering](https://cloud.google.com/secret-manager/docs/filtering). List only secrets matching the filter. If filter is empty, all secrets are listed.
10945    ///
10946    /// Sets the *filter* query property to the given value.
10947    pub fn filter(mut self, new_value: &str) -> ProjectSecretListCall<'a, C> {
10948        self._filter = Some(new_value.to_string());
10949        self
10950    }
10951    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10952    /// while executing the actual API request.
10953    ///
10954    /// ````text
10955    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10956    /// ````
10957    ///
10958    /// Sets the *delegate* property to the given value.
10959    pub fn delegate(
10960        mut self,
10961        new_value: &'a mut dyn common::Delegate,
10962    ) -> ProjectSecretListCall<'a, C> {
10963        self._delegate = Some(new_value);
10964        self
10965    }
10966
10967    /// Set any additional parameter of the query string used in the request.
10968    /// It should be used to set parameters which are not yet available through their own
10969    /// setters.
10970    ///
10971    /// Please note that this method must not be used to set any of the known parameters
10972    /// which have their own setter method. If done anyway, the request will fail.
10973    ///
10974    /// # Additional Parameters
10975    ///
10976    /// * *$.xgafv* (query-string) - V1 error format.
10977    /// * *access_token* (query-string) - OAuth access token.
10978    /// * *alt* (query-string) - Data format for response.
10979    /// * *callback* (query-string) - JSONP
10980    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10981    /// * *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.
10982    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10983    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10984    /// * *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.
10985    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10986    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10987    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretListCall<'a, C>
10988    where
10989        T: AsRef<str>,
10990    {
10991        self._additional_params
10992            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10993        self
10994    }
10995
10996    /// Identifies the authorization scope for the method you are building.
10997    ///
10998    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10999    /// [`Scope::CloudPlatform`].
11000    ///
11001    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11002    /// tokens for more than one scope.
11003    ///
11004    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11005    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11006    /// sufficient, a read-write scope will do as well.
11007    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretListCall<'a, C>
11008    where
11009        St: AsRef<str>,
11010    {
11011        self._scopes.insert(String::from(scope.as_ref()));
11012        self
11013    }
11014    /// Identifies the authorization scope(s) for the method you are building.
11015    ///
11016    /// See [`Self::add_scope()`] for details.
11017    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretListCall<'a, C>
11018    where
11019        I: IntoIterator<Item = St>,
11020        St: AsRef<str>,
11021    {
11022        self._scopes
11023            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11024        self
11025    }
11026
11027    /// Removes all scopes, and no default scope will be used either.
11028    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11029    /// for details).
11030    pub fn clear_scopes(mut self) -> ProjectSecretListCall<'a, C> {
11031        self._scopes.clear();
11032        self
11033    }
11034}
11035
11036/// Updates metadata of an existing Secret.
11037///
11038/// A builder for the *secrets.patch* method supported by a *project* resource.
11039/// It is not used directly, but through a [`ProjectMethods`] instance.
11040///
11041/// # Example
11042///
11043/// Instantiate a resource method builder
11044///
11045/// ```test_harness,no_run
11046/// # extern crate hyper;
11047/// # extern crate hyper_rustls;
11048/// # extern crate google_secretmanager1 as secretmanager1;
11049/// use secretmanager1::api::Secret;
11050/// # async fn dox() {
11051/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11052///
11053/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11054/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11055/// #     .with_native_roots()
11056/// #     .unwrap()
11057/// #     .https_only()
11058/// #     .enable_http2()
11059/// #     .build();
11060///
11061/// # let executor = hyper_util::rt::TokioExecutor::new();
11062/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11063/// #     secret,
11064/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11065/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11066/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11067/// #     ),
11068/// # ).build().await.unwrap();
11069///
11070/// # let client = hyper_util::client::legacy::Client::builder(
11071/// #     hyper_util::rt::TokioExecutor::new()
11072/// # )
11073/// # .build(
11074/// #     hyper_rustls::HttpsConnectorBuilder::new()
11075/// #         .with_native_roots()
11076/// #         .unwrap()
11077/// #         .https_or_http()
11078/// #         .enable_http2()
11079/// #         .build()
11080/// # );
11081/// # let mut hub = SecretManager::new(client, auth);
11082/// // As the method needs a request, you would usually fill it with the desired information
11083/// // into the respective structure. Some of the parts shown here might not be applicable !
11084/// // Values shown here are possibly random and not representative !
11085/// let mut req = Secret::default();
11086///
11087/// // You can configure optional parameters by calling the respective setters at will, and
11088/// // execute the final call using `doit()`.
11089/// // Values shown here are possibly random and not representative !
11090/// let result = hub.projects().secrets_patch(req, "name")
11091///              .update_mask(FieldMask::new::<&str>(&[]))
11092///              .doit().await;
11093/// # }
11094/// ```
11095pub struct ProjectSecretPatchCall<'a, C>
11096where
11097    C: 'a,
11098{
11099    hub: &'a SecretManager<C>,
11100    _request: Secret,
11101    _name: String,
11102    _update_mask: Option<common::FieldMask>,
11103    _delegate: Option<&'a mut dyn common::Delegate>,
11104    _additional_params: HashMap<String, String>,
11105    _scopes: BTreeSet<String>,
11106}
11107
11108impl<'a, C> common::CallBuilder for ProjectSecretPatchCall<'a, C> {}
11109
11110impl<'a, C> ProjectSecretPatchCall<'a, C>
11111where
11112    C: common::Connector,
11113{
11114    /// Perform the operation you have build so far.
11115    pub async fn doit(mut self) -> common::Result<(common::Response, Secret)> {
11116        use std::borrow::Cow;
11117        use std::io::{Read, Seek};
11118
11119        use common::{url::Params, ToParts};
11120        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11121
11122        let mut dd = common::DefaultDelegate;
11123        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11124        dlg.begin(common::MethodInfo {
11125            id: "secretmanager.projects.secrets.patch",
11126            http_method: hyper::Method::PATCH,
11127        });
11128
11129        for &field in ["alt", "name", "updateMask"].iter() {
11130            if self._additional_params.contains_key(field) {
11131                dlg.finished(false);
11132                return Err(common::Error::FieldClash(field));
11133            }
11134        }
11135
11136        let mut params = Params::with_capacity(5 + self._additional_params.len());
11137        params.push("name", self._name);
11138        if let Some(value) = self._update_mask.as_ref() {
11139            params.push("updateMask", value.to_string());
11140        }
11141
11142        params.extend(self._additional_params.iter());
11143
11144        params.push("alt", "json");
11145        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11146        if self._scopes.is_empty() {
11147            self._scopes
11148                .insert(Scope::CloudPlatform.as_ref().to_string());
11149        }
11150
11151        #[allow(clippy::single_element_loop)]
11152        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11153            url = params.uri_replacement(url, param_name, find_this, true);
11154        }
11155        {
11156            let to_remove = ["name"];
11157            params.remove_params(&to_remove);
11158        }
11159
11160        let url = params.parse_with_url(&url);
11161
11162        let mut json_mime_type = mime::APPLICATION_JSON;
11163        let mut request_value_reader = {
11164            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11165            common::remove_json_null_values(&mut value);
11166            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11167            serde_json::to_writer(&mut dst, &value).unwrap();
11168            dst
11169        };
11170        let request_size = request_value_reader
11171            .seek(std::io::SeekFrom::End(0))
11172            .unwrap();
11173        request_value_reader
11174            .seek(std::io::SeekFrom::Start(0))
11175            .unwrap();
11176
11177        loop {
11178            let token = match self
11179                .hub
11180                .auth
11181                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11182                .await
11183            {
11184                Ok(token) => token,
11185                Err(e) => match dlg.token(e) {
11186                    Ok(token) => token,
11187                    Err(e) => {
11188                        dlg.finished(false);
11189                        return Err(common::Error::MissingToken(e));
11190                    }
11191                },
11192            };
11193            request_value_reader
11194                .seek(std::io::SeekFrom::Start(0))
11195                .unwrap();
11196            let mut req_result = {
11197                let client = &self.hub.client;
11198                dlg.pre_request();
11199                let mut req_builder = hyper::Request::builder()
11200                    .method(hyper::Method::PATCH)
11201                    .uri(url.as_str())
11202                    .header(USER_AGENT, self.hub._user_agent.clone());
11203
11204                if let Some(token) = token.as_ref() {
11205                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11206                }
11207
11208                let request = req_builder
11209                    .header(CONTENT_TYPE, json_mime_type.to_string())
11210                    .header(CONTENT_LENGTH, request_size as u64)
11211                    .body(common::to_body(
11212                        request_value_reader.get_ref().clone().into(),
11213                    ));
11214
11215                client.request(request.unwrap()).await
11216            };
11217
11218            match req_result {
11219                Err(err) => {
11220                    if let common::Retry::After(d) = dlg.http_error(&err) {
11221                        sleep(d).await;
11222                        continue;
11223                    }
11224                    dlg.finished(false);
11225                    return Err(common::Error::HttpError(err));
11226                }
11227                Ok(res) => {
11228                    let (mut parts, body) = res.into_parts();
11229                    let mut body = common::Body::new(body);
11230                    if !parts.status.is_success() {
11231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11232                        let error = serde_json::from_str(&common::to_string(&bytes));
11233                        let response = common::to_response(parts, bytes.into());
11234
11235                        if let common::Retry::After(d) =
11236                            dlg.http_failure(&response, error.as_ref().ok())
11237                        {
11238                            sleep(d).await;
11239                            continue;
11240                        }
11241
11242                        dlg.finished(false);
11243
11244                        return Err(match error {
11245                            Ok(value) => common::Error::BadRequest(value),
11246                            _ => common::Error::Failure(response),
11247                        });
11248                    }
11249                    let response = {
11250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11251                        let encoded = common::to_string(&bytes);
11252                        match serde_json::from_str(&encoded) {
11253                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11254                            Err(error) => {
11255                                dlg.response_json_decode_error(&encoded, &error);
11256                                return Err(common::Error::JsonDecodeError(
11257                                    encoded.to_string(),
11258                                    error,
11259                                ));
11260                            }
11261                        }
11262                    };
11263
11264                    dlg.finished(true);
11265                    return Ok(response);
11266                }
11267            }
11268        }
11269    }
11270
11271    ///
11272    /// Sets the *request* property to the given value.
11273    ///
11274    /// Even though the property as already been set when instantiating this call,
11275    /// we provide this method for API completeness.
11276    pub fn request(mut self, new_value: Secret) -> ProjectSecretPatchCall<'a, C> {
11277        self._request = new_value;
11278        self
11279    }
11280    /// Output only. The resource name of the Secret in the format `projects/*/secrets/*`.
11281    ///
11282    /// Sets the *name* path property to the given value.
11283    ///
11284    /// Even though the property as already been set when instantiating this call,
11285    /// we provide this method for API completeness.
11286    pub fn name(mut self, new_value: &str) -> ProjectSecretPatchCall<'a, C> {
11287        self._name = new_value.to_string();
11288        self
11289    }
11290    /// Required. Specifies the fields to be updated.
11291    ///
11292    /// Sets the *update mask* query property to the given value.
11293    pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectSecretPatchCall<'a, C> {
11294        self._update_mask = Some(new_value);
11295        self
11296    }
11297    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11298    /// while executing the actual API request.
11299    ///
11300    /// ````text
11301    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11302    /// ````
11303    ///
11304    /// Sets the *delegate* property to the given value.
11305    pub fn delegate(
11306        mut self,
11307        new_value: &'a mut dyn common::Delegate,
11308    ) -> ProjectSecretPatchCall<'a, C> {
11309        self._delegate = Some(new_value);
11310        self
11311    }
11312
11313    /// Set any additional parameter of the query string used in the request.
11314    /// It should be used to set parameters which are not yet available through their own
11315    /// setters.
11316    ///
11317    /// Please note that this method must not be used to set any of the known parameters
11318    /// which have their own setter method. If done anyway, the request will fail.
11319    ///
11320    /// # Additional Parameters
11321    ///
11322    /// * *$.xgafv* (query-string) - V1 error format.
11323    /// * *access_token* (query-string) - OAuth access token.
11324    /// * *alt* (query-string) - Data format for response.
11325    /// * *callback* (query-string) - JSONP
11326    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11327    /// * *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.
11328    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11329    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11330    /// * *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.
11331    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11332    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11333    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretPatchCall<'a, C>
11334    where
11335        T: AsRef<str>,
11336    {
11337        self._additional_params
11338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11339        self
11340    }
11341
11342    /// Identifies the authorization scope for the method you are building.
11343    ///
11344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11345    /// [`Scope::CloudPlatform`].
11346    ///
11347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11348    /// tokens for more than one scope.
11349    ///
11350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11352    /// sufficient, a read-write scope will do as well.
11353    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretPatchCall<'a, C>
11354    where
11355        St: AsRef<str>,
11356    {
11357        self._scopes.insert(String::from(scope.as_ref()));
11358        self
11359    }
11360    /// Identifies the authorization scope(s) for the method you are building.
11361    ///
11362    /// See [`Self::add_scope()`] for details.
11363    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretPatchCall<'a, C>
11364    where
11365        I: IntoIterator<Item = St>,
11366        St: AsRef<str>,
11367    {
11368        self._scopes
11369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11370        self
11371    }
11372
11373    /// Removes all scopes, and no default scope will be used either.
11374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11375    /// for details).
11376    pub fn clear_scopes(mut self) -> ProjectSecretPatchCall<'a, C> {
11377        self._scopes.clear();
11378        self
11379    }
11380}
11381
11382/// Sets the access control policy on the specified secret. Replaces any existing policy. Permissions on SecretVersions are enforced according to the policy set on the associated Secret.
11383///
11384/// A builder for the *secrets.setIamPolicy* method supported by a *project* resource.
11385/// It is not used directly, but through a [`ProjectMethods`] instance.
11386///
11387/// # Example
11388///
11389/// Instantiate a resource method builder
11390///
11391/// ```test_harness,no_run
11392/// # extern crate hyper;
11393/// # extern crate hyper_rustls;
11394/// # extern crate google_secretmanager1 as secretmanager1;
11395/// use secretmanager1::api::SetIamPolicyRequest;
11396/// # async fn dox() {
11397/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11398///
11399/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11400/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11401/// #     .with_native_roots()
11402/// #     .unwrap()
11403/// #     .https_only()
11404/// #     .enable_http2()
11405/// #     .build();
11406///
11407/// # let executor = hyper_util::rt::TokioExecutor::new();
11408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11409/// #     secret,
11410/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11411/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11412/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11413/// #     ),
11414/// # ).build().await.unwrap();
11415///
11416/// # let client = hyper_util::client::legacy::Client::builder(
11417/// #     hyper_util::rt::TokioExecutor::new()
11418/// # )
11419/// # .build(
11420/// #     hyper_rustls::HttpsConnectorBuilder::new()
11421/// #         .with_native_roots()
11422/// #         .unwrap()
11423/// #         .https_or_http()
11424/// #         .enable_http2()
11425/// #         .build()
11426/// # );
11427/// # let mut hub = SecretManager::new(client, auth);
11428/// // As the method needs a request, you would usually fill it with the desired information
11429/// // into the respective structure. Some of the parts shown here might not be applicable !
11430/// // Values shown here are possibly random and not representative !
11431/// let mut req = SetIamPolicyRequest::default();
11432///
11433/// // You can configure optional parameters by calling the respective setters at will, and
11434/// // execute the final call using `doit()`.
11435/// // Values shown here are possibly random and not representative !
11436/// let result = hub.projects().secrets_set_iam_policy(req, "resource")
11437///              .doit().await;
11438/// # }
11439/// ```
11440pub struct ProjectSecretSetIamPolicyCall<'a, C>
11441where
11442    C: 'a,
11443{
11444    hub: &'a SecretManager<C>,
11445    _request: SetIamPolicyRequest,
11446    _resource: String,
11447    _delegate: Option<&'a mut dyn common::Delegate>,
11448    _additional_params: HashMap<String, String>,
11449    _scopes: BTreeSet<String>,
11450}
11451
11452impl<'a, C> common::CallBuilder for ProjectSecretSetIamPolicyCall<'a, C> {}
11453
11454impl<'a, C> ProjectSecretSetIamPolicyCall<'a, C>
11455where
11456    C: common::Connector,
11457{
11458    /// Perform the operation you have build so far.
11459    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
11460        use std::borrow::Cow;
11461        use std::io::{Read, Seek};
11462
11463        use common::{url::Params, ToParts};
11464        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11465
11466        let mut dd = common::DefaultDelegate;
11467        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11468        dlg.begin(common::MethodInfo {
11469            id: "secretmanager.projects.secrets.setIamPolicy",
11470            http_method: hyper::Method::POST,
11471        });
11472
11473        for &field in ["alt", "resource"].iter() {
11474            if self._additional_params.contains_key(field) {
11475                dlg.finished(false);
11476                return Err(common::Error::FieldClash(field));
11477            }
11478        }
11479
11480        let mut params = Params::with_capacity(4 + self._additional_params.len());
11481        params.push("resource", self._resource);
11482
11483        params.extend(self._additional_params.iter());
11484
11485        params.push("alt", "json");
11486        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
11487        if self._scopes.is_empty() {
11488            self._scopes
11489                .insert(Scope::CloudPlatform.as_ref().to_string());
11490        }
11491
11492        #[allow(clippy::single_element_loop)]
11493        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11494            url = params.uri_replacement(url, param_name, find_this, true);
11495        }
11496        {
11497            let to_remove = ["resource"];
11498            params.remove_params(&to_remove);
11499        }
11500
11501        let url = params.parse_with_url(&url);
11502
11503        let mut json_mime_type = mime::APPLICATION_JSON;
11504        let mut request_value_reader = {
11505            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11506            common::remove_json_null_values(&mut value);
11507            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11508            serde_json::to_writer(&mut dst, &value).unwrap();
11509            dst
11510        };
11511        let request_size = request_value_reader
11512            .seek(std::io::SeekFrom::End(0))
11513            .unwrap();
11514        request_value_reader
11515            .seek(std::io::SeekFrom::Start(0))
11516            .unwrap();
11517
11518        loop {
11519            let token = match self
11520                .hub
11521                .auth
11522                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11523                .await
11524            {
11525                Ok(token) => token,
11526                Err(e) => match dlg.token(e) {
11527                    Ok(token) => token,
11528                    Err(e) => {
11529                        dlg.finished(false);
11530                        return Err(common::Error::MissingToken(e));
11531                    }
11532                },
11533            };
11534            request_value_reader
11535                .seek(std::io::SeekFrom::Start(0))
11536                .unwrap();
11537            let mut req_result = {
11538                let client = &self.hub.client;
11539                dlg.pre_request();
11540                let mut req_builder = hyper::Request::builder()
11541                    .method(hyper::Method::POST)
11542                    .uri(url.as_str())
11543                    .header(USER_AGENT, self.hub._user_agent.clone());
11544
11545                if let Some(token) = token.as_ref() {
11546                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11547                }
11548
11549                let request = req_builder
11550                    .header(CONTENT_TYPE, json_mime_type.to_string())
11551                    .header(CONTENT_LENGTH, request_size as u64)
11552                    .body(common::to_body(
11553                        request_value_reader.get_ref().clone().into(),
11554                    ));
11555
11556                client.request(request.unwrap()).await
11557            };
11558
11559            match req_result {
11560                Err(err) => {
11561                    if let common::Retry::After(d) = dlg.http_error(&err) {
11562                        sleep(d).await;
11563                        continue;
11564                    }
11565                    dlg.finished(false);
11566                    return Err(common::Error::HttpError(err));
11567                }
11568                Ok(res) => {
11569                    let (mut parts, body) = res.into_parts();
11570                    let mut body = common::Body::new(body);
11571                    if !parts.status.is_success() {
11572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11573                        let error = serde_json::from_str(&common::to_string(&bytes));
11574                        let response = common::to_response(parts, bytes.into());
11575
11576                        if let common::Retry::After(d) =
11577                            dlg.http_failure(&response, error.as_ref().ok())
11578                        {
11579                            sleep(d).await;
11580                            continue;
11581                        }
11582
11583                        dlg.finished(false);
11584
11585                        return Err(match error {
11586                            Ok(value) => common::Error::BadRequest(value),
11587                            _ => common::Error::Failure(response),
11588                        });
11589                    }
11590                    let response = {
11591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11592                        let encoded = common::to_string(&bytes);
11593                        match serde_json::from_str(&encoded) {
11594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11595                            Err(error) => {
11596                                dlg.response_json_decode_error(&encoded, &error);
11597                                return Err(common::Error::JsonDecodeError(
11598                                    encoded.to_string(),
11599                                    error,
11600                                ));
11601                            }
11602                        }
11603                    };
11604
11605                    dlg.finished(true);
11606                    return Ok(response);
11607                }
11608            }
11609        }
11610    }
11611
11612    ///
11613    /// Sets the *request* property to the given value.
11614    ///
11615    /// Even though the property as already been set when instantiating this call,
11616    /// we provide this method for API completeness.
11617    pub fn request(
11618        mut self,
11619        new_value: SetIamPolicyRequest,
11620    ) -> ProjectSecretSetIamPolicyCall<'a, C> {
11621        self._request = new_value;
11622        self
11623    }
11624    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
11625    ///
11626    /// Sets the *resource* path property to the given value.
11627    ///
11628    /// Even though the property as already been set when instantiating this call,
11629    /// we provide this method for API completeness.
11630    pub fn resource(mut self, new_value: &str) -> ProjectSecretSetIamPolicyCall<'a, C> {
11631        self._resource = new_value.to_string();
11632        self
11633    }
11634    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11635    /// while executing the actual API request.
11636    ///
11637    /// ````text
11638    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11639    /// ````
11640    ///
11641    /// Sets the *delegate* property to the given value.
11642    pub fn delegate(
11643        mut self,
11644        new_value: &'a mut dyn common::Delegate,
11645    ) -> ProjectSecretSetIamPolicyCall<'a, C> {
11646        self._delegate = Some(new_value);
11647        self
11648    }
11649
11650    /// Set any additional parameter of the query string used in the request.
11651    /// It should be used to set parameters which are not yet available through their own
11652    /// setters.
11653    ///
11654    /// Please note that this method must not be used to set any of the known parameters
11655    /// which have their own setter method. If done anyway, the request will fail.
11656    ///
11657    /// # Additional Parameters
11658    ///
11659    /// * *$.xgafv* (query-string) - V1 error format.
11660    /// * *access_token* (query-string) - OAuth access token.
11661    /// * *alt* (query-string) - Data format for response.
11662    /// * *callback* (query-string) - JSONP
11663    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11664    /// * *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.
11665    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11666    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11667    /// * *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.
11668    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11669    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11670    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretSetIamPolicyCall<'a, C>
11671    where
11672        T: AsRef<str>,
11673    {
11674        self._additional_params
11675            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11676        self
11677    }
11678
11679    /// Identifies the authorization scope for the method you are building.
11680    ///
11681    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11682    /// [`Scope::CloudPlatform`].
11683    ///
11684    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11685    /// tokens for more than one scope.
11686    ///
11687    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11688    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11689    /// sufficient, a read-write scope will do as well.
11690    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretSetIamPolicyCall<'a, C>
11691    where
11692        St: AsRef<str>,
11693    {
11694        self._scopes.insert(String::from(scope.as_ref()));
11695        self
11696    }
11697    /// Identifies the authorization scope(s) for the method you are building.
11698    ///
11699    /// See [`Self::add_scope()`] for details.
11700    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretSetIamPolicyCall<'a, C>
11701    where
11702        I: IntoIterator<Item = St>,
11703        St: AsRef<str>,
11704    {
11705        self._scopes
11706            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11707        self
11708    }
11709
11710    /// Removes all scopes, and no default scope will be used either.
11711    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11712    /// for details).
11713    pub fn clear_scopes(mut self) -> ProjectSecretSetIamPolicyCall<'a, C> {
11714        self._scopes.clear();
11715        self
11716    }
11717}
11718
11719/// Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
11720///
11721/// A builder for the *secrets.testIamPermissions* method supported by a *project* resource.
11722/// It is not used directly, but through a [`ProjectMethods`] instance.
11723///
11724/// # Example
11725///
11726/// Instantiate a resource method builder
11727///
11728/// ```test_harness,no_run
11729/// # extern crate hyper;
11730/// # extern crate hyper_rustls;
11731/// # extern crate google_secretmanager1 as secretmanager1;
11732/// use secretmanager1::api::TestIamPermissionsRequest;
11733/// # async fn dox() {
11734/// # use secretmanager1::{SecretManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11735///
11736/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11737/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11738/// #     .with_native_roots()
11739/// #     .unwrap()
11740/// #     .https_only()
11741/// #     .enable_http2()
11742/// #     .build();
11743///
11744/// # let executor = hyper_util::rt::TokioExecutor::new();
11745/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11746/// #     secret,
11747/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11748/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11749/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11750/// #     ),
11751/// # ).build().await.unwrap();
11752///
11753/// # let client = hyper_util::client::legacy::Client::builder(
11754/// #     hyper_util::rt::TokioExecutor::new()
11755/// # )
11756/// # .build(
11757/// #     hyper_rustls::HttpsConnectorBuilder::new()
11758/// #         .with_native_roots()
11759/// #         .unwrap()
11760/// #         .https_or_http()
11761/// #         .enable_http2()
11762/// #         .build()
11763/// # );
11764/// # let mut hub = SecretManager::new(client, auth);
11765/// // As the method needs a request, you would usually fill it with the desired information
11766/// // into the respective structure. Some of the parts shown here might not be applicable !
11767/// // Values shown here are possibly random and not representative !
11768/// let mut req = TestIamPermissionsRequest::default();
11769///
11770/// // You can configure optional parameters by calling the respective setters at will, and
11771/// // execute the final call using `doit()`.
11772/// // Values shown here are possibly random and not representative !
11773/// let result = hub.projects().secrets_test_iam_permissions(req, "resource")
11774///              .doit().await;
11775/// # }
11776/// ```
11777pub struct ProjectSecretTestIamPermissionCall<'a, C>
11778where
11779    C: 'a,
11780{
11781    hub: &'a SecretManager<C>,
11782    _request: TestIamPermissionsRequest,
11783    _resource: String,
11784    _delegate: Option<&'a mut dyn common::Delegate>,
11785    _additional_params: HashMap<String, String>,
11786    _scopes: BTreeSet<String>,
11787}
11788
11789impl<'a, C> common::CallBuilder for ProjectSecretTestIamPermissionCall<'a, C> {}
11790
11791impl<'a, C> ProjectSecretTestIamPermissionCall<'a, C>
11792where
11793    C: common::Connector,
11794{
11795    /// Perform the operation you have build so far.
11796    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
11797        use std::borrow::Cow;
11798        use std::io::{Read, Seek};
11799
11800        use common::{url::Params, ToParts};
11801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11802
11803        let mut dd = common::DefaultDelegate;
11804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11805        dlg.begin(common::MethodInfo {
11806            id: "secretmanager.projects.secrets.testIamPermissions",
11807            http_method: hyper::Method::POST,
11808        });
11809
11810        for &field in ["alt", "resource"].iter() {
11811            if self._additional_params.contains_key(field) {
11812                dlg.finished(false);
11813                return Err(common::Error::FieldClash(field));
11814            }
11815        }
11816
11817        let mut params = Params::with_capacity(4 + self._additional_params.len());
11818        params.push("resource", self._resource);
11819
11820        params.extend(self._additional_params.iter());
11821
11822        params.push("alt", "json");
11823        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
11824        if self._scopes.is_empty() {
11825            self._scopes
11826                .insert(Scope::CloudPlatform.as_ref().to_string());
11827        }
11828
11829        #[allow(clippy::single_element_loop)]
11830        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11831            url = params.uri_replacement(url, param_name, find_this, true);
11832        }
11833        {
11834            let to_remove = ["resource"];
11835            params.remove_params(&to_remove);
11836        }
11837
11838        let url = params.parse_with_url(&url);
11839
11840        let mut json_mime_type = mime::APPLICATION_JSON;
11841        let mut request_value_reader = {
11842            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11843            common::remove_json_null_values(&mut value);
11844            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11845            serde_json::to_writer(&mut dst, &value).unwrap();
11846            dst
11847        };
11848        let request_size = request_value_reader
11849            .seek(std::io::SeekFrom::End(0))
11850            .unwrap();
11851        request_value_reader
11852            .seek(std::io::SeekFrom::Start(0))
11853            .unwrap();
11854
11855        loop {
11856            let token = match self
11857                .hub
11858                .auth
11859                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11860                .await
11861            {
11862                Ok(token) => token,
11863                Err(e) => match dlg.token(e) {
11864                    Ok(token) => token,
11865                    Err(e) => {
11866                        dlg.finished(false);
11867                        return Err(common::Error::MissingToken(e));
11868                    }
11869                },
11870            };
11871            request_value_reader
11872                .seek(std::io::SeekFrom::Start(0))
11873                .unwrap();
11874            let mut req_result = {
11875                let client = &self.hub.client;
11876                dlg.pre_request();
11877                let mut req_builder = hyper::Request::builder()
11878                    .method(hyper::Method::POST)
11879                    .uri(url.as_str())
11880                    .header(USER_AGENT, self.hub._user_agent.clone());
11881
11882                if let Some(token) = token.as_ref() {
11883                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11884                }
11885
11886                let request = req_builder
11887                    .header(CONTENT_TYPE, json_mime_type.to_string())
11888                    .header(CONTENT_LENGTH, request_size as u64)
11889                    .body(common::to_body(
11890                        request_value_reader.get_ref().clone().into(),
11891                    ));
11892
11893                client.request(request.unwrap()).await
11894            };
11895
11896            match req_result {
11897                Err(err) => {
11898                    if let common::Retry::After(d) = dlg.http_error(&err) {
11899                        sleep(d).await;
11900                        continue;
11901                    }
11902                    dlg.finished(false);
11903                    return Err(common::Error::HttpError(err));
11904                }
11905                Ok(res) => {
11906                    let (mut parts, body) = res.into_parts();
11907                    let mut body = common::Body::new(body);
11908                    if !parts.status.is_success() {
11909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11910                        let error = serde_json::from_str(&common::to_string(&bytes));
11911                        let response = common::to_response(parts, bytes.into());
11912
11913                        if let common::Retry::After(d) =
11914                            dlg.http_failure(&response, error.as_ref().ok())
11915                        {
11916                            sleep(d).await;
11917                            continue;
11918                        }
11919
11920                        dlg.finished(false);
11921
11922                        return Err(match error {
11923                            Ok(value) => common::Error::BadRequest(value),
11924                            _ => common::Error::Failure(response),
11925                        });
11926                    }
11927                    let response = {
11928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11929                        let encoded = common::to_string(&bytes);
11930                        match serde_json::from_str(&encoded) {
11931                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11932                            Err(error) => {
11933                                dlg.response_json_decode_error(&encoded, &error);
11934                                return Err(common::Error::JsonDecodeError(
11935                                    encoded.to_string(),
11936                                    error,
11937                                ));
11938                            }
11939                        }
11940                    };
11941
11942                    dlg.finished(true);
11943                    return Ok(response);
11944                }
11945            }
11946        }
11947    }
11948
11949    ///
11950    /// Sets the *request* property to the given value.
11951    ///
11952    /// Even though the property as already been set when instantiating this call,
11953    /// we provide this method for API completeness.
11954    pub fn request(
11955        mut self,
11956        new_value: TestIamPermissionsRequest,
11957    ) -> ProjectSecretTestIamPermissionCall<'a, C> {
11958        self._request = new_value;
11959        self
11960    }
11961    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
11962    ///
11963    /// Sets the *resource* path property to the given value.
11964    ///
11965    /// Even though the property as already been set when instantiating this call,
11966    /// we provide this method for API completeness.
11967    pub fn resource(mut self, new_value: &str) -> ProjectSecretTestIamPermissionCall<'a, C> {
11968        self._resource = new_value.to_string();
11969        self
11970    }
11971    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11972    /// while executing the actual API request.
11973    ///
11974    /// ````text
11975    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11976    /// ````
11977    ///
11978    /// Sets the *delegate* property to the given value.
11979    pub fn delegate(
11980        mut self,
11981        new_value: &'a mut dyn common::Delegate,
11982    ) -> ProjectSecretTestIamPermissionCall<'a, C> {
11983        self._delegate = Some(new_value);
11984        self
11985    }
11986
11987    /// Set any additional parameter of the query string used in the request.
11988    /// It should be used to set parameters which are not yet available through their own
11989    /// setters.
11990    ///
11991    /// Please note that this method must not be used to set any of the known parameters
11992    /// which have their own setter method. If done anyway, the request will fail.
11993    ///
11994    /// # Additional Parameters
11995    ///
11996    /// * *$.xgafv* (query-string) - V1 error format.
11997    /// * *access_token* (query-string) - OAuth access token.
11998    /// * *alt* (query-string) - Data format for response.
11999    /// * *callback* (query-string) - JSONP
12000    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12001    /// * *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.
12002    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12003    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12004    /// * *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.
12005    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12006    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12007    pub fn param<T>(mut self, name: T, value: T) -> ProjectSecretTestIamPermissionCall<'a, C>
12008    where
12009        T: AsRef<str>,
12010    {
12011        self._additional_params
12012            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12013        self
12014    }
12015
12016    /// Identifies the authorization scope for the method you are building.
12017    ///
12018    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12019    /// [`Scope::CloudPlatform`].
12020    ///
12021    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12022    /// tokens for more than one scope.
12023    ///
12024    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12025    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12026    /// sufficient, a read-write scope will do as well.
12027    pub fn add_scope<St>(mut self, scope: St) -> ProjectSecretTestIamPermissionCall<'a, C>
12028    where
12029        St: AsRef<str>,
12030    {
12031        self._scopes.insert(String::from(scope.as_ref()));
12032        self
12033    }
12034    /// Identifies the authorization scope(s) for the method you are building.
12035    ///
12036    /// See [`Self::add_scope()`] for details.
12037    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSecretTestIamPermissionCall<'a, C>
12038    where
12039        I: IntoIterator<Item = St>,
12040        St: AsRef<str>,
12041    {
12042        self._scopes
12043            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12044        self
12045    }
12046
12047    /// Removes all scopes, and no default scope will be used either.
12048    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12049    /// for details).
12050    pub fn clear_scopes(mut self) -> ProjectSecretTestIamPermissionCall<'a, C> {
12051        self._scopes.clear();
12052        self
12053    }
12054}