google_siteverification1/
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    /// Manage the list of sites and domains you control
17    Full,
18
19    /// Manage your new site verifications with Google
20    VerifyOnly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::Full => "https://www.googleapis.com/auth/siteverification",
27            Scope::VerifyOnly => "https://www.googleapis.com/auth/siteverification.verify_only",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Full
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all SiteVerification related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_siteverification1 as siteverification1;
53/// use siteverification1::api::SiteVerificationWebResourceResource;
54/// use siteverification1::{Result, Error};
55/// # async fn dox() {
56/// use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = SiteVerification::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = SiteVerificationWebResourceResource::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.web_resource().insert(req, "verificationMethod")
103///              .doit().await;
104///
105/// match result {
106///     Err(e) => match e {
107///         // The Error enum provides details about what exactly happened.
108///         // You can also just use its `Debug`, `Display` or `Error` traits
109///          Error::HttpError(_)
110///         |Error::Io(_)
111///         |Error::MissingAPIKey
112///         |Error::MissingToken(_)
113///         |Error::Cancelled
114///         |Error::UploadSizeLimitExceeded(_, _)
115///         |Error::Failure(_)
116///         |Error::BadRequest(_)
117///         |Error::FieldClash(_)
118///         |Error::JsonDecodeError(_, _) => println!("{}", e),
119///     },
120///     Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct SiteVerification<C> {
126    pub client: common::Client<C>,
127    pub auth: Box<dyn common::GetToken>,
128    _user_agent: String,
129    _base_url: String,
130    _root_url: String,
131}
132
133impl<C> common::Hub for SiteVerification<C> {}
134
135impl<'a, C> SiteVerification<C> {
136    pub fn new<A: 'static + common::GetToken>(
137        client: common::Client<C>,
138        auth: A,
139    ) -> SiteVerification<C> {
140        SiteVerification {
141            client,
142            auth: Box::new(auth),
143            _user_agent: "google-api-rust-client/7.0.0".to_string(),
144            _base_url: "https://www.googleapis.com/siteVerification/v1/".to_string(),
145            _root_url: "https://www.googleapis.com/".to_string(),
146        }
147    }
148
149    pub fn web_resource(&'a self) -> WebResourceMethods<'a, C> {
150        WebResourceMethods { hub: self }
151    }
152
153    /// Set the user-agent header field to use in all requests to the server.
154    /// It defaults to `google-api-rust-client/7.0.0`.
155    ///
156    /// Returns the previously set user-agent.
157    pub fn user_agent(&mut self, agent_name: String) -> String {
158        std::mem::replace(&mut self._user_agent, agent_name)
159    }
160
161    /// Set the base url to use in all requests to the server.
162    /// It defaults to `https://www.googleapis.com/siteVerification/v1/`.
163    ///
164    /// Returns the previously set base url.
165    pub fn base_url(&mut self, new_base_url: String) -> String {
166        std::mem::replace(&mut self._base_url, new_base_url)
167    }
168
169    /// Set the root url to use in all requests to the server.
170    /// It defaults to `https://www.googleapis.com/`.
171    ///
172    /// Returns the previously set root url.
173    pub fn root_url(&mut self, new_root_url: String) -> String {
174        std::mem::replace(&mut self._root_url, new_root_url)
175    }
176}
177
178// ############
179// SCHEMAS ###
180// ##########
181/// There is no detailed description.
182///
183/// # Activities
184///
185/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
186/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
187///
188/// * [get token web resource](WebResourceGetTokenCall) (request)
189#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
190#[serde_with::serde_as]
191#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
192pub struct SiteVerificationWebResourceGettokenRequest {
193    /// The site for which a verification token will be generated.
194    pub site: Option<SiteVerificationWebResourceGettokenRequestSite>,
195    /// The verification method that will be used to verify this site. For sites, 'FILE' or 'META' methods may be used. For domains, only 'DNS' may be used.
196    #[serde(rename = "verificationMethod")]
197    pub verification_method: Option<String>,
198}
199
200impl common::RequestValue for SiteVerificationWebResourceGettokenRequest {}
201
202/// There is no detailed description.
203///
204/// # Activities
205///
206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
208///
209/// * [get token web resource](WebResourceGetTokenCall) (response)
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct SiteVerificationWebResourceGettokenResponse {
214    /// The verification method to use in conjunction with this token. For FILE, the token should be placed in the top-level directory of the site, stored inside a file of the same name. For META, the token should be placed in the HEAD tag of the default page that is loaded for the site. For DNS, the token should be placed in a TXT record of the domain.
215    pub method: Option<String>,
216    /// The verification token. The token must be placed appropriately in order for verification to succeed.
217    pub token: Option<String>,
218}
219
220impl common::ResponseResult for SiteVerificationWebResourceGettokenResponse {}
221
222/// There is no detailed description.
223///
224/// # Activities
225///
226/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
227/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
228///
229/// * [list web resource](WebResourceListCall) (response)
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct SiteVerificationWebResourceListResponse {
234    /// The list of sites that are owned by the authenticated user.
235    pub items: Option<Vec<SiteVerificationWebResourceResource>>,
236}
237
238impl common::ResponseResult for SiteVerificationWebResourceListResponse {}
239
240/// There is no detailed description.
241///
242/// # Activities
243///
244/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
245/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
246///
247/// * [get web resource](WebResourceGetCall) (response)
248/// * [insert web resource](WebResourceInsertCall) (request|response)
249/// * [patch web resource](WebResourcePatchCall) (request|response)
250/// * [update web resource](WebResourceUpdateCall) (request|response)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct SiteVerificationWebResourceResource {
255    /// The string used to identify this site. This value should be used in the "id" portion of the REST URL for the Get, Update, and Delete operations.
256    pub id: Option<String>,
257    /// The email addresses of all verified owners.
258    pub owners: Option<Vec<String>>,
259    /// The address and type of a site that is verified or will be verified.
260    pub site: Option<SiteVerificationWebResourceResourceSite>,
261}
262
263impl common::RequestValue for SiteVerificationWebResourceResource {}
264impl common::ResponseResult for SiteVerificationWebResourceResource {}
265
266/// The site for which a verification token will be generated.
267///
268/// This type is not used in any activity, and only used as *part* of another schema.
269///
270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
271#[serde_with::serde_as]
272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
273pub struct SiteVerificationWebResourceGettokenRequestSite {
274    /// The site identifier. If the type is set to SITE, the identifier is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain name.
275    pub identifier: Option<String>,
276    /// The type of resource to be verified. Can be SITE or INET_DOMAIN (domain name).
277    #[serde(rename = "type")]
278    pub type_: Option<String>,
279}
280
281impl common::NestedType for SiteVerificationWebResourceGettokenRequestSite {}
282impl common::Part for SiteVerificationWebResourceGettokenRequestSite {}
283
284/// The address and type of a site that is verified or will be verified.
285///
286/// This type is not used in any activity, and only used as *part* of another schema.
287///
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct SiteVerificationWebResourceResourceSite {
292    /// The site identifier. If the type is set to SITE, the identifier is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain name.
293    pub identifier: Option<String>,
294    /// The site type. Can be SITE or INET_DOMAIN (domain name).
295    #[serde(rename = "type")]
296    pub type_: Option<String>,
297}
298
299impl common::NestedType for SiteVerificationWebResourceResourceSite {}
300impl common::Part for SiteVerificationWebResourceResourceSite {}
301
302// ###################
303// MethodBuilders ###
304// #################
305
306/// A builder providing access to all methods supported on *webResource* resources.
307/// It is not used directly, but through the [`SiteVerification`] hub.
308///
309/// # Example
310///
311/// Instantiate a resource builder
312///
313/// ```test_harness,no_run
314/// extern crate hyper;
315/// extern crate hyper_rustls;
316/// extern crate google_siteverification1 as siteverification1;
317///
318/// # async fn dox() {
319/// use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
320///
321/// let secret: yup_oauth2::ApplicationSecret = Default::default();
322/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
323///     .with_native_roots()
324///     .unwrap()
325///     .https_only()
326///     .enable_http2()
327///     .build();
328///
329/// let executor = hyper_util::rt::TokioExecutor::new();
330/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
331///     secret,
332///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
333///     yup_oauth2::client::CustomHyperClientBuilder::from(
334///         hyper_util::client::legacy::Client::builder(executor).build(connector),
335///     ),
336/// ).build().await.unwrap();
337///
338/// let client = hyper_util::client::legacy::Client::builder(
339///     hyper_util::rt::TokioExecutor::new()
340/// )
341/// .build(
342///     hyper_rustls::HttpsConnectorBuilder::new()
343///         .with_native_roots()
344///         .unwrap()
345///         .https_or_http()
346///         .enable_http2()
347///         .build()
348/// );
349/// let mut hub = SiteVerification::new(client, auth);
350/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
351/// // like `delete(...)`, `get(...)`, `get_token(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
352/// // to build up your call.
353/// let rb = hub.web_resource();
354/// # }
355/// ```
356pub struct WebResourceMethods<'a, C>
357where
358    C: 'a,
359{
360    hub: &'a SiteVerification<C>,
361}
362
363impl<'a, C> common::MethodsBuilder for WebResourceMethods<'a, C> {}
364
365impl<'a, C> WebResourceMethods<'a, C> {
366    /// Create a builder to help you perform the following task:
367    ///
368    /// Relinquish ownership of a website or domain.
369    ///
370    /// # Arguments
371    ///
372    /// * `id` - The id of a verified site or domain.
373    pub fn delete(&self, id: &str) -> WebResourceDeleteCall<'a, C> {
374        WebResourceDeleteCall {
375            hub: self.hub,
376            _id: id.to_string(),
377            _delegate: Default::default(),
378            _additional_params: Default::default(),
379            _scopes: Default::default(),
380        }
381    }
382
383    /// Create a builder to help you perform the following task:
384    ///
385    /// Get the most current data for a website or domain.
386    ///
387    /// # Arguments
388    ///
389    /// * `id` - The id of a verified site or domain.
390    pub fn get(&self, id: &str) -> WebResourceGetCall<'a, C> {
391        WebResourceGetCall {
392            hub: self.hub,
393            _id: id.to_string(),
394            _delegate: Default::default(),
395            _additional_params: Default::default(),
396            _scopes: Default::default(),
397        }
398    }
399
400    /// Create a builder to help you perform the following task:
401    ///
402    /// Get a verification token for placing on a website or domain.
403    ///
404    /// # Arguments
405    ///
406    /// * `request` - No description provided.
407    pub fn get_token(
408        &self,
409        request: SiteVerificationWebResourceGettokenRequest,
410    ) -> WebResourceGetTokenCall<'a, C> {
411        WebResourceGetTokenCall {
412            hub: self.hub,
413            _request: request,
414            _delegate: Default::default(),
415            _additional_params: Default::default(),
416            _scopes: Default::default(),
417        }
418    }
419
420    /// Create a builder to help you perform the following task:
421    ///
422    /// Attempt verification of a website or domain.
423    ///
424    /// # Arguments
425    ///
426    /// * `request` - No description provided.
427    /// * `verificationMethod` - The method to use for verifying a site or domain.
428    pub fn insert(
429        &self,
430        request: SiteVerificationWebResourceResource,
431        verification_method: &str,
432    ) -> WebResourceInsertCall<'a, C> {
433        WebResourceInsertCall {
434            hub: self.hub,
435            _request: request,
436            _verification_method: verification_method.to_string(),
437            _delegate: Default::default(),
438            _additional_params: Default::default(),
439            _scopes: Default::default(),
440        }
441    }
442
443    /// Create a builder to help you perform the following task:
444    ///
445    /// Get the list of your verified websites and domains.
446    pub fn list(&self) -> WebResourceListCall<'a, C> {
447        WebResourceListCall {
448            hub: self.hub,
449            _delegate: Default::default(),
450            _additional_params: Default::default(),
451            _scopes: Default::default(),
452        }
453    }
454
455    /// Create a builder to help you perform the following task:
456    ///
457    /// Modify the list of owners for your website or domain. This method supports patch semantics.
458    ///
459    /// # Arguments
460    ///
461    /// * `request` - No description provided.
462    /// * `id` - The id of a verified site or domain.
463    pub fn patch(
464        &self,
465        request: SiteVerificationWebResourceResource,
466        id: &str,
467    ) -> WebResourcePatchCall<'a, C> {
468        WebResourcePatchCall {
469            hub: self.hub,
470            _request: request,
471            _id: id.to_string(),
472            _delegate: Default::default(),
473            _additional_params: Default::default(),
474            _scopes: Default::default(),
475        }
476    }
477
478    /// Create a builder to help you perform the following task:
479    ///
480    /// Modify the list of owners for your website or domain.
481    ///
482    /// # Arguments
483    ///
484    /// * `request` - No description provided.
485    /// * `id` - The id of a verified site or domain.
486    pub fn update(
487        &self,
488        request: SiteVerificationWebResourceResource,
489        id: &str,
490    ) -> WebResourceUpdateCall<'a, C> {
491        WebResourceUpdateCall {
492            hub: self.hub,
493            _request: request,
494            _id: id.to_string(),
495            _delegate: Default::default(),
496            _additional_params: Default::default(),
497            _scopes: Default::default(),
498        }
499    }
500}
501
502// ###################
503// CallBuilders   ###
504// #################
505
506/// Relinquish ownership of a website or domain.
507///
508/// A builder for the *delete* method supported by a *webResource* resource.
509/// It is not used directly, but through a [`WebResourceMethods`] instance.
510///
511/// # Example
512///
513/// Instantiate a resource method builder
514///
515/// ```test_harness,no_run
516/// # extern crate hyper;
517/// # extern crate hyper_rustls;
518/// # extern crate google_siteverification1 as siteverification1;
519/// # async fn dox() {
520/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
521///
522/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
523/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
524/// #     .with_native_roots()
525/// #     .unwrap()
526/// #     .https_only()
527/// #     .enable_http2()
528/// #     .build();
529///
530/// # let executor = hyper_util::rt::TokioExecutor::new();
531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
532/// #     secret,
533/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
534/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
535/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
536/// #     ),
537/// # ).build().await.unwrap();
538///
539/// # let client = hyper_util::client::legacy::Client::builder(
540/// #     hyper_util::rt::TokioExecutor::new()
541/// # )
542/// # .build(
543/// #     hyper_rustls::HttpsConnectorBuilder::new()
544/// #         .with_native_roots()
545/// #         .unwrap()
546/// #         .https_or_http()
547/// #         .enable_http2()
548/// #         .build()
549/// # );
550/// # let mut hub = SiteVerification::new(client, auth);
551/// // You can configure optional parameters by calling the respective setters at will, and
552/// // execute the final call using `doit()`.
553/// // Values shown here are possibly random and not representative !
554/// let result = hub.web_resource().delete("id")
555///              .doit().await;
556/// # }
557/// ```
558pub struct WebResourceDeleteCall<'a, C>
559where
560    C: 'a,
561{
562    hub: &'a SiteVerification<C>,
563    _id: String,
564    _delegate: Option<&'a mut dyn common::Delegate>,
565    _additional_params: HashMap<String, String>,
566    _scopes: BTreeSet<String>,
567}
568
569impl<'a, C> common::CallBuilder for WebResourceDeleteCall<'a, C> {}
570
571impl<'a, C> WebResourceDeleteCall<'a, C>
572where
573    C: common::Connector,
574{
575    /// Perform the operation you have build so far.
576    pub async fn doit(mut self) -> common::Result<common::Response> {
577        use std::borrow::Cow;
578        use std::io::{Read, Seek};
579
580        use common::{url::Params, ToParts};
581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
582
583        let mut dd = common::DefaultDelegate;
584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
585        dlg.begin(common::MethodInfo {
586            id: "siteVerification.webResource.delete",
587            http_method: hyper::Method::DELETE,
588        });
589
590        for &field in ["id"].iter() {
591            if self._additional_params.contains_key(field) {
592                dlg.finished(false);
593                return Err(common::Error::FieldClash(field));
594            }
595        }
596
597        let mut params = Params::with_capacity(2 + self._additional_params.len());
598        params.push("id", self._id);
599
600        params.extend(self._additional_params.iter());
601
602        let mut url = self.hub._base_url.clone() + "webResource/{id}";
603        if self._scopes.is_empty() {
604            self._scopes.insert(Scope::Full.as_ref().to_string());
605        }
606
607        #[allow(clippy::single_element_loop)]
608        for &(find_this, param_name) in [("{id}", "id")].iter() {
609            url = params.uri_replacement(url, param_name, find_this, false);
610        }
611        {
612            let to_remove = ["id"];
613            params.remove_params(&to_remove);
614        }
615
616        let url = params.parse_with_url(&url);
617
618        loop {
619            let token = match self
620                .hub
621                .auth
622                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
623                .await
624            {
625                Ok(token) => token,
626                Err(e) => match dlg.token(e) {
627                    Ok(token) => token,
628                    Err(e) => {
629                        dlg.finished(false);
630                        return Err(common::Error::MissingToken(e));
631                    }
632                },
633            };
634            let mut req_result = {
635                let client = &self.hub.client;
636                dlg.pre_request();
637                let mut req_builder = hyper::Request::builder()
638                    .method(hyper::Method::DELETE)
639                    .uri(url.as_str())
640                    .header(USER_AGENT, self.hub._user_agent.clone());
641
642                if let Some(token) = token.as_ref() {
643                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
644                }
645
646                let request = req_builder
647                    .header(CONTENT_LENGTH, 0_u64)
648                    .body(common::to_body::<String>(None));
649
650                client.request(request.unwrap()).await
651            };
652
653            match req_result {
654                Err(err) => {
655                    if let common::Retry::After(d) = dlg.http_error(&err) {
656                        sleep(d).await;
657                        continue;
658                    }
659                    dlg.finished(false);
660                    return Err(common::Error::HttpError(err));
661                }
662                Ok(res) => {
663                    let (mut parts, body) = res.into_parts();
664                    let mut body = common::Body::new(body);
665                    if !parts.status.is_success() {
666                        let bytes = common::to_bytes(body).await.unwrap_or_default();
667                        let error = serde_json::from_str(&common::to_string(&bytes));
668                        let response = common::to_response(parts, bytes.into());
669
670                        if let common::Retry::After(d) =
671                            dlg.http_failure(&response, error.as_ref().ok())
672                        {
673                            sleep(d).await;
674                            continue;
675                        }
676
677                        dlg.finished(false);
678
679                        return Err(match error {
680                            Ok(value) => common::Error::BadRequest(value),
681                            _ => common::Error::Failure(response),
682                        });
683                    }
684                    let response = common::Response::from_parts(parts, body);
685
686                    dlg.finished(true);
687                    return Ok(response);
688                }
689            }
690        }
691    }
692
693    /// The id of a verified site or domain.
694    ///
695    /// Sets the *id* path property to the given value.
696    ///
697    /// Even though the property as already been set when instantiating this call,
698    /// we provide this method for API completeness.
699    pub fn id(mut self, new_value: &str) -> WebResourceDeleteCall<'a, C> {
700        self._id = new_value.to_string();
701        self
702    }
703    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
704    /// while executing the actual API request.
705    ///
706    /// ````text
707    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
708    /// ````
709    ///
710    /// Sets the *delegate* property to the given value.
711    pub fn delegate(
712        mut self,
713        new_value: &'a mut dyn common::Delegate,
714    ) -> WebResourceDeleteCall<'a, C> {
715        self._delegate = Some(new_value);
716        self
717    }
718
719    /// Set any additional parameter of the query string used in the request.
720    /// It should be used to set parameters which are not yet available through their own
721    /// setters.
722    ///
723    /// Please note that this method must not be used to set any of the known parameters
724    /// which have their own setter method. If done anyway, the request will fail.
725    ///
726    /// # Additional Parameters
727    ///
728    /// * *alt* (query-string) - Data format for the response.
729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
730    /// * *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.
731    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
732    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
733    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
734    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
735    pub fn param<T>(mut self, name: T, value: T) -> WebResourceDeleteCall<'a, C>
736    where
737        T: AsRef<str>,
738    {
739        self._additional_params
740            .insert(name.as_ref().to_string(), value.as_ref().to_string());
741        self
742    }
743
744    /// Identifies the authorization scope for the method you are building.
745    ///
746    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
747    /// [`Scope::Full`].
748    ///
749    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
750    /// tokens for more than one scope.
751    ///
752    /// Usually there is more than one suitable scope to authorize an operation, some of which may
753    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
754    /// sufficient, a read-write scope will do as well.
755    pub fn add_scope<St>(mut self, scope: St) -> WebResourceDeleteCall<'a, C>
756    where
757        St: AsRef<str>,
758    {
759        self._scopes.insert(String::from(scope.as_ref()));
760        self
761    }
762    /// Identifies the authorization scope(s) for the method you are building.
763    ///
764    /// See [`Self::add_scope()`] for details.
765    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceDeleteCall<'a, C>
766    where
767        I: IntoIterator<Item = St>,
768        St: AsRef<str>,
769    {
770        self._scopes
771            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
772        self
773    }
774
775    /// Removes all scopes, and no default scope will be used either.
776    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
777    /// for details).
778    pub fn clear_scopes(mut self) -> WebResourceDeleteCall<'a, C> {
779        self._scopes.clear();
780        self
781    }
782}
783
784/// Get the most current data for a website or domain.
785///
786/// A builder for the *get* method supported by a *webResource* resource.
787/// It is not used directly, but through a [`WebResourceMethods`] instance.
788///
789/// # Example
790///
791/// Instantiate a resource method builder
792///
793/// ```test_harness,no_run
794/// # extern crate hyper;
795/// # extern crate hyper_rustls;
796/// # extern crate google_siteverification1 as siteverification1;
797/// # async fn dox() {
798/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
799///
800/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
801/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
802/// #     .with_native_roots()
803/// #     .unwrap()
804/// #     .https_only()
805/// #     .enable_http2()
806/// #     .build();
807///
808/// # let executor = hyper_util::rt::TokioExecutor::new();
809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
810/// #     secret,
811/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
812/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
813/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
814/// #     ),
815/// # ).build().await.unwrap();
816///
817/// # let client = hyper_util::client::legacy::Client::builder(
818/// #     hyper_util::rt::TokioExecutor::new()
819/// # )
820/// # .build(
821/// #     hyper_rustls::HttpsConnectorBuilder::new()
822/// #         .with_native_roots()
823/// #         .unwrap()
824/// #         .https_or_http()
825/// #         .enable_http2()
826/// #         .build()
827/// # );
828/// # let mut hub = SiteVerification::new(client, auth);
829/// // You can configure optional parameters by calling the respective setters at will, and
830/// // execute the final call using `doit()`.
831/// // Values shown here are possibly random and not representative !
832/// let result = hub.web_resource().get("id")
833///              .doit().await;
834/// # }
835/// ```
836pub struct WebResourceGetCall<'a, C>
837where
838    C: 'a,
839{
840    hub: &'a SiteVerification<C>,
841    _id: String,
842    _delegate: Option<&'a mut dyn common::Delegate>,
843    _additional_params: HashMap<String, String>,
844    _scopes: BTreeSet<String>,
845}
846
847impl<'a, C> common::CallBuilder for WebResourceGetCall<'a, C> {}
848
849impl<'a, C> WebResourceGetCall<'a, C>
850where
851    C: common::Connector,
852{
853    /// Perform the operation you have build so far.
854    pub async fn doit(
855        mut self,
856    ) -> common::Result<(common::Response, SiteVerificationWebResourceResource)> {
857        use std::borrow::Cow;
858        use std::io::{Read, Seek};
859
860        use common::{url::Params, ToParts};
861        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
862
863        let mut dd = common::DefaultDelegate;
864        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
865        dlg.begin(common::MethodInfo {
866            id: "siteVerification.webResource.get",
867            http_method: hyper::Method::GET,
868        });
869
870        for &field in ["alt", "id"].iter() {
871            if self._additional_params.contains_key(field) {
872                dlg.finished(false);
873                return Err(common::Error::FieldClash(field));
874            }
875        }
876
877        let mut params = Params::with_capacity(3 + self._additional_params.len());
878        params.push("id", self._id);
879
880        params.extend(self._additional_params.iter());
881
882        params.push("alt", "json");
883        let mut url = self.hub._base_url.clone() + "webResource/{id}";
884        if self._scopes.is_empty() {
885            self._scopes.insert(Scope::Full.as_ref().to_string());
886        }
887
888        #[allow(clippy::single_element_loop)]
889        for &(find_this, param_name) in [("{id}", "id")].iter() {
890            url = params.uri_replacement(url, param_name, find_this, false);
891        }
892        {
893            let to_remove = ["id"];
894            params.remove_params(&to_remove);
895        }
896
897        let url = params.parse_with_url(&url);
898
899        loop {
900            let token = match self
901                .hub
902                .auth
903                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
904                .await
905            {
906                Ok(token) => token,
907                Err(e) => match dlg.token(e) {
908                    Ok(token) => token,
909                    Err(e) => {
910                        dlg.finished(false);
911                        return Err(common::Error::MissingToken(e));
912                    }
913                },
914            };
915            let mut req_result = {
916                let client = &self.hub.client;
917                dlg.pre_request();
918                let mut req_builder = hyper::Request::builder()
919                    .method(hyper::Method::GET)
920                    .uri(url.as_str())
921                    .header(USER_AGENT, self.hub._user_agent.clone());
922
923                if let Some(token) = token.as_ref() {
924                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
925                }
926
927                let request = req_builder
928                    .header(CONTENT_LENGTH, 0_u64)
929                    .body(common::to_body::<String>(None));
930
931                client.request(request.unwrap()).await
932            };
933
934            match req_result {
935                Err(err) => {
936                    if let common::Retry::After(d) = dlg.http_error(&err) {
937                        sleep(d).await;
938                        continue;
939                    }
940                    dlg.finished(false);
941                    return Err(common::Error::HttpError(err));
942                }
943                Ok(res) => {
944                    let (mut parts, body) = res.into_parts();
945                    let mut body = common::Body::new(body);
946                    if !parts.status.is_success() {
947                        let bytes = common::to_bytes(body).await.unwrap_or_default();
948                        let error = serde_json::from_str(&common::to_string(&bytes));
949                        let response = common::to_response(parts, bytes.into());
950
951                        if let common::Retry::After(d) =
952                            dlg.http_failure(&response, error.as_ref().ok())
953                        {
954                            sleep(d).await;
955                            continue;
956                        }
957
958                        dlg.finished(false);
959
960                        return Err(match error {
961                            Ok(value) => common::Error::BadRequest(value),
962                            _ => common::Error::Failure(response),
963                        });
964                    }
965                    let response = {
966                        let bytes = common::to_bytes(body).await.unwrap_or_default();
967                        let encoded = common::to_string(&bytes);
968                        match serde_json::from_str(&encoded) {
969                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
970                            Err(error) => {
971                                dlg.response_json_decode_error(&encoded, &error);
972                                return Err(common::Error::JsonDecodeError(
973                                    encoded.to_string(),
974                                    error,
975                                ));
976                            }
977                        }
978                    };
979
980                    dlg.finished(true);
981                    return Ok(response);
982                }
983            }
984        }
985    }
986
987    /// The id of a verified site or domain.
988    ///
989    /// Sets the *id* path property to the given value.
990    ///
991    /// Even though the property as already been set when instantiating this call,
992    /// we provide this method for API completeness.
993    pub fn id(mut self, new_value: &str) -> WebResourceGetCall<'a, C> {
994        self._id = new_value.to_string();
995        self
996    }
997    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
998    /// while executing the actual API request.
999    ///
1000    /// ````text
1001    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1002    /// ````
1003    ///
1004    /// Sets the *delegate* property to the given value.
1005    pub fn delegate(
1006        mut self,
1007        new_value: &'a mut dyn common::Delegate,
1008    ) -> WebResourceGetCall<'a, C> {
1009        self._delegate = Some(new_value);
1010        self
1011    }
1012
1013    /// Set any additional parameter of the query string used in the request.
1014    /// It should be used to set parameters which are not yet available through their own
1015    /// setters.
1016    ///
1017    /// Please note that this method must not be used to set any of the known parameters
1018    /// which have their own setter method. If done anyway, the request will fail.
1019    ///
1020    /// # Additional Parameters
1021    ///
1022    /// * *alt* (query-string) - Data format for the response.
1023    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1024    /// * *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.
1025    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1026    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1027    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1028    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1029    pub fn param<T>(mut self, name: T, value: T) -> WebResourceGetCall<'a, C>
1030    where
1031        T: AsRef<str>,
1032    {
1033        self._additional_params
1034            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1035        self
1036    }
1037
1038    /// Identifies the authorization scope for the method you are building.
1039    ///
1040    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1041    /// [`Scope::Full`].
1042    ///
1043    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1044    /// tokens for more than one scope.
1045    ///
1046    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1047    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1048    /// sufficient, a read-write scope will do as well.
1049    pub fn add_scope<St>(mut self, scope: St) -> WebResourceGetCall<'a, C>
1050    where
1051        St: AsRef<str>,
1052    {
1053        self._scopes.insert(String::from(scope.as_ref()));
1054        self
1055    }
1056    /// Identifies the authorization scope(s) for the method you are building.
1057    ///
1058    /// See [`Self::add_scope()`] for details.
1059    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceGetCall<'a, C>
1060    where
1061        I: IntoIterator<Item = St>,
1062        St: AsRef<str>,
1063    {
1064        self._scopes
1065            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1066        self
1067    }
1068
1069    /// Removes all scopes, and no default scope will be used either.
1070    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1071    /// for details).
1072    pub fn clear_scopes(mut self) -> WebResourceGetCall<'a, C> {
1073        self._scopes.clear();
1074        self
1075    }
1076}
1077
1078/// Get a verification token for placing on a website or domain.
1079///
1080/// A builder for the *getToken* method supported by a *webResource* resource.
1081/// It is not used directly, but through a [`WebResourceMethods`] instance.
1082///
1083/// # Example
1084///
1085/// Instantiate a resource method builder
1086///
1087/// ```test_harness,no_run
1088/// # extern crate hyper;
1089/// # extern crate hyper_rustls;
1090/// # extern crate google_siteverification1 as siteverification1;
1091/// use siteverification1::api::SiteVerificationWebResourceGettokenRequest;
1092/// # async fn dox() {
1093/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1094///
1095/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1096/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1097/// #     .with_native_roots()
1098/// #     .unwrap()
1099/// #     .https_only()
1100/// #     .enable_http2()
1101/// #     .build();
1102///
1103/// # let executor = hyper_util::rt::TokioExecutor::new();
1104/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1105/// #     secret,
1106/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1107/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1108/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1109/// #     ),
1110/// # ).build().await.unwrap();
1111///
1112/// # let client = hyper_util::client::legacy::Client::builder(
1113/// #     hyper_util::rt::TokioExecutor::new()
1114/// # )
1115/// # .build(
1116/// #     hyper_rustls::HttpsConnectorBuilder::new()
1117/// #         .with_native_roots()
1118/// #         .unwrap()
1119/// #         .https_or_http()
1120/// #         .enable_http2()
1121/// #         .build()
1122/// # );
1123/// # let mut hub = SiteVerification::new(client, auth);
1124/// // As the method needs a request, you would usually fill it with the desired information
1125/// // into the respective structure. Some of the parts shown here might not be applicable !
1126/// // Values shown here are possibly random and not representative !
1127/// let mut req = SiteVerificationWebResourceGettokenRequest::default();
1128///
1129/// // You can configure optional parameters by calling the respective setters at will, and
1130/// // execute the final call using `doit()`.
1131/// // Values shown here are possibly random and not representative !
1132/// let result = hub.web_resource().get_token(req)
1133///              .doit().await;
1134/// # }
1135/// ```
1136pub struct WebResourceGetTokenCall<'a, C>
1137where
1138    C: 'a,
1139{
1140    hub: &'a SiteVerification<C>,
1141    _request: SiteVerificationWebResourceGettokenRequest,
1142    _delegate: Option<&'a mut dyn common::Delegate>,
1143    _additional_params: HashMap<String, String>,
1144    _scopes: BTreeSet<String>,
1145}
1146
1147impl<'a, C> common::CallBuilder for WebResourceGetTokenCall<'a, C> {}
1148
1149impl<'a, C> WebResourceGetTokenCall<'a, C>
1150where
1151    C: common::Connector,
1152{
1153    /// Perform the operation you have build so far.
1154    pub async fn doit(
1155        mut self,
1156    ) -> common::Result<(
1157        common::Response,
1158        SiteVerificationWebResourceGettokenResponse,
1159    )> {
1160        use std::borrow::Cow;
1161        use std::io::{Read, Seek};
1162
1163        use common::{url::Params, ToParts};
1164        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1165
1166        let mut dd = common::DefaultDelegate;
1167        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1168        dlg.begin(common::MethodInfo {
1169            id: "siteVerification.webResource.getToken",
1170            http_method: hyper::Method::POST,
1171        });
1172
1173        for &field in ["alt"].iter() {
1174            if self._additional_params.contains_key(field) {
1175                dlg.finished(false);
1176                return Err(common::Error::FieldClash(field));
1177            }
1178        }
1179
1180        let mut params = Params::with_capacity(3 + self._additional_params.len());
1181
1182        params.extend(self._additional_params.iter());
1183
1184        params.push("alt", "json");
1185        let mut url = self.hub._base_url.clone() + "token";
1186        if self._scopes.is_empty() {
1187            self._scopes.insert(Scope::Full.as_ref().to_string());
1188        }
1189
1190        let url = params.parse_with_url(&url);
1191
1192        let mut json_mime_type = mime::APPLICATION_JSON;
1193        let mut request_value_reader = {
1194            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1195            common::remove_json_null_values(&mut value);
1196            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1197            serde_json::to_writer(&mut dst, &value).unwrap();
1198            dst
1199        };
1200        let request_size = request_value_reader
1201            .seek(std::io::SeekFrom::End(0))
1202            .unwrap();
1203        request_value_reader
1204            .seek(std::io::SeekFrom::Start(0))
1205            .unwrap();
1206
1207        loop {
1208            let token = match self
1209                .hub
1210                .auth
1211                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1212                .await
1213            {
1214                Ok(token) => token,
1215                Err(e) => match dlg.token(e) {
1216                    Ok(token) => token,
1217                    Err(e) => {
1218                        dlg.finished(false);
1219                        return Err(common::Error::MissingToken(e));
1220                    }
1221                },
1222            };
1223            request_value_reader
1224                .seek(std::io::SeekFrom::Start(0))
1225                .unwrap();
1226            let mut req_result = {
1227                let client = &self.hub.client;
1228                dlg.pre_request();
1229                let mut req_builder = hyper::Request::builder()
1230                    .method(hyper::Method::POST)
1231                    .uri(url.as_str())
1232                    .header(USER_AGENT, self.hub._user_agent.clone());
1233
1234                if let Some(token) = token.as_ref() {
1235                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1236                }
1237
1238                let request = req_builder
1239                    .header(CONTENT_TYPE, json_mime_type.to_string())
1240                    .header(CONTENT_LENGTH, request_size as u64)
1241                    .body(common::to_body(
1242                        request_value_reader.get_ref().clone().into(),
1243                    ));
1244
1245                client.request(request.unwrap()).await
1246            };
1247
1248            match req_result {
1249                Err(err) => {
1250                    if let common::Retry::After(d) = dlg.http_error(&err) {
1251                        sleep(d).await;
1252                        continue;
1253                    }
1254                    dlg.finished(false);
1255                    return Err(common::Error::HttpError(err));
1256                }
1257                Ok(res) => {
1258                    let (mut parts, body) = res.into_parts();
1259                    let mut body = common::Body::new(body);
1260                    if !parts.status.is_success() {
1261                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1262                        let error = serde_json::from_str(&common::to_string(&bytes));
1263                        let response = common::to_response(parts, bytes.into());
1264
1265                        if let common::Retry::After(d) =
1266                            dlg.http_failure(&response, error.as_ref().ok())
1267                        {
1268                            sleep(d).await;
1269                            continue;
1270                        }
1271
1272                        dlg.finished(false);
1273
1274                        return Err(match error {
1275                            Ok(value) => common::Error::BadRequest(value),
1276                            _ => common::Error::Failure(response),
1277                        });
1278                    }
1279                    let response = {
1280                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1281                        let encoded = common::to_string(&bytes);
1282                        match serde_json::from_str(&encoded) {
1283                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1284                            Err(error) => {
1285                                dlg.response_json_decode_error(&encoded, &error);
1286                                return Err(common::Error::JsonDecodeError(
1287                                    encoded.to_string(),
1288                                    error,
1289                                ));
1290                            }
1291                        }
1292                    };
1293
1294                    dlg.finished(true);
1295                    return Ok(response);
1296                }
1297            }
1298        }
1299    }
1300
1301    ///
1302    /// Sets the *request* property to the given value.
1303    ///
1304    /// Even though the property as already been set when instantiating this call,
1305    /// we provide this method for API completeness.
1306    pub fn request(
1307        mut self,
1308        new_value: SiteVerificationWebResourceGettokenRequest,
1309    ) -> WebResourceGetTokenCall<'a, C> {
1310        self._request = new_value;
1311        self
1312    }
1313    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1314    /// while executing the actual API request.
1315    ///
1316    /// ````text
1317    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1318    /// ````
1319    ///
1320    /// Sets the *delegate* property to the given value.
1321    pub fn delegate(
1322        mut self,
1323        new_value: &'a mut dyn common::Delegate,
1324    ) -> WebResourceGetTokenCall<'a, C> {
1325        self._delegate = Some(new_value);
1326        self
1327    }
1328
1329    /// Set any additional parameter of the query string used in the request.
1330    /// It should be used to set parameters which are not yet available through their own
1331    /// setters.
1332    ///
1333    /// Please note that this method must not be used to set any of the known parameters
1334    /// which have their own setter method. If done anyway, the request will fail.
1335    ///
1336    /// # Additional Parameters
1337    ///
1338    /// * *alt* (query-string) - Data format for the response.
1339    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1340    /// * *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.
1341    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1342    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1343    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1344    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1345    pub fn param<T>(mut self, name: T, value: T) -> WebResourceGetTokenCall<'a, C>
1346    where
1347        T: AsRef<str>,
1348    {
1349        self._additional_params
1350            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1351        self
1352    }
1353
1354    /// Identifies the authorization scope for the method you are building.
1355    ///
1356    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1357    /// [`Scope::Full`].
1358    ///
1359    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1360    /// tokens for more than one scope.
1361    ///
1362    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1363    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1364    /// sufficient, a read-write scope will do as well.
1365    pub fn add_scope<St>(mut self, scope: St) -> WebResourceGetTokenCall<'a, C>
1366    where
1367        St: AsRef<str>,
1368    {
1369        self._scopes.insert(String::from(scope.as_ref()));
1370        self
1371    }
1372    /// Identifies the authorization scope(s) for the method you are building.
1373    ///
1374    /// See [`Self::add_scope()`] for details.
1375    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceGetTokenCall<'a, C>
1376    where
1377        I: IntoIterator<Item = St>,
1378        St: AsRef<str>,
1379    {
1380        self._scopes
1381            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1382        self
1383    }
1384
1385    /// Removes all scopes, and no default scope will be used either.
1386    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1387    /// for details).
1388    pub fn clear_scopes(mut self) -> WebResourceGetTokenCall<'a, C> {
1389        self._scopes.clear();
1390        self
1391    }
1392}
1393
1394/// Attempt verification of a website or domain.
1395///
1396/// A builder for the *insert* method supported by a *webResource* resource.
1397/// It is not used directly, but through a [`WebResourceMethods`] instance.
1398///
1399/// # Example
1400///
1401/// Instantiate a resource method builder
1402///
1403/// ```test_harness,no_run
1404/// # extern crate hyper;
1405/// # extern crate hyper_rustls;
1406/// # extern crate google_siteverification1 as siteverification1;
1407/// use siteverification1::api::SiteVerificationWebResourceResource;
1408/// # async fn dox() {
1409/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1410///
1411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1412/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1413/// #     .with_native_roots()
1414/// #     .unwrap()
1415/// #     .https_only()
1416/// #     .enable_http2()
1417/// #     .build();
1418///
1419/// # let executor = hyper_util::rt::TokioExecutor::new();
1420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1421/// #     secret,
1422/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1423/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1424/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1425/// #     ),
1426/// # ).build().await.unwrap();
1427///
1428/// # let client = hyper_util::client::legacy::Client::builder(
1429/// #     hyper_util::rt::TokioExecutor::new()
1430/// # )
1431/// # .build(
1432/// #     hyper_rustls::HttpsConnectorBuilder::new()
1433/// #         .with_native_roots()
1434/// #         .unwrap()
1435/// #         .https_or_http()
1436/// #         .enable_http2()
1437/// #         .build()
1438/// # );
1439/// # let mut hub = SiteVerification::new(client, auth);
1440/// // As the method needs a request, you would usually fill it with the desired information
1441/// // into the respective structure. Some of the parts shown here might not be applicable !
1442/// // Values shown here are possibly random and not representative !
1443/// let mut req = SiteVerificationWebResourceResource::default();
1444///
1445/// // You can configure optional parameters by calling the respective setters at will, and
1446/// // execute the final call using `doit()`.
1447/// // Values shown here are possibly random and not representative !
1448/// let result = hub.web_resource().insert(req, "verificationMethod")
1449///              .doit().await;
1450/// # }
1451/// ```
1452pub struct WebResourceInsertCall<'a, C>
1453where
1454    C: 'a,
1455{
1456    hub: &'a SiteVerification<C>,
1457    _request: SiteVerificationWebResourceResource,
1458    _verification_method: String,
1459    _delegate: Option<&'a mut dyn common::Delegate>,
1460    _additional_params: HashMap<String, String>,
1461    _scopes: BTreeSet<String>,
1462}
1463
1464impl<'a, C> common::CallBuilder for WebResourceInsertCall<'a, C> {}
1465
1466impl<'a, C> WebResourceInsertCall<'a, C>
1467where
1468    C: common::Connector,
1469{
1470    /// Perform the operation you have build so far.
1471    pub async fn doit(
1472        mut self,
1473    ) -> common::Result<(common::Response, SiteVerificationWebResourceResource)> {
1474        use std::borrow::Cow;
1475        use std::io::{Read, Seek};
1476
1477        use common::{url::Params, ToParts};
1478        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1479
1480        let mut dd = common::DefaultDelegate;
1481        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1482        dlg.begin(common::MethodInfo {
1483            id: "siteVerification.webResource.insert",
1484            http_method: hyper::Method::POST,
1485        });
1486
1487        for &field in ["alt", "verificationMethod"].iter() {
1488            if self._additional_params.contains_key(field) {
1489                dlg.finished(false);
1490                return Err(common::Error::FieldClash(field));
1491            }
1492        }
1493
1494        let mut params = Params::with_capacity(4 + self._additional_params.len());
1495        params.push("verificationMethod", self._verification_method);
1496
1497        params.extend(self._additional_params.iter());
1498
1499        params.push("alt", "json");
1500        let mut url = self.hub._base_url.clone() + "webResource";
1501        if self._scopes.is_empty() {
1502            self._scopes.insert(Scope::Full.as_ref().to_string());
1503        }
1504
1505        let url = params.parse_with_url(&url);
1506
1507        let mut json_mime_type = mime::APPLICATION_JSON;
1508        let mut request_value_reader = {
1509            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1510            common::remove_json_null_values(&mut value);
1511            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1512            serde_json::to_writer(&mut dst, &value).unwrap();
1513            dst
1514        };
1515        let request_size = request_value_reader
1516            .seek(std::io::SeekFrom::End(0))
1517            .unwrap();
1518        request_value_reader
1519            .seek(std::io::SeekFrom::Start(0))
1520            .unwrap();
1521
1522        loop {
1523            let token = match self
1524                .hub
1525                .auth
1526                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1527                .await
1528            {
1529                Ok(token) => token,
1530                Err(e) => match dlg.token(e) {
1531                    Ok(token) => token,
1532                    Err(e) => {
1533                        dlg.finished(false);
1534                        return Err(common::Error::MissingToken(e));
1535                    }
1536                },
1537            };
1538            request_value_reader
1539                .seek(std::io::SeekFrom::Start(0))
1540                .unwrap();
1541            let mut req_result = {
1542                let client = &self.hub.client;
1543                dlg.pre_request();
1544                let mut req_builder = hyper::Request::builder()
1545                    .method(hyper::Method::POST)
1546                    .uri(url.as_str())
1547                    .header(USER_AGENT, self.hub._user_agent.clone());
1548
1549                if let Some(token) = token.as_ref() {
1550                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1551                }
1552
1553                let request = req_builder
1554                    .header(CONTENT_TYPE, json_mime_type.to_string())
1555                    .header(CONTENT_LENGTH, request_size as u64)
1556                    .body(common::to_body(
1557                        request_value_reader.get_ref().clone().into(),
1558                    ));
1559
1560                client.request(request.unwrap()).await
1561            };
1562
1563            match req_result {
1564                Err(err) => {
1565                    if let common::Retry::After(d) = dlg.http_error(&err) {
1566                        sleep(d).await;
1567                        continue;
1568                    }
1569                    dlg.finished(false);
1570                    return Err(common::Error::HttpError(err));
1571                }
1572                Ok(res) => {
1573                    let (mut parts, body) = res.into_parts();
1574                    let mut body = common::Body::new(body);
1575                    if !parts.status.is_success() {
1576                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1577                        let error = serde_json::from_str(&common::to_string(&bytes));
1578                        let response = common::to_response(parts, bytes.into());
1579
1580                        if let common::Retry::After(d) =
1581                            dlg.http_failure(&response, error.as_ref().ok())
1582                        {
1583                            sleep(d).await;
1584                            continue;
1585                        }
1586
1587                        dlg.finished(false);
1588
1589                        return Err(match error {
1590                            Ok(value) => common::Error::BadRequest(value),
1591                            _ => common::Error::Failure(response),
1592                        });
1593                    }
1594                    let response = {
1595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1596                        let encoded = common::to_string(&bytes);
1597                        match serde_json::from_str(&encoded) {
1598                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1599                            Err(error) => {
1600                                dlg.response_json_decode_error(&encoded, &error);
1601                                return Err(common::Error::JsonDecodeError(
1602                                    encoded.to_string(),
1603                                    error,
1604                                ));
1605                            }
1606                        }
1607                    };
1608
1609                    dlg.finished(true);
1610                    return Ok(response);
1611                }
1612            }
1613        }
1614    }
1615
1616    ///
1617    /// Sets the *request* property to the given value.
1618    ///
1619    /// Even though the property as already been set when instantiating this call,
1620    /// we provide this method for API completeness.
1621    pub fn request(
1622        mut self,
1623        new_value: SiteVerificationWebResourceResource,
1624    ) -> WebResourceInsertCall<'a, C> {
1625        self._request = new_value;
1626        self
1627    }
1628    /// The method to use for verifying a site or domain.
1629    ///
1630    /// Sets the *verification method* query property to the given value.
1631    ///
1632    /// Even though the property as already been set when instantiating this call,
1633    /// we provide this method for API completeness.
1634    pub fn verification_method(mut self, new_value: &str) -> WebResourceInsertCall<'a, C> {
1635        self._verification_method = new_value.to_string();
1636        self
1637    }
1638    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1639    /// while executing the actual API request.
1640    ///
1641    /// ````text
1642    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1643    /// ````
1644    ///
1645    /// Sets the *delegate* property to the given value.
1646    pub fn delegate(
1647        mut self,
1648        new_value: &'a mut dyn common::Delegate,
1649    ) -> WebResourceInsertCall<'a, C> {
1650        self._delegate = Some(new_value);
1651        self
1652    }
1653
1654    /// Set any additional parameter of the query string used in the request.
1655    /// It should be used to set parameters which are not yet available through their own
1656    /// setters.
1657    ///
1658    /// Please note that this method must not be used to set any of the known parameters
1659    /// which have their own setter method. If done anyway, the request will fail.
1660    ///
1661    /// # Additional Parameters
1662    ///
1663    /// * *alt* (query-string) - Data format for the response.
1664    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1665    /// * *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.
1666    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1667    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1668    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1669    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1670    pub fn param<T>(mut self, name: T, value: T) -> WebResourceInsertCall<'a, C>
1671    where
1672        T: AsRef<str>,
1673    {
1674        self._additional_params
1675            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1676        self
1677    }
1678
1679    /// Identifies the authorization scope for the method you are building.
1680    ///
1681    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1682    /// [`Scope::Full`].
1683    ///
1684    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1685    /// tokens for more than one scope.
1686    ///
1687    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1688    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1689    /// sufficient, a read-write scope will do as well.
1690    pub fn add_scope<St>(mut self, scope: St) -> WebResourceInsertCall<'a, C>
1691    where
1692        St: AsRef<str>,
1693    {
1694        self._scopes.insert(String::from(scope.as_ref()));
1695        self
1696    }
1697    /// Identifies the authorization scope(s) for the method you are building.
1698    ///
1699    /// See [`Self::add_scope()`] for details.
1700    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceInsertCall<'a, C>
1701    where
1702        I: IntoIterator<Item = St>,
1703        St: AsRef<str>,
1704    {
1705        self._scopes
1706            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1707        self
1708    }
1709
1710    /// Removes all scopes, and no default scope will be used either.
1711    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1712    /// for details).
1713    pub fn clear_scopes(mut self) -> WebResourceInsertCall<'a, C> {
1714        self._scopes.clear();
1715        self
1716    }
1717}
1718
1719/// Get the list of your verified websites and domains.
1720///
1721/// A builder for the *list* method supported by a *webResource* resource.
1722/// It is not used directly, but through a [`WebResourceMethods`] instance.
1723///
1724/// # Example
1725///
1726/// Instantiate a resource method builder
1727///
1728/// ```test_harness,no_run
1729/// # extern crate hyper;
1730/// # extern crate hyper_rustls;
1731/// # extern crate google_siteverification1 as siteverification1;
1732/// # async fn dox() {
1733/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1734///
1735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1736/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1737/// #     .with_native_roots()
1738/// #     .unwrap()
1739/// #     .https_only()
1740/// #     .enable_http2()
1741/// #     .build();
1742///
1743/// # let executor = hyper_util::rt::TokioExecutor::new();
1744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1745/// #     secret,
1746/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1747/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1748/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1749/// #     ),
1750/// # ).build().await.unwrap();
1751///
1752/// # let client = hyper_util::client::legacy::Client::builder(
1753/// #     hyper_util::rt::TokioExecutor::new()
1754/// # )
1755/// # .build(
1756/// #     hyper_rustls::HttpsConnectorBuilder::new()
1757/// #         .with_native_roots()
1758/// #         .unwrap()
1759/// #         .https_or_http()
1760/// #         .enable_http2()
1761/// #         .build()
1762/// # );
1763/// # let mut hub = SiteVerification::new(client, auth);
1764/// // You can configure optional parameters by calling the respective setters at will, and
1765/// // execute the final call using `doit()`.
1766/// // Values shown here are possibly random and not representative !
1767/// let result = hub.web_resource().list()
1768///              .doit().await;
1769/// # }
1770/// ```
1771pub struct WebResourceListCall<'a, C>
1772where
1773    C: 'a,
1774{
1775    hub: &'a SiteVerification<C>,
1776    _delegate: Option<&'a mut dyn common::Delegate>,
1777    _additional_params: HashMap<String, String>,
1778    _scopes: BTreeSet<String>,
1779}
1780
1781impl<'a, C> common::CallBuilder for WebResourceListCall<'a, C> {}
1782
1783impl<'a, C> WebResourceListCall<'a, C>
1784where
1785    C: common::Connector,
1786{
1787    /// Perform the operation you have build so far.
1788    pub async fn doit(
1789        mut self,
1790    ) -> common::Result<(common::Response, SiteVerificationWebResourceListResponse)> {
1791        use std::borrow::Cow;
1792        use std::io::{Read, Seek};
1793
1794        use common::{url::Params, ToParts};
1795        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1796
1797        let mut dd = common::DefaultDelegate;
1798        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1799        dlg.begin(common::MethodInfo {
1800            id: "siteVerification.webResource.list",
1801            http_method: hyper::Method::GET,
1802        });
1803
1804        for &field in ["alt"].iter() {
1805            if self._additional_params.contains_key(field) {
1806                dlg.finished(false);
1807                return Err(common::Error::FieldClash(field));
1808            }
1809        }
1810
1811        let mut params = Params::with_capacity(2 + self._additional_params.len());
1812
1813        params.extend(self._additional_params.iter());
1814
1815        params.push("alt", "json");
1816        let mut url = self.hub._base_url.clone() + "webResource";
1817        if self._scopes.is_empty() {
1818            self._scopes.insert(Scope::Full.as_ref().to_string());
1819        }
1820
1821        let url = params.parse_with_url(&url);
1822
1823        loop {
1824            let token = match self
1825                .hub
1826                .auth
1827                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1828                .await
1829            {
1830                Ok(token) => token,
1831                Err(e) => match dlg.token(e) {
1832                    Ok(token) => token,
1833                    Err(e) => {
1834                        dlg.finished(false);
1835                        return Err(common::Error::MissingToken(e));
1836                    }
1837                },
1838            };
1839            let mut req_result = {
1840                let client = &self.hub.client;
1841                dlg.pre_request();
1842                let mut req_builder = hyper::Request::builder()
1843                    .method(hyper::Method::GET)
1844                    .uri(url.as_str())
1845                    .header(USER_AGENT, self.hub._user_agent.clone());
1846
1847                if let Some(token) = token.as_ref() {
1848                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1849                }
1850
1851                let request = req_builder
1852                    .header(CONTENT_LENGTH, 0_u64)
1853                    .body(common::to_body::<String>(None));
1854
1855                client.request(request.unwrap()).await
1856            };
1857
1858            match req_result {
1859                Err(err) => {
1860                    if let common::Retry::After(d) = dlg.http_error(&err) {
1861                        sleep(d).await;
1862                        continue;
1863                    }
1864                    dlg.finished(false);
1865                    return Err(common::Error::HttpError(err));
1866                }
1867                Ok(res) => {
1868                    let (mut parts, body) = res.into_parts();
1869                    let mut body = common::Body::new(body);
1870                    if !parts.status.is_success() {
1871                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1872                        let error = serde_json::from_str(&common::to_string(&bytes));
1873                        let response = common::to_response(parts, bytes.into());
1874
1875                        if let common::Retry::After(d) =
1876                            dlg.http_failure(&response, error.as_ref().ok())
1877                        {
1878                            sleep(d).await;
1879                            continue;
1880                        }
1881
1882                        dlg.finished(false);
1883
1884                        return Err(match error {
1885                            Ok(value) => common::Error::BadRequest(value),
1886                            _ => common::Error::Failure(response),
1887                        });
1888                    }
1889                    let response = {
1890                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1891                        let encoded = common::to_string(&bytes);
1892                        match serde_json::from_str(&encoded) {
1893                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1894                            Err(error) => {
1895                                dlg.response_json_decode_error(&encoded, &error);
1896                                return Err(common::Error::JsonDecodeError(
1897                                    encoded.to_string(),
1898                                    error,
1899                                ));
1900                            }
1901                        }
1902                    };
1903
1904                    dlg.finished(true);
1905                    return Ok(response);
1906                }
1907            }
1908        }
1909    }
1910
1911    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1912    /// while executing the actual API request.
1913    ///
1914    /// ````text
1915    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1916    /// ````
1917    ///
1918    /// Sets the *delegate* property to the given value.
1919    pub fn delegate(
1920        mut self,
1921        new_value: &'a mut dyn common::Delegate,
1922    ) -> WebResourceListCall<'a, C> {
1923        self._delegate = Some(new_value);
1924        self
1925    }
1926
1927    /// Set any additional parameter of the query string used in the request.
1928    /// It should be used to set parameters which are not yet available through their own
1929    /// setters.
1930    ///
1931    /// Please note that this method must not be used to set any of the known parameters
1932    /// which have their own setter method. If done anyway, the request will fail.
1933    ///
1934    /// # Additional Parameters
1935    ///
1936    /// * *alt* (query-string) - Data format for the response.
1937    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1938    /// * *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.
1939    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1940    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1941    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1942    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1943    pub fn param<T>(mut self, name: T, value: T) -> WebResourceListCall<'a, C>
1944    where
1945        T: AsRef<str>,
1946    {
1947        self._additional_params
1948            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1949        self
1950    }
1951
1952    /// Identifies the authorization scope for the method you are building.
1953    ///
1954    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1955    /// [`Scope::Full`].
1956    ///
1957    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1958    /// tokens for more than one scope.
1959    ///
1960    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1961    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1962    /// sufficient, a read-write scope will do as well.
1963    pub fn add_scope<St>(mut self, scope: St) -> WebResourceListCall<'a, C>
1964    where
1965        St: AsRef<str>,
1966    {
1967        self._scopes.insert(String::from(scope.as_ref()));
1968        self
1969    }
1970    /// Identifies the authorization scope(s) for the method you are building.
1971    ///
1972    /// See [`Self::add_scope()`] for details.
1973    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceListCall<'a, C>
1974    where
1975        I: IntoIterator<Item = St>,
1976        St: AsRef<str>,
1977    {
1978        self._scopes
1979            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1980        self
1981    }
1982
1983    /// Removes all scopes, and no default scope will be used either.
1984    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1985    /// for details).
1986    pub fn clear_scopes(mut self) -> WebResourceListCall<'a, C> {
1987        self._scopes.clear();
1988        self
1989    }
1990}
1991
1992/// Modify the list of owners for your website or domain. This method supports patch semantics.
1993///
1994/// A builder for the *patch* method supported by a *webResource* resource.
1995/// It is not used directly, but through a [`WebResourceMethods`] instance.
1996///
1997/// # Example
1998///
1999/// Instantiate a resource method builder
2000///
2001/// ```test_harness,no_run
2002/// # extern crate hyper;
2003/// # extern crate hyper_rustls;
2004/// # extern crate google_siteverification1 as siteverification1;
2005/// use siteverification1::api::SiteVerificationWebResourceResource;
2006/// # async fn dox() {
2007/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2008///
2009/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2010/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2011/// #     .with_native_roots()
2012/// #     .unwrap()
2013/// #     .https_only()
2014/// #     .enable_http2()
2015/// #     .build();
2016///
2017/// # let executor = hyper_util::rt::TokioExecutor::new();
2018/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2019/// #     secret,
2020/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2021/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2022/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2023/// #     ),
2024/// # ).build().await.unwrap();
2025///
2026/// # let client = hyper_util::client::legacy::Client::builder(
2027/// #     hyper_util::rt::TokioExecutor::new()
2028/// # )
2029/// # .build(
2030/// #     hyper_rustls::HttpsConnectorBuilder::new()
2031/// #         .with_native_roots()
2032/// #         .unwrap()
2033/// #         .https_or_http()
2034/// #         .enable_http2()
2035/// #         .build()
2036/// # );
2037/// # let mut hub = SiteVerification::new(client, auth);
2038/// // As the method needs a request, you would usually fill it with the desired information
2039/// // into the respective structure. Some of the parts shown here might not be applicable !
2040/// // Values shown here are possibly random and not representative !
2041/// let mut req = SiteVerificationWebResourceResource::default();
2042///
2043/// // You can configure optional parameters by calling the respective setters at will, and
2044/// // execute the final call using `doit()`.
2045/// // Values shown here are possibly random and not representative !
2046/// let result = hub.web_resource().patch(req, "id")
2047///              .doit().await;
2048/// # }
2049/// ```
2050pub struct WebResourcePatchCall<'a, C>
2051where
2052    C: 'a,
2053{
2054    hub: &'a SiteVerification<C>,
2055    _request: SiteVerificationWebResourceResource,
2056    _id: String,
2057    _delegate: Option<&'a mut dyn common::Delegate>,
2058    _additional_params: HashMap<String, String>,
2059    _scopes: BTreeSet<String>,
2060}
2061
2062impl<'a, C> common::CallBuilder for WebResourcePatchCall<'a, C> {}
2063
2064impl<'a, C> WebResourcePatchCall<'a, C>
2065where
2066    C: common::Connector,
2067{
2068    /// Perform the operation you have build so far.
2069    pub async fn doit(
2070        mut self,
2071    ) -> common::Result<(common::Response, SiteVerificationWebResourceResource)> {
2072        use std::borrow::Cow;
2073        use std::io::{Read, Seek};
2074
2075        use common::{url::Params, ToParts};
2076        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2077
2078        let mut dd = common::DefaultDelegate;
2079        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2080        dlg.begin(common::MethodInfo {
2081            id: "siteVerification.webResource.patch",
2082            http_method: hyper::Method::PATCH,
2083        });
2084
2085        for &field in ["alt", "id"].iter() {
2086            if self._additional_params.contains_key(field) {
2087                dlg.finished(false);
2088                return Err(common::Error::FieldClash(field));
2089            }
2090        }
2091
2092        let mut params = Params::with_capacity(4 + self._additional_params.len());
2093        params.push("id", self._id);
2094
2095        params.extend(self._additional_params.iter());
2096
2097        params.push("alt", "json");
2098        let mut url = self.hub._base_url.clone() + "webResource/{id}";
2099        if self._scopes.is_empty() {
2100            self._scopes.insert(Scope::Full.as_ref().to_string());
2101        }
2102
2103        #[allow(clippy::single_element_loop)]
2104        for &(find_this, param_name) in [("{id}", "id")].iter() {
2105            url = params.uri_replacement(url, param_name, find_this, false);
2106        }
2107        {
2108            let to_remove = ["id"];
2109            params.remove_params(&to_remove);
2110        }
2111
2112        let url = params.parse_with_url(&url);
2113
2114        let mut json_mime_type = mime::APPLICATION_JSON;
2115        let mut request_value_reader = {
2116            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2117            common::remove_json_null_values(&mut value);
2118            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2119            serde_json::to_writer(&mut dst, &value).unwrap();
2120            dst
2121        };
2122        let request_size = request_value_reader
2123            .seek(std::io::SeekFrom::End(0))
2124            .unwrap();
2125        request_value_reader
2126            .seek(std::io::SeekFrom::Start(0))
2127            .unwrap();
2128
2129        loop {
2130            let token = match self
2131                .hub
2132                .auth
2133                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2134                .await
2135            {
2136                Ok(token) => token,
2137                Err(e) => match dlg.token(e) {
2138                    Ok(token) => token,
2139                    Err(e) => {
2140                        dlg.finished(false);
2141                        return Err(common::Error::MissingToken(e));
2142                    }
2143                },
2144            };
2145            request_value_reader
2146                .seek(std::io::SeekFrom::Start(0))
2147                .unwrap();
2148            let mut req_result = {
2149                let client = &self.hub.client;
2150                dlg.pre_request();
2151                let mut req_builder = hyper::Request::builder()
2152                    .method(hyper::Method::PATCH)
2153                    .uri(url.as_str())
2154                    .header(USER_AGENT, self.hub._user_agent.clone());
2155
2156                if let Some(token) = token.as_ref() {
2157                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2158                }
2159
2160                let request = req_builder
2161                    .header(CONTENT_TYPE, json_mime_type.to_string())
2162                    .header(CONTENT_LENGTH, request_size as u64)
2163                    .body(common::to_body(
2164                        request_value_reader.get_ref().clone().into(),
2165                    ));
2166
2167                client.request(request.unwrap()).await
2168            };
2169
2170            match req_result {
2171                Err(err) => {
2172                    if let common::Retry::After(d) = dlg.http_error(&err) {
2173                        sleep(d).await;
2174                        continue;
2175                    }
2176                    dlg.finished(false);
2177                    return Err(common::Error::HttpError(err));
2178                }
2179                Ok(res) => {
2180                    let (mut parts, body) = res.into_parts();
2181                    let mut body = common::Body::new(body);
2182                    if !parts.status.is_success() {
2183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2184                        let error = serde_json::from_str(&common::to_string(&bytes));
2185                        let response = common::to_response(parts, bytes.into());
2186
2187                        if let common::Retry::After(d) =
2188                            dlg.http_failure(&response, error.as_ref().ok())
2189                        {
2190                            sleep(d).await;
2191                            continue;
2192                        }
2193
2194                        dlg.finished(false);
2195
2196                        return Err(match error {
2197                            Ok(value) => common::Error::BadRequest(value),
2198                            _ => common::Error::Failure(response),
2199                        });
2200                    }
2201                    let response = {
2202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2203                        let encoded = common::to_string(&bytes);
2204                        match serde_json::from_str(&encoded) {
2205                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2206                            Err(error) => {
2207                                dlg.response_json_decode_error(&encoded, &error);
2208                                return Err(common::Error::JsonDecodeError(
2209                                    encoded.to_string(),
2210                                    error,
2211                                ));
2212                            }
2213                        }
2214                    };
2215
2216                    dlg.finished(true);
2217                    return Ok(response);
2218                }
2219            }
2220        }
2221    }
2222
2223    ///
2224    /// Sets the *request* property to the given value.
2225    ///
2226    /// Even though the property as already been set when instantiating this call,
2227    /// we provide this method for API completeness.
2228    pub fn request(
2229        mut self,
2230        new_value: SiteVerificationWebResourceResource,
2231    ) -> WebResourcePatchCall<'a, C> {
2232        self._request = new_value;
2233        self
2234    }
2235    /// The id of a verified site or domain.
2236    ///
2237    /// Sets the *id* path property to the given value.
2238    ///
2239    /// Even though the property as already been set when instantiating this call,
2240    /// we provide this method for API completeness.
2241    pub fn id(mut self, new_value: &str) -> WebResourcePatchCall<'a, C> {
2242        self._id = new_value.to_string();
2243        self
2244    }
2245    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2246    /// while executing the actual API request.
2247    ///
2248    /// ````text
2249    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2250    /// ````
2251    ///
2252    /// Sets the *delegate* property to the given value.
2253    pub fn delegate(
2254        mut self,
2255        new_value: &'a mut dyn common::Delegate,
2256    ) -> WebResourcePatchCall<'a, C> {
2257        self._delegate = Some(new_value);
2258        self
2259    }
2260
2261    /// Set any additional parameter of the query string used in the request.
2262    /// It should be used to set parameters which are not yet available through their own
2263    /// setters.
2264    ///
2265    /// Please note that this method must not be used to set any of the known parameters
2266    /// which have their own setter method. If done anyway, the request will fail.
2267    ///
2268    /// # Additional Parameters
2269    ///
2270    /// * *alt* (query-string) - Data format for the response.
2271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2272    /// * *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.
2273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2275    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2276    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2277    pub fn param<T>(mut self, name: T, value: T) -> WebResourcePatchCall<'a, C>
2278    where
2279        T: AsRef<str>,
2280    {
2281        self._additional_params
2282            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2283        self
2284    }
2285
2286    /// Identifies the authorization scope for the method you are building.
2287    ///
2288    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2289    /// [`Scope::Full`].
2290    ///
2291    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2292    /// tokens for more than one scope.
2293    ///
2294    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2295    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2296    /// sufficient, a read-write scope will do as well.
2297    pub fn add_scope<St>(mut self, scope: St) -> WebResourcePatchCall<'a, C>
2298    where
2299        St: AsRef<str>,
2300    {
2301        self._scopes.insert(String::from(scope.as_ref()));
2302        self
2303    }
2304    /// Identifies the authorization scope(s) for the method you are building.
2305    ///
2306    /// See [`Self::add_scope()`] for details.
2307    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourcePatchCall<'a, C>
2308    where
2309        I: IntoIterator<Item = St>,
2310        St: AsRef<str>,
2311    {
2312        self._scopes
2313            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2314        self
2315    }
2316
2317    /// Removes all scopes, and no default scope will be used either.
2318    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2319    /// for details).
2320    pub fn clear_scopes(mut self) -> WebResourcePatchCall<'a, C> {
2321        self._scopes.clear();
2322        self
2323    }
2324}
2325
2326/// Modify the list of owners for your website or domain.
2327///
2328/// A builder for the *update* method supported by a *webResource* resource.
2329/// It is not used directly, but through a [`WebResourceMethods`] instance.
2330///
2331/// # Example
2332///
2333/// Instantiate a resource method builder
2334///
2335/// ```test_harness,no_run
2336/// # extern crate hyper;
2337/// # extern crate hyper_rustls;
2338/// # extern crate google_siteverification1 as siteverification1;
2339/// use siteverification1::api::SiteVerificationWebResourceResource;
2340/// # async fn dox() {
2341/// # use siteverification1::{SiteVerification, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2342///
2343/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2344/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2345/// #     .with_native_roots()
2346/// #     .unwrap()
2347/// #     .https_only()
2348/// #     .enable_http2()
2349/// #     .build();
2350///
2351/// # let executor = hyper_util::rt::TokioExecutor::new();
2352/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2353/// #     secret,
2354/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2355/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2356/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2357/// #     ),
2358/// # ).build().await.unwrap();
2359///
2360/// # let client = hyper_util::client::legacy::Client::builder(
2361/// #     hyper_util::rt::TokioExecutor::new()
2362/// # )
2363/// # .build(
2364/// #     hyper_rustls::HttpsConnectorBuilder::new()
2365/// #         .with_native_roots()
2366/// #         .unwrap()
2367/// #         .https_or_http()
2368/// #         .enable_http2()
2369/// #         .build()
2370/// # );
2371/// # let mut hub = SiteVerification::new(client, auth);
2372/// // As the method needs a request, you would usually fill it with the desired information
2373/// // into the respective structure. Some of the parts shown here might not be applicable !
2374/// // Values shown here are possibly random and not representative !
2375/// let mut req = SiteVerificationWebResourceResource::default();
2376///
2377/// // You can configure optional parameters by calling the respective setters at will, and
2378/// // execute the final call using `doit()`.
2379/// // Values shown here are possibly random and not representative !
2380/// let result = hub.web_resource().update(req, "id")
2381///              .doit().await;
2382/// # }
2383/// ```
2384pub struct WebResourceUpdateCall<'a, C>
2385where
2386    C: 'a,
2387{
2388    hub: &'a SiteVerification<C>,
2389    _request: SiteVerificationWebResourceResource,
2390    _id: String,
2391    _delegate: Option<&'a mut dyn common::Delegate>,
2392    _additional_params: HashMap<String, String>,
2393    _scopes: BTreeSet<String>,
2394}
2395
2396impl<'a, C> common::CallBuilder for WebResourceUpdateCall<'a, C> {}
2397
2398impl<'a, C> WebResourceUpdateCall<'a, C>
2399where
2400    C: common::Connector,
2401{
2402    /// Perform the operation you have build so far.
2403    pub async fn doit(
2404        mut self,
2405    ) -> common::Result<(common::Response, SiteVerificationWebResourceResource)> {
2406        use std::borrow::Cow;
2407        use std::io::{Read, Seek};
2408
2409        use common::{url::Params, ToParts};
2410        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2411
2412        let mut dd = common::DefaultDelegate;
2413        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2414        dlg.begin(common::MethodInfo {
2415            id: "siteVerification.webResource.update",
2416            http_method: hyper::Method::PUT,
2417        });
2418
2419        for &field in ["alt", "id"].iter() {
2420            if self._additional_params.contains_key(field) {
2421                dlg.finished(false);
2422                return Err(common::Error::FieldClash(field));
2423            }
2424        }
2425
2426        let mut params = Params::with_capacity(4 + self._additional_params.len());
2427        params.push("id", self._id);
2428
2429        params.extend(self._additional_params.iter());
2430
2431        params.push("alt", "json");
2432        let mut url = self.hub._base_url.clone() + "webResource/{id}";
2433        if self._scopes.is_empty() {
2434            self._scopes.insert(Scope::Full.as_ref().to_string());
2435        }
2436
2437        #[allow(clippy::single_element_loop)]
2438        for &(find_this, param_name) in [("{id}", "id")].iter() {
2439            url = params.uri_replacement(url, param_name, find_this, false);
2440        }
2441        {
2442            let to_remove = ["id"];
2443            params.remove_params(&to_remove);
2444        }
2445
2446        let url = params.parse_with_url(&url);
2447
2448        let mut json_mime_type = mime::APPLICATION_JSON;
2449        let mut request_value_reader = {
2450            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2451            common::remove_json_null_values(&mut value);
2452            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2453            serde_json::to_writer(&mut dst, &value).unwrap();
2454            dst
2455        };
2456        let request_size = request_value_reader
2457            .seek(std::io::SeekFrom::End(0))
2458            .unwrap();
2459        request_value_reader
2460            .seek(std::io::SeekFrom::Start(0))
2461            .unwrap();
2462
2463        loop {
2464            let token = match self
2465                .hub
2466                .auth
2467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2468                .await
2469            {
2470                Ok(token) => token,
2471                Err(e) => match dlg.token(e) {
2472                    Ok(token) => token,
2473                    Err(e) => {
2474                        dlg.finished(false);
2475                        return Err(common::Error::MissingToken(e));
2476                    }
2477                },
2478            };
2479            request_value_reader
2480                .seek(std::io::SeekFrom::Start(0))
2481                .unwrap();
2482            let mut req_result = {
2483                let client = &self.hub.client;
2484                dlg.pre_request();
2485                let mut req_builder = hyper::Request::builder()
2486                    .method(hyper::Method::PUT)
2487                    .uri(url.as_str())
2488                    .header(USER_AGENT, self.hub._user_agent.clone());
2489
2490                if let Some(token) = token.as_ref() {
2491                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2492                }
2493
2494                let request = req_builder
2495                    .header(CONTENT_TYPE, json_mime_type.to_string())
2496                    .header(CONTENT_LENGTH, request_size as u64)
2497                    .body(common::to_body(
2498                        request_value_reader.get_ref().clone().into(),
2499                    ));
2500
2501                client.request(request.unwrap()).await
2502            };
2503
2504            match req_result {
2505                Err(err) => {
2506                    if let common::Retry::After(d) = dlg.http_error(&err) {
2507                        sleep(d).await;
2508                        continue;
2509                    }
2510                    dlg.finished(false);
2511                    return Err(common::Error::HttpError(err));
2512                }
2513                Ok(res) => {
2514                    let (mut parts, body) = res.into_parts();
2515                    let mut body = common::Body::new(body);
2516                    if !parts.status.is_success() {
2517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2518                        let error = serde_json::from_str(&common::to_string(&bytes));
2519                        let response = common::to_response(parts, bytes.into());
2520
2521                        if let common::Retry::After(d) =
2522                            dlg.http_failure(&response, error.as_ref().ok())
2523                        {
2524                            sleep(d).await;
2525                            continue;
2526                        }
2527
2528                        dlg.finished(false);
2529
2530                        return Err(match error {
2531                            Ok(value) => common::Error::BadRequest(value),
2532                            _ => common::Error::Failure(response),
2533                        });
2534                    }
2535                    let response = {
2536                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2537                        let encoded = common::to_string(&bytes);
2538                        match serde_json::from_str(&encoded) {
2539                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2540                            Err(error) => {
2541                                dlg.response_json_decode_error(&encoded, &error);
2542                                return Err(common::Error::JsonDecodeError(
2543                                    encoded.to_string(),
2544                                    error,
2545                                ));
2546                            }
2547                        }
2548                    };
2549
2550                    dlg.finished(true);
2551                    return Ok(response);
2552                }
2553            }
2554        }
2555    }
2556
2557    ///
2558    /// Sets the *request* property to the given value.
2559    ///
2560    /// Even though the property as already been set when instantiating this call,
2561    /// we provide this method for API completeness.
2562    pub fn request(
2563        mut self,
2564        new_value: SiteVerificationWebResourceResource,
2565    ) -> WebResourceUpdateCall<'a, C> {
2566        self._request = new_value;
2567        self
2568    }
2569    /// The id of a verified site or domain.
2570    ///
2571    /// Sets the *id* path property to the given value.
2572    ///
2573    /// Even though the property as already been set when instantiating this call,
2574    /// we provide this method for API completeness.
2575    pub fn id(mut self, new_value: &str) -> WebResourceUpdateCall<'a, C> {
2576        self._id = new_value.to_string();
2577        self
2578    }
2579    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2580    /// while executing the actual API request.
2581    ///
2582    /// ````text
2583    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2584    /// ````
2585    ///
2586    /// Sets the *delegate* property to the given value.
2587    pub fn delegate(
2588        mut self,
2589        new_value: &'a mut dyn common::Delegate,
2590    ) -> WebResourceUpdateCall<'a, C> {
2591        self._delegate = Some(new_value);
2592        self
2593    }
2594
2595    /// Set any additional parameter of the query string used in the request.
2596    /// It should be used to set parameters which are not yet available through their own
2597    /// setters.
2598    ///
2599    /// Please note that this method must not be used to set any of the known parameters
2600    /// which have their own setter method. If done anyway, the request will fail.
2601    ///
2602    /// # Additional Parameters
2603    ///
2604    /// * *alt* (query-string) - Data format for the response.
2605    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2606    /// * *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.
2607    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2608    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2609    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2610    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2611    pub fn param<T>(mut self, name: T, value: T) -> WebResourceUpdateCall<'a, C>
2612    where
2613        T: AsRef<str>,
2614    {
2615        self._additional_params
2616            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2617        self
2618    }
2619
2620    /// Identifies the authorization scope for the method you are building.
2621    ///
2622    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2623    /// [`Scope::Full`].
2624    ///
2625    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2626    /// tokens for more than one scope.
2627    ///
2628    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2629    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2630    /// sufficient, a read-write scope will do as well.
2631    pub fn add_scope<St>(mut self, scope: St) -> WebResourceUpdateCall<'a, C>
2632    where
2633        St: AsRef<str>,
2634    {
2635        self._scopes.insert(String::from(scope.as_ref()));
2636        self
2637    }
2638    /// Identifies the authorization scope(s) for the method you are building.
2639    ///
2640    /// See [`Self::add_scope()`] for details.
2641    pub fn add_scopes<I, St>(mut self, scopes: I) -> WebResourceUpdateCall<'a, C>
2642    where
2643        I: IntoIterator<Item = St>,
2644        St: AsRef<str>,
2645    {
2646        self._scopes
2647            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2648        self
2649    }
2650
2651    /// Removes all scopes, and no default scope will be used either.
2652    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2653    /// for details).
2654    pub fn clear_scopes(mut self) -> WebResourceUpdateCall<'a, C> {
2655        self._scopes.clear();
2656        self
2657    }
2658}