google_apikeys2/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18
19    /// View your data across Google Cloud services and see the email address of your Google Account
20    CloudPlatformReadOnly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::CloudPlatformReadOnly => {
28                "https://www.googleapis.com/auth/cloud-platform.read-only"
29            }
30        }
31    }
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Scope {
36    fn default() -> Scope {
37        Scope::CloudPlatform
38    }
39}
40
41// ########
42// HUB ###
43// ######
44
45/// Central instance to access all ApiKeysService related resource activities
46///
47/// # Examples
48///
49/// Instantiate a new hub
50///
51/// ```test_harness,no_run
52/// extern crate hyper;
53/// extern crate hyper_rustls;
54/// extern crate google_apikeys2 as apikeys2;
55/// use apikeys2::api::V2Key;
56/// use apikeys2::{Result, Error};
57/// # async fn dox() {
58/// use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
59///
60/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
61/// // `client_secret`, among other things.
62/// let secret: yup_oauth2::ApplicationSecret = Default::default();
63/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
64/// // unless you replace  `None` with the desired Flow.
65/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
66/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
67/// // retrieve them from storage.
68/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
69///     .with_native_roots()
70///     .unwrap()
71///     .https_only()
72///     .enable_http2()
73///     .build();
74///
75/// let executor = hyper_util::rt::TokioExecutor::new();
76/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
77///     secret,
78///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
79///     yup_oauth2::client::CustomHyperClientBuilder::from(
80///         hyper_util::client::legacy::Client::builder(executor).build(connector),
81///     ),
82/// ).build().await.unwrap();
83///
84/// let client = hyper_util::client::legacy::Client::builder(
85///     hyper_util::rt::TokioExecutor::new()
86/// )
87/// .build(
88///     hyper_rustls::HttpsConnectorBuilder::new()
89///         .with_native_roots()
90///         .unwrap()
91///         .https_or_http()
92///         .enable_http2()
93///         .build()
94/// );
95/// let mut hub = ApiKeysService::new(client, auth);
96/// // As the method needs a request, you would usually fill it with the desired information
97/// // into the respective structure. Some of the parts shown here might not be applicable !
98/// // Values shown here are possibly random and not representative !
99/// let mut req = V2Key::default();
100///
101/// // You can configure optional parameters by calling the respective setters at will, and
102/// // execute the final call using `doit()`.
103/// // Values shown here are possibly random and not representative !
104/// let result = hub.projects().locations_keys_create(req, "parent")
105///              .key_id("At")
106///              .doit().await;
107///
108/// match result {
109///     Err(e) => match e {
110///         // The Error enum provides details about what exactly happened.
111///         // You can also just use its `Debug`, `Display` or `Error` traits
112///          Error::HttpError(_)
113///         |Error::Io(_)
114///         |Error::MissingAPIKey
115///         |Error::MissingToken(_)
116///         |Error::Cancelled
117///         |Error::UploadSizeLimitExceeded(_, _)
118///         |Error::Failure(_)
119///         |Error::BadRequest(_)
120///         |Error::FieldClash(_)
121///         |Error::JsonDecodeError(_, _) => println!("{}", e),
122///     },
123///     Ok(res) => println!("Success: {:?}", res),
124/// }
125/// # }
126/// ```
127#[derive(Clone)]
128pub struct ApiKeysService<C> {
129    pub client: common::Client<C>,
130    pub auth: Box<dyn common::GetToken>,
131    _user_agent: String,
132    _base_url: String,
133    _root_url: String,
134}
135
136impl<C> common::Hub for ApiKeysService<C> {}
137
138impl<'a, C> ApiKeysService<C> {
139    pub fn new<A: 'static + common::GetToken>(
140        client: common::Client<C>,
141        auth: A,
142    ) -> ApiKeysService<C> {
143        ApiKeysService {
144            client,
145            auth: Box::new(auth),
146            _user_agent: "google-api-rust-client/7.0.0".to_string(),
147            _base_url: "https://apikeys.googleapis.com/".to_string(),
148            _root_url: "https://apikeys.googleapis.com/".to_string(),
149        }
150    }
151
152    pub fn keys(&'a self) -> KeyMethods<'a, C> {
153        KeyMethods { hub: self }
154    }
155    pub fn operations(&'a self) -> OperationMethods<'a, C> {
156        OperationMethods { hub: self }
157    }
158    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
159        ProjectMethods { hub: self }
160    }
161
162    /// Set the user-agent header field to use in all requests to the server.
163    /// It defaults to `google-api-rust-client/7.0.0`.
164    ///
165    /// Returns the previously set user-agent.
166    pub fn user_agent(&mut self, agent_name: String) -> String {
167        std::mem::replace(&mut self._user_agent, agent_name)
168    }
169
170    /// Set the base url to use in all requests to the server.
171    /// It defaults to `https://apikeys.googleapis.com/`.
172    ///
173    /// Returns the previously set base url.
174    pub fn base_url(&mut self, new_base_url: String) -> String {
175        std::mem::replace(&mut self._base_url, new_base_url)
176    }
177
178    /// Set the root url to use in all requests to the server.
179    /// It defaults to `https://apikeys.googleapis.com/`.
180    ///
181    /// Returns the previously set root url.
182    pub fn root_url(&mut self, new_root_url: String) -> String {
183        std::mem::replace(&mut self._root_url, new_root_url)
184    }
185}
186
187// ############
188// SCHEMAS ###
189// ##########
190/// This resource represents a long-running operation that is the result of a network API call.
191///
192/// # Activities
193///
194/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
195/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
196///
197/// * [get operations](OperationGetCall) (response)
198/// * [locations keys create projects](ProjectLocationKeyCreateCall) (response)
199/// * [locations keys delete projects](ProjectLocationKeyDeleteCall) (response)
200/// * [locations keys patch projects](ProjectLocationKeyPatchCall) (response)
201/// * [locations keys undelete projects](ProjectLocationKeyUndeleteCall) (response)
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct Operation {
206    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
207    pub done: Option<bool>,
208    /// The error result of the operation in case of failure or cancellation.
209    pub error: Option<Status>,
210    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
211    pub metadata: Option<HashMap<String, serde_json::Value>>,
212    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
213    pub name: Option<String>,
214    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
215    pub response: Option<HashMap<String, serde_json::Value>>,
216}
217
218impl common::Resource for Operation {}
219impl common::ResponseResult for Operation {}
220
221/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
222///
223/// This type is not used in any activity, and only used as *part* of another schema.
224///
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct Status {
229    /// The status code, which should be an enum value of google.rpc.Code.
230    pub code: Option<i32>,
231    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
232    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
233    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
234    pub message: Option<String>,
235}
236
237impl common::Part for Status {}
238
239/// Identifier of an Android application for key use.
240///
241/// This type is not used in any activity, and only used as *part* of another schema.
242///
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct V2AndroidApplication {
247    /// The package name of the application.
248    #[serde(rename = "packageName")]
249    pub package_name: Option<String>,
250    /// The SHA1 fingerprint of the application. For example, both sha1 formats are acceptable : DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09 or DA39A3EE5E6B4B0D3255BFEF95601890AFD80709. Output format is the latter.
251    #[serde(rename = "sha1Fingerprint")]
252    pub sha1_fingerprint: Option<String>,
253}
254
255impl common::Part for V2AndroidApplication {}
256
257/// The Android apps that are allowed to use the key.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct V2AndroidKeyRestrictions {
265    /// A list of Android applications that are allowed to make API calls with this key.
266    #[serde(rename = "allowedApplications")]
267    pub allowed_applications: Option<Vec<V2AndroidApplication>>,
268}
269
270impl common::Part for V2AndroidKeyRestrictions {}
271
272/// A restriction for a specific service and optionally one or multiple specific methods. Both fields are case insensitive.
273///
274/// This type is not used in any activity, and only used as *part* of another schema.
275///
276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
277#[serde_with::serde_as]
278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
279pub struct V2ApiTarget {
280    /// Optional. List of one or more methods that can be called. If empty, all methods for the service are allowed. A wildcard (*) can be used as the last symbol. Valid examples: `google.cloud.translate.v2.TranslateService.GetSupportedLanguage` `TranslateText` `Get*` `translate.googleapis.com.Get*`
281    pub methods: Option<Vec<String>>,
282    /// The service for this restriction. It should be the canonical service name, for example: `translate.googleapis.com`. You can use [`gcloud services list`](https://cloud.google.com/sdk/gcloud/reference/services/list) to get a list of services that are enabled in the project.
283    pub service: Option<String>,
284}
285
286impl common::Part for V2ApiTarget {}
287
288/// The HTTP referrers (websites) that are allowed to use the key.
289///
290/// This type is not used in any activity, and only used as *part* of another schema.
291///
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct V2BrowserKeyRestrictions {
296    /// A list of regular expressions for the referrer URLs that are allowed to make API calls with this key.
297    #[serde(rename = "allowedReferrers")]
298    pub allowed_referrers: Option<Vec<String>>,
299}
300
301impl common::Part for V2BrowserKeyRestrictions {}
302
303/// Response message for `GetKeyString` method.
304///
305/// # Activities
306///
307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
309///
310/// * [locations keys get key string projects](ProjectLocationKeyGetKeyStringCall) (response)
311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
312#[serde_with::serde_as]
313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
314pub struct V2GetKeyStringResponse {
315    /// An encrypted and signed value of the key.
316    #[serde(rename = "keyString")]
317    pub key_string: Option<String>,
318}
319
320impl common::ResponseResult for V2GetKeyStringResponse {}
321
322/// The iOS apps that are allowed to use the key.
323///
324/// This type is not used in any activity, and only used as *part* of another schema.
325///
326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
327#[serde_with::serde_as]
328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
329pub struct V2IosKeyRestrictions {
330    /// A list of bundle IDs that are allowed when making API calls with this key.
331    #[serde(rename = "allowedBundleIds")]
332    pub allowed_bundle_ids: Option<Vec<String>>,
333}
334
335impl common::Part for V2IosKeyRestrictions {}
336
337/// The representation of a key managed by the API Keys API.
338///
339/// # Activities
340///
341/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
342/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
343///
344/// * [locations keys create projects](ProjectLocationKeyCreateCall) (request)
345/// * [locations keys get projects](ProjectLocationKeyGetCall) (response)
346/// * [locations keys patch projects](ProjectLocationKeyPatchCall) (request)
347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
348#[serde_with::serde_as]
349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
350pub struct V2Key {
351    /// Annotations is an unstructured key-value map stored with a policy that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects.
352    pub annotations: Option<HashMap<String, String>>,
353    /// Output only. A timestamp identifying the time this key was originally created.
354    #[serde(rename = "createTime")]
355    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
356    /// Output only. A timestamp when this key was deleted. If the resource is not deleted, this must be empty.
357    #[serde(rename = "deleteTime")]
358    pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
359    /// Human-readable display name of this key that you can modify. The maximum length is 63 characters.
360    #[serde(rename = "displayName")]
361    pub display_name: Option<String>,
362    /// Output only. A checksum computed by the server based on the current value of the Key resource. This may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding. See https://google.aip.dev/154.
363    pub etag: Option<String>,
364    /// Output only. An encrypted and signed value held by this key. This field can be accessed only through the `GetKeyString` method.
365    #[serde(rename = "keyString")]
366    pub key_string: Option<String>,
367    /// Output only. The resource name of the key. The `name` has the form: `projects//locations/global/keys/`. For example: `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value for location is `global`.
368    pub name: Option<String>,
369    /// Key restrictions.
370    pub restrictions: Option<V2Restrictions>,
371    /// Optional. The email address of [the service account](https://cloud.google.com/iam/docs/service-accounts) the key is bound to.
372    #[serde(rename = "serviceAccountEmail")]
373    pub service_account_email: Option<String>,
374    /// Output only. Unique id in UUID4 format.
375    pub uid: Option<String>,
376    /// Output only. A timestamp identifying the time this key was last updated.
377    #[serde(rename = "updateTime")]
378    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
379}
380
381impl common::RequestValue for V2Key {}
382impl common::ResponseResult for V2Key {}
383
384/// Response message for `ListKeys` method.
385///
386/// # Activities
387///
388/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
389/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
390///
391/// * [locations keys list projects](ProjectLocationKeyListCall) (response)
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct V2ListKeysResponse {
396    /// A list of API keys.
397    pub keys: Option<Vec<V2Key>>,
398    /// The pagination token for the next page of results.
399    #[serde(rename = "nextPageToken")]
400    pub next_page_token: Option<String>,
401}
402
403impl common::ResponseResult for V2ListKeysResponse {}
404
405/// Response message for `LookupKey` method.
406///
407/// # Activities
408///
409/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
410/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
411///
412/// * [lookup key keys](KeyLookupKeyCall) (response)
413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
414#[serde_with::serde_as]
415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
416pub struct V2LookupKeyResponse {
417    /// The resource name of the API key. If the API key has been purged, resource name is empty.
418    pub name: Option<String>,
419    /// The project that owns the key with the value specified in the request.
420    pub parent: Option<String>,
421}
422
423impl common::ResponseResult for V2LookupKeyResponse {}
424
425/// Describes the restrictions on the key.
426///
427/// This type is not used in any activity, and only used as *part* of another schema.
428///
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct V2Restrictions {
433    /// The Android apps that are allowed to use the key.
434    #[serde(rename = "androidKeyRestrictions")]
435    pub android_key_restrictions: Option<V2AndroidKeyRestrictions>,
436    /// A restriction for a specific service and optionally one or more specific methods. Requests are allowed if they match any of these restrictions. If no restrictions are specified, all targets are allowed.
437    #[serde(rename = "apiTargets")]
438    pub api_targets: Option<Vec<V2ApiTarget>>,
439    /// The HTTP referrers (websites) that are allowed to use the key.
440    #[serde(rename = "browserKeyRestrictions")]
441    pub browser_key_restrictions: Option<V2BrowserKeyRestrictions>,
442    /// The iOS apps that are allowed to use the key.
443    #[serde(rename = "iosKeyRestrictions")]
444    pub ios_key_restrictions: Option<V2IosKeyRestrictions>,
445    /// The IP addresses of callers that are allowed to use the key.
446    #[serde(rename = "serverKeyRestrictions")]
447    pub server_key_restrictions: Option<V2ServerKeyRestrictions>,
448}
449
450impl common::Part for V2Restrictions {}
451
452/// The IP addresses of callers that are allowed to use the key.
453///
454/// This type is not used in any activity, and only used as *part* of another schema.
455///
456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
457#[serde_with::serde_as]
458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
459pub struct V2ServerKeyRestrictions {
460    /// A list of the caller IP addresses that are allowed to make API calls with this key.
461    #[serde(rename = "allowedIps")]
462    pub allowed_ips: Option<Vec<String>>,
463}
464
465impl common::Part for V2ServerKeyRestrictions {}
466
467/// Request message for `UndeleteKey` method.
468///
469/// # Activities
470///
471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
473///
474/// * [locations keys undelete projects](ProjectLocationKeyUndeleteCall) (request)
475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
476#[serde_with::serde_as]
477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
478pub struct V2UndeleteKeyRequest {
479    _never_set: Option<bool>,
480}
481
482impl common::RequestValue for V2UndeleteKeyRequest {}
483
484// ###################
485// MethodBuilders ###
486// #################
487
488/// A builder providing access to all methods supported on *key* resources.
489/// It is not used directly, but through the [`ApiKeysService`] hub.
490///
491/// # Example
492///
493/// Instantiate a resource builder
494///
495/// ```test_harness,no_run
496/// extern crate hyper;
497/// extern crate hyper_rustls;
498/// extern crate google_apikeys2 as apikeys2;
499///
500/// # async fn dox() {
501/// use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
502///
503/// let secret: yup_oauth2::ApplicationSecret = Default::default();
504/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
505///     .with_native_roots()
506///     .unwrap()
507///     .https_only()
508///     .enable_http2()
509///     .build();
510///
511/// let executor = hyper_util::rt::TokioExecutor::new();
512/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
513///     secret,
514///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
515///     yup_oauth2::client::CustomHyperClientBuilder::from(
516///         hyper_util::client::legacy::Client::builder(executor).build(connector),
517///     ),
518/// ).build().await.unwrap();
519///
520/// let client = hyper_util::client::legacy::Client::builder(
521///     hyper_util::rt::TokioExecutor::new()
522/// )
523/// .build(
524///     hyper_rustls::HttpsConnectorBuilder::new()
525///         .with_native_roots()
526///         .unwrap()
527///         .https_or_http()
528///         .enable_http2()
529///         .build()
530/// );
531/// let mut hub = ApiKeysService::new(client, auth);
532/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
533/// // like `lookup_key(...)`
534/// // to build up your call.
535/// let rb = hub.keys();
536/// # }
537/// ```
538pub struct KeyMethods<'a, C>
539where
540    C: 'a,
541{
542    hub: &'a ApiKeysService<C>,
543}
544
545impl<'a, C> common::MethodsBuilder for KeyMethods<'a, C> {}
546
547impl<'a, C> KeyMethods<'a, C> {
548    /// Create a builder to help you perform the following task:
549    ///
550    /// Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the `apikeys.keys.lookup` permission on the parent project.
551    pub fn lookup_key(&self) -> KeyLookupKeyCall<'a, C> {
552        KeyLookupKeyCall {
553            hub: self.hub,
554            _key_string: Default::default(),
555            _delegate: Default::default(),
556            _additional_params: Default::default(),
557            _scopes: Default::default(),
558        }
559    }
560}
561
562/// A builder providing access to all methods supported on *operation* resources.
563/// It is not used directly, but through the [`ApiKeysService`] hub.
564///
565/// # Example
566///
567/// Instantiate a resource builder
568///
569/// ```test_harness,no_run
570/// extern crate hyper;
571/// extern crate hyper_rustls;
572/// extern crate google_apikeys2 as apikeys2;
573///
574/// # async fn dox() {
575/// use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
576///
577/// let secret: yup_oauth2::ApplicationSecret = Default::default();
578/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
579///     .with_native_roots()
580///     .unwrap()
581///     .https_only()
582///     .enable_http2()
583///     .build();
584///
585/// let executor = hyper_util::rt::TokioExecutor::new();
586/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
587///     secret,
588///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
589///     yup_oauth2::client::CustomHyperClientBuilder::from(
590///         hyper_util::client::legacy::Client::builder(executor).build(connector),
591///     ),
592/// ).build().await.unwrap();
593///
594/// let client = hyper_util::client::legacy::Client::builder(
595///     hyper_util::rt::TokioExecutor::new()
596/// )
597/// .build(
598///     hyper_rustls::HttpsConnectorBuilder::new()
599///         .with_native_roots()
600///         .unwrap()
601///         .https_or_http()
602///         .enable_http2()
603///         .build()
604/// );
605/// let mut hub = ApiKeysService::new(client, auth);
606/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
607/// // like `get(...)`
608/// // to build up your call.
609/// let rb = hub.operations();
610/// # }
611/// ```
612pub struct OperationMethods<'a, C>
613where
614    C: 'a,
615{
616    hub: &'a ApiKeysService<C>,
617}
618
619impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
620
621impl<'a, C> OperationMethods<'a, C> {
622    /// Create a builder to help you perform the following task:
623    ///
624    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
625    ///
626    /// # Arguments
627    ///
628    /// * `name` - The name of the operation resource.
629    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
630        OperationGetCall {
631            hub: self.hub,
632            _name: name.to_string(),
633            _delegate: Default::default(),
634            _additional_params: Default::default(),
635            _scopes: Default::default(),
636        }
637    }
638}
639
640/// A builder providing access to all methods supported on *project* resources.
641/// It is not used directly, but through the [`ApiKeysService`] hub.
642///
643/// # Example
644///
645/// Instantiate a resource builder
646///
647/// ```test_harness,no_run
648/// extern crate hyper;
649/// extern crate hyper_rustls;
650/// extern crate google_apikeys2 as apikeys2;
651///
652/// # async fn dox() {
653/// use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
654///
655/// let secret: yup_oauth2::ApplicationSecret = Default::default();
656/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
657///     .with_native_roots()
658///     .unwrap()
659///     .https_only()
660///     .enable_http2()
661///     .build();
662///
663/// let executor = hyper_util::rt::TokioExecutor::new();
664/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
665///     secret,
666///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
667///     yup_oauth2::client::CustomHyperClientBuilder::from(
668///         hyper_util::client::legacy::Client::builder(executor).build(connector),
669///     ),
670/// ).build().await.unwrap();
671///
672/// let client = hyper_util::client::legacy::Client::builder(
673///     hyper_util::rt::TokioExecutor::new()
674/// )
675/// .build(
676///     hyper_rustls::HttpsConnectorBuilder::new()
677///         .with_native_roots()
678///         .unwrap()
679///         .https_or_http()
680///         .enable_http2()
681///         .build()
682/// );
683/// let mut hub = ApiKeysService::new(client, auth);
684/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
685/// // like `locations_keys_create(...)`, `locations_keys_delete(...)`, `locations_keys_get(...)`, `locations_keys_get_key_string(...)`, `locations_keys_list(...)`, `locations_keys_patch(...)` and `locations_keys_undelete(...)`
686/// // to build up your call.
687/// let rb = hub.projects();
688/// # }
689/// ```
690pub struct ProjectMethods<'a, C>
691where
692    C: 'a,
693{
694    hub: &'a ApiKeysService<C>,
695}
696
697impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
698
699impl<'a, C> ProjectMethods<'a, C> {
700    /// Create a builder to help you perform the following task:
701    ///
702    /// Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.
703    ///
704    /// # Arguments
705    ///
706    /// * `request` - No description provided.
707    /// * `parent` - Required. The project in which the API key is created.
708    pub fn locations_keys_create(
709        &self,
710        request: V2Key,
711        parent: &str,
712    ) -> ProjectLocationKeyCreateCall<'a, C> {
713        ProjectLocationKeyCreateCall {
714            hub: self.hub,
715            _request: request,
716            _parent: parent.to_string(),
717            _key_id: Default::default(),
718            _delegate: Default::default(),
719            _additional_params: Default::default(),
720            _scopes: Default::default(),
721        }
722    }
723
724    /// Create a builder to help you perform the following task:
725    ///
726    /// Deletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. NOTE: Key is a global resource; hence the only supported value for location is `global`.
727    ///
728    /// # Arguments
729    ///
730    /// * `name` - Required. The resource name of the API key to be deleted.
731    pub fn locations_keys_delete(&self, name: &str) -> ProjectLocationKeyDeleteCall<'a, C> {
732        ProjectLocationKeyDeleteCall {
733            hub: self.hub,
734            _name: name.to_string(),
735            _etag: Default::default(),
736            _delegate: Default::default(),
737            _additional_params: Default::default(),
738            _scopes: Default::default(),
739        }
740    }
741
742    /// Create a builder to help you perform the following task:
743    ///
744    /// Gets the metadata for an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
745    ///
746    /// # Arguments
747    ///
748    /// * `name` - Required. The resource name of the API key to get.
749    pub fn locations_keys_get(&self, name: &str) -> ProjectLocationKeyGetCall<'a, C> {
750        ProjectLocationKeyGetCall {
751            hub: self.hub,
752            _name: name.to_string(),
753            _delegate: Default::default(),
754            _additional_params: Default::default(),
755            _scopes: Default::default(),
756        }
757    }
758
759    /// Create a builder to help you perform the following task:
760    ///
761    /// Get the key string for an API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.
762    ///
763    /// # Arguments
764    ///
765    /// * `name` - Required. The resource name of the API key to be retrieved.
766    pub fn locations_keys_get_key_string(
767        &self,
768        name: &str,
769    ) -> ProjectLocationKeyGetKeyStringCall<'a, C> {
770        ProjectLocationKeyGetKeyStringCall {
771            hub: self.hub,
772            _name: name.to_string(),
773            _delegate: Default::default(),
774            _additional_params: Default::default(),
775            _scopes: Default::default(),
776        }
777    }
778
779    /// Create a builder to help you perform the following task:
780    ///
781    /// Lists the API keys owned by a project. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
782    ///
783    /// # Arguments
784    ///
785    /// * `parent` - Required. Lists all API keys associated with this project.
786    pub fn locations_keys_list(&self, parent: &str) -> ProjectLocationKeyListCall<'a, C> {
787        ProjectLocationKeyListCall {
788            hub: self.hub,
789            _parent: parent.to_string(),
790            _show_deleted: Default::default(),
791            _page_token: Default::default(),
792            _page_size: Default::default(),
793            _delegate: Default::default(),
794            _additional_params: Default::default(),
795            _scopes: Default::default(),
796        }
797    }
798
799    /// Create a builder to help you perform the following task:
800    ///
801    /// Patches the modifiable fields of an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
802    ///
803    /// # Arguments
804    ///
805    /// * `request` - No description provided.
806    /// * `name` - Output only. The resource name of the key. The `name` has the form: `projects//locations/global/keys/`. For example: `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value for location is `global`.
807    pub fn locations_keys_patch(
808        &self,
809        request: V2Key,
810        name: &str,
811    ) -> ProjectLocationKeyPatchCall<'a, C> {
812        ProjectLocationKeyPatchCall {
813            hub: self.hub,
814            _request: request,
815            _name: name.to_string(),
816            _update_mask: Default::default(),
817            _delegate: Default::default(),
818            _additional_params: Default::default(),
819            _scopes: Default::default(),
820        }
821    }
822
823    /// Create a builder to help you perform the following task:
824    ///
825    /// Undeletes an API key which was deleted within 30 days. NOTE: Key is a global resource; hence the only supported value for location is `global`.
826    ///
827    /// # Arguments
828    ///
829    /// * `request` - No description provided.
830    /// * `name` - Required. The resource name of the API key to be undeleted.
831    pub fn locations_keys_undelete(
832        &self,
833        request: V2UndeleteKeyRequest,
834        name: &str,
835    ) -> ProjectLocationKeyUndeleteCall<'a, C> {
836        ProjectLocationKeyUndeleteCall {
837            hub: self.hub,
838            _request: request,
839            _name: name.to_string(),
840            _delegate: Default::default(),
841            _additional_params: Default::default(),
842            _scopes: Default::default(),
843        }
844    }
845}
846
847// ###################
848// CallBuilders   ###
849// #################
850
851/// Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been purged, resource name will not be set. The service account must have the `apikeys.keys.lookup` permission on the parent project.
852///
853/// A builder for the *lookupKey* method supported by a *key* resource.
854/// It is not used directly, but through a [`KeyMethods`] instance.
855///
856/// # Example
857///
858/// Instantiate a resource method builder
859///
860/// ```test_harness,no_run
861/// # extern crate hyper;
862/// # extern crate hyper_rustls;
863/// # extern crate google_apikeys2 as apikeys2;
864/// # async fn dox() {
865/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
866///
867/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
868/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
869/// #     .with_native_roots()
870/// #     .unwrap()
871/// #     .https_only()
872/// #     .enable_http2()
873/// #     .build();
874///
875/// # let executor = hyper_util::rt::TokioExecutor::new();
876/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
877/// #     secret,
878/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
879/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
880/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
881/// #     ),
882/// # ).build().await.unwrap();
883///
884/// # let client = hyper_util::client::legacy::Client::builder(
885/// #     hyper_util::rt::TokioExecutor::new()
886/// # )
887/// # .build(
888/// #     hyper_rustls::HttpsConnectorBuilder::new()
889/// #         .with_native_roots()
890/// #         .unwrap()
891/// #         .https_or_http()
892/// #         .enable_http2()
893/// #         .build()
894/// # );
895/// # let mut hub = ApiKeysService::new(client, auth);
896/// // You can configure optional parameters by calling the respective setters at will, and
897/// // execute the final call using `doit()`.
898/// // Values shown here are possibly random and not representative !
899/// let result = hub.keys().lookup_key()
900///              .key_string("sanctus")
901///              .doit().await;
902/// # }
903/// ```
904pub struct KeyLookupKeyCall<'a, C>
905where
906    C: 'a,
907{
908    hub: &'a ApiKeysService<C>,
909    _key_string: Option<String>,
910    _delegate: Option<&'a mut dyn common::Delegate>,
911    _additional_params: HashMap<String, String>,
912    _scopes: BTreeSet<String>,
913}
914
915impl<'a, C> common::CallBuilder for KeyLookupKeyCall<'a, C> {}
916
917impl<'a, C> KeyLookupKeyCall<'a, C>
918where
919    C: common::Connector,
920{
921    /// Perform the operation you have build so far.
922    pub async fn doit(mut self) -> common::Result<(common::Response, V2LookupKeyResponse)> {
923        use std::borrow::Cow;
924        use std::io::{Read, Seek};
925
926        use common::{url::Params, ToParts};
927        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
928
929        let mut dd = common::DefaultDelegate;
930        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
931        dlg.begin(common::MethodInfo {
932            id: "apikeys.keys.lookupKey",
933            http_method: hyper::Method::GET,
934        });
935
936        for &field in ["alt", "keyString"].iter() {
937            if self._additional_params.contains_key(field) {
938                dlg.finished(false);
939                return Err(common::Error::FieldClash(field));
940            }
941        }
942
943        let mut params = Params::with_capacity(3 + self._additional_params.len());
944        if let Some(value) = self._key_string.as_ref() {
945            params.push("keyString", value);
946        }
947
948        params.extend(self._additional_params.iter());
949
950        params.push("alt", "json");
951        let mut url = self.hub._base_url.clone() + "v2/keys:lookupKey";
952        if self._scopes.is_empty() {
953            self._scopes
954                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
955        }
956
957        let url = params.parse_with_url(&url);
958
959        loop {
960            let token = match self
961                .hub
962                .auth
963                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
964                .await
965            {
966                Ok(token) => token,
967                Err(e) => match dlg.token(e) {
968                    Ok(token) => token,
969                    Err(e) => {
970                        dlg.finished(false);
971                        return Err(common::Error::MissingToken(e));
972                    }
973                },
974            };
975            let mut req_result = {
976                let client = &self.hub.client;
977                dlg.pre_request();
978                let mut req_builder = hyper::Request::builder()
979                    .method(hyper::Method::GET)
980                    .uri(url.as_str())
981                    .header(USER_AGENT, self.hub._user_agent.clone());
982
983                if let Some(token) = token.as_ref() {
984                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
985                }
986
987                let request = req_builder
988                    .header(CONTENT_LENGTH, 0_u64)
989                    .body(common::to_body::<String>(None));
990
991                client.request(request.unwrap()).await
992            };
993
994            match req_result {
995                Err(err) => {
996                    if let common::Retry::After(d) = dlg.http_error(&err) {
997                        sleep(d).await;
998                        continue;
999                    }
1000                    dlg.finished(false);
1001                    return Err(common::Error::HttpError(err));
1002                }
1003                Ok(res) => {
1004                    let (mut parts, body) = res.into_parts();
1005                    let mut body = common::Body::new(body);
1006                    if !parts.status.is_success() {
1007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1008                        let error = serde_json::from_str(&common::to_string(&bytes));
1009                        let response = common::to_response(parts, bytes.into());
1010
1011                        if let common::Retry::After(d) =
1012                            dlg.http_failure(&response, error.as_ref().ok())
1013                        {
1014                            sleep(d).await;
1015                            continue;
1016                        }
1017
1018                        dlg.finished(false);
1019
1020                        return Err(match error {
1021                            Ok(value) => common::Error::BadRequest(value),
1022                            _ => common::Error::Failure(response),
1023                        });
1024                    }
1025                    let response = {
1026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1027                        let encoded = common::to_string(&bytes);
1028                        match serde_json::from_str(&encoded) {
1029                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1030                            Err(error) => {
1031                                dlg.response_json_decode_error(&encoded, &error);
1032                                return Err(common::Error::JsonDecodeError(
1033                                    encoded.to_string(),
1034                                    error,
1035                                ));
1036                            }
1037                        }
1038                    };
1039
1040                    dlg.finished(true);
1041                    return Ok(response);
1042                }
1043            }
1044        }
1045    }
1046
1047    /// Required. Finds the project that owns the key string value.
1048    ///
1049    /// Sets the *key string* query property to the given value.
1050    pub fn key_string(mut self, new_value: &str) -> KeyLookupKeyCall<'a, C> {
1051        self._key_string = Some(new_value.to_string());
1052        self
1053    }
1054    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1055    /// while executing the actual API request.
1056    ///
1057    /// ````text
1058    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1059    /// ````
1060    ///
1061    /// Sets the *delegate* property to the given value.
1062    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> KeyLookupKeyCall<'a, C> {
1063        self._delegate = Some(new_value);
1064        self
1065    }
1066
1067    /// Set any additional parameter of the query string used in the request.
1068    /// It should be used to set parameters which are not yet available through their own
1069    /// setters.
1070    ///
1071    /// Please note that this method must not be used to set any of the known parameters
1072    /// which have their own setter method. If done anyway, the request will fail.
1073    ///
1074    /// # Additional Parameters
1075    ///
1076    /// * *$.xgafv* (query-string) - V1 error format.
1077    /// * *access_token* (query-string) - OAuth access token.
1078    /// * *alt* (query-string) - Data format for response.
1079    /// * *callback* (query-string) - JSONP
1080    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1081    /// * *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.
1082    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1083    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1084    /// * *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.
1085    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1086    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1087    pub fn param<T>(mut self, name: T, value: T) -> KeyLookupKeyCall<'a, C>
1088    where
1089        T: AsRef<str>,
1090    {
1091        self._additional_params
1092            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1093        self
1094    }
1095
1096    /// Identifies the authorization scope for the method you are building.
1097    ///
1098    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1099    /// [`Scope::CloudPlatformReadOnly`].
1100    ///
1101    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1102    /// tokens for more than one scope.
1103    ///
1104    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1105    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1106    /// sufficient, a read-write scope will do as well.
1107    pub fn add_scope<St>(mut self, scope: St) -> KeyLookupKeyCall<'a, C>
1108    where
1109        St: AsRef<str>,
1110    {
1111        self._scopes.insert(String::from(scope.as_ref()));
1112        self
1113    }
1114    /// Identifies the authorization scope(s) for the method you are building.
1115    ///
1116    /// See [`Self::add_scope()`] for details.
1117    pub fn add_scopes<I, St>(mut self, scopes: I) -> KeyLookupKeyCall<'a, C>
1118    where
1119        I: IntoIterator<Item = St>,
1120        St: AsRef<str>,
1121    {
1122        self._scopes
1123            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1124        self
1125    }
1126
1127    /// Removes all scopes, and no default scope will be used either.
1128    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1129    /// for details).
1130    pub fn clear_scopes(mut self) -> KeyLookupKeyCall<'a, C> {
1131        self._scopes.clear();
1132        self
1133    }
1134}
1135
1136/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1137///
1138/// A builder for the *get* method supported by a *operation* resource.
1139/// It is not used directly, but through a [`OperationMethods`] instance.
1140///
1141/// # Example
1142///
1143/// Instantiate a resource method builder
1144///
1145/// ```test_harness,no_run
1146/// # extern crate hyper;
1147/// # extern crate hyper_rustls;
1148/// # extern crate google_apikeys2 as apikeys2;
1149/// # async fn dox() {
1150/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1151///
1152/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1153/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1154/// #     .with_native_roots()
1155/// #     .unwrap()
1156/// #     .https_only()
1157/// #     .enable_http2()
1158/// #     .build();
1159///
1160/// # let executor = hyper_util::rt::TokioExecutor::new();
1161/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1162/// #     secret,
1163/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1164/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1165/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1166/// #     ),
1167/// # ).build().await.unwrap();
1168///
1169/// # let client = hyper_util::client::legacy::Client::builder(
1170/// #     hyper_util::rt::TokioExecutor::new()
1171/// # )
1172/// # .build(
1173/// #     hyper_rustls::HttpsConnectorBuilder::new()
1174/// #         .with_native_roots()
1175/// #         .unwrap()
1176/// #         .https_or_http()
1177/// #         .enable_http2()
1178/// #         .build()
1179/// # );
1180/// # let mut hub = ApiKeysService::new(client, auth);
1181/// // You can configure optional parameters by calling the respective setters at will, and
1182/// // execute the final call using `doit()`.
1183/// // Values shown here are possibly random and not representative !
1184/// let result = hub.operations().get("name")
1185///              .doit().await;
1186/// # }
1187/// ```
1188pub struct OperationGetCall<'a, C>
1189where
1190    C: 'a,
1191{
1192    hub: &'a ApiKeysService<C>,
1193    _name: String,
1194    _delegate: Option<&'a mut dyn common::Delegate>,
1195    _additional_params: HashMap<String, String>,
1196    _scopes: BTreeSet<String>,
1197}
1198
1199impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
1200
1201impl<'a, C> OperationGetCall<'a, C>
1202where
1203    C: common::Connector,
1204{
1205    /// Perform the operation you have build so far.
1206    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1207        use std::borrow::Cow;
1208        use std::io::{Read, Seek};
1209
1210        use common::{url::Params, ToParts};
1211        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1212
1213        let mut dd = common::DefaultDelegate;
1214        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1215        dlg.begin(common::MethodInfo {
1216            id: "apikeys.operations.get",
1217            http_method: hyper::Method::GET,
1218        });
1219
1220        for &field in ["alt", "name"].iter() {
1221            if self._additional_params.contains_key(field) {
1222                dlg.finished(false);
1223                return Err(common::Error::FieldClash(field));
1224            }
1225        }
1226
1227        let mut params = Params::with_capacity(3 + self._additional_params.len());
1228        params.push("name", self._name);
1229
1230        params.extend(self._additional_params.iter());
1231
1232        params.push("alt", "json");
1233        let mut url = self.hub._base_url.clone() + "v2/{+name}";
1234        if self._scopes.is_empty() {
1235            self._scopes
1236                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
1237        }
1238
1239        #[allow(clippy::single_element_loop)]
1240        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1241            url = params.uri_replacement(url, param_name, find_this, true);
1242        }
1243        {
1244            let to_remove = ["name"];
1245            params.remove_params(&to_remove);
1246        }
1247
1248        let url = params.parse_with_url(&url);
1249
1250        loop {
1251            let token = match self
1252                .hub
1253                .auth
1254                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1255                .await
1256            {
1257                Ok(token) => token,
1258                Err(e) => match dlg.token(e) {
1259                    Ok(token) => token,
1260                    Err(e) => {
1261                        dlg.finished(false);
1262                        return Err(common::Error::MissingToken(e));
1263                    }
1264                },
1265            };
1266            let mut req_result = {
1267                let client = &self.hub.client;
1268                dlg.pre_request();
1269                let mut req_builder = hyper::Request::builder()
1270                    .method(hyper::Method::GET)
1271                    .uri(url.as_str())
1272                    .header(USER_AGENT, self.hub._user_agent.clone());
1273
1274                if let Some(token) = token.as_ref() {
1275                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1276                }
1277
1278                let request = req_builder
1279                    .header(CONTENT_LENGTH, 0_u64)
1280                    .body(common::to_body::<String>(None));
1281
1282                client.request(request.unwrap()).await
1283            };
1284
1285            match req_result {
1286                Err(err) => {
1287                    if let common::Retry::After(d) = dlg.http_error(&err) {
1288                        sleep(d).await;
1289                        continue;
1290                    }
1291                    dlg.finished(false);
1292                    return Err(common::Error::HttpError(err));
1293                }
1294                Ok(res) => {
1295                    let (mut parts, body) = res.into_parts();
1296                    let mut body = common::Body::new(body);
1297                    if !parts.status.is_success() {
1298                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1299                        let error = serde_json::from_str(&common::to_string(&bytes));
1300                        let response = common::to_response(parts, bytes.into());
1301
1302                        if let common::Retry::After(d) =
1303                            dlg.http_failure(&response, error.as_ref().ok())
1304                        {
1305                            sleep(d).await;
1306                            continue;
1307                        }
1308
1309                        dlg.finished(false);
1310
1311                        return Err(match error {
1312                            Ok(value) => common::Error::BadRequest(value),
1313                            _ => common::Error::Failure(response),
1314                        });
1315                    }
1316                    let response = {
1317                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1318                        let encoded = common::to_string(&bytes);
1319                        match serde_json::from_str(&encoded) {
1320                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1321                            Err(error) => {
1322                                dlg.response_json_decode_error(&encoded, &error);
1323                                return Err(common::Error::JsonDecodeError(
1324                                    encoded.to_string(),
1325                                    error,
1326                                ));
1327                            }
1328                        }
1329                    };
1330
1331                    dlg.finished(true);
1332                    return Ok(response);
1333                }
1334            }
1335        }
1336    }
1337
1338    /// The name of the operation resource.
1339    ///
1340    /// Sets the *name* path property to the given value.
1341    ///
1342    /// Even though the property as already been set when instantiating this call,
1343    /// we provide this method for API completeness.
1344    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
1345        self._name = new_value.to_string();
1346        self
1347    }
1348    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1349    /// while executing the actual API request.
1350    ///
1351    /// ````text
1352    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1353    /// ````
1354    ///
1355    /// Sets the *delegate* property to the given value.
1356    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
1357        self._delegate = Some(new_value);
1358        self
1359    }
1360
1361    /// Set any additional parameter of the query string used in the request.
1362    /// It should be used to set parameters which are not yet available through their own
1363    /// setters.
1364    ///
1365    /// Please note that this method must not be used to set any of the known parameters
1366    /// which have their own setter method. If done anyway, the request will fail.
1367    ///
1368    /// # Additional Parameters
1369    ///
1370    /// * *$.xgafv* (query-string) - V1 error format.
1371    /// * *access_token* (query-string) - OAuth access token.
1372    /// * *alt* (query-string) - Data format for response.
1373    /// * *callback* (query-string) - JSONP
1374    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1375    /// * *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.
1376    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1377    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1378    /// * *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.
1379    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1380    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1381    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
1382    where
1383        T: AsRef<str>,
1384    {
1385        self._additional_params
1386            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1387        self
1388    }
1389
1390    /// Identifies the authorization scope for the method you are building.
1391    ///
1392    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1393    /// [`Scope::CloudPlatformReadOnly`].
1394    ///
1395    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1396    /// tokens for more than one scope.
1397    ///
1398    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1399    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1400    /// sufficient, a read-write scope will do as well.
1401    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
1402    where
1403        St: AsRef<str>,
1404    {
1405        self._scopes.insert(String::from(scope.as_ref()));
1406        self
1407    }
1408    /// Identifies the authorization scope(s) for the method you are building.
1409    ///
1410    /// See [`Self::add_scope()`] for details.
1411    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
1412    where
1413        I: IntoIterator<Item = St>,
1414        St: AsRef<str>,
1415    {
1416        self._scopes
1417            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1418        self
1419    }
1420
1421    /// Removes all scopes, and no default scope will be used either.
1422    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1423    /// for details).
1424    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
1425        self._scopes.clear();
1426        self
1427    }
1428}
1429
1430/// Creates a new API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.
1431///
1432/// A builder for the *locations.keys.create* method supported by a *project* resource.
1433/// It is not used directly, but through a [`ProjectMethods`] instance.
1434///
1435/// # Example
1436///
1437/// Instantiate a resource method builder
1438///
1439/// ```test_harness,no_run
1440/// # extern crate hyper;
1441/// # extern crate hyper_rustls;
1442/// # extern crate google_apikeys2 as apikeys2;
1443/// use apikeys2::api::V2Key;
1444/// # async fn dox() {
1445/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1446///
1447/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1448/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1449/// #     .with_native_roots()
1450/// #     .unwrap()
1451/// #     .https_only()
1452/// #     .enable_http2()
1453/// #     .build();
1454///
1455/// # let executor = hyper_util::rt::TokioExecutor::new();
1456/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1457/// #     secret,
1458/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1459/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1460/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1461/// #     ),
1462/// # ).build().await.unwrap();
1463///
1464/// # let client = hyper_util::client::legacy::Client::builder(
1465/// #     hyper_util::rt::TokioExecutor::new()
1466/// # )
1467/// # .build(
1468/// #     hyper_rustls::HttpsConnectorBuilder::new()
1469/// #         .with_native_roots()
1470/// #         .unwrap()
1471/// #         .https_or_http()
1472/// #         .enable_http2()
1473/// #         .build()
1474/// # );
1475/// # let mut hub = ApiKeysService::new(client, auth);
1476/// // As the method needs a request, you would usually fill it with the desired information
1477/// // into the respective structure. Some of the parts shown here might not be applicable !
1478/// // Values shown here are possibly random and not representative !
1479/// let mut req = V2Key::default();
1480///
1481/// // You can configure optional parameters by calling the respective setters at will, and
1482/// // execute the final call using `doit()`.
1483/// // Values shown here are possibly random and not representative !
1484/// let result = hub.projects().locations_keys_create(req, "parent")
1485///              .key_id("takimata")
1486///              .doit().await;
1487/// # }
1488/// ```
1489pub struct ProjectLocationKeyCreateCall<'a, C>
1490where
1491    C: 'a,
1492{
1493    hub: &'a ApiKeysService<C>,
1494    _request: V2Key,
1495    _parent: String,
1496    _key_id: Option<String>,
1497    _delegate: Option<&'a mut dyn common::Delegate>,
1498    _additional_params: HashMap<String, String>,
1499    _scopes: BTreeSet<String>,
1500}
1501
1502impl<'a, C> common::CallBuilder for ProjectLocationKeyCreateCall<'a, C> {}
1503
1504impl<'a, C> ProjectLocationKeyCreateCall<'a, C>
1505where
1506    C: common::Connector,
1507{
1508    /// Perform the operation you have build so far.
1509    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1510        use std::borrow::Cow;
1511        use std::io::{Read, Seek};
1512
1513        use common::{url::Params, ToParts};
1514        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1515
1516        let mut dd = common::DefaultDelegate;
1517        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1518        dlg.begin(common::MethodInfo {
1519            id: "apikeys.projects.locations.keys.create",
1520            http_method: hyper::Method::POST,
1521        });
1522
1523        for &field in ["alt", "parent", "keyId"].iter() {
1524            if self._additional_params.contains_key(field) {
1525                dlg.finished(false);
1526                return Err(common::Error::FieldClash(field));
1527            }
1528        }
1529
1530        let mut params = Params::with_capacity(5 + self._additional_params.len());
1531        params.push("parent", self._parent);
1532        if let Some(value) = self._key_id.as_ref() {
1533            params.push("keyId", value);
1534        }
1535
1536        params.extend(self._additional_params.iter());
1537
1538        params.push("alt", "json");
1539        let mut url = self.hub._base_url.clone() + "v2/{+parent}/keys";
1540        if self._scopes.is_empty() {
1541            self._scopes
1542                .insert(Scope::CloudPlatform.as_ref().to_string());
1543        }
1544
1545        #[allow(clippy::single_element_loop)]
1546        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1547            url = params.uri_replacement(url, param_name, find_this, true);
1548        }
1549        {
1550            let to_remove = ["parent"];
1551            params.remove_params(&to_remove);
1552        }
1553
1554        let url = params.parse_with_url(&url);
1555
1556        let mut json_mime_type = mime::APPLICATION_JSON;
1557        let mut request_value_reader = {
1558            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1559            common::remove_json_null_values(&mut value);
1560            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1561            serde_json::to_writer(&mut dst, &value).unwrap();
1562            dst
1563        };
1564        let request_size = request_value_reader
1565            .seek(std::io::SeekFrom::End(0))
1566            .unwrap();
1567        request_value_reader
1568            .seek(std::io::SeekFrom::Start(0))
1569            .unwrap();
1570
1571        loop {
1572            let token = match self
1573                .hub
1574                .auth
1575                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1576                .await
1577            {
1578                Ok(token) => token,
1579                Err(e) => match dlg.token(e) {
1580                    Ok(token) => token,
1581                    Err(e) => {
1582                        dlg.finished(false);
1583                        return Err(common::Error::MissingToken(e));
1584                    }
1585                },
1586            };
1587            request_value_reader
1588                .seek(std::io::SeekFrom::Start(0))
1589                .unwrap();
1590            let mut req_result = {
1591                let client = &self.hub.client;
1592                dlg.pre_request();
1593                let mut req_builder = hyper::Request::builder()
1594                    .method(hyper::Method::POST)
1595                    .uri(url.as_str())
1596                    .header(USER_AGENT, self.hub._user_agent.clone());
1597
1598                if let Some(token) = token.as_ref() {
1599                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1600                }
1601
1602                let request = req_builder
1603                    .header(CONTENT_TYPE, json_mime_type.to_string())
1604                    .header(CONTENT_LENGTH, request_size as u64)
1605                    .body(common::to_body(
1606                        request_value_reader.get_ref().clone().into(),
1607                    ));
1608
1609                client.request(request.unwrap()).await
1610            };
1611
1612            match req_result {
1613                Err(err) => {
1614                    if let common::Retry::After(d) = dlg.http_error(&err) {
1615                        sleep(d).await;
1616                        continue;
1617                    }
1618                    dlg.finished(false);
1619                    return Err(common::Error::HttpError(err));
1620                }
1621                Ok(res) => {
1622                    let (mut parts, body) = res.into_parts();
1623                    let mut body = common::Body::new(body);
1624                    if !parts.status.is_success() {
1625                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1626                        let error = serde_json::from_str(&common::to_string(&bytes));
1627                        let response = common::to_response(parts, bytes.into());
1628
1629                        if let common::Retry::After(d) =
1630                            dlg.http_failure(&response, error.as_ref().ok())
1631                        {
1632                            sleep(d).await;
1633                            continue;
1634                        }
1635
1636                        dlg.finished(false);
1637
1638                        return Err(match error {
1639                            Ok(value) => common::Error::BadRequest(value),
1640                            _ => common::Error::Failure(response),
1641                        });
1642                    }
1643                    let response = {
1644                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1645                        let encoded = common::to_string(&bytes);
1646                        match serde_json::from_str(&encoded) {
1647                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1648                            Err(error) => {
1649                                dlg.response_json_decode_error(&encoded, &error);
1650                                return Err(common::Error::JsonDecodeError(
1651                                    encoded.to_string(),
1652                                    error,
1653                                ));
1654                            }
1655                        }
1656                    };
1657
1658                    dlg.finished(true);
1659                    return Ok(response);
1660                }
1661            }
1662        }
1663    }
1664
1665    ///
1666    /// Sets the *request* property to the given value.
1667    ///
1668    /// Even though the property as already been set when instantiating this call,
1669    /// we provide this method for API completeness.
1670    pub fn request(mut self, new_value: V2Key) -> ProjectLocationKeyCreateCall<'a, C> {
1671        self._request = new_value;
1672        self
1673    }
1674    /// Required. The project in which the API key is created.
1675    ///
1676    /// Sets the *parent* path property to the given value.
1677    ///
1678    /// Even though the property as already been set when instantiating this call,
1679    /// we provide this method for API completeness.
1680    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyCreateCall<'a, C> {
1681        self._parent = new_value.to_string();
1682        self
1683    }
1684    /// User specified key id (optional). If specified, it will become the final component of the key resource name. The id must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the id must match the regular expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like string.
1685    ///
1686    /// Sets the *key id* query property to the given value.
1687    pub fn key_id(mut self, new_value: &str) -> ProjectLocationKeyCreateCall<'a, C> {
1688        self._key_id = Some(new_value.to_string());
1689        self
1690    }
1691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1692    /// while executing the actual API request.
1693    ///
1694    /// ````text
1695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1696    /// ````
1697    ///
1698    /// Sets the *delegate* property to the given value.
1699    pub fn delegate(
1700        mut self,
1701        new_value: &'a mut dyn common::Delegate,
1702    ) -> ProjectLocationKeyCreateCall<'a, C> {
1703        self._delegate = Some(new_value);
1704        self
1705    }
1706
1707    /// Set any additional parameter of the query string used in the request.
1708    /// It should be used to set parameters which are not yet available through their own
1709    /// setters.
1710    ///
1711    /// Please note that this method must not be used to set any of the known parameters
1712    /// which have their own setter method. If done anyway, the request will fail.
1713    ///
1714    /// # Additional Parameters
1715    ///
1716    /// * *$.xgafv* (query-string) - V1 error format.
1717    /// * *access_token* (query-string) - OAuth access token.
1718    /// * *alt* (query-string) - Data format for response.
1719    /// * *callback* (query-string) - JSONP
1720    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1721    /// * *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.
1722    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1723    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1724    /// * *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.
1725    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1726    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1727    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyCreateCall<'a, C>
1728    where
1729        T: AsRef<str>,
1730    {
1731        self._additional_params
1732            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1733        self
1734    }
1735
1736    /// Identifies the authorization scope for the method you are building.
1737    ///
1738    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1739    /// [`Scope::CloudPlatform`].
1740    ///
1741    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1742    /// tokens for more than one scope.
1743    ///
1744    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1745    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1746    /// sufficient, a read-write scope will do as well.
1747    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyCreateCall<'a, C>
1748    where
1749        St: AsRef<str>,
1750    {
1751        self._scopes.insert(String::from(scope.as_ref()));
1752        self
1753    }
1754    /// Identifies the authorization scope(s) for the method you are building.
1755    ///
1756    /// See [`Self::add_scope()`] for details.
1757    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyCreateCall<'a, C>
1758    where
1759        I: IntoIterator<Item = St>,
1760        St: AsRef<str>,
1761    {
1762        self._scopes
1763            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1764        self
1765    }
1766
1767    /// Removes all scopes, and no default scope will be used either.
1768    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1769    /// for details).
1770    pub fn clear_scopes(mut self) -> ProjectLocationKeyCreateCall<'a, C> {
1771        self._scopes.clear();
1772        self
1773    }
1774}
1775
1776/// Deletes an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. NOTE: Key is a global resource; hence the only supported value for location is `global`.
1777///
1778/// A builder for the *locations.keys.delete* method supported by a *project* resource.
1779/// It is not used directly, but through a [`ProjectMethods`] instance.
1780///
1781/// # Example
1782///
1783/// Instantiate a resource method builder
1784///
1785/// ```test_harness,no_run
1786/// # extern crate hyper;
1787/// # extern crate hyper_rustls;
1788/// # extern crate google_apikeys2 as apikeys2;
1789/// # async fn dox() {
1790/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1791///
1792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1793/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1794/// #     .with_native_roots()
1795/// #     .unwrap()
1796/// #     .https_only()
1797/// #     .enable_http2()
1798/// #     .build();
1799///
1800/// # let executor = hyper_util::rt::TokioExecutor::new();
1801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1802/// #     secret,
1803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1804/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1805/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1806/// #     ),
1807/// # ).build().await.unwrap();
1808///
1809/// # let client = hyper_util::client::legacy::Client::builder(
1810/// #     hyper_util::rt::TokioExecutor::new()
1811/// # )
1812/// # .build(
1813/// #     hyper_rustls::HttpsConnectorBuilder::new()
1814/// #         .with_native_roots()
1815/// #         .unwrap()
1816/// #         .https_or_http()
1817/// #         .enable_http2()
1818/// #         .build()
1819/// # );
1820/// # let mut hub = ApiKeysService::new(client, auth);
1821/// // You can configure optional parameters by calling the respective setters at will, and
1822/// // execute the final call using `doit()`.
1823/// // Values shown here are possibly random and not representative !
1824/// let result = hub.projects().locations_keys_delete("name")
1825///              .etag("duo")
1826///              .doit().await;
1827/// # }
1828/// ```
1829pub struct ProjectLocationKeyDeleteCall<'a, C>
1830where
1831    C: 'a,
1832{
1833    hub: &'a ApiKeysService<C>,
1834    _name: String,
1835    _etag: Option<String>,
1836    _delegate: Option<&'a mut dyn common::Delegate>,
1837    _additional_params: HashMap<String, String>,
1838    _scopes: BTreeSet<String>,
1839}
1840
1841impl<'a, C> common::CallBuilder for ProjectLocationKeyDeleteCall<'a, C> {}
1842
1843impl<'a, C> ProjectLocationKeyDeleteCall<'a, C>
1844where
1845    C: common::Connector,
1846{
1847    /// Perform the operation you have build so far.
1848    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1849        use std::borrow::Cow;
1850        use std::io::{Read, Seek};
1851
1852        use common::{url::Params, ToParts};
1853        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1854
1855        let mut dd = common::DefaultDelegate;
1856        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1857        dlg.begin(common::MethodInfo {
1858            id: "apikeys.projects.locations.keys.delete",
1859            http_method: hyper::Method::DELETE,
1860        });
1861
1862        for &field in ["alt", "name", "etag"].iter() {
1863            if self._additional_params.contains_key(field) {
1864                dlg.finished(false);
1865                return Err(common::Error::FieldClash(field));
1866            }
1867        }
1868
1869        let mut params = Params::with_capacity(4 + self._additional_params.len());
1870        params.push("name", self._name);
1871        if let Some(value) = self._etag.as_ref() {
1872            params.push("etag", value);
1873        }
1874
1875        params.extend(self._additional_params.iter());
1876
1877        params.push("alt", "json");
1878        let mut url = self.hub._base_url.clone() + "v2/{+name}";
1879        if self._scopes.is_empty() {
1880            self._scopes
1881                .insert(Scope::CloudPlatform.as_ref().to_string());
1882        }
1883
1884        #[allow(clippy::single_element_loop)]
1885        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1886            url = params.uri_replacement(url, param_name, find_this, true);
1887        }
1888        {
1889            let to_remove = ["name"];
1890            params.remove_params(&to_remove);
1891        }
1892
1893        let url = params.parse_with_url(&url);
1894
1895        loop {
1896            let token = match self
1897                .hub
1898                .auth
1899                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1900                .await
1901            {
1902                Ok(token) => token,
1903                Err(e) => match dlg.token(e) {
1904                    Ok(token) => token,
1905                    Err(e) => {
1906                        dlg.finished(false);
1907                        return Err(common::Error::MissingToken(e));
1908                    }
1909                },
1910            };
1911            let mut req_result = {
1912                let client = &self.hub.client;
1913                dlg.pre_request();
1914                let mut req_builder = hyper::Request::builder()
1915                    .method(hyper::Method::DELETE)
1916                    .uri(url.as_str())
1917                    .header(USER_AGENT, self.hub._user_agent.clone());
1918
1919                if let Some(token) = token.as_ref() {
1920                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1921                }
1922
1923                let request = req_builder
1924                    .header(CONTENT_LENGTH, 0_u64)
1925                    .body(common::to_body::<String>(None));
1926
1927                client.request(request.unwrap()).await
1928            };
1929
1930            match req_result {
1931                Err(err) => {
1932                    if let common::Retry::After(d) = dlg.http_error(&err) {
1933                        sleep(d).await;
1934                        continue;
1935                    }
1936                    dlg.finished(false);
1937                    return Err(common::Error::HttpError(err));
1938                }
1939                Ok(res) => {
1940                    let (mut parts, body) = res.into_parts();
1941                    let mut body = common::Body::new(body);
1942                    if !parts.status.is_success() {
1943                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1944                        let error = serde_json::from_str(&common::to_string(&bytes));
1945                        let response = common::to_response(parts, bytes.into());
1946
1947                        if let common::Retry::After(d) =
1948                            dlg.http_failure(&response, error.as_ref().ok())
1949                        {
1950                            sleep(d).await;
1951                            continue;
1952                        }
1953
1954                        dlg.finished(false);
1955
1956                        return Err(match error {
1957                            Ok(value) => common::Error::BadRequest(value),
1958                            _ => common::Error::Failure(response),
1959                        });
1960                    }
1961                    let response = {
1962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1963                        let encoded = common::to_string(&bytes);
1964                        match serde_json::from_str(&encoded) {
1965                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1966                            Err(error) => {
1967                                dlg.response_json_decode_error(&encoded, &error);
1968                                return Err(common::Error::JsonDecodeError(
1969                                    encoded.to_string(),
1970                                    error,
1971                                ));
1972                            }
1973                        }
1974                    };
1975
1976                    dlg.finished(true);
1977                    return Ok(response);
1978                }
1979            }
1980        }
1981    }
1982
1983    /// Required. The resource name of the API key to be deleted.
1984    ///
1985    /// Sets the *name* path property to the given value.
1986    ///
1987    /// Even though the property as already been set when instantiating this call,
1988    /// we provide this method for API completeness.
1989    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyDeleteCall<'a, C> {
1990        self._name = new_value.to_string();
1991        self
1992    }
1993    /// Optional. The etag known to the client for the expected state of the key. This is to be used for optimistic concurrency.
1994    ///
1995    /// Sets the *etag* query property to the given value.
1996    pub fn etag(mut self, new_value: &str) -> ProjectLocationKeyDeleteCall<'a, C> {
1997        self._etag = Some(new_value.to_string());
1998        self
1999    }
2000    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2001    /// while executing the actual API request.
2002    ///
2003    /// ````text
2004    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2005    /// ````
2006    ///
2007    /// Sets the *delegate* property to the given value.
2008    pub fn delegate(
2009        mut self,
2010        new_value: &'a mut dyn common::Delegate,
2011    ) -> ProjectLocationKeyDeleteCall<'a, C> {
2012        self._delegate = Some(new_value);
2013        self
2014    }
2015
2016    /// Set any additional parameter of the query string used in the request.
2017    /// It should be used to set parameters which are not yet available through their own
2018    /// setters.
2019    ///
2020    /// Please note that this method must not be used to set any of the known parameters
2021    /// which have their own setter method. If done anyway, the request will fail.
2022    ///
2023    /// # Additional Parameters
2024    ///
2025    /// * *$.xgafv* (query-string) - V1 error format.
2026    /// * *access_token* (query-string) - OAuth access token.
2027    /// * *alt* (query-string) - Data format for response.
2028    /// * *callback* (query-string) - JSONP
2029    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2030    /// * *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.
2031    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2032    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2033    /// * *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.
2034    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2035    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2036    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyDeleteCall<'a, C>
2037    where
2038        T: AsRef<str>,
2039    {
2040        self._additional_params
2041            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2042        self
2043    }
2044
2045    /// Identifies the authorization scope for the method you are building.
2046    ///
2047    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2048    /// [`Scope::CloudPlatform`].
2049    ///
2050    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2051    /// tokens for more than one scope.
2052    ///
2053    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2054    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2055    /// sufficient, a read-write scope will do as well.
2056    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyDeleteCall<'a, C>
2057    where
2058        St: AsRef<str>,
2059    {
2060        self._scopes.insert(String::from(scope.as_ref()));
2061        self
2062    }
2063    /// Identifies the authorization scope(s) for the method you are building.
2064    ///
2065    /// See [`Self::add_scope()`] for details.
2066    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyDeleteCall<'a, C>
2067    where
2068        I: IntoIterator<Item = St>,
2069        St: AsRef<str>,
2070    {
2071        self._scopes
2072            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2073        self
2074    }
2075
2076    /// Removes all scopes, and no default scope will be used either.
2077    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2078    /// for details).
2079    pub fn clear_scopes(mut self) -> ProjectLocationKeyDeleteCall<'a, C> {
2080        self._scopes.clear();
2081        self
2082    }
2083}
2084
2085/// Gets the metadata for an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
2086///
2087/// A builder for the *locations.keys.get* method supported by a *project* resource.
2088/// It is not used directly, but through a [`ProjectMethods`] instance.
2089///
2090/// # Example
2091///
2092/// Instantiate a resource method builder
2093///
2094/// ```test_harness,no_run
2095/// # extern crate hyper;
2096/// # extern crate hyper_rustls;
2097/// # extern crate google_apikeys2 as apikeys2;
2098/// # async fn dox() {
2099/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2100///
2101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2103/// #     .with_native_roots()
2104/// #     .unwrap()
2105/// #     .https_only()
2106/// #     .enable_http2()
2107/// #     .build();
2108///
2109/// # let executor = hyper_util::rt::TokioExecutor::new();
2110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2111/// #     secret,
2112/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2113/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2114/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2115/// #     ),
2116/// # ).build().await.unwrap();
2117///
2118/// # let client = hyper_util::client::legacy::Client::builder(
2119/// #     hyper_util::rt::TokioExecutor::new()
2120/// # )
2121/// # .build(
2122/// #     hyper_rustls::HttpsConnectorBuilder::new()
2123/// #         .with_native_roots()
2124/// #         .unwrap()
2125/// #         .https_or_http()
2126/// #         .enable_http2()
2127/// #         .build()
2128/// # );
2129/// # let mut hub = ApiKeysService::new(client, auth);
2130/// // You can configure optional parameters by calling the respective setters at will, and
2131/// // execute the final call using `doit()`.
2132/// // Values shown here are possibly random and not representative !
2133/// let result = hub.projects().locations_keys_get("name")
2134///              .doit().await;
2135/// # }
2136/// ```
2137pub struct ProjectLocationKeyGetCall<'a, C>
2138where
2139    C: 'a,
2140{
2141    hub: &'a ApiKeysService<C>,
2142    _name: String,
2143    _delegate: Option<&'a mut dyn common::Delegate>,
2144    _additional_params: HashMap<String, String>,
2145    _scopes: BTreeSet<String>,
2146}
2147
2148impl<'a, C> common::CallBuilder for ProjectLocationKeyGetCall<'a, C> {}
2149
2150impl<'a, C> ProjectLocationKeyGetCall<'a, C>
2151where
2152    C: common::Connector,
2153{
2154    /// Perform the operation you have build so far.
2155    pub async fn doit(mut self) -> common::Result<(common::Response, V2Key)> {
2156        use std::borrow::Cow;
2157        use std::io::{Read, Seek};
2158
2159        use common::{url::Params, ToParts};
2160        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2161
2162        let mut dd = common::DefaultDelegate;
2163        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2164        dlg.begin(common::MethodInfo {
2165            id: "apikeys.projects.locations.keys.get",
2166            http_method: hyper::Method::GET,
2167        });
2168
2169        for &field in ["alt", "name"].iter() {
2170            if self._additional_params.contains_key(field) {
2171                dlg.finished(false);
2172                return Err(common::Error::FieldClash(field));
2173            }
2174        }
2175
2176        let mut params = Params::with_capacity(3 + self._additional_params.len());
2177        params.push("name", self._name);
2178
2179        params.extend(self._additional_params.iter());
2180
2181        params.push("alt", "json");
2182        let mut url = self.hub._base_url.clone() + "v2/{+name}";
2183        if self._scopes.is_empty() {
2184            self._scopes
2185                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2186        }
2187
2188        #[allow(clippy::single_element_loop)]
2189        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2190            url = params.uri_replacement(url, param_name, find_this, true);
2191        }
2192        {
2193            let to_remove = ["name"];
2194            params.remove_params(&to_remove);
2195        }
2196
2197        let url = params.parse_with_url(&url);
2198
2199        loop {
2200            let token = match self
2201                .hub
2202                .auth
2203                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2204                .await
2205            {
2206                Ok(token) => token,
2207                Err(e) => match dlg.token(e) {
2208                    Ok(token) => token,
2209                    Err(e) => {
2210                        dlg.finished(false);
2211                        return Err(common::Error::MissingToken(e));
2212                    }
2213                },
2214            };
2215            let mut req_result = {
2216                let client = &self.hub.client;
2217                dlg.pre_request();
2218                let mut req_builder = hyper::Request::builder()
2219                    .method(hyper::Method::GET)
2220                    .uri(url.as_str())
2221                    .header(USER_AGENT, self.hub._user_agent.clone());
2222
2223                if let Some(token) = token.as_ref() {
2224                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2225                }
2226
2227                let request = req_builder
2228                    .header(CONTENT_LENGTH, 0_u64)
2229                    .body(common::to_body::<String>(None));
2230
2231                client.request(request.unwrap()).await
2232            };
2233
2234            match req_result {
2235                Err(err) => {
2236                    if let common::Retry::After(d) = dlg.http_error(&err) {
2237                        sleep(d).await;
2238                        continue;
2239                    }
2240                    dlg.finished(false);
2241                    return Err(common::Error::HttpError(err));
2242                }
2243                Ok(res) => {
2244                    let (mut parts, body) = res.into_parts();
2245                    let mut body = common::Body::new(body);
2246                    if !parts.status.is_success() {
2247                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2248                        let error = serde_json::from_str(&common::to_string(&bytes));
2249                        let response = common::to_response(parts, bytes.into());
2250
2251                        if let common::Retry::After(d) =
2252                            dlg.http_failure(&response, error.as_ref().ok())
2253                        {
2254                            sleep(d).await;
2255                            continue;
2256                        }
2257
2258                        dlg.finished(false);
2259
2260                        return Err(match error {
2261                            Ok(value) => common::Error::BadRequest(value),
2262                            _ => common::Error::Failure(response),
2263                        });
2264                    }
2265                    let response = {
2266                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2267                        let encoded = common::to_string(&bytes);
2268                        match serde_json::from_str(&encoded) {
2269                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2270                            Err(error) => {
2271                                dlg.response_json_decode_error(&encoded, &error);
2272                                return Err(common::Error::JsonDecodeError(
2273                                    encoded.to_string(),
2274                                    error,
2275                                ));
2276                            }
2277                        }
2278                    };
2279
2280                    dlg.finished(true);
2281                    return Ok(response);
2282                }
2283            }
2284        }
2285    }
2286
2287    /// Required. The resource name of the API key to get.
2288    ///
2289    /// Sets the *name* path property to the given value.
2290    ///
2291    /// Even though the property as already been set when instantiating this call,
2292    /// we provide this method for API completeness.
2293    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyGetCall<'a, C> {
2294        self._name = new_value.to_string();
2295        self
2296    }
2297    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2298    /// while executing the actual API request.
2299    ///
2300    /// ````text
2301    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2302    /// ````
2303    ///
2304    /// Sets the *delegate* property to the given value.
2305    pub fn delegate(
2306        mut self,
2307        new_value: &'a mut dyn common::Delegate,
2308    ) -> ProjectLocationKeyGetCall<'a, C> {
2309        self._delegate = Some(new_value);
2310        self
2311    }
2312
2313    /// Set any additional parameter of the query string used in the request.
2314    /// It should be used to set parameters which are not yet available through their own
2315    /// setters.
2316    ///
2317    /// Please note that this method must not be used to set any of the known parameters
2318    /// which have their own setter method. If done anyway, the request will fail.
2319    ///
2320    /// # Additional Parameters
2321    ///
2322    /// * *$.xgafv* (query-string) - V1 error format.
2323    /// * *access_token* (query-string) - OAuth access token.
2324    /// * *alt* (query-string) - Data format for response.
2325    /// * *callback* (query-string) - JSONP
2326    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2327    /// * *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.
2328    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2329    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2330    /// * *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.
2331    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2332    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2333    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyGetCall<'a, C>
2334    where
2335        T: AsRef<str>,
2336    {
2337        self._additional_params
2338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2339        self
2340    }
2341
2342    /// Identifies the authorization scope for the method you are building.
2343    ///
2344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2345    /// [`Scope::CloudPlatformReadOnly`].
2346    ///
2347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2348    /// tokens for more than one scope.
2349    ///
2350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2352    /// sufficient, a read-write scope will do as well.
2353    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyGetCall<'a, C>
2354    where
2355        St: AsRef<str>,
2356    {
2357        self._scopes.insert(String::from(scope.as_ref()));
2358        self
2359    }
2360    /// Identifies the authorization scope(s) for the method you are building.
2361    ///
2362    /// See [`Self::add_scope()`] for details.
2363    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyGetCall<'a, C>
2364    where
2365        I: IntoIterator<Item = St>,
2366        St: AsRef<str>,
2367    {
2368        self._scopes
2369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2370        self
2371    }
2372
2373    /// Removes all scopes, and no default scope will be used either.
2374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2375    /// for details).
2376    pub fn clear_scopes(mut self) -> ProjectLocationKeyGetCall<'a, C> {
2377        self._scopes.clear();
2378        self
2379    }
2380}
2381
2382/// Get the key string for an API key. NOTE: Key is a global resource; hence the only supported value for location is `global`.
2383///
2384/// A builder for the *locations.keys.getKeyString* method supported by a *project* resource.
2385/// It is not used directly, but through a [`ProjectMethods`] instance.
2386///
2387/// # Example
2388///
2389/// Instantiate a resource method builder
2390///
2391/// ```test_harness,no_run
2392/// # extern crate hyper;
2393/// # extern crate hyper_rustls;
2394/// # extern crate google_apikeys2 as apikeys2;
2395/// # async fn dox() {
2396/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2397///
2398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2400/// #     .with_native_roots()
2401/// #     .unwrap()
2402/// #     .https_only()
2403/// #     .enable_http2()
2404/// #     .build();
2405///
2406/// # let executor = hyper_util::rt::TokioExecutor::new();
2407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2408/// #     secret,
2409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2412/// #     ),
2413/// # ).build().await.unwrap();
2414///
2415/// # let client = hyper_util::client::legacy::Client::builder(
2416/// #     hyper_util::rt::TokioExecutor::new()
2417/// # )
2418/// # .build(
2419/// #     hyper_rustls::HttpsConnectorBuilder::new()
2420/// #         .with_native_roots()
2421/// #         .unwrap()
2422/// #         .https_or_http()
2423/// #         .enable_http2()
2424/// #         .build()
2425/// # );
2426/// # let mut hub = ApiKeysService::new(client, auth);
2427/// // You can configure optional parameters by calling the respective setters at will, and
2428/// // execute the final call using `doit()`.
2429/// // Values shown here are possibly random and not representative !
2430/// let result = hub.projects().locations_keys_get_key_string("name")
2431///              .doit().await;
2432/// # }
2433/// ```
2434pub struct ProjectLocationKeyGetKeyStringCall<'a, C>
2435where
2436    C: 'a,
2437{
2438    hub: &'a ApiKeysService<C>,
2439    _name: String,
2440    _delegate: Option<&'a mut dyn common::Delegate>,
2441    _additional_params: HashMap<String, String>,
2442    _scopes: BTreeSet<String>,
2443}
2444
2445impl<'a, C> common::CallBuilder for ProjectLocationKeyGetKeyStringCall<'a, C> {}
2446
2447impl<'a, C> ProjectLocationKeyGetKeyStringCall<'a, C>
2448where
2449    C: common::Connector,
2450{
2451    /// Perform the operation you have build so far.
2452    pub async fn doit(mut self) -> common::Result<(common::Response, V2GetKeyStringResponse)> {
2453        use std::borrow::Cow;
2454        use std::io::{Read, Seek};
2455
2456        use common::{url::Params, ToParts};
2457        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2458
2459        let mut dd = common::DefaultDelegate;
2460        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2461        dlg.begin(common::MethodInfo {
2462            id: "apikeys.projects.locations.keys.getKeyString",
2463            http_method: hyper::Method::GET,
2464        });
2465
2466        for &field in ["alt", "name"].iter() {
2467            if self._additional_params.contains_key(field) {
2468                dlg.finished(false);
2469                return Err(common::Error::FieldClash(field));
2470            }
2471        }
2472
2473        let mut params = Params::with_capacity(3 + self._additional_params.len());
2474        params.push("name", self._name);
2475
2476        params.extend(self._additional_params.iter());
2477
2478        params.push("alt", "json");
2479        let mut url = self.hub._base_url.clone() + "v2/{+name}/keyString";
2480        if self._scopes.is_empty() {
2481            self._scopes
2482                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2483        }
2484
2485        #[allow(clippy::single_element_loop)]
2486        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2487            url = params.uri_replacement(url, param_name, find_this, true);
2488        }
2489        {
2490            let to_remove = ["name"];
2491            params.remove_params(&to_remove);
2492        }
2493
2494        let url = params.parse_with_url(&url);
2495
2496        loop {
2497            let token = match self
2498                .hub
2499                .auth
2500                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2501                .await
2502            {
2503                Ok(token) => token,
2504                Err(e) => match dlg.token(e) {
2505                    Ok(token) => token,
2506                    Err(e) => {
2507                        dlg.finished(false);
2508                        return Err(common::Error::MissingToken(e));
2509                    }
2510                },
2511            };
2512            let mut req_result = {
2513                let client = &self.hub.client;
2514                dlg.pre_request();
2515                let mut req_builder = hyper::Request::builder()
2516                    .method(hyper::Method::GET)
2517                    .uri(url.as_str())
2518                    .header(USER_AGENT, self.hub._user_agent.clone());
2519
2520                if let Some(token) = token.as_ref() {
2521                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2522                }
2523
2524                let request = req_builder
2525                    .header(CONTENT_LENGTH, 0_u64)
2526                    .body(common::to_body::<String>(None));
2527
2528                client.request(request.unwrap()).await
2529            };
2530
2531            match req_result {
2532                Err(err) => {
2533                    if let common::Retry::After(d) = dlg.http_error(&err) {
2534                        sleep(d).await;
2535                        continue;
2536                    }
2537                    dlg.finished(false);
2538                    return Err(common::Error::HttpError(err));
2539                }
2540                Ok(res) => {
2541                    let (mut parts, body) = res.into_parts();
2542                    let mut body = common::Body::new(body);
2543                    if !parts.status.is_success() {
2544                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2545                        let error = serde_json::from_str(&common::to_string(&bytes));
2546                        let response = common::to_response(parts, bytes.into());
2547
2548                        if let common::Retry::After(d) =
2549                            dlg.http_failure(&response, error.as_ref().ok())
2550                        {
2551                            sleep(d).await;
2552                            continue;
2553                        }
2554
2555                        dlg.finished(false);
2556
2557                        return Err(match error {
2558                            Ok(value) => common::Error::BadRequest(value),
2559                            _ => common::Error::Failure(response),
2560                        });
2561                    }
2562                    let response = {
2563                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2564                        let encoded = common::to_string(&bytes);
2565                        match serde_json::from_str(&encoded) {
2566                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2567                            Err(error) => {
2568                                dlg.response_json_decode_error(&encoded, &error);
2569                                return Err(common::Error::JsonDecodeError(
2570                                    encoded.to_string(),
2571                                    error,
2572                                ));
2573                            }
2574                        }
2575                    };
2576
2577                    dlg.finished(true);
2578                    return Ok(response);
2579                }
2580            }
2581        }
2582    }
2583
2584    /// Required. The resource name of the API key to be retrieved.
2585    ///
2586    /// Sets the *name* path property to the given value.
2587    ///
2588    /// Even though the property as already been set when instantiating this call,
2589    /// we provide this method for API completeness.
2590    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyGetKeyStringCall<'a, C> {
2591        self._name = new_value.to_string();
2592        self
2593    }
2594    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2595    /// while executing the actual API request.
2596    ///
2597    /// ````text
2598    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2599    /// ````
2600    ///
2601    /// Sets the *delegate* property to the given value.
2602    pub fn delegate(
2603        mut self,
2604        new_value: &'a mut dyn common::Delegate,
2605    ) -> ProjectLocationKeyGetKeyStringCall<'a, C> {
2606        self._delegate = Some(new_value);
2607        self
2608    }
2609
2610    /// Set any additional parameter of the query string used in the request.
2611    /// It should be used to set parameters which are not yet available through their own
2612    /// setters.
2613    ///
2614    /// Please note that this method must not be used to set any of the known parameters
2615    /// which have their own setter method. If done anyway, the request will fail.
2616    ///
2617    /// # Additional Parameters
2618    ///
2619    /// * *$.xgafv* (query-string) - V1 error format.
2620    /// * *access_token* (query-string) - OAuth access token.
2621    /// * *alt* (query-string) - Data format for response.
2622    /// * *callback* (query-string) - JSONP
2623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2624    /// * *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.
2625    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2626    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2627    /// * *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.
2628    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2629    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2630    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyGetKeyStringCall<'a, C>
2631    where
2632        T: AsRef<str>,
2633    {
2634        self._additional_params
2635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2636        self
2637    }
2638
2639    /// Identifies the authorization scope for the method you are building.
2640    ///
2641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2642    /// [`Scope::CloudPlatformReadOnly`].
2643    ///
2644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2645    /// tokens for more than one scope.
2646    ///
2647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2649    /// sufficient, a read-write scope will do as well.
2650    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyGetKeyStringCall<'a, C>
2651    where
2652        St: AsRef<str>,
2653    {
2654        self._scopes.insert(String::from(scope.as_ref()));
2655        self
2656    }
2657    /// Identifies the authorization scope(s) for the method you are building.
2658    ///
2659    /// See [`Self::add_scope()`] for details.
2660    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyGetKeyStringCall<'a, C>
2661    where
2662        I: IntoIterator<Item = St>,
2663        St: AsRef<str>,
2664    {
2665        self._scopes
2666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2667        self
2668    }
2669
2670    /// Removes all scopes, and no default scope will be used either.
2671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2672    /// for details).
2673    pub fn clear_scopes(mut self) -> ProjectLocationKeyGetKeyStringCall<'a, C> {
2674        self._scopes.clear();
2675        self
2676    }
2677}
2678
2679/// Lists the API keys owned by a project. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
2680///
2681/// A builder for the *locations.keys.list* method supported by a *project* resource.
2682/// It is not used directly, but through a [`ProjectMethods`] instance.
2683///
2684/// # Example
2685///
2686/// Instantiate a resource method builder
2687///
2688/// ```test_harness,no_run
2689/// # extern crate hyper;
2690/// # extern crate hyper_rustls;
2691/// # extern crate google_apikeys2 as apikeys2;
2692/// # async fn dox() {
2693/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2694///
2695/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2696/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2697/// #     .with_native_roots()
2698/// #     .unwrap()
2699/// #     .https_only()
2700/// #     .enable_http2()
2701/// #     .build();
2702///
2703/// # let executor = hyper_util::rt::TokioExecutor::new();
2704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2705/// #     secret,
2706/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2707/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2708/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2709/// #     ),
2710/// # ).build().await.unwrap();
2711///
2712/// # let client = hyper_util::client::legacy::Client::builder(
2713/// #     hyper_util::rt::TokioExecutor::new()
2714/// # )
2715/// # .build(
2716/// #     hyper_rustls::HttpsConnectorBuilder::new()
2717/// #         .with_native_roots()
2718/// #         .unwrap()
2719/// #         .https_or_http()
2720/// #         .enable_http2()
2721/// #         .build()
2722/// # );
2723/// # let mut hub = ApiKeysService::new(client, auth);
2724/// // You can configure optional parameters by calling the respective setters at will, and
2725/// // execute the final call using `doit()`.
2726/// // Values shown here are possibly random and not representative !
2727/// let result = hub.projects().locations_keys_list("parent")
2728///              .show_deleted(false)
2729///              .page_token("dolor")
2730///              .page_size(-17)
2731///              .doit().await;
2732/// # }
2733/// ```
2734pub struct ProjectLocationKeyListCall<'a, C>
2735where
2736    C: 'a,
2737{
2738    hub: &'a ApiKeysService<C>,
2739    _parent: String,
2740    _show_deleted: Option<bool>,
2741    _page_token: Option<String>,
2742    _page_size: Option<i32>,
2743    _delegate: Option<&'a mut dyn common::Delegate>,
2744    _additional_params: HashMap<String, String>,
2745    _scopes: BTreeSet<String>,
2746}
2747
2748impl<'a, C> common::CallBuilder for ProjectLocationKeyListCall<'a, C> {}
2749
2750impl<'a, C> ProjectLocationKeyListCall<'a, C>
2751where
2752    C: common::Connector,
2753{
2754    /// Perform the operation you have build so far.
2755    pub async fn doit(mut self) -> common::Result<(common::Response, V2ListKeysResponse)> {
2756        use std::borrow::Cow;
2757        use std::io::{Read, Seek};
2758
2759        use common::{url::Params, ToParts};
2760        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2761
2762        let mut dd = common::DefaultDelegate;
2763        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2764        dlg.begin(common::MethodInfo {
2765            id: "apikeys.projects.locations.keys.list",
2766            http_method: hyper::Method::GET,
2767        });
2768
2769        for &field in ["alt", "parent", "showDeleted", "pageToken", "pageSize"].iter() {
2770            if self._additional_params.contains_key(field) {
2771                dlg.finished(false);
2772                return Err(common::Error::FieldClash(field));
2773            }
2774        }
2775
2776        let mut params = Params::with_capacity(6 + self._additional_params.len());
2777        params.push("parent", self._parent);
2778        if let Some(value) = self._show_deleted.as_ref() {
2779            params.push("showDeleted", value.to_string());
2780        }
2781        if let Some(value) = self._page_token.as_ref() {
2782            params.push("pageToken", value);
2783        }
2784        if let Some(value) = self._page_size.as_ref() {
2785            params.push("pageSize", value.to_string());
2786        }
2787
2788        params.extend(self._additional_params.iter());
2789
2790        params.push("alt", "json");
2791        let mut url = self.hub._base_url.clone() + "v2/{+parent}/keys";
2792        if self._scopes.is_empty() {
2793            self._scopes
2794                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2795        }
2796
2797        #[allow(clippy::single_element_loop)]
2798        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2799            url = params.uri_replacement(url, param_name, find_this, true);
2800        }
2801        {
2802            let to_remove = ["parent"];
2803            params.remove_params(&to_remove);
2804        }
2805
2806        let url = params.parse_with_url(&url);
2807
2808        loop {
2809            let token = match self
2810                .hub
2811                .auth
2812                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2813                .await
2814            {
2815                Ok(token) => token,
2816                Err(e) => match dlg.token(e) {
2817                    Ok(token) => token,
2818                    Err(e) => {
2819                        dlg.finished(false);
2820                        return Err(common::Error::MissingToken(e));
2821                    }
2822                },
2823            };
2824            let mut req_result = {
2825                let client = &self.hub.client;
2826                dlg.pre_request();
2827                let mut req_builder = hyper::Request::builder()
2828                    .method(hyper::Method::GET)
2829                    .uri(url.as_str())
2830                    .header(USER_AGENT, self.hub._user_agent.clone());
2831
2832                if let Some(token) = token.as_ref() {
2833                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2834                }
2835
2836                let request = req_builder
2837                    .header(CONTENT_LENGTH, 0_u64)
2838                    .body(common::to_body::<String>(None));
2839
2840                client.request(request.unwrap()).await
2841            };
2842
2843            match req_result {
2844                Err(err) => {
2845                    if let common::Retry::After(d) = dlg.http_error(&err) {
2846                        sleep(d).await;
2847                        continue;
2848                    }
2849                    dlg.finished(false);
2850                    return Err(common::Error::HttpError(err));
2851                }
2852                Ok(res) => {
2853                    let (mut parts, body) = res.into_parts();
2854                    let mut body = common::Body::new(body);
2855                    if !parts.status.is_success() {
2856                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2857                        let error = serde_json::from_str(&common::to_string(&bytes));
2858                        let response = common::to_response(parts, bytes.into());
2859
2860                        if let common::Retry::After(d) =
2861                            dlg.http_failure(&response, error.as_ref().ok())
2862                        {
2863                            sleep(d).await;
2864                            continue;
2865                        }
2866
2867                        dlg.finished(false);
2868
2869                        return Err(match error {
2870                            Ok(value) => common::Error::BadRequest(value),
2871                            _ => common::Error::Failure(response),
2872                        });
2873                    }
2874                    let response = {
2875                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2876                        let encoded = common::to_string(&bytes);
2877                        match serde_json::from_str(&encoded) {
2878                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2879                            Err(error) => {
2880                                dlg.response_json_decode_error(&encoded, &error);
2881                                return Err(common::Error::JsonDecodeError(
2882                                    encoded.to_string(),
2883                                    error,
2884                                ));
2885                            }
2886                        }
2887                    };
2888
2889                    dlg.finished(true);
2890                    return Ok(response);
2891                }
2892            }
2893        }
2894    }
2895
2896    /// Required. Lists all API keys associated with this project.
2897    ///
2898    /// Sets the *parent* path property to the given value.
2899    ///
2900    /// Even though the property as already been set when instantiating this call,
2901    /// we provide this method for API completeness.
2902    pub fn parent(mut self, new_value: &str) -> ProjectLocationKeyListCall<'a, C> {
2903        self._parent = new_value.to_string();
2904        self
2905    }
2906    /// Optional. Indicate that keys deleted in the past 30 days should also be returned.
2907    ///
2908    /// Sets the *show deleted* query property to the given value.
2909    pub fn show_deleted(mut self, new_value: bool) -> ProjectLocationKeyListCall<'a, C> {
2910        self._show_deleted = Some(new_value);
2911        self
2912    }
2913    /// Optional. Requests a specific page of results.
2914    ///
2915    /// Sets the *page token* query property to the given value.
2916    pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyListCall<'a, C> {
2917        self._page_token = Some(new_value.to_string());
2918        self
2919    }
2920    /// Optional. Specifies the maximum number of results to be returned at a time.
2921    ///
2922    /// Sets the *page size* query property to the given value.
2923    pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyListCall<'a, C> {
2924        self._page_size = Some(new_value);
2925        self
2926    }
2927    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2928    /// while executing the actual API request.
2929    ///
2930    /// ````text
2931    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2932    /// ````
2933    ///
2934    /// Sets the *delegate* property to the given value.
2935    pub fn delegate(
2936        mut self,
2937        new_value: &'a mut dyn common::Delegate,
2938    ) -> ProjectLocationKeyListCall<'a, C> {
2939        self._delegate = Some(new_value);
2940        self
2941    }
2942
2943    /// Set any additional parameter of the query string used in the request.
2944    /// It should be used to set parameters which are not yet available through their own
2945    /// setters.
2946    ///
2947    /// Please note that this method must not be used to set any of the known parameters
2948    /// which have their own setter method. If done anyway, the request will fail.
2949    ///
2950    /// # Additional Parameters
2951    ///
2952    /// * *$.xgafv* (query-string) - V1 error format.
2953    /// * *access_token* (query-string) - OAuth access token.
2954    /// * *alt* (query-string) - Data format for response.
2955    /// * *callback* (query-string) - JSONP
2956    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2957    /// * *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.
2958    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2959    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2960    /// * *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.
2961    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2962    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2963    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyListCall<'a, C>
2964    where
2965        T: AsRef<str>,
2966    {
2967        self._additional_params
2968            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2969        self
2970    }
2971
2972    /// Identifies the authorization scope for the method you are building.
2973    ///
2974    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2975    /// [`Scope::CloudPlatformReadOnly`].
2976    ///
2977    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2978    /// tokens for more than one scope.
2979    ///
2980    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2981    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2982    /// sufficient, a read-write scope will do as well.
2983    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyListCall<'a, C>
2984    where
2985        St: AsRef<str>,
2986    {
2987        self._scopes.insert(String::from(scope.as_ref()));
2988        self
2989    }
2990    /// Identifies the authorization scope(s) for the method you are building.
2991    ///
2992    /// See [`Self::add_scope()`] for details.
2993    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyListCall<'a, C>
2994    where
2995        I: IntoIterator<Item = St>,
2996        St: AsRef<str>,
2997    {
2998        self._scopes
2999            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3000        self
3001    }
3002
3003    /// Removes all scopes, and no default scope will be used either.
3004    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3005    /// for details).
3006    pub fn clear_scopes(mut self) -> ProjectLocationKeyListCall<'a, C> {
3007        self._scopes.clear();
3008        self
3009    }
3010}
3011
3012/// Patches the modifiable fields of an API key. The key string of the API key isn't included in the response. NOTE: Key is a global resource; hence the only supported value for location is `global`.
3013///
3014/// A builder for the *locations.keys.patch* method supported by a *project* resource.
3015/// It is not used directly, but through a [`ProjectMethods`] instance.
3016///
3017/// # Example
3018///
3019/// Instantiate a resource method builder
3020///
3021/// ```test_harness,no_run
3022/// # extern crate hyper;
3023/// # extern crate hyper_rustls;
3024/// # extern crate google_apikeys2 as apikeys2;
3025/// use apikeys2::api::V2Key;
3026/// # async fn dox() {
3027/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3028///
3029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3030/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3031/// #     .with_native_roots()
3032/// #     .unwrap()
3033/// #     .https_only()
3034/// #     .enable_http2()
3035/// #     .build();
3036///
3037/// # let executor = hyper_util::rt::TokioExecutor::new();
3038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3039/// #     secret,
3040/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3041/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3042/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3043/// #     ),
3044/// # ).build().await.unwrap();
3045///
3046/// # let client = hyper_util::client::legacy::Client::builder(
3047/// #     hyper_util::rt::TokioExecutor::new()
3048/// # )
3049/// # .build(
3050/// #     hyper_rustls::HttpsConnectorBuilder::new()
3051/// #         .with_native_roots()
3052/// #         .unwrap()
3053/// #         .https_or_http()
3054/// #         .enable_http2()
3055/// #         .build()
3056/// # );
3057/// # let mut hub = ApiKeysService::new(client, auth);
3058/// // As the method needs a request, you would usually fill it with the desired information
3059/// // into the respective structure. Some of the parts shown here might not be applicable !
3060/// // Values shown here are possibly random and not representative !
3061/// let mut req = V2Key::default();
3062///
3063/// // You can configure optional parameters by calling the respective setters at will, and
3064/// // execute the final call using `doit()`.
3065/// // Values shown here are possibly random and not representative !
3066/// let result = hub.projects().locations_keys_patch(req, "name")
3067///              .update_mask(FieldMask::new::<&str>(&[]))
3068///              .doit().await;
3069/// # }
3070/// ```
3071pub struct ProjectLocationKeyPatchCall<'a, C>
3072where
3073    C: 'a,
3074{
3075    hub: &'a ApiKeysService<C>,
3076    _request: V2Key,
3077    _name: String,
3078    _update_mask: Option<common::FieldMask>,
3079    _delegate: Option<&'a mut dyn common::Delegate>,
3080    _additional_params: HashMap<String, String>,
3081    _scopes: BTreeSet<String>,
3082}
3083
3084impl<'a, C> common::CallBuilder for ProjectLocationKeyPatchCall<'a, C> {}
3085
3086impl<'a, C> ProjectLocationKeyPatchCall<'a, C>
3087where
3088    C: common::Connector,
3089{
3090    /// Perform the operation you have build so far.
3091    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3092        use std::borrow::Cow;
3093        use std::io::{Read, Seek};
3094
3095        use common::{url::Params, ToParts};
3096        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3097
3098        let mut dd = common::DefaultDelegate;
3099        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3100        dlg.begin(common::MethodInfo {
3101            id: "apikeys.projects.locations.keys.patch",
3102            http_method: hyper::Method::PATCH,
3103        });
3104
3105        for &field in ["alt", "name", "updateMask"].iter() {
3106            if self._additional_params.contains_key(field) {
3107                dlg.finished(false);
3108                return Err(common::Error::FieldClash(field));
3109            }
3110        }
3111
3112        let mut params = Params::with_capacity(5 + self._additional_params.len());
3113        params.push("name", self._name);
3114        if let Some(value) = self._update_mask.as_ref() {
3115            params.push("updateMask", value.to_string());
3116        }
3117
3118        params.extend(self._additional_params.iter());
3119
3120        params.push("alt", "json");
3121        let mut url = self.hub._base_url.clone() + "v2/{+name}";
3122        if self._scopes.is_empty() {
3123            self._scopes
3124                .insert(Scope::CloudPlatform.as_ref().to_string());
3125        }
3126
3127        #[allow(clippy::single_element_loop)]
3128        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3129            url = params.uri_replacement(url, param_name, find_this, true);
3130        }
3131        {
3132            let to_remove = ["name"];
3133            params.remove_params(&to_remove);
3134        }
3135
3136        let url = params.parse_with_url(&url);
3137
3138        let mut json_mime_type = mime::APPLICATION_JSON;
3139        let mut request_value_reader = {
3140            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3141            common::remove_json_null_values(&mut value);
3142            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3143            serde_json::to_writer(&mut dst, &value).unwrap();
3144            dst
3145        };
3146        let request_size = request_value_reader
3147            .seek(std::io::SeekFrom::End(0))
3148            .unwrap();
3149        request_value_reader
3150            .seek(std::io::SeekFrom::Start(0))
3151            .unwrap();
3152
3153        loop {
3154            let token = match self
3155                .hub
3156                .auth
3157                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3158                .await
3159            {
3160                Ok(token) => token,
3161                Err(e) => match dlg.token(e) {
3162                    Ok(token) => token,
3163                    Err(e) => {
3164                        dlg.finished(false);
3165                        return Err(common::Error::MissingToken(e));
3166                    }
3167                },
3168            };
3169            request_value_reader
3170                .seek(std::io::SeekFrom::Start(0))
3171                .unwrap();
3172            let mut req_result = {
3173                let client = &self.hub.client;
3174                dlg.pre_request();
3175                let mut req_builder = hyper::Request::builder()
3176                    .method(hyper::Method::PATCH)
3177                    .uri(url.as_str())
3178                    .header(USER_AGENT, self.hub._user_agent.clone());
3179
3180                if let Some(token) = token.as_ref() {
3181                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3182                }
3183
3184                let request = req_builder
3185                    .header(CONTENT_TYPE, json_mime_type.to_string())
3186                    .header(CONTENT_LENGTH, request_size as u64)
3187                    .body(common::to_body(
3188                        request_value_reader.get_ref().clone().into(),
3189                    ));
3190
3191                client.request(request.unwrap()).await
3192            };
3193
3194            match req_result {
3195                Err(err) => {
3196                    if let common::Retry::After(d) = dlg.http_error(&err) {
3197                        sleep(d).await;
3198                        continue;
3199                    }
3200                    dlg.finished(false);
3201                    return Err(common::Error::HttpError(err));
3202                }
3203                Ok(res) => {
3204                    let (mut parts, body) = res.into_parts();
3205                    let mut body = common::Body::new(body);
3206                    if !parts.status.is_success() {
3207                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3208                        let error = serde_json::from_str(&common::to_string(&bytes));
3209                        let response = common::to_response(parts, bytes.into());
3210
3211                        if let common::Retry::After(d) =
3212                            dlg.http_failure(&response, error.as_ref().ok())
3213                        {
3214                            sleep(d).await;
3215                            continue;
3216                        }
3217
3218                        dlg.finished(false);
3219
3220                        return Err(match error {
3221                            Ok(value) => common::Error::BadRequest(value),
3222                            _ => common::Error::Failure(response),
3223                        });
3224                    }
3225                    let response = {
3226                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3227                        let encoded = common::to_string(&bytes);
3228                        match serde_json::from_str(&encoded) {
3229                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3230                            Err(error) => {
3231                                dlg.response_json_decode_error(&encoded, &error);
3232                                return Err(common::Error::JsonDecodeError(
3233                                    encoded.to_string(),
3234                                    error,
3235                                ));
3236                            }
3237                        }
3238                    };
3239
3240                    dlg.finished(true);
3241                    return Ok(response);
3242                }
3243            }
3244        }
3245    }
3246
3247    ///
3248    /// Sets the *request* property to the given value.
3249    ///
3250    /// Even though the property as already been set when instantiating this call,
3251    /// we provide this method for API completeness.
3252    pub fn request(mut self, new_value: V2Key) -> ProjectLocationKeyPatchCall<'a, C> {
3253        self._request = new_value;
3254        self
3255    }
3256    /// Output only. The resource name of the key. The `name` has the form: `projects//locations/global/keys/`. For example: `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value for location is `global`.
3257    ///
3258    /// Sets the *name* path property to the given value.
3259    ///
3260    /// Even though the property as already been set when instantiating this call,
3261    /// we provide this method for API completeness.
3262    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyPatchCall<'a, C> {
3263        self._name = new_value.to_string();
3264        self
3265    }
3266    /// The field mask specifies which fields to be updated as part of this request. All other fields are ignored. Mutable fields are: `display_name`, `restrictions`, and `annotations`. If an update mask is not provided, the service treats it as an implied mask equivalent to all allowed fields that are set on the wire. If the field mask has a special value "*", the service treats it equivalent to replace all allowed mutable fields.
3267    ///
3268    /// Sets the *update mask* query property to the given value.
3269    pub fn update_mask(
3270        mut self,
3271        new_value: common::FieldMask,
3272    ) -> ProjectLocationKeyPatchCall<'a, C> {
3273        self._update_mask = Some(new_value);
3274        self
3275    }
3276    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3277    /// while executing the actual API request.
3278    ///
3279    /// ````text
3280    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3281    /// ````
3282    ///
3283    /// Sets the *delegate* property to the given value.
3284    pub fn delegate(
3285        mut self,
3286        new_value: &'a mut dyn common::Delegate,
3287    ) -> ProjectLocationKeyPatchCall<'a, C> {
3288        self._delegate = Some(new_value);
3289        self
3290    }
3291
3292    /// Set any additional parameter of the query string used in the request.
3293    /// It should be used to set parameters which are not yet available through their own
3294    /// setters.
3295    ///
3296    /// Please note that this method must not be used to set any of the known parameters
3297    /// which have their own setter method. If done anyway, the request will fail.
3298    ///
3299    /// # Additional Parameters
3300    ///
3301    /// * *$.xgafv* (query-string) - V1 error format.
3302    /// * *access_token* (query-string) - OAuth access token.
3303    /// * *alt* (query-string) - Data format for response.
3304    /// * *callback* (query-string) - JSONP
3305    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3306    /// * *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.
3307    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3308    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3309    /// * *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.
3310    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3311    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3312    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyPatchCall<'a, C>
3313    where
3314        T: AsRef<str>,
3315    {
3316        self._additional_params
3317            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3318        self
3319    }
3320
3321    /// Identifies the authorization scope for the method you are building.
3322    ///
3323    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3324    /// [`Scope::CloudPlatform`].
3325    ///
3326    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3327    /// tokens for more than one scope.
3328    ///
3329    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3330    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3331    /// sufficient, a read-write scope will do as well.
3332    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyPatchCall<'a, C>
3333    where
3334        St: AsRef<str>,
3335    {
3336        self._scopes.insert(String::from(scope.as_ref()));
3337        self
3338    }
3339    /// Identifies the authorization scope(s) for the method you are building.
3340    ///
3341    /// See [`Self::add_scope()`] for details.
3342    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyPatchCall<'a, C>
3343    where
3344        I: IntoIterator<Item = St>,
3345        St: AsRef<str>,
3346    {
3347        self._scopes
3348            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3349        self
3350    }
3351
3352    /// Removes all scopes, and no default scope will be used either.
3353    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3354    /// for details).
3355    pub fn clear_scopes(mut self) -> ProjectLocationKeyPatchCall<'a, C> {
3356        self._scopes.clear();
3357        self
3358    }
3359}
3360
3361/// Undeletes an API key which was deleted within 30 days. NOTE: Key is a global resource; hence the only supported value for location is `global`.
3362///
3363/// A builder for the *locations.keys.undelete* method supported by a *project* resource.
3364/// It is not used directly, but through a [`ProjectMethods`] instance.
3365///
3366/// # Example
3367///
3368/// Instantiate a resource method builder
3369///
3370/// ```test_harness,no_run
3371/// # extern crate hyper;
3372/// # extern crate hyper_rustls;
3373/// # extern crate google_apikeys2 as apikeys2;
3374/// use apikeys2::api::V2UndeleteKeyRequest;
3375/// # async fn dox() {
3376/// # use apikeys2::{ApiKeysService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3377///
3378/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3379/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3380/// #     .with_native_roots()
3381/// #     .unwrap()
3382/// #     .https_only()
3383/// #     .enable_http2()
3384/// #     .build();
3385///
3386/// # let executor = hyper_util::rt::TokioExecutor::new();
3387/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3388/// #     secret,
3389/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3390/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3391/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3392/// #     ),
3393/// # ).build().await.unwrap();
3394///
3395/// # let client = hyper_util::client::legacy::Client::builder(
3396/// #     hyper_util::rt::TokioExecutor::new()
3397/// # )
3398/// # .build(
3399/// #     hyper_rustls::HttpsConnectorBuilder::new()
3400/// #         .with_native_roots()
3401/// #         .unwrap()
3402/// #         .https_or_http()
3403/// #         .enable_http2()
3404/// #         .build()
3405/// # );
3406/// # let mut hub = ApiKeysService::new(client, auth);
3407/// // As the method needs a request, you would usually fill it with the desired information
3408/// // into the respective structure. Some of the parts shown here might not be applicable !
3409/// // Values shown here are possibly random and not representative !
3410/// let mut req = V2UndeleteKeyRequest::default();
3411///
3412/// // You can configure optional parameters by calling the respective setters at will, and
3413/// // execute the final call using `doit()`.
3414/// // Values shown here are possibly random and not representative !
3415/// let result = hub.projects().locations_keys_undelete(req, "name")
3416///              .doit().await;
3417/// # }
3418/// ```
3419pub struct ProjectLocationKeyUndeleteCall<'a, C>
3420where
3421    C: 'a,
3422{
3423    hub: &'a ApiKeysService<C>,
3424    _request: V2UndeleteKeyRequest,
3425    _name: String,
3426    _delegate: Option<&'a mut dyn common::Delegate>,
3427    _additional_params: HashMap<String, String>,
3428    _scopes: BTreeSet<String>,
3429}
3430
3431impl<'a, C> common::CallBuilder for ProjectLocationKeyUndeleteCall<'a, C> {}
3432
3433impl<'a, C> ProjectLocationKeyUndeleteCall<'a, C>
3434where
3435    C: common::Connector,
3436{
3437    /// Perform the operation you have build so far.
3438    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3439        use std::borrow::Cow;
3440        use std::io::{Read, Seek};
3441
3442        use common::{url::Params, ToParts};
3443        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3444
3445        let mut dd = common::DefaultDelegate;
3446        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3447        dlg.begin(common::MethodInfo {
3448            id: "apikeys.projects.locations.keys.undelete",
3449            http_method: hyper::Method::POST,
3450        });
3451
3452        for &field in ["alt", "name"].iter() {
3453            if self._additional_params.contains_key(field) {
3454                dlg.finished(false);
3455                return Err(common::Error::FieldClash(field));
3456            }
3457        }
3458
3459        let mut params = Params::with_capacity(4 + self._additional_params.len());
3460        params.push("name", self._name);
3461
3462        params.extend(self._additional_params.iter());
3463
3464        params.push("alt", "json");
3465        let mut url = self.hub._base_url.clone() + "v2/{+name}:undelete";
3466        if self._scopes.is_empty() {
3467            self._scopes
3468                .insert(Scope::CloudPlatform.as_ref().to_string());
3469        }
3470
3471        #[allow(clippy::single_element_loop)]
3472        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3473            url = params.uri_replacement(url, param_name, find_this, true);
3474        }
3475        {
3476            let to_remove = ["name"];
3477            params.remove_params(&to_remove);
3478        }
3479
3480        let url = params.parse_with_url(&url);
3481
3482        let mut json_mime_type = mime::APPLICATION_JSON;
3483        let mut request_value_reader = {
3484            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3485            common::remove_json_null_values(&mut value);
3486            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3487            serde_json::to_writer(&mut dst, &value).unwrap();
3488            dst
3489        };
3490        let request_size = request_value_reader
3491            .seek(std::io::SeekFrom::End(0))
3492            .unwrap();
3493        request_value_reader
3494            .seek(std::io::SeekFrom::Start(0))
3495            .unwrap();
3496
3497        loop {
3498            let token = match self
3499                .hub
3500                .auth
3501                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3502                .await
3503            {
3504                Ok(token) => token,
3505                Err(e) => match dlg.token(e) {
3506                    Ok(token) => token,
3507                    Err(e) => {
3508                        dlg.finished(false);
3509                        return Err(common::Error::MissingToken(e));
3510                    }
3511                },
3512            };
3513            request_value_reader
3514                .seek(std::io::SeekFrom::Start(0))
3515                .unwrap();
3516            let mut req_result = {
3517                let client = &self.hub.client;
3518                dlg.pre_request();
3519                let mut req_builder = hyper::Request::builder()
3520                    .method(hyper::Method::POST)
3521                    .uri(url.as_str())
3522                    .header(USER_AGENT, self.hub._user_agent.clone());
3523
3524                if let Some(token) = token.as_ref() {
3525                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3526                }
3527
3528                let request = req_builder
3529                    .header(CONTENT_TYPE, json_mime_type.to_string())
3530                    .header(CONTENT_LENGTH, request_size as u64)
3531                    .body(common::to_body(
3532                        request_value_reader.get_ref().clone().into(),
3533                    ));
3534
3535                client.request(request.unwrap()).await
3536            };
3537
3538            match req_result {
3539                Err(err) => {
3540                    if let common::Retry::After(d) = dlg.http_error(&err) {
3541                        sleep(d).await;
3542                        continue;
3543                    }
3544                    dlg.finished(false);
3545                    return Err(common::Error::HttpError(err));
3546                }
3547                Ok(res) => {
3548                    let (mut parts, body) = res.into_parts();
3549                    let mut body = common::Body::new(body);
3550                    if !parts.status.is_success() {
3551                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3552                        let error = serde_json::from_str(&common::to_string(&bytes));
3553                        let response = common::to_response(parts, bytes.into());
3554
3555                        if let common::Retry::After(d) =
3556                            dlg.http_failure(&response, error.as_ref().ok())
3557                        {
3558                            sleep(d).await;
3559                            continue;
3560                        }
3561
3562                        dlg.finished(false);
3563
3564                        return Err(match error {
3565                            Ok(value) => common::Error::BadRequest(value),
3566                            _ => common::Error::Failure(response),
3567                        });
3568                    }
3569                    let response = {
3570                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3571                        let encoded = common::to_string(&bytes);
3572                        match serde_json::from_str(&encoded) {
3573                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3574                            Err(error) => {
3575                                dlg.response_json_decode_error(&encoded, &error);
3576                                return Err(common::Error::JsonDecodeError(
3577                                    encoded.to_string(),
3578                                    error,
3579                                ));
3580                            }
3581                        }
3582                    };
3583
3584                    dlg.finished(true);
3585                    return Ok(response);
3586                }
3587            }
3588        }
3589    }
3590
3591    ///
3592    /// Sets the *request* property to the given value.
3593    ///
3594    /// Even though the property as already been set when instantiating this call,
3595    /// we provide this method for API completeness.
3596    pub fn request(
3597        mut self,
3598        new_value: V2UndeleteKeyRequest,
3599    ) -> ProjectLocationKeyUndeleteCall<'a, C> {
3600        self._request = new_value;
3601        self
3602    }
3603    /// Required. The resource name of the API key to be undeleted.
3604    ///
3605    /// Sets the *name* path property to the given value.
3606    ///
3607    /// Even though the property as already been set when instantiating this call,
3608    /// we provide this method for API completeness.
3609    pub fn name(mut self, new_value: &str) -> ProjectLocationKeyUndeleteCall<'a, C> {
3610        self._name = new_value.to_string();
3611        self
3612    }
3613    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3614    /// while executing the actual API request.
3615    ///
3616    /// ````text
3617    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3618    /// ````
3619    ///
3620    /// Sets the *delegate* property to the given value.
3621    pub fn delegate(
3622        mut self,
3623        new_value: &'a mut dyn common::Delegate,
3624    ) -> ProjectLocationKeyUndeleteCall<'a, C> {
3625        self._delegate = Some(new_value);
3626        self
3627    }
3628
3629    /// Set any additional parameter of the query string used in the request.
3630    /// It should be used to set parameters which are not yet available through their own
3631    /// setters.
3632    ///
3633    /// Please note that this method must not be used to set any of the known parameters
3634    /// which have their own setter method. If done anyway, the request will fail.
3635    ///
3636    /// # Additional Parameters
3637    ///
3638    /// * *$.xgafv* (query-string) - V1 error format.
3639    /// * *access_token* (query-string) - OAuth access token.
3640    /// * *alt* (query-string) - Data format for response.
3641    /// * *callback* (query-string) - JSONP
3642    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3643    /// * *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.
3644    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3645    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3646    /// * *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.
3647    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3648    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3649    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationKeyUndeleteCall<'a, C>
3650    where
3651        T: AsRef<str>,
3652    {
3653        self._additional_params
3654            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3655        self
3656    }
3657
3658    /// Identifies the authorization scope for the method you are building.
3659    ///
3660    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3661    /// [`Scope::CloudPlatform`].
3662    ///
3663    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3664    /// tokens for more than one scope.
3665    ///
3666    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3667    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3668    /// sufficient, a read-write scope will do as well.
3669    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationKeyUndeleteCall<'a, C>
3670    where
3671        St: AsRef<str>,
3672    {
3673        self._scopes.insert(String::from(scope.as_ref()));
3674        self
3675    }
3676    /// Identifies the authorization scope(s) for the method you are building.
3677    ///
3678    /// See [`Self::add_scope()`] for details.
3679    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationKeyUndeleteCall<'a, C>
3680    where
3681        I: IntoIterator<Item = St>,
3682        St: AsRef<str>,
3683    {
3684        self._scopes
3685            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3686        self
3687    }
3688
3689    /// Removes all scopes, and no default scope will be used either.
3690    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3691    /// for details).
3692    pub fn clear_scopes(mut self) -> ProjectLocationKeyUndeleteCall<'a, C> {
3693        self._scopes.clear();
3694        self
3695    }
3696}