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