google_searchconsole1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and manage Search Console data for your verified sites
17    Webmaster,
18
19    /// View Search Console data for your verified sites
20    WebmasterReadonly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::Webmaster => "https://www.googleapis.com/auth/webmasters",
27            Scope::WebmasterReadonly => "https://www.googleapis.com/auth/webmasters.readonly",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::WebmasterReadonly
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all SearchConsole 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_searchconsole1 as searchconsole1;
53/// use searchconsole1::api::SearchAnalyticsQueryRequest;
54/// use searchconsole1::{Result, Error};
55/// # async fn dox() {
56/// use searchconsole1::{SearchConsole, 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 = SearchConsole::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 = SearchAnalyticsQueryRequest::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.searchanalytics().query(req, "siteUrl")
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 SearchConsole<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 SearchConsole<C> {}
123
124impl<'a, C> SearchConsole<C> {
125    pub fn new<A: 'static + common::GetToken>(
126        client: common::Client<C>,
127        auth: A,
128    ) -> SearchConsole<C> {
129        SearchConsole {
130            client,
131            auth: Box::new(auth),
132            _user_agent: "google-api-rust-client/6.0.0".to_string(),
133            _base_url: "https://searchconsole.googleapis.com/".to_string(),
134            _root_url: "https://searchconsole.googleapis.com/".to_string(),
135        }
136    }
137
138    pub fn searchanalytics(&'a self) -> SearchanalyticMethods<'a, C> {
139        SearchanalyticMethods { hub: self }
140    }
141    pub fn sitemaps(&'a self) -> SitemapMethods<'a, C> {
142        SitemapMethods { hub: self }
143    }
144    pub fn sites(&'a self) -> SiteMethods<'a, C> {
145        SiteMethods { hub: self }
146    }
147    pub fn url_inspection(&'a self) -> UrlInspectionMethods<'a, C> {
148        UrlInspectionMethods { hub: self }
149    }
150    pub fn url_testing_tools(&'a self) -> UrlTestingToolMethods<'a, C> {
151        UrlTestingToolMethods { hub: self }
152    }
153
154    /// Set the user-agent header field to use in all requests to the server.
155    /// It defaults to `google-api-rust-client/6.0.0`.
156    ///
157    /// Returns the previously set user-agent.
158    pub fn user_agent(&mut self, agent_name: String) -> String {
159        std::mem::replace(&mut self._user_agent, agent_name)
160    }
161
162    /// Set the base url to use in all requests to the server.
163    /// It defaults to `https://searchconsole.googleapis.com/`.
164    ///
165    /// Returns the previously set base url.
166    pub fn base_url(&mut self, new_base_url: String) -> String {
167        std::mem::replace(&mut self._base_url, new_base_url)
168    }
169
170    /// Set the root url to use in all requests to the server.
171    /// It defaults to `https://searchconsole.googleapis.com/`.
172    ///
173    /// Returns the previously set root url.
174    pub fn root_url(&mut self, new_root_url: String) -> String {
175        std::mem::replace(&mut self._root_url, new_root_url)
176    }
177}
178
179// ############
180// SCHEMAS ###
181// ##########
182/// AMP inspection result of the live page or the current information from Google's index, depending on whether you requested a live inspection or not.
183///
184/// This type is not used in any activity, and only used as *part* of another schema.
185///
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AmpInspectionResult {
190    /// Index status of the AMP URL.
191    #[serde(rename = "ampIndexStatusVerdict")]
192    pub amp_index_status_verdict: Option<String>,
193    /// URL of the AMP that was inspected. If the submitted URL is a desktop page that refers to an AMP version, the AMP version will be inspected.
194    #[serde(rename = "ampUrl")]
195    pub amp_url: Option<String>,
196    /// Whether or not the page blocks indexing through a noindex rule.
197    #[serde(rename = "indexingState")]
198    pub indexing_state: Option<String>,
199    /// A list of zero or more AMP issues found for the inspected URL.
200    pub issues: Option<Vec<AmpIssue>>,
201    /// Last time this AMP version was crawled by Google. Absent if the URL was never crawled successfully.
202    #[serde(rename = "lastCrawlTime")]
203    pub last_crawl_time: Option<chrono::DateTime<chrono::offset::Utc>>,
204    /// Whether or not Google could fetch the AMP.
205    #[serde(rename = "pageFetchState")]
206    pub page_fetch_state: Option<String>,
207    /// Whether or not the page is blocked to Google by a robots.txt rule.
208    #[serde(rename = "robotsTxtState")]
209    pub robots_txt_state: Option<String>,
210    /// The status of the most severe error on the page. If a page has both warnings and errors, the page status is error. Error status means the page cannot be shown in Search results.
211    pub verdict: Option<String>,
212}
213
214impl common::Part for AmpInspectionResult {}
215
216/// AMP issue.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct AmpIssue {
224    /// Brief description of this issue.
225    #[serde(rename = "issueMessage")]
226    pub issue_message: Option<String>,
227    /// Severity of this issue: WARNING or ERROR.
228    pub severity: Option<String>,
229}
230
231impl common::Part for AmpIssue {}
232
233/// There is no detailed description.
234///
235/// This type is not used in any activity, and only used as *part* of another schema.
236///
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct ApiDataRow {
241    /// no description provided
242    pub clicks: Option<f64>,
243    /// no description provided
244    pub ctr: Option<f64>,
245    /// no description provided
246    pub impressions: Option<f64>,
247    /// no description provided
248    pub keys: Option<Vec<String>>,
249    /// no description provided
250    pub position: Option<f64>,
251}
252
253impl common::Part for ApiDataRow {}
254
255/// A filter test to be applied to each row in the data set, where a match can return the row. Filters are string comparisons, and values and dimension names are not case-sensitive. Individual filters are either AND'ed or OR'ed within their parent filter group, according to the group's group type. You do not need to group by a specified dimension to filter against it.
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 ApiDimensionFilter {
263    /// no description provided
264    pub dimension: Option<String>,
265    /// no description provided
266    pub expression: Option<String>,
267    /// no description provided
268    pub operator: Option<String>,
269}
270
271impl common::Part for ApiDimensionFilter {}
272
273/// A set of dimension value filters to test against each row. Only rows that pass all filter groups will be returned. All results within a filter group are either AND'ed or OR'ed together, depending on the group type selected. All filter groups are AND'ed together.
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 ApiDimensionFilterGroup {
281    /// no description provided
282    pub filters: Option<Vec<ApiDimensionFilter>>,
283    /// no description provided
284    #[serde(rename = "groupType")]
285    pub group_type: Option<String>,
286}
287
288impl common::Part for ApiDimensionFilterGroup {}
289
290/// Blocked resource.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct BlockedResource {
298    /// URL of the blocked resource.
299    pub url: Option<String>,
300}
301
302impl common::Part for BlockedResource {}
303
304/// Rich Results items grouped by type.
305///
306/// This type is not used in any activity, and only used as *part* of another schema.
307///
308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
309#[serde_with::serde_as]
310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
311pub struct DetectedItems {
312    /// List of Rich Results items.
313    pub items: Option<Vec<Item>>,
314    /// Rich Results type
315    #[serde(rename = "richResultType")]
316    pub rich_result_type: Option<String>,
317}
318
319impl common::Part for DetectedItems {}
320
321/// Describe image data.
322///
323/// This type is not used in any activity, and only used as *part* of another schema.
324///
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct Image {
329    /// Image data in format determined by the mime type. Currently, the format will always be "image/png", but this might change in the future.
330    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
331    pub data: Option<Vec<u8>>,
332    /// The mime-type of the image data.
333    #[serde(rename = "mimeType")]
334    pub mime_type: Option<String>,
335}
336
337impl common::Part for Image {}
338
339/// Results of index status inspection for either the live page or the version in Google's index, depending on whether you requested a live inspection or not. For more information, see the [Index coverage report documentation](https://support.google.com/webmasters/answer/7440203).
340///
341/// This type is not used in any activity, and only used as *part* of another schema.
342///
343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
344#[serde_with::serde_as]
345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
346pub struct IndexStatusInspectionResult {
347    /// Could Google find and index the page. More details about page indexing appear in 'indexing_state'.
348    #[serde(rename = "coverageState")]
349    pub coverage_state: Option<String>,
350    /// Primary crawler that was used by Google to crawl your site.
351    #[serde(rename = "crawledAs")]
352    pub crawled_as: Option<String>,
353    /// The URL of the page that Google selected as canonical. If the page was not indexed, this field is absent.
354    #[serde(rename = "googleCanonical")]
355    pub google_canonical: Option<String>,
356    /// Whether or not the page blocks indexing through a noindex rule.
357    #[serde(rename = "indexingState")]
358    pub indexing_state: Option<String>,
359    /// Last time this URL was crawled by Google using the [primary crawler](https://support.google.com/webmasters/answer/7440203#primary_crawler). Absent if the URL was never crawled successfully.
360    #[serde(rename = "lastCrawlTime")]
361    pub last_crawl_time: Option<chrono::DateTime<chrono::offset::Utc>>,
362    /// Whether or not Google could retrieve the page from your server. Equivalent to ["page fetch"](https://support.google.com/webmasters/answer/9012289#index_coverage) in the URL inspection report.
363    #[serde(rename = "pageFetchState")]
364    pub page_fetch_state: Option<String>,
365    /// URLs that link to the inspected URL, directly and indirectly.
366    #[serde(rename = "referringUrls")]
367    pub referring_urls: Option<Vec<String>>,
368    /// Whether or not the page is blocked to Google by a robots.txt rule.
369    #[serde(rename = "robotsTxtState")]
370    pub robots_txt_state: Option<String>,
371    /// Any sitemaps that this URL was listed in, as known by Google. Not guaranteed to be an exhaustive list, especially if Google did not discover this URL through a sitemap. Absent if no sitemaps were found.
372    pub sitemap: Option<Vec<String>>,
373    /// The URL that your page or site [declares as canonical](https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls?#define-canonical). If you did not declare a canonical URL, this field is absent.
374    #[serde(rename = "userCanonical")]
375    pub user_canonical: Option<String>,
376    /// High level verdict about whether the URL *is* indexed (indexed status), or *can be* indexed (live inspection).
377    pub verdict: Option<String>,
378}
379
380impl common::Part for IndexStatusInspectionResult {}
381
382/// Index inspection request.
383///
384/// # Activities
385///
386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
388///
389/// * [index inspect url inspection](UrlInspectionIndexInspectCall) (request)
390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
391#[serde_with::serde_as]
392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
393pub struct InspectUrlIndexRequest {
394    /// Required. URL to inspect. Must be under the property specified in "site_url".
395    #[serde(rename = "inspectionUrl")]
396    pub inspection_url: Option<String>,
397    /// Optional. An [IETF BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language code representing the requested language for translated issue messages, e.g. "en-US", "or "de-CH". Default value is "en-US".
398    #[serde(rename = "languageCode")]
399    pub language_code: Option<String>,
400    /// Required. The URL of the property as defined in Search Console. **Examples:** `http://www.example.com/` for a URL-prefix property, or `sc-domain:example.com` for a Domain property.
401    #[serde(rename = "siteUrl")]
402    pub site_url: Option<String>,
403}
404
405impl common::RequestValue for InspectUrlIndexRequest {}
406
407/// Index-Status inspection response.
408///
409/// # Activities
410///
411/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
412/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
413///
414/// * [index inspect url inspection](UrlInspectionIndexInspectCall) (response)
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct InspectUrlIndexResponse {
419    /// URL inspection results.
420    #[serde(rename = "inspectionResult")]
421    pub inspection_result: Option<UrlInspectionResult>,
422}
423
424impl common::ResponseResult for InspectUrlIndexResponse {}
425
426/// A specific rich result found on the page.
427///
428/// This type is not used in any activity, and only used as *part* of another schema.
429///
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct Item {
434    /// A list of zero or more rich result issues found for this instance.
435    pub issues: Option<Vec<RichResultsIssue>>,
436    /// The user-provided name of this item.
437    pub name: Option<String>,
438}
439
440impl common::Part for Item {}
441
442/// Mobile-friendly issue.
443///
444/// This type is not used in any activity, and only used as *part* of another schema.
445///
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct MobileFriendlyIssue {
450    /// Rule violated.
451    pub rule: Option<String>,
452}
453
454impl common::Part for MobileFriendlyIssue {}
455
456/// Mobile-usability inspection results.
457///
458/// This type is not used in any activity, and only used as *part* of another schema.
459///
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct MobileUsabilityInspectionResult {
464    /// A list of zero or more mobile-usability issues detected for this URL.
465    pub issues: Option<Vec<MobileUsabilityIssue>>,
466    /// High-level mobile-usability inspection result for this URL.
467    pub verdict: Option<String>,
468}
469
470impl common::Part for MobileUsabilityInspectionResult {}
471
472/// Mobile-usability issue.
473///
474/// This type is not used in any activity, and only used as *part* of another schema.
475///
476#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
477#[serde_with::serde_as]
478#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
479pub struct MobileUsabilityIssue {
480    /// Mobile-usability issue type.
481    #[serde(rename = "issueType")]
482    pub issue_type: Option<String>,
483    /// Additional information regarding the issue.
484    pub message: Option<String>,
485    /// Not returned; reserved for future use.
486    pub severity: Option<String>,
487}
488
489impl common::Part for MobileUsabilityIssue {}
490
491/// Information about a resource with issue.
492///
493/// This type is not used in any activity, and only used as *part* of another schema.
494///
495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
496#[serde_with::serde_as]
497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
498pub struct ResourceIssue {
499    /// Describes a blocked resource issue.
500    #[serde(rename = "blockedResource")]
501    pub blocked_resource: Option<BlockedResource>,
502}
503
504impl common::Part for ResourceIssue {}
505
506/// Rich-Results inspection result, including any rich results found at this URL.
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct RichResultsInspectionResult {
514    /// A list of zero or more rich results detected on this page. Rich results that cannot even be parsed due to syntactic issues will not be listed here.
515    #[serde(rename = "detectedItems")]
516    pub detected_items: Option<Vec<DetectedItems>>,
517    /// High-level rich results inspection result for this URL.
518    pub verdict: Option<String>,
519}
520
521impl common::Part for RichResultsInspectionResult {}
522
523/// Severity and status of a single issue affecting a single rich result instance on a page.
524///
525/// This type is not used in any activity, and only used as *part* of another schema.
526///
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct RichResultsIssue {
531    /// Rich Results issue type.
532    #[serde(rename = "issueMessage")]
533    pub issue_message: Option<String>,
534    /// Severity of this issue: WARNING, or ERROR. Items with an issue of status ERROR cannot appear with rich result features in Google Search results.
535    pub severity: Option<String>,
536}
537
538impl common::Part for RichResultsIssue {}
539
540/// Mobile-friendly test request.
541///
542/// # Activities
543///
544/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
545/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
546///
547/// * [mobile friendly test run url testing tools](UrlTestingToolMobileFriendlyTestRunCall) (request)
548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
549#[serde_with::serde_as]
550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
551pub struct RunMobileFriendlyTestRequest {
552    /// Whether or not screenshot is requested. Default is false.
553    #[serde(rename = "requestScreenshot")]
554    pub request_screenshot: Option<bool>,
555    /// URL for inspection.
556    pub url: Option<String>,
557}
558
559impl common::RequestValue for RunMobileFriendlyTestRequest {}
560
561/// Mobile-friendly test response, including mobile-friendly issues and resource issues.
562///
563/// # Activities
564///
565/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
566/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
567///
568/// * [mobile friendly test run url testing tools](UrlTestingToolMobileFriendlyTestRunCall) (response)
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct RunMobileFriendlyTestResponse {
573    /// Test verdict, whether the page is mobile friendly or not.
574    #[serde(rename = "mobileFriendliness")]
575    pub mobile_friendliness: Option<String>,
576    /// List of mobile-usability issues.
577    #[serde(rename = "mobileFriendlyIssues")]
578    pub mobile_friendly_issues: Option<Vec<MobileFriendlyIssue>>,
579    /// Information about embedded resources issues.
580    #[serde(rename = "resourceIssues")]
581    pub resource_issues: Option<Vec<ResourceIssue>>,
582    /// Screenshot of the requested URL.
583    pub screenshot: Option<Image>,
584    /// Final state of the test, can be either complete or an error.
585    #[serde(rename = "testStatus")]
586    pub test_status: Option<TestStatus>,
587}
588
589impl common::ResponseResult for RunMobileFriendlyTestResponse {}
590
591/// There is no detailed description.
592///
593/// # Activities
594///
595/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
596/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
597///
598/// * [query searchanalytics](SearchanalyticQueryCall) (request)
599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
600#[serde_with::serde_as]
601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
602pub struct SearchAnalyticsQueryRequest {
603    /// [Optional; Default is \"auto\"] How data is aggregated. If aggregated by property, all data for the same property is aggregated; if aggregated by page, all data is aggregated by canonical URI. If you filter or group by page, choose AUTO; otherwise you can aggregate either by property or by page, depending on how you want your data calculated; see the help documentation to learn how data is calculated differently by site versus by page. **Note:** If you group or filter by page, you cannot aggregate by property. If you specify any value other than AUTO, the aggregation type in the result will match the requested type, or if you request an invalid type, you will get an error. The API will never change your aggregation type if the requested type is invalid.
604    #[serde(rename = "aggregationType")]
605    pub aggregation_type: Option<String>,
606    /// The data state to be fetched, can be full or all, the latter including full and partial data.
607    #[serde(rename = "dataState")]
608    pub data_state: Option<String>,
609    /// [Optional] Zero or more filters to apply to the dimension grouping values; for example, 'query contains \"buy\"' to see only data where the query string contains the substring \"buy\" (not case-sensitive). You can filter by a dimension without grouping by it.
610    #[serde(rename = "dimensionFilterGroups")]
611    pub dimension_filter_groups: Option<Vec<ApiDimensionFilterGroup>>,
612    /// [Optional] Zero or more dimensions to group results by. Dimensions are the group-by values in the Search Analytics page. Dimensions are combined to create a unique row key for each row. Results are grouped in the order that you supply these dimensions.
613    pub dimensions: Option<Vec<String>>,
614    /// [Required] End date of the requested date range, in YYYY-MM-DD format, in PST (UTC - 8:00). Must be greater than or equal to the start date. This value is included in the range.
615    #[serde(rename = "endDate")]
616    pub end_date: Option<String>,
617    /// [Optional; Default is 1000] The maximum number of rows to return. Must be a number from 1 to 25,000 (inclusive).
618    #[serde(rename = "rowLimit")]
619    pub row_limit: Option<i32>,
620    /// [Optional; Default is \"web\"] The search type to filter for.
621    #[serde(rename = "searchType")]
622    pub search_type: Option<String>,
623    ///  [Required] Start date of the requested date range, in YYYY-MM-DD format, in PST time (UTC - 8:00). Must be less than or equal to the end date. This value is included in the range.
624    #[serde(rename = "startDate")]
625    pub start_date: Option<String>,
626    /// [Optional; Default is 0] Zero-based index of the first row in the response. Must be a non-negative number.
627    #[serde(rename = "startRow")]
628    pub start_row: Option<i32>,
629    /// Optional. [Optional; Default is \"web\"] Type of report: search type, or either Discover or Gnews.
630    #[serde(rename = "type")]
631    pub type_: Option<String>,
632}
633
634impl common::RequestValue for SearchAnalyticsQueryRequest {}
635
636/// A list of rows, one per result, grouped by key. Metrics in each row are aggregated for all data grouped by that key either by page or property, as specified by the aggregation type parameter.
637///
638/// # Activities
639///
640/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
641/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
642///
643/// * [query searchanalytics](SearchanalyticQueryCall) (response)
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct SearchAnalyticsQueryResponse {
648    /// How the results were aggregated.
649    #[serde(rename = "responseAggregationType")]
650    pub response_aggregation_type: Option<String>,
651    /// A list of rows grouped by the key values in the order given in the query.
652    pub rows: Option<Vec<ApiDataRow>>,
653}
654
655impl common::ResponseResult for SearchAnalyticsQueryResponse {}
656
657/// List of sitemaps.
658///
659/// # Activities
660///
661/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
662/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
663///
664/// * [list sitemaps](SitemapListCall) (response)
665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
666#[serde_with::serde_as]
667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
668pub struct SitemapsListResponse {
669    /// Contains detailed information about a specific URL submitted as a [sitemap](https://support.google.com/webmasters/answer/156184).
670    pub sitemap: Option<Vec<WmxSitemap>>,
671}
672
673impl common::ResponseResult for SitemapsListResponse {}
674
675/// List of sites with access level information.
676///
677/// # Activities
678///
679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
681///
682/// * [list sites](SiteListCall) (response)
683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
684#[serde_with::serde_as]
685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
686pub struct SitesListResponse {
687    /// Contains permission level information about a Search Console site. For more information, see [Permissions in Search Console](https://support.google.com/webmasters/answer/2451999).
688    #[serde(rename = "siteEntry")]
689    pub site_entry: Option<Vec<WmxSite>>,
690}
691
692impl common::ResponseResult for SitesListResponse {}
693
694/// Final state of the test, including error details if necessary.
695///
696/// This type is not used in any activity, and only used as *part* of another schema.
697///
698#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
699#[serde_with::serde_as]
700#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
701pub struct TestStatus {
702    /// Error details if applicable.
703    pub details: Option<String>,
704    /// Status of the test.
705    pub status: Option<String>,
706}
707
708impl common::Part for TestStatus {}
709
710/// URL inspection result, including all inspection results.
711///
712/// This type is not used in any activity, and only used as *part* of another schema.
713///
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct UrlInspectionResult {
718    /// Result of the AMP analysis. Absent if the page is not an AMP page.
719    #[serde(rename = "ampResult")]
720    pub amp_result: Option<AmpInspectionResult>,
721    /// Result of the index status analysis.
722    #[serde(rename = "indexStatusResult")]
723    pub index_status_result: Option<IndexStatusInspectionResult>,
724    /// Link to Search Console URL inspection.
725    #[serde(rename = "inspectionResultLink")]
726    pub inspection_result_link: Option<String>,
727    /// Result of the Mobile usability analysis.
728    #[serde(rename = "mobileUsabilityResult")]
729    pub mobile_usability_result: Option<MobileUsabilityInspectionResult>,
730    /// Result of the Rich Results analysis. Absent if there are no rich results found.
731    #[serde(rename = "richResultsResult")]
732    pub rich_results_result: Option<RichResultsInspectionResult>,
733}
734
735impl common::Part for UrlInspectionResult {}
736
737/// Contains permission level information about a Search Console site. For more information, see [Permissions in Search Console](https://support.google.com/webmasters/answer/2451999).
738///
739/// # Activities
740///
741/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
742/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
743///
744/// * [get sites](SiteGetCall) (response)
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct WmxSite {
749    /// The user's permission level for the site.
750    #[serde(rename = "permissionLevel")]
751    pub permission_level: Option<String>,
752    /// The URL of the site.
753    #[serde(rename = "siteUrl")]
754    pub site_url: Option<String>,
755}
756
757impl common::ResponseResult for WmxSite {}
758
759/// Contains detailed information about a specific URL submitted as a [sitemap](https://support.google.com/webmasters/answer/156184).
760///
761/// # Activities
762///
763/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
764/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
765///
766/// * [get sitemaps](SitemapGetCall) (response)
767#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
768#[serde_with::serde_as]
769#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
770pub struct WmxSitemap {
771    /// The various content types in the sitemap.
772    pub contents: Option<Vec<WmxSitemapContent>>,
773    /// Number of errors in the sitemap. These are issues with the sitemap itself that need to be fixed before it can be processed correctly.
774    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
775    pub errors: Option<i64>,
776    /// If true, the sitemap has not been processed.
777    #[serde(rename = "isPending")]
778    pub is_pending: Option<bool>,
779    /// If true, the sitemap is a collection of sitemaps.
780    #[serde(rename = "isSitemapsIndex")]
781    pub is_sitemaps_index: Option<bool>,
782    /// Date & time in which this sitemap was last downloaded. Date format is in RFC 3339 format (yyyy-mm-dd).
783    #[serde(rename = "lastDownloaded")]
784    pub last_downloaded: Option<chrono::DateTime<chrono::offset::Utc>>,
785    /// Date & time in which this sitemap was submitted. Date format is in RFC 3339 format (yyyy-mm-dd).
786    #[serde(rename = "lastSubmitted")]
787    pub last_submitted: Option<chrono::DateTime<chrono::offset::Utc>>,
788    /// The url of the sitemap.
789    pub path: Option<String>,
790    /// The type of the sitemap. For example: `rssFeed`.
791    #[serde(rename = "type")]
792    pub type_: Option<String>,
793    /// Number of warnings for the sitemap. These are generally non-critical issues with URLs in the sitemaps.
794    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
795    pub warnings: Option<i64>,
796}
797
798impl common::ResponseResult for WmxSitemap {}
799
800/// Information about the various content types in the sitemap.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct WmxSitemapContent {
808    /// *Deprecated; do not use.*
809    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
810    pub indexed: Option<i64>,
811    /// The number of URLs in the sitemap (of the content type).
812    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
813    pub submitted: Option<i64>,
814    /// The specific type of content in this sitemap. For example: `web`.
815    #[serde(rename = "type")]
816    pub type_: Option<String>,
817}
818
819impl common::Part for WmxSitemapContent {}
820
821// ###################
822// MethodBuilders ###
823// #################
824
825/// A builder providing access to all methods supported on *searchanalytic* resources.
826/// It is not used directly, but through the [`SearchConsole`] hub.
827///
828/// # Example
829///
830/// Instantiate a resource builder
831///
832/// ```test_harness,no_run
833/// extern crate hyper;
834/// extern crate hyper_rustls;
835/// extern crate google_searchconsole1 as searchconsole1;
836///
837/// # async fn dox() {
838/// use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
839///
840/// let secret: yup_oauth2::ApplicationSecret = Default::default();
841/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
842///     secret,
843///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
844/// ).build().await.unwrap();
845///
846/// let client = hyper_util::client::legacy::Client::builder(
847///     hyper_util::rt::TokioExecutor::new()
848/// )
849/// .build(
850///     hyper_rustls::HttpsConnectorBuilder::new()
851///         .with_native_roots()
852///         .unwrap()
853///         .https_or_http()
854///         .enable_http1()
855///         .build()
856/// );
857/// let mut hub = SearchConsole::new(client, auth);
858/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
859/// // like `query(...)`
860/// // to build up your call.
861/// let rb = hub.searchanalytics();
862/// # }
863/// ```
864pub struct SearchanalyticMethods<'a, C>
865where
866    C: 'a,
867{
868    hub: &'a SearchConsole<C>,
869}
870
871impl<'a, C> common::MethodsBuilder for SearchanalyticMethods<'a, C> {}
872
873impl<'a, C> SearchanalyticMethods<'a, C> {
874    /// Create a builder to help you perform the following task:
875    ///
876    /// Query your data with filters and parameters that you define. Returns zero or more rows grouped by the row keys that you define. You must define a date range of one or more days. When date is one of the group by values, any days without data are omitted from the result list. If you need to know which days have data, issue a broad date range query grouped by date for any metric, and see which day rows are returned.
877    ///
878    /// # Arguments
879    ///
880    /// * `request` - No description provided.
881    /// * `siteUrl` - The site's URL, including protocol. For example: `http://www.example.com/`.
882    pub fn query(
883        &self,
884        request: SearchAnalyticsQueryRequest,
885        site_url: &str,
886    ) -> SearchanalyticQueryCall<'a, C> {
887        SearchanalyticQueryCall {
888            hub: self.hub,
889            _request: request,
890            _site_url: site_url.to_string(),
891            _delegate: Default::default(),
892            _additional_params: Default::default(),
893            _scopes: Default::default(),
894        }
895    }
896}
897
898/// A builder providing access to all methods supported on *sitemap* resources.
899/// It is not used directly, but through the [`SearchConsole`] hub.
900///
901/// # Example
902///
903/// Instantiate a resource builder
904///
905/// ```test_harness,no_run
906/// extern crate hyper;
907/// extern crate hyper_rustls;
908/// extern crate google_searchconsole1 as searchconsole1;
909///
910/// # async fn dox() {
911/// use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
912///
913/// let secret: yup_oauth2::ApplicationSecret = Default::default();
914/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
915///     secret,
916///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
917/// ).build().await.unwrap();
918///
919/// let client = hyper_util::client::legacy::Client::builder(
920///     hyper_util::rt::TokioExecutor::new()
921/// )
922/// .build(
923///     hyper_rustls::HttpsConnectorBuilder::new()
924///         .with_native_roots()
925///         .unwrap()
926///         .https_or_http()
927///         .enable_http1()
928///         .build()
929/// );
930/// let mut hub = SearchConsole::new(client, auth);
931/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
932/// // like `delete(...)`, `get(...)`, `list(...)` and `submit(...)`
933/// // to build up your call.
934/// let rb = hub.sitemaps();
935/// # }
936/// ```
937pub struct SitemapMethods<'a, C>
938where
939    C: 'a,
940{
941    hub: &'a SearchConsole<C>,
942}
943
944impl<'a, C> common::MethodsBuilder for SitemapMethods<'a, C> {}
945
946impl<'a, C> SitemapMethods<'a, C> {
947    /// Create a builder to help you perform the following task:
948    ///
949    /// Deletes a sitemap from the Sitemaps report. Does not stop Google from crawling this sitemap or the URLs that were previously crawled in the deleted sitemap.
950    ///
951    /// # Arguments
952    ///
953    /// * `siteUrl` - The site's URL, including protocol. For example: `http://www.example.com/`.
954    /// * `feedpath` - The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
955    pub fn delete(&self, site_url: &str, feedpath: &str) -> SitemapDeleteCall<'a, C> {
956        SitemapDeleteCall {
957            hub: self.hub,
958            _site_url: site_url.to_string(),
959            _feedpath: feedpath.to_string(),
960            _delegate: Default::default(),
961            _additional_params: Default::default(),
962            _scopes: Default::default(),
963        }
964    }
965
966    /// Create a builder to help you perform the following task:
967    ///
968    /// Retrieves information about a specific sitemap.
969    ///
970    /// # Arguments
971    ///
972    /// * `siteUrl` - The site's URL, including protocol. For example: `http://www.example.com/`.
973    /// * `feedpath` - The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
974    pub fn get(&self, site_url: &str, feedpath: &str) -> SitemapGetCall<'a, C> {
975        SitemapGetCall {
976            hub: self.hub,
977            _site_url: site_url.to_string(),
978            _feedpath: feedpath.to_string(),
979            _delegate: Default::default(),
980            _additional_params: Default::default(),
981            _scopes: Default::default(),
982        }
983    }
984
985    /// Create a builder to help you perform the following task:
986    ///
987    /// Lists the [sitemaps-entries](https://developers.google.com/webmaster-tools/v3/sitemaps) submitted for this site, or included in the sitemap index file (if `sitemapIndex` is specified in the request).
988    ///
989    /// # Arguments
990    ///
991    /// * `siteUrl` - The site's URL, including protocol. For example: `http://www.example.com/`.
992    pub fn list(&self, site_url: &str) -> SitemapListCall<'a, C> {
993        SitemapListCall {
994            hub: self.hub,
995            _site_url: site_url.to_string(),
996            _sitemap_index: Default::default(),
997            _delegate: Default::default(),
998            _additional_params: Default::default(),
999            _scopes: Default::default(),
1000        }
1001    }
1002
1003    /// Create a builder to help you perform the following task:
1004    ///
1005    /// Submits a sitemap for a site.
1006    ///
1007    /// # Arguments
1008    ///
1009    /// * `siteUrl` - The site's URL, including protocol. For example: `http://www.example.com/`.
1010    /// * `feedpath` - The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
1011    pub fn submit(&self, site_url: &str, feedpath: &str) -> SitemapSubmitCall<'a, C> {
1012        SitemapSubmitCall {
1013            hub: self.hub,
1014            _site_url: site_url.to_string(),
1015            _feedpath: feedpath.to_string(),
1016            _delegate: Default::default(),
1017            _additional_params: Default::default(),
1018            _scopes: Default::default(),
1019        }
1020    }
1021}
1022
1023/// A builder providing access to all methods supported on *site* resources.
1024/// It is not used directly, but through the [`SearchConsole`] hub.
1025///
1026/// # Example
1027///
1028/// Instantiate a resource builder
1029///
1030/// ```test_harness,no_run
1031/// extern crate hyper;
1032/// extern crate hyper_rustls;
1033/// extern crate google_searchconsole1 as searchconsole1;
1034///
1035/// # async fn dox() {
1036/// use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1037///
1038/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1039/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1040///     secret,
1041///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1042/// ).build().await.unwrap();
1043///
1044/// let client = hyper_util::client::legacy::Client::builder(
1045///     hyper_util::rt::TokioExecutor::new()
1046/// )
1047/// .build(
1048///     hyper_rustls::HttpsConnectorBuilder::new()
1049///         .with_native_roots()
1050///         .unwrap()
1051///         .https_or_http()
1052///         .enable_http1()
1053///         .build()
1054/// );
1055/// let mut hub = SearchConsole::new(client, auth);
1056/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1057/// // like `add(...)`, `delete(...)`, `get(...)` and `list(...)`
1058/// // to build up your call.
1059/// let rb = hub.sites();
1060/// # }
1061/// ```
1062pub struct SiteMethods<'a, C>
1063where
1064    C: 'a,
1065{
1066    hub: &'a SearchConsole<C>,
1067}
1068
1069impl<'a, C> common::MethodsBuilder for SiteMethods<'a, C> {}
1070
1071impl<'a, C> SiteMethods<'a, C> {
1072    /// Create a builder to help you perform the following task:
1073    ///
1074    ///  Adds a site to the set of the user's sites in Search Console.
1075    ///
1076    /// # Arguments
1077    ///
1078    /// * `siteUrl` - The URL of the site to add.
1079    pub fn add(&self, site_url: &str) -> SiteAddCall<'a, C> {
1080        SiteAddCall {
1081            hub: self.hub,
1082            _site_url: site_url.to_string(),
1083            _delegate: Default::default(),
1084            _additional_params: Default::default(),
1085            _scopes: Default::default(),
1086        }
1087    }
1088
1089    /// Create a builder to help you perform the following task:
1090    ///
1091    ///  Removes a site from the set of the user's Search Console sites.
1092    ///
1093    /// # Arguments
1094    ///
1095    /// * `siteUrl` - The URI of the property as defined in Search Console. **Examples:** `http://www.example.com/` or `sc-domain:example.com`.
1096    pub fn delete(&self, site_url: &str) -> SiteDeleteCall<'a, C> {
1097        SiteDeleteCall {
1098            hub: self.hub,
1099            _site_url: site_url.to_string(),
1100            _delegate: Default::default(),
1101            _additional_params: Default::default(),
1102            _scopes: Default::default(),
1103        }
1104    }
1105
1106    /// Create a builder to help you perform the following task:
1107    ///
1108    ///  Retrieves information about specific site.
1109    ///
1110    /// # Arguments
1111    ///
1112    /// * `siteUrl` - The URI of the property as defined in Search Console. **Examples:** `http://www.example.com/` or `sc-domain:example.com`.
1113    pub fn get(&self, site_url: &str) -> SiteGetCall<'a, C> {
1114        SiteGetCall {
1115            hub: self.hub,
1116            _site_url: site_url.to_string(),
1117            _delegate: Default::default(),
1118            _additional_params: Default::default(),
1119            _scopes: Default::default(),
1120        }
1121    }
1122
1123    /// Create a builder to help you perform the following task:
1124    ///
1125    ///  Lists the user's Search Console sites.
1126    pub fn list(&self) -> SiteListCall<'a, C> {
1127        SiteListCall {
1128            hub: self.hub,
1129            _delegate: Default::default(),
1130            _additional_params: Default::default(),
1131            _scopes: Default::default(),
1132        }
1133    }
1134}
1135
1136/// A builder providing access to all methods supported on *urlInspection* resources.
1137/// It is not used directly, but through the [`SearchConsole`] hub.
1138///
1139/// # Example
1140///
1141/// Instantiate a resource builder
1142///
1143/// ```test_harness,no_run
1144/// extern crate hyper;
1145/// extern crate hyper_rustls;
1146/// extern crate google_searchconsole1 as searchconsole1;
1147///
1148/// # async fn dox() {
1149/// use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1150///
1151/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1152/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1153///     secret,
1154///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1155/// ).build().await.unwrap();
1156///
1157/// let client = hyper_util::client::legacy::Client::builder(
1158///     hyper_util::rt::TokioExecutor::new()
1159/// )
1160/// .build(
1161///     hyper_rustls::HttpsConnectorBuilder::new()
1162///         .with_native_roots()
1163///         .unwrap()
1164///         .https_or_http()
1165///         .enable_http1()
1166///         .build()
1167/// );
1168/// let mut hub = SearchConsole::new(client, auth);
1169/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1170/// // like `index_inspect(...)`
1171/// // to build up your call.
1172/// let rb = hub.url_inspection();
1173/// # }
1174/// ```
1175pub struct UrlInspectionMethods<'a, C>
1176where
1177    C: 'a,
1178{
1179    hub: &'a SearchConsole<C>,
1180}
1181
1182impl<'a, C> common::MethodsBuilder for UrlInspectionMethods<'a, C> {}
1183
1184impl<'a, C> UrlInspectionMethods<'a, C> {
1185    /// Create a builder to help you perform the following task:
1186    ///
1187    /// Index inspection.
1188    ///
1189    /// # Arguments
1190    ///
1191    /// * `request` - No description provided.
1192    pub fn index_inspect(
1193        &self,
1194        request: InspectUrlIndexRequest,
1195    ) -> UrlInspectionIndexInspectCall<'a, C> {
1196        UrlInspectionIndexInspectCall {
1197            hub: self.hub,
1198            _request: request,
1199            _delegate: Default::default(),
1200            _additional_params: Default::default(),
1201            _scopes: Default::default(),
1202        }
1203    }
1204}
1205
1206/// A builder providing access to all methods supported on *urlTestingTool* resources.
1207/// It is not used directly, but through the [`SearchConsole`] hub.
1208///
1209/// # Example
1210///
1211/// Instantiate a resource builder
1212///
1213/// ```test_harness,no_run
1214/// extern crate hyper;
1215/// extern crate hyper_rustls;
1216/// extern crate google_searchconsole1 as searchconsole1;
1217///
1218/// # async fn dox() {
1219/// use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1220///
1221/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1222/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1223///     secret,
1224///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1225/// ).build().await.unwrap();
1226///
1227/// let client = hyper_util::client::legacy::Client::builder(
1228///     hyper_util::rt::TokioExecutor::new()
1229/// )
1230/// .build(
1231///     hyper_rustls::HttpsConnectorBuilder::new()
1232///         .with_native_roots()
1233///         .unwrap()
1234///         .https_or_http()
1235///         .enable_http1()
1236///         .build()
1237/// );
1238/// let mut hub = SearchConsole::new(client, auth);
1239/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1240/// // like `mobile_friendly_test_run(...)`
1241/// // to build up your call.
1242/// let rb = hub.url_testing_tools();
1243/// # }
1244/// ```
1245pub struct UrlTestingToolMethods<'a, C>
1246where
1247    C: 'a,
1248{
1249    hub: &'a SearchConsole<C>,
1250}
1251
1252impl<'a, C> common::MethodsBuilder for UrlTestingToolMethods<'a, C> {}
1253
1254impl<'a, C> UrlTestingToolMethods<'a, C> {
1255    /// Create a builder to help you perform the following task:
1256    ///
1257    /// Runs Mobile-Friendly Test for a given URL.
1258    ///
1259    /// # Arguments
1260    ///
1261    /// * `request` - No description provided.
1262    pub fn mobile_friendly_test_run(
1263        &self,
1264        request: RunMobileFriendlyTestRequest,
1265    ) -> UrlTestingToolMobileFriendlyTestRunCall<'a, C> {
1266        UrlTestingToolMobileFriendlyTestRunCall {
1267            hub: self.hub,
1268            _request: request,
1269            _delegate: Default::default(),
1270            _additional_params: Default::default(),
1271        }
1272    }
1273}
1274
1275// ###################
1276// CallBuilders   ###
1277// #################
1278
1279/// Query your data with filters and parameters that you define. Returns zero or more rows grouped by the row keys that you define. You must define a date range of one or more days. When date is one of the group by values, any days without data are omitted from the result list. If you need to know which days have data, issue a broad date range query grouped by date for any metric, and see which day rows are returned.
1280///
1281/// A builder for the *query* method supported by a *searchanalytic* resource.
1282/// It is not used directly, but through a [`SearchanalyticMethods`] instance.
1283///
1284/// # Example
1285///
1286/// Instantiate a resource method builder
1287///
1288/// ```test_harness,no_run
1289/// # extern crate hyper;
1290/// # extern crate hyper_rustls;
1291/// # extern crate google_searchconsole1 as searchconsole1;
1292/// use searchconsole1::api::SearchAnalyticsQueryRequest;
1293/// # async fn dox() {
1294/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1295///
1296/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1298/// #     secret,
1299/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1300/// # ).build().await.unwrap();
1301///
1302/// # let client = hyper_util::client::legacy::Client::builder(
1303/// #     hyper_util::rt::TokioExecutor::new()
1304/// # )
1305/// # .build(
1306/// #     hyper_rustls::HttpsConnectorBuilder::new()
1307/// #         .with_native_roots()
1308/// #         .unwrap()
1309/// #         .https_or_http()
1310/// #         .enable_http1()
1311/// #         .build()
1312/// # );
1313/// # let mut hub = SearchConsole::new(client, auth);
1314/// // As the method needs a request, you would usually fill it with the desired information
1315/// // into the respective structure. Some of the parts shown here might not be applicable !
1316/// // Values shown here are possibly random and not representative !
1317/// let mut req = SearchAnalyticsQueryRequest::default();
1318///
1319/// // You can configure optional parameters by calling the respective setters at will, and
1320/// // execute the final call using `doit()`.
1321/// // Values shown here are possibly random and not representative !
1322/// let result = hub.searchanalytics().query(req, "siteUrl")
1323///              .doit().await;
1324/// # }
1325/// ```
1326pub struct SearchanalyticQueryCall<'a, C>
1327where
1328    C: 'a,
1329{
1330    hub: &'a SearchConsole<C>,
1331    _request: SearchAnalyticsQueryRequest,
1332    _site_url: String,
1333    _delegate: Option<&'a mut dyn common::Delegate>,
1334    _additional_params: HashMap<String, String>,
1335    _scopes: BTreeSet<String>,
1336}
1337
1338impl<'a, C> common::CallBuilder for SearchanalyticQueryCall<'a, C> {}
1339
1340impl<'a, C> SearchanalyticQueryCall<'a, C>
1341where
1342    C: common::Connector,
1343{
1344    /// Perform the operation you have build so far.
1345    pub async fn doit(
1346        mut self,
1347    ) -> common::Result<(common::Response, SearchAnalyticsQueryResponse)> {
1348        use std::borrow::Cow;
1349        use std::io::{Read, Seek};
1350
1351        use common::{url::Params, ToParts};
1352        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1353
1354        let mut dd = common::DefaultDelegate;
1355        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1356        dlg.begin(common::MethodInfo {
1357            id: "webmasters.searchanalytics.query",
1358            http_method: hyper::Method::POST,
1359        });
1360
1361        for &field in ["alt", "siteUrl"].iter() {
1362            if self._additional_params.contains_key(field) {
1363                dlg.finished(false);
1364                return Err(common::Error::FieldClash(field));
1365            }
1366        }
1367
1368        let mut params = Params::with_capacity(4 + self._additional_params.len());
1369        params.push("siteUrl", self._site_url);
1370
1371        params.extend(self._additional_params.iter());
1372
1373        params.push("alt", "json");
1374        let mut url =
1375            self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}/searchAnalytics/query";
1376        if self._scopes.is_empty() {
1377            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
1378        }
1379
1380        #[allow(clippy::single_element_loop)]
1381        for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
1382            url = params.uri_replacement(url, param_name, find_this, false);
1383        }
1384        {
1385            let to_remove = ["siteUrl"];
1386            params.remove_params(&to_remove);
1387        }
1388
1389        let url = params.parse_with_url(&url);
1390
1391        let mut json_mime_type = mime::APPLICATION_JSON;
1392        let mut request_value_reader = {
1393            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1394            common::remove_json_null_values(&mut value);
1395            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1396            serde_json::to_writer(&mut dst, &value).unwrap();
1397            dst
1398        };
1399        let request_size = request_value_reader
1400            .seek(std::io::SeekFrom::End(0))
1401            .unwrap();
1402        request_value_reader
1403            .seek(std::io::SeekFrom::Start(0))
1404            .unwrap();
1405
1406        loop {
1407            let token = match self
1408                .hub
1409                .auth
1410                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1411                .await
1412            {
1413                Ok(token) => token,
1414                Err(e) => match dlg.token(e) {
1415                    Ok(token) => token,
1416                    Err(e) => {
1417                        dlg.finished(false);
1418                        return Err(common::Error::MissingToken(e));
1419                    }
1420                },
1421            };
1422            request_value_reader
1423                .seek(std::io::SeekFrom::Start(0))
1424                .unwrap();
1425            let mut req_result = {
1426                let client = &self.hub.client;
1427                dlg.pre_request();
1428                let mut req_builder = hyper::Request::builder()
1429                    .method(hyper::Method::POST)
1430                    .uri(url.as_str())
1431                    .header(USER_AGENT, self.hub._user_agent.clone());
1432
1433                if let Some(token) = token.as_ref() {
1434                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1435                }
1436
1437                let request = req_builder
1438                    .header(CONTENT_TYPE, json_mime_type.to_string())
1439                    .header(CONTENT_LENGTH, request_size as u64)
1440                    .body(common::to_body(
1441                        request_value_reader.get_ref().clone().into(),
1442                    ));
1443
1444                client.request(request.unwrap()).await
1445            };
1446
1447            match req_result {
1448                Err(err) => {
1449                    if let common::Retry::After(d) = dlg.http_error(&err) {
1450                        sleep(d).await;
1451                        continue;
1452                    }
1453                    dlg.finished(false);
1454                    return Err(common::Error::HttpError(err));
1455                }
1456                Ok(res) => {
1457                    let (mut parts, body) = res.into_parts();
1458                    let mut body = common::Body::new(body);
1459                    if !parts.status.is_success() {
1460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1461                        let error = serde_json::from_str(&common::to_string(&bytes));
1462                        let response = common::to_response(parts, bytes.into());
1463
1464                        if let common::Retry::After(d) =
1465                            dlg.http_failure(&response, error.as_ref().ok())
1466                        {
1467                            sleep(d).await;
1468                            continue;
1469                        }
1470
1471                        dlg.finished(false);
1472
1473                        return Err(match error {
1474                            Ok(value) => common::Error::BadRequest(value),
1475                            _ => common::Error::Failure(response),
1476                        });
1477                    }
1478                    let response = {
1479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1480                        let encoded = common::to_string(&bytes);
1481                        match serde_json::from_str(&encoded) {
1482                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1483                            Err(error) => {
1484                                dlg.response_json_decode_error(&encoded, &error);
1485                                return Err(common::Error::JsonDecodeError(
1486                                    encoded.to_string(),
1487                                    error,
1488                                ));
1489                            }
1490                        }
1491                    };
1492
1493                    dlg.finished(true);
1494                    return Ok(response);
1495                }
1496            }
1497        }
1498    }
1499
1500    ///
1501    /// Sets the *request* property to the given value.
1502    ///
1503    /// Even though the property as already been set when instantiating this call,
1504    /// we provide this method for API completeness.
1505    pub fn request(
1506        mut self,
1507        new_value: SearchAnalyticsQueryRequest,
1508    ) -> SearchanalyticQueryCall<'a, C> {
1509        self._request = new_value;
1510        self
1511    }
1512    /// The site's URL, including protocol. For example: `http://www.example.com/`.
1513    ///
1514    /// Sets the *site url* path property to the given value.
1515    ///
1516    /// Even though the property as already been set when instantiating this call,
1517    /// we provide this method for API completeness.
1518    pub fn site_url(mut self, new_value: &str) -> SearchanalyticQueryCall<'a, C> {
1519        self._site_url = new_value.to_string();
1520        self
1521    }
1522    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1523    /// while executing the actual API request.
1524    ///
1525    /// ````text
1526    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1527    /// ````
1528    ///
1529    /// Sets the *delegate* property to the given value.
1530    pub fn delegate(
1531        mut self,
1532        new_value: &'a mut dyn common::Delegate,
1533    ) -> SearchanalyticQueryCall<'a, C> {
1534        self._delegate = Some(new_value);
1535        self
1536    }
1537
1538    /// Set any additional parameter of the query string used in the request.
1539    /// It should be used to set parameters which are not yet available through their own
1540    /// setters.
1541    ///
1542    /// Please note that this method must not be used to set any of the known parameters
1543    /// which have their own setter method. If done anyway, the request will fail.
1544    ///
1545    /// # Additional Parameters
1546    ///
1547    /// * *$.xgafv* (query-string) - V1 error format.
1548    /// * *access_token* (query-string) - OAuth access token.
1549    /// * *alt* (query-string) - Data format for response.
1550    /// * *callback* (query-string) - JSONP
1551    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1552    /// * *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.
1553    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1554    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1555    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1556    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1557    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1558    pub fn param<T>(mut self, name: T, value: T) -> SearchanalyticQueryCall<'a, C>
1559    where
1560        T: AsRef<str>,
1561    {
1562        self._additional_params
1563            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1564        self
1565    }
1566
1567    /// Identifies the authorization scope for the method you are building.
1568    ///
1569    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1570    /// [`Scope::Webmaster`].
1571    ///
1572    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1573    /// tokens for more than one scope.
1574    ///
1575    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1576    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1577    /// sufficient, a read-write scope will do as well.
1578    pub fn add_scope<St>(mut self, scope: St) -> SearchanalyticQueryCall<'a, C>
1579    where
1580        St: AsRef<str>,
1581    {
1582        self._scopes.insert(String::from(scope.as_ref()));
1583        self
1584    }
1585    /// Identifies the authorization scope(s) for the method you are building.
1586    ///
1587    /// See [`Self::add_scope()`] for details.
1588    pub fn add_scopes<I, St>(mut self, scopes: I) -> SearchanalyticQueryCall<'a, C>
1589    where
1590        I: IntoIterator<Item = St>,
1591        St: AsRef<str>,
1592    {
1593        self._scopes
1594            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1595        self
1596    }
1597
1598    /// Removes all scopes, and no default scope will be used either.
1599    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1600    /// for details).
1601    pub fn clear_scopes(mut self) -> SearchanalyticQueryCall<'a, C> {
1602        self._scopes.clear();
1603        self
1604    }
1605}
1606
1607/// Deletes a sitemap from the Sitemaps report. Does not stop Google from crawling this sitemap or the URLs that were previously crawled in the deleted sitemap.
1608///
1609/// A builder for the *delete* method supported by a *sitemap* resource.
1610/// It is not used directly, but through a [`SitemapMethods`] instance.
1611///
1612/// # Example
1613///
1614/// Instantiate a resource method builder
1615///
1616/// ```test_harness,no_run
1617/// # extern crate hyper;
1618/// # extern crate hyper_rustls;
1619/// # extern crate google_searchconsole1 as searchconsole1;
1620/// # async fn dox() {
1621/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1622///
1623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1625/// #     secret,
1626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1627/// # ).build().await.unwrap();
1628///
1629/// # let client = hyper_util::client::legacy::Client::builder(
1630/// #     hyper_util::rt::TokioExecutor::new()
1631/// # )
1632/// # .build(
1633/// #     hyper_rustls::HttpsConnectorBuilder::new()
1634/// #         .with_native_roots()
1635/// #         .unwrap()
1636/// #         .https_or_http()
1637/// #         .enable_http1()
1638/// #         .build()
1639/// # );
1640/// # let mut hub = SearchConsole::new(client, auth);
1641/// // You can configure optional parameters by calling the respective setters at will, and
1642/// // execute the final call using `doit()`.
1643/// // Values shown here are possibly random and not representative !
1644/// let result = hub.sitemaps().delete("siteUrl", "feedpath")
1645///              .doit().await;
1646/// # }
1647/// ```
1648pub struct SitemapDeleteCall<'a, C>
1649where
1650    C: 'a,
1651{
1652    hub: &'a SearchConsole<C>,
1653    _site_url: String,
1654    _feedpath: String,
1655    _delegate: Option<&'a mut dyn common::Delegate>,
1656    _additional_params: HashMap<String, String>,
1657    _scopes: BTreeSet<String>,
1658}
1659
1660impl<'a, C> common::CallBuilder for SitemapDeleteCall<'a, C> {}
1661
1662impl<'a, C> SitemapDeleteCall<'a, C>
1663where
1664    C: common::Connector,
1665{
1666    /// Perform the operation you have build so far.
1667    pub async fn doit(mut self) -> common::Result<common::Response> {
1668        use std::borrow::Cow;
1669        use std::io::{Read, Seek};
1670
1671        use common::{url::Params, ToParts};
1672        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1673
1674        let mut dd = common::DefaultDelegate;
1675        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1676        dlg.begin(common::MethodInfo {
1677            id: "webmasters.sitemaps.delete",
1678            http_method: hyper::Method::DELETE,
1679        });
1680
1681        for &field in ["siteUrl", "feedpath"].iter() {
1682            if self._additional_params.contains_key(field) {
1683                dlg.finished(false);
1684                return Err(common::Error::FieldClash(field));
1685            }
1686        }
1687
1688        let mut params = Params::with_capacity(3 + self._additional_params.len());
1689        params.push("siteUrl", self._site_url);
1690        params.push("feedpath", self._feedpath);
1691
1692        params.extend(self._additional_params.iter());
1693
1694        let mut url =
1695            self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}";
1696        if self._scopes.is_empty() {
1697            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
1698        }
1699
1700        #[allow(clippy::single_element_loop)]
1701        for &(find_this, param_name) in
1702            [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
1703        {
1704            url = params.uri_replacement(url, param_name, find_this, false);
1705        }
1706        {
1707            let to_remove = ["feedpath", "siteUrl"];
1708            params.remove_params(&to_remove);
1709        }
1710
1711        let url = params.parse_with_url(&url);
1712
1713        loop {
1714            let token = match self
1715                .hub
1716                .auth
1717                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1718                .await
1719            {
1720                Ok(token) => token,
1721                Err(e) => match dlg.token(e) {
1722                    Ok(token) => token,
1723                    Err(e) => {
1724                        dlg.finished(false);
1725                        return Err(common::Error::MissingToken(e));
1726                    }
1727                },
1728            };
1729            let mut req_result = {
1730                let client = &self.hub.client;
1731                dlg.pre_request();
1732                let mut req_builder = hyper::Request::builder()
1733                    .method(hyper::Method::DELETE)
1734                    .uri(url.as_str())
1735                    .header(USER_AGENT, self.hub._user_agent.clone());
1736
1737                if let Some(token) = token.as_ref() {
1738                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1739                }
1740
1741                let request = req_builder
1742                    .header(CONTENT_LENGTH, 0_u64)
1743                    .body(common::to_body::<String>(None));
1744
1745                client.request(request.unwrap()).await
1746            };
1747
1748            match req_result {
1749                Err(err) => {
1750                    if let common::Retry::After(d) = dlg.http_error(&err) {
1751                        sleep(d).await;
1752                        continue;
1753                    }
1754                    dlg.finished(false);
1755                    return Err(common::Error::HttpError(err));
1756                }
1757                Ok(res) => {
1758                    let (mut parts, body) = res.into_parts();
1759                    let mut body = common::Body::new(body);
1760                    if !parts.status.is_success() {
1761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1762                        let error = serde_json::from_str(&common::to_string(&bytes));
1763                        let response = common::to_response(parts, bytes.into());
1764
1765                        if let common::Retry::After(d) =
1766                            dlg.http_failure(&response, error.as_ref().ok())
1767                        {
1768                            sleep(d).await;
1769                            continue;
1770                        }
1771
1772                        dlg.finished(false);
1773
1774                        return Err(match error {
1775                            Ok(value) => common::Error::BadRequest(value),
1776                            _ => common::Error::Failure(response),
1777                        });
1778                    }
1779                    let response = common::Response::from_parts(parts, body);
1780
1781                    dlg.finished(true);
1782                    return Ok(response);
1783                }
1784            }
1785        }
1786    }
1787
1788    /// The site's URL, including protocol. For example: `http://www.example.com/`.
1789    ///
1790    /// Sets the *site url* path property to the given value.
1791    ///
1792    /// Even though the property as already been set when instantiating this call,
1793    /// we provide this method for API completeness.
1794    pub fn site_url(mut self, new_value: &str) -> SitemapDeleteCall<'a, C> {
1795        self._site_url = new_value.to_string();
1796        self
1797    }
1798    /// The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
1799    ///
1800    /// Sets the *feedpath* path property to the given value.
1801    ///
1802    /// Even though the property as already been set when instantiating this call,
1803    /// we provide this method for API completeness.
1804    pub fn feedpath(mut self, new_value: &str) -> SitemapDeleteCall<'a, C> {
1805        self._feedpath = new_value.to_string();
1806        self
1807    }
1808    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1809    /// while executing the actual API request.
1810    ///
1811    /// ````text
1812    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1813    /// ````
1814    ///
1815    /// Sets the *delegate* property to the given value.
1816    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapDeleteCall<'a, C> {
1817        self._delegate = Some(new_value);
1818        self
1819    }
1820
1821    /// Set any additional parameter of the query string used in the request.
1822    /// It should be used to set parameters which are not yet available through their own
1823    /// setters.
1824    ///
1825    /// Please note that this method must not be used to set any of the known parameters
1826    /// which have their own setter method. If done anyway, the request will fail.
1827    ///
1828    /// # Additional Parameters
1829    ///
1830    /// * *$.xgafv* (query-string) - V1 error format.
1831    /// * *access_token* (query-string) - OAuth access token.
1832    /// * *alt* (query-string) - Data format for response.
1833    /// * *callback* (query-string) - JSONP
1834    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1835    /// * *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.
1836    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1837    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1838    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1839    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1840    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1841    pub fn param<T>(mut self, name: T, value: T) -> SitemapDeleteCall<'a, C>
1842    where
1843        T: AsRef<str>,
1844    {
1845        self._additional_params
1846            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1847        self
1848    }
1849
1850    /// Identifies the authorization scope for the method you are building.
1851    ///
1852    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1853    /// [`Scope::Webmaster`].
1854    ///
1855    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1856    /// tokens for more than one scope.
1857    ///
1858    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1859    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1860    /// sufficient, a read-write scope will do as well.
1861    pub fn add_scope<St>(mut self, scope: St) -> SitemapDeleteCall<'a, C>
1862    where
1863        St: AsRef<str>,
1864    {
1865        self._scopes.insert(String::from(scope.as_ref()));
1866        self
1867    }
1868    /// Identifies the authorization scope(s) for the method you are building.
1869    ///
1870    /// See [`Self::add_scope()`] for details.
1871    pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapDeleteCall<'a, C>
1872    where
1873        I: IntoIterator<Item = St>,
1874        St: AsRef<str>,
1875    {
1876        self._scopes
1877            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1878        self
1879    }
1880
1881    /// Removes all scopes, and no default scope will be used either.
1882    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1883    /// for details).
1884    pub fn clear_scopes(mut self) -> SitemapDeleteCall<'a, C> {
1885        self._scopes.clear();
1886        self
1887    }
1888}
1889
1890/// Retrieves information about a specific sitemap.
1891///
1892/// A builder for the *get* method supported by a *sitemap* resource.
1893/// It is not used directly, but through a [`SitemapMethods`] instance.
1894///
1895/// # Example
1896///
1897/// Instantiate a resource method builder
1898///
1899/// ```test_harness,no_run
1900/// # extern crate hyper;
1901/// # extern crate hyper_rustls;
1902/// # extern crate google_searchconsole1 as searchconsole1;
1903/// # async fn dox() {
1904/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1905///
1906/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1908/// #     secret,
1909/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1910/// # ).build().await.unwrap();
1911///
1912/// # let client = hyper_util::client::legacy::Client::builder(
1913/// #     hyper_util::rt::TokioExecutor::new()
1914/// # )
1915/// # .build(
1916/// #     hyper_rustls::HttpsConnectorBuilder::new()
1917/// #         .with_native_roots()
1918/// #         .unwrap()
1919/// #         .https_or_http()
1920/// #         .enable_http1()
1921/// #         .build()
1922/// # );
1923/// # let mut hub = SearchConsole::new(client, auth);
1924/// // You can configure optional parameters by calling the respective setters at will, and
1925/// // execute the final call using `doit()`.
1926/// // Values shown here are possibly random and not representative !
1927/// let result = hub.sitemaps().get("siteUrl", "feedpath")
1928///              .doit().await;
1929/// # }
1930/// ```
1931pub struct SitemapGetCall<'a, C>
1932where
1933    C: 'a,
1934{
1935    hub: &'a SearchConsole<C>,
1936    _site_url: String,
1937    _feedpath: String,
1938    _delegate: Option<&'a mut dyn common::Delegate>,
1939    _additional_params: HashMap<String, String>,
1940    _scopes: BTreeSet<String>,
1941}
1942
1943impl<'a, C> common::CallBuilder for SitemapGetCall<'a, C> {}
1944
1945impl<'a, C> SitemapGetCall<'a, C>
1946where
1947    C: common::Connector,
1948{
1949    /// Perform the operation you have build so far.
1950    pub async fn doit(mut self) -> common::Result<(common::Response, WmxSitemap)> {
1951        use std::borrow::Cow;
1952        use std::io::{Read, Seek};
1953
1954        use common::{url::Params, ToParts};
1955        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1956
1957        let mut dd = common::DefaultDelegate;
1958        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1959        dlg.begin(common::MethodInfo {
1960            id: "webmasters.sitemaps.get",
1961            http_method: hyper::Method::GET,
1962        });
1963
1964        for &field in ["alt", "siteUrl", "feedpath"].iter() {
1965            if self._additional_params.contains_key(field) {
1966                dlg.finished(false);
1967                return Err(common::Error::FieldClash(field));
1968            }
1969        }
1970
1971        let mut params = Params::with_capacity(4 + self._additional_params.len());
1972        params.push("siteUrl", self._site_url);
1973        params.push("feedpath", self._feedpath);
1974
1975        params.extend(self._additional_params.iter());
1976
1977        params.push("alt", "json");
1978        let mut url =
1979            self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}";
1980        if self._scopes.is_empty() {
1981            self._scopes
1982                .insert(Scope::WebmasterReadonly.as_ref().to_string());
1983        }
1984
1985        #[allow(clippy::single_element_loop)]
1986        for &(find_this, param_name) in
1987            [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
1988        {
1989            url = params.uri_replacement(url, param_name, find_this, false);
1990        }
1991        {
1992            let to_remove = ["feedpath", "siteUrl"];
1993            params.remove_params(&to_remove);
1994        }
1995
1996        let url = params.parse_with_url(&url);
1997
1998        loop {
1999            let token = match self
2000                .hub
2001                .auth
2002                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2003                .await
2004            {
2005                Ok(token) => token,
2006                Err(e) => match dlg.token(e) {
2007                    Ok(token) => token,
2008                    Err(e) => {
2009                        dlg.finished(false);
2010                        return Err(common::Error::MissingToken(e));
2011                    }
2012                },
2013            };
2014            let mut req_result = {
2015                let client = &self.hub.client;
2016                dlg.pre_request();
2017                let mut req_builder = hyper::Request::builder()
2018                    .method(hyper::Method::GET)
2019                    .uri(url.as_str())
2020                    .header(USER_AGENT, self.hub._user_agent.clone());
2021
2022                if let Some(token) = token.as_ref() {
2023                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2024                }
2025
2026                let request = req_builder
2027                    .header(CONTENT_LENGTH, 0_u64)
2028                    .body(common::to_body::<String>(None));
2029
2030                client.request(request.unwrap()).await
2031            };
2032
2033            match req_result {
2034                Err(err) => {
2035                    if let common::Retry::After(d) = dlg.http_error(&err) {
2036                        sleep(d).await;
2037                        continue;
2038                    }
2039                    dlg.finished(false);
2040                    return Err(common::Error::HttpError(err));
2041                }
2042                Ok(res) => {
2043                    let (mut parts, body) = res.into_parts();
2044                    let mut body = common::Body::new(body);
2045                    if !parts.status.is_success() {
2046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2047                        let error = serde_json::from_str(&common::to_string(&bytes));
2048                        let response = common::to_response(parts, bytes.into());
2049
2050                        if let common::Retry::After(d) =
2051                            dlg.http_failure(&response, error.as_ref().ok())
2052                        {
2053                            sleep(d).await;
2054                            continue;
2055                        }
2056
2057                        dlg.finished(false);
2058
2059                        return Err(match error {
2060                            Ok(value) => common::Error::BadRequest(value),
2061                            _ => common::Error::Failure(response),
2062                        });
2063                    }
2064                    let response = {
2065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2066                        let encoded = common::to_string(&bytes);
2067                        match serde_json::from_str(&encoded) {
2068                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2069                            Err(error) => {
2070                                dlg.response_json_decode_error(&encoded, &error);
2071                                return Err(common::Error::JsonDecodeError(
2072                                    encoded.to_string(),
2073                                    error,
2074                                ));
2075                            }
2076                        }
2077                    };
2078
2079                    dlg.finished(true);
2080                    return Ok(response);
2081                }
2082            }
2083        }
2084    }
2085
2086    /// The site's URL, including protocol. For example: `http://www.example.com/`.
2087    ///
2088    /// Sets the *site url* path property to the given value.
2089    ///
2090    /// Even though the property as already been set when instantiating this call,
2091    /// we provide this method for API completeness.
2092    pub fn site_url(mut self, new_value: &str) -> SitemapGetCall<'a, C> {
2093        self._site_url = new_value.to_string();
2094        self
2095    }
2096    /// The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
2097    ///
2098    /// Sets the *feedpath* path property to the given value.
2099    ///
2100    /// Even though the property as already been set when instantiating this call,
2101    /// we provide this method for API completeness.
2102    pub fn feedpath(mut self, new_value: &str) -> SitemapGetCall<'a, C> {
2103        self._feedpath = new_value.to_string();
2104        self
2105    }
2106    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2107    /// while executing the actual API request.
2108    ///
2109    /// ````text
2110    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2111    /// ````
2112    ///
2113    /// Sets the *delegate* property to the given value.
2114    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapGetCall<'a, C> {
2115        self._delegate = Some(new_value);
2116        self
2117    }
2118
2119    /// Set any additional parameter of the query string used in the request.
2120    /// It should be used to set parameters which are not yet available through their own
2121    /// setters.
2122    ///
2123    /// Please note that this method must not be used to set any of the known parameters
2124    /// which have their own setter method. If done anyway, the request will fail.
2125    ///
2126    /// # Additional Parameters
2127    ///
2128    /// * *$.xgafv* (query-string) - V1 error format.
2129    /// * *access_token* (query-string) - OAuth access token.
2130    /// * *alt* (query-string) - Data format for response.
2131    /// * *callback* (query-string) - JSONP
2132    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2133    /// * *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.
2134    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2135    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2136    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2137    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2138    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2139    pub fn param<T>(mut self, name: T, value: T) -> SitemapGetCall<'a, C>
2140    where
2141        T: AsRef<str>,
2142    {
2143        self._additional_params
2144            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2145        self
2146    }
2147
2148    /// Identifies the authorization scope for the method you are building.
2149    ///
2150    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2151    /// [`Scope::WebmasterReadonly`].
2152    ///
2153    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2154    /// tokens for more than one scope.
2155    ///
2156    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2157    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2158    /// sufficient, a read-write scope will do as well.
2159    pub fn add_scope<St>(mut self, scope: St) -> SitemapGetCall<'a, C>
2160    where
2161        St: AsRef<str>,
2162    {
2163        self._scopes.insert(String::from(scope.as_ref()));
2164        self
2165    }
2166    /// Identifies the authorization scope(s) for the method you are building.
2167    ///
2168    /// See [`Self::add_scope()`] for details.
2169    pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapGetCall<'a, C>
2170    where
2171        I: IntoIterator<Item = St>,
2172        St: AsRef<str>,
2173    {
2174        self._scopes
2175            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2176        self
2177    }
2178
2179    /// Removes all scopes, and no default scope will be used either.
2180    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2181    /// for details).
2182    pub fn clear_scopes(mut self) -> SitemapGetCall<'a, C> {
2183        self._scopes.clear();
2184        self
2185    }
2186}
2187
2188/// Lists the [sitemaps-entries](https://developers.google.com/webmaster-tools/v3/sitemaps) submitted for this site, or included in the sitemap index file (if `sitemapIndex` is specified in the request).
2189///
2190/// A builder for the *list* method supported by a *sitemap* resource.
2191/// It is not used directly, but through a [`SitemapMethods`] instance.
2192///
2193/// # Example
2194///
2195/// Instantiate a resource method builder
2196///
2197/// ```test_harness,no_run
2198/// # extern crate hyper;
2199/// # extern crate hyper_rustls;
2200/// # extern crate google_searchconsole1 as searchconsole1;
2201/// # async fn dox() {
2202/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2203///
2204/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2206/// #     secret,
2207/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2208/// # ).build().await.unwrap();
2209///
2210/// # let client = hyper_util::client::legacy::Client::builder(
2211/// #     hyper_util::rt::TokioExecutor::new()
2212/// # )
2213/// # .build(
2214/// #     hyper_rustls::HttpsConnectorBuilder::new()
2215/// #         .with_native_roots()
2216/// #         .unwrap()
2217/// #         .https_or_http()
2218/// #         .enable_http1()
2219/// #         .build()
2220/// # );
2221/// # let mut hub = SearchConsole::new(client, auth);
2222/// // You can configure optional parameters by calling the respective setters at will, and
2223/// // execute the final call using `doit()`.
2224/// // Values shown here are possibly random and not representative !
2225/// let result = hub.sitemaps().list("siteUrl")
2226///              .sitemap_index("takimata")
2227///              .doit().await;
2228/// # }
2229/// ```
2230pub struct SitemapListCall<'a, C>
2231where
2232    C: 'a,
2233{
2234    hub: &'a SearchConsole<C>,
2235    _site_url: String,
2236    _sitemap_index: Option<String>,
2237    _delegate: Option<&'a mut dyn common::Delegate>,
2238    _additional_params: HashMap<String, String>,
2239    _scopes: BTreeSet<String>,
2240}
2241
2242impl<'a, C> common::CallBuilder for SitemapListCall<'a, C> {}
2243
2244impl<'a, C> SitemapListCall<'a, C>
2245where
2246    C: common::Connector,
2247{
2248    /// Perform the operation you have build so far.
2249    pub async fn doit(mut self) -> common::Result<(common::Response, SitemapsListResponse)> {
2250        use std::borrow::Cow;
2251        use std::io::{Read, Seek};
2252
2253        use common::{url::Params, ToParts};
2254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2255
2256        let mut dd = common::DefaultDelegate;
2257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2258        dlg.begin(common::MethodInfo {
2259            id: "webmasters.sitemaps.list",
2260            http_method: hyper::Method::GET,
2261        });
2262
2263        for &field in ["alt", "siteUrl", "sitemapIndex"].iter() {
2264            if self._additional_params.contains_key(field) {
2265                dlg.finished(false);
2266                return Err(common::Error::FieldClash(field));
2267            }
2268        }
2269
2270        let mut params = Params::with_capacity(4 + self._additional_params.len());
2271        params.push("siteUrl", self._site_url);
2272        if let Some(value) = self._sitemap_index.as_ref() {
2273            params.push("sitemapIndex", value);
2274        }
2275
2276        params.extend(self._additional_params.iter());
2277
2278        params.push("alt", "json");
2279        let mut url = self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}/sitemaps";
2280        if self._scopes.is_empty() {
2281            self._scopes
2282                .insert(Scope::WebmasterReadonly.as_ref().to_string());
2283        }
2284
2285        #[allow(clippy::single_element_loop)]
2286        for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
2287            url = params.uri_replacement(url, param_name, find_this, false);
2288        }
2289        {
2290            let to_remove = ["siteUrl"];
2291            params.remove_params(&to_remove);
2292        }
2293
2294        let url = params.parse_with_url(&url);
2295
2296        loop {
2297            let token = match self
2298                .hub
2299                .auth
2300                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2301                .await
2302            {
2303                Ok(token) => token,
2304                Err(e) => match dlg.token(e) {
2305                    Ok(token) => token,
2306                    Err(e) => {
2307                        dlg.finished(false);
2308                        return Err(common::Error::MissingToken(e));
2309                    }
2310                },
2311            };
2312            let mut req_result = {
2313                let client = &self.hub.client;
2314                dlg.pre_request();
2315                let mut req_builder = hyper::Request::builder()
2316                    .method(hyper::Method::GET)
2317                    .uri(url.as_str())
2318                    .header(USER_AGENT, self.hub._user_agent.clone());
2319
2320                if let Some(token) = token.as_ref() {
2321                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2322                }
2323
2324                let request = req_builder
2325                    .header(CONTENT_LENGTH, 0_u64)
2326                    .body(common::to_body::<String>(None));
2327
2328                client.request(request.unwrap()).await
2329            };
2330
2331            match req_result {
2332                Err(err) => {
2333                    if let common::Retry::After(d) = dlg.http_error(&err) {
2334                        sleep(d).await;
2335                        continue;
2336                    }
2337                    dlg.finished(false);
2338                    return Err(common::Error::HttpError(err));
2339                }
2340                Ok(res) => {
2341                    let (mut parts, body) = res.into_parts();
2342                    let mut body = common::Body::new(body);
2343                    if !parts.status.is_success() {
2344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2345                        let error = serde_json::from_str(&common::to_string(&bytes));
2346                        let response = common::to_response(parts, bytes.into());
2347
2348                        if let common::Retry::After(d) =
2349                            dlg.http_failure(&response, error.as_ref().ok())
2350                        {
2351                            sleep(d).await;
2352                            continue;
2353                        }
2354
2355                        dlg.finished(false);
2356
2357                        return Err(match error {
2358                            Ok(value) => common::Error::BadRequest(value),
2359                            _ => common::Error::Failure(response),
2360                        });
2361                    }
2362                    let response = {
2363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2364                        let encoded = common::to_string(&bytes);
2365                        match serde_json::from_str(&encoded) {
2366                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2367                            Err(error) => {
2368                                dlg.response_json_decode_error(&encoded, &error);
2369                                return Err(common::Error::JsonDecodeError(
2370                                    encoded.to_string(),
2371                                    error,
2372                                ));
2373                            }
2374                        }
2375                    };
2376
2377                    dlg.finished(true);
2378                    return Ok(response);
2379                }
2380            }
2381        }
2382    }
2383
2384    /// The site's URL, including protocol. For example: `http://www.example.com/`.
2385    ///
2386    /// Sets the *site url* path property to the given value.
2387    ///
2388    /// Even though the property as already been set when instantiating this call,
2389    /// we provide this method for API completeness.
2390    pub fn site_url(mut self, new_value: &str) -> SitemapListCall<'a, C> {
2391        self._site_url = new_value.to_string();
2392        self
2393    }
2394    ///  A URL of a site's sitemap index. For example: `http://www.example.com/sitemapindex.xml`.
2395    ///
2396    /// Sets the *sitemap index* query property to the given value.
2397    pub fn sitemap_index(mut self, new_value: &str) -> SitemapListCall<'a, C> {
2398        self._sitemap_index = Some(new_value.to_string());
2399        self
2400    }
2401    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2402    /// while executing the actual API request.
2403    ///
2404    /// ````text
2405    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2406    /// ````
2407    ///
2408    /// Sets the *delegate* property to the given value.
2409    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapListCall<'a, C> {
2410        self._delegate = Some(new_value);
2411        self
2412    }
2413
2414    /// Set any additional parameter of the query string used in the request.
2415    /// It should be used to set parameters which are not yet available through their own
2416    /// setters.
2417    ///
2418    /// Please note that this method must not be used to set any of the known parameters
2419    /// which have their own setter method. If done anyway, the request will fail.
2420    ///
2421    /// # Additional Parameters
2422    ///
2423    /// * *$.xgafv* (query-string) - V1 error format.
2424    /// * *access_token* (query-string) - OAuth access token.
2425    /// * *alt* (query-string) - Data format for response.
2426    /// * *callback* (query-string) - JSONP
2427    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2428    /// * *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.
2429    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2430    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2431    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2432    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2433    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2434    pub fn param<T>(mut self, name: T, value: T) -> SitemapListCall<'a, C>
2435    where
2436        T: AsRef<str>,
2437    {
2438        self._additional_params
2439            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2440        self
2441    }
2442
2443    /// Identifies the authorization scope for the method you are building.
2444    ///
2445    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2446    /// [`Scope::WebmasterReadonly`].
2447    ///
2448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2449    /// tokens for more than one scope.
2450    ///
2451    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2452    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2453    /// sufficient, a read-write scope will do as well.
2454    pub fn add_scope<St>(mut self, scope: St) -> SitemapListCall<'a, C>
2455    where
2456        St: AsRef<str>,
2457    {
2458        self._scopes.insert(String::from(scope.as_ref()));
2459        self
2460    }
2461    /// Identifies the authorization scope(s) for the method you are building.
2462    ///
2463    /// See [`Self::add_scope()`] for details.
2464    pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapListCall<'a, C>
2465    where
2466        I: IntoIterator<Item = St>,
2467        St: AsRef<str>,
2468    {
2469        self._scopes
2470            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2471        self
2472    }
2473
2474    /// Removes all scopes, and no default scope will be used either.
2475    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2476    /// for details).
2477    pub fn clear_scopes(mut self) -> SitemapListCall<'a, C> {
2478        self._scopes.clear();
2479        self
2480    }
2481}
2482
2483/// Submits a sitemap for a site.
2484///
2485/// A builder for the *submit* method supported by a *sitemap* resource.
2486/// It is not used directly, but through a [`SitemapMethods`] instance.
2487///
2488/// # Example
2489///
2490/// Instantiate a resource method builder
2491///
2492/// ```test_harness,no_run
2493/// # extern crate hyper;
2494/// # extern crate hyper_rustls;
2495/// # extern crate google_searchconsole1 as searchconsole1;
2496/// # async fn dox() {
2497/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2498///
2499/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2501/// #     secret,
2502/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2503/// # ).build().await.unwrap();
2504///
2505/// # let client = hyper_util::client::legacy::Client::builder(
2506/// #     hyper_util::rt::TokioExecutor::new()
2507/// # )
2508/// # .build(
2509/// #     hyper_rustls::HttpsConnectorBuilder::new()
2510/// #         .with_native_roots()
2511/// #         .unwrap()
2512/// #         .https_or_http()
2513/// #         .enable_http1()
2514/// #         .build()
2515/// # );
2516/// # let mut hub = SearchConsole::new(client, auth);
2517/// // You can configure optional parameters by calling the respective setters at will, and
2518/// // execute the final call using `doit()`.
2519/// // Values shown here are possibly random and not representative !
2520/// let result = hub.sitemaps().submit("siteUrl", "feedpath")
2521///              .doit().await;
2522/// # }
2523/// ```
2524pub struct SitemapSubmitCall<'a, C>
2525where
2526    C: 'a,
2527{
2528    hub: &'a SearchConsole<C>,
2529    _site_url: String,
2530    _feedpath: String,
2531    _delegate: Option<&'a mut dyn common::Delegate>,
2532    _additional_params: HashMap<String, String>,
2533    _scopes: BTreeSet<String>,
2534}
2535
2536impl<'a, C> common::CallBuilder for SitemapSubmitCall<'a, C> {}
2537
2538impl<'a, C> SitemapSubmitCall<'a, C>
2539where
2540    C: common::Connector,
2541{
2542    /// Perform the operation you have build so far.
2543    pub async fn doit(mut self) -> common::Result<common::Response> {
2544        use std::borrow::Cow;
2545        use std::io::{Read, Seek};
2546
2547        use common::{url::Params, ToParts};
2548        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2549
2550        let mut dd = common::DefaultDelegate;
2551        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2552        dlg.begin(common::MethodInfo {
2553            id: "webmasters.sitemaps.submit",
2554            http_method: hyper::Method::PUT,
2555        });
2556
2557        for &field in ["siteUrl", "feedpath"].iter() {
2558            if self._additional_params.contains_key(field) {
2559                dlg.finished(false);
2560                return Err(common::Error::FieldClash(field));
2561            }
2562        }
2563
2564        let mut params = Params::with_capacity(3 + self._additional_params.len());
2565        params.push("siteUrl", self._site_url);
2566        params.push("feedpath", self._feedpath);
2567
2568        params.extend(self._additional_params.iter());
2569
2570        let mut url =
2571            self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}";
2572        if self._scopes.is_empty() {
2573            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
2574        }
2575
2576        #[allow(clippy::single_element_loop)]
2577        for &(find_this, param_name) in
2578            [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
2579        {
2580            url = params.uri_replacement(url, param_name, find_this, false);
2581        }
2582        {
2583            let to_remove = ["feedpath", "siteUrl"];
2584            params.remove_params(&to_remove);
2585        }
2586
2587        let url = params.parse_with_url(&url);
2588
2589        loop {
2590            let token = match self
2591                .hub
2592                .auth
2593                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2594                .await
2595            {
2596                Ok(token) => token,
2597                Err(e) => match dlg.token(e) {
2598                    Ok(token) => token,
2599                    Err(e) => {
2600                        dlg.finished(false);
2601                        return Err(common::Error::MissingToken(e));
2602                    }
2603                },
2604            };
2605            let mut req_result = {
2606                let client = &self.hub.client;
2607                dlg.pre_request();
2608                let mut req_builder = hyper::Request::builder()
2609                    .method(hyper::Method::PUT)
2610                    .uri(url.as_str())
2611                    .header(USER_AGENT, self.hub._user_agent.clone());
2612
2613                if let Some(token) = token.as_ref() {
2614                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2615                }
2616
2617                let request = req_builder
2618                    .header(CONTENT_LENGTH, 0_u64)
2619                    .body(common::to_body::<String>(None));
2620
2621                client.request(request.unwrap()).await
2622            };
2623
2624            match req_result {
2625                Err(err) => {
2626                    if let common::Retry::After(d) = dlg.http_error(&err) {
2627                        sleep(d).await;
2628                        continue;
2629                    }
2630                    dlg.finished(false);
2631                    return Err(common::Error::HttpError(err));
2632                }
2633                Ok(res) => {
2634                    let (mut parts, body) = res.into_parts();
2635                    let mut body = common::Body::new(body);
2636                    if !parts.status.is_success() {
2637                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2638                        let error = serde_json::from_str(&common::to_string(&bytes));
2639                        let response = common::to_response(parts, bytes.into());
2640
2641                        if let common::Retry::After(d) =
2642                            dlg.http_failure(&response, error.as_ref().ok())
2643                        {
2644                            sleep(d).await;
2645                            continue;
2646                        }
2647
2648                        dlg.finished(false);
2649
2650                        return Err(match error {
2651                            Ok(value) => common::Error::BadRequest(value),
2652                            _ => common::Error::Failure(response),
2653                        });
2654                    }
2655                    let response = common::Response::from_parts(parts, body);
2656
2657                    dlg.finished(true);
2658                    return Ok(response);
2659                }
2660            }
2661        }
2662    }
2663
2664    /// The site's URL, including protocol. For example: `http://www.example.com/`.
2665    ///
2666    /// Sets the *site url* path property to the given value.
2667    ///
2668    /// Even though the property as already been set when instantiating this call,
2669    /// we provide this method for API completeness.
2670    pub fn site_url(mut self, new_value: &str) -> SitemapSubmitCall<'a, C> {
2671        self._site_url = new_value.to_string();
2672        self
2673    }
2674    /// The URL of the actual sitemap. For example: `http://www.example.com/sitemap.xml`.
2675    ///
2676    /// Sets the *feedpath* path property to the given value.
2677    ///
2678    /// Even though the property as already been set when instantiating this call,
2679    /// we provide this method for API completeness.
2680    pub fn feedpath(mut self, new_value: &str) -> SitemapSubmitCall<'a, C> {
2681        self._feedpath = new_value.to_string();
2682        self
2683    }
2684    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2685    /// while executing the actual API request.
2686    ///
2687    /// ````text
2688    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2689    /// ````
2690    ///
2691    /// Sets the *delegate* property to the given value.
2692    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapSubmitCall<'a, C> {
2693        self._delegate = Some(new_value);
2694        self
2695    }
2696
2697    /// Set any additional parameter of the query string used in the request.
2698    /// It should be used to set parameters which are not yet available through their own
2699    /// setters.
2700    ///
2701    /// Please note that this method must not be used to set any of the known parameters
2702    /// which have their own setter method. If done anyway, the request will fail.
2703    ///
2704    /// # Additional Parameters
2705    ///
2706    /// * *$.xgafv* (query-string) - V1 error format.
2707    /// * *access_token* (query-string) - OAuth access token.
2708    /// * *alt* (query-string) - Data format for response.
2709    /// * *callback* (query-string) - JSONP
2710    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2711    /// * *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.
2712    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2713    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2714    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2715    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2716    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2717    pub fn param<T>(mut self, name: T, value: T) -> SitemapSubmitCall<'a, C>
2718    where
2719        T: AsRef<str>,
2720    {
2721        self._additional_params
2722            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2723        self
2724    }
2725
2726    /// Identifies the authorization scope for the method you are building.
2727    ///
2728    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2729    /// [`Scope::Webmaster`].
2730    ///
2731    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2732    /// tokens for more than one scope.
2733    ///
2734    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2735    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2736    /// sufficient, a read-write scope will do as well.
2737    pub fn add_scope<St>(mut self, scope: St) -> SitemapSubmitCall<'a, C>
2738    where
2739        St: AsRef<str>,
2740    {
2741        self._scopes.insert(String::from(scope.as_ref()));
2742        self
2743    }
2744    /// Identifies the authorization scope(s) for the method you are building.
2745    ///
2746    /// See [`Self::add_scope()`] for details.
2747    pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapSubmitCall<'a, C>
2748    where
2749        I: IntoIterator<Item = St>,
2750        St: AsRef<str>,
2751    {
2752        self._scopes
2753            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2754        self
2755    }
2756
2757    /// Removes all scopes, and no default scope will be used either.
2758    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2759    /// for details).
2760    pub fn clear_scopes(mut self) -> SitemapSubmitCall<'a, C> {
2761        self._scopes.clear();
2762        self
2763    }
2764}
2765
2766///  Adds a site to the set of the user's sites in Search Console.
2767///
2768/// A builder for the *add* method supported by a *site* resource.
2769/// It is not used directly, but through a [`SiteMethods`] instance.
2770///
2771/// # Example
2772///
2773/// Instantiate a resource method builder
2774///
2775/// ```test_harness,no_run
2776/// # extern crate hyper;
2777/// # extern crate hyper_rustls;
2778/// # extern crate google_searchconsole1 as searchconsole1;
2779/// # async fn dox() {
2780/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2781///
2782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2783/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2784/// #     secret,
2785/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2786/// # ).build().await.unwrap();
2787///
2788/// # let client = hyper_util::client::legacy::Client::builder(
2789/// #     hyper_util::rt::TokioExecutor::new()
2790/// # )
2791/// # .build(
2792/// #     hyper_rustls::HttpsConnectorBuilder::new()
2793/// #         .with_native_roots()
2794/// #         .unwrap()
2795/// #         .https_or_http()
2796/// #         .enable_http1()
2797/// #         .build()
2798/// # );
2799/// # let mut hub = SearchConsole::new(client, auth);
2800/// // You can configure optional parameters by calling the respective setters at will, and
2801/// // execute the final call using `doit()`.
2802/// // Values shown here are possibly random and not representative !
2803/// let result = hub.sites().add("siteUrl")
2804///              .doit().await;
2805/// # }
2806/// ```
2807pub struct SiteAddCall<'a, C>
2808where
2809    C: 'a,
2810{
2811    hub: &'a SearchConsole<C>,
2812    _site_url: String,
2813    _delegate: Option<&'a mut dyn common::Delegate>,
2814    _additional_params: HashMap<String, String>,
2815    _scopes: BTreeSet<String>,
2816}
2817
2818impl<'a, C> common::CallBuilder for SiteAddCall<'a, C> {}
2819
2820impl<'a, C> SiteAddCall<'a, C>
2821where
2822    C: common::Connector,
2823{
2824    /// Perform the operation you have build so far.
2825    pub async fn doit(mut self) -> common::Result<common::Response> {
2826        use std::borrow::Cow;
2827        use std::io::{Read, Seek};
2828
2829        use common::{url::Params, ToParts};
2830        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2831
2832        let mut dd = common::DefaultDelegate;
2833        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2834        dlg.begin(common::MethodInfo {
2835            id: "webmasters.sites.add",
2836            http_method: hyper::Method::PUT,
2837        });
2838
2839        for &field in ["siteUrl"].iter() {
2840            if self._additional_params.contains_key(field) {
2841                dlg.finished(false);
2842                return Err(common::Error::FieldClash(field));
2843            }
2844        }
2845
2846        let mut params = Params::with_capacity(2 + self._additional_params.len());
2847        params.push("siteUrl", self._site_url);
2848
2849        params.extend(self._additional_params.iter());
2850
2851        let mut url = self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}";
2852        if self._scopes.is_empty() {
2853            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
2854        }
2855
2856        #[allow(clippy::single_element_loop)]
2857        for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
2858            url = params.uri_replacement(url, param_name, find_this, false);
2859        }
2860        {
2861            let to_remove = ["siteUrl"];
2862            params.remove_params(&to_remove);
2863        }
2864
2865        let url = params.parse_with_url(&url);
2866
2867        loop {
2868            let token = match self
2869                .hub
2870                .auth
2871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2872                .await
2873            {
2874                Ok(token) => token,
2875                Err(e) => match dlg.token(e) {
2876                    Ok(token) => token,
2877                    Err(e) => {
2878                        dlg.finished(false);
2879                        return Err(common::Error::MissingToken(e));
2880                    }
2881                },
2882            };
2883            let mut req_result = {
2884                let client = &self.hub.client;
2885                dlg.pre_request();
2886                let mut req_builder = hyper::Request::builder()
2887                    .method(hyper::Method::PUT)
2888                    .uri(url.as_str())
2889                    .header(USER_AGENT, self.hub._user_agent.clone());
2890
2891                if let Some(token) = token.as_ref() {
2892                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2893                }
2894
2895                let request = req_builder
2896                    .header(CONTENT_LENGTH, 0_u64)
2897                    .body(common::to_body::<String>(None));
2898
2899                client.request(request.unwrap()).await
2900            };
2901
2902            match req_result {
2903                Err(err) => {
2904                    if let common::Retry::After(d) = dlg.http_error(&err) {
2905                        sleep(d).await;
2906                        continue;
2907                    }
2908                    dlg.finished(false);
2909                    return Err(common::Error::HttpError(err));
2910                }
2911                Ok(res) => {
2912                    let (mut parts, body) = res.into_parts();
2913                    let mut body = common::Body::new(body);
2914                    if !parts.status.is_success() {
2915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2916                        let error = serde_json::from_str(&common::to_string(&bytes));
2917                        let response = common::to_response(parts, bytes.into());
2918
2919                        if let common::Retry::After(d) =
2920                            dlg.http_failure(&response, error.as_ref().ok())
2921                        {
2922                            sleep(d).await;
2923                            continue;
2924                        }
2925
2926                        dlg.finished(false);
2927
2928                        return Err(match error {
2929                            Ok(value) => common::Error::BadRequest(value),
2930                            _ => common::Error::Failure(response),
2931                        });
2932                    }
2933                    let response = common::Response::from_parts(parts, body);
2934
2935                    dlg.finished(true);
2936                    return Ok(response);
2937                }
2938            }
2939        }
2940    }
2941
2942    /// The URL of the site to add.
2943    ///
2944    /// Sets the *site url* path property to the given value.
2945    ///
2946    /// Even though the property as already been set when instantiating this call,
2947    /// we provide this method for API completeness.
2948    pub fn site_url(mut self, new_value: &str) -> SiteAddCall<'a, C> {
2949        self._site_url = new_value.to_string();
2950        self
2951    }
2952    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2953    /// while executing the actual API request.
2954    ///
2955    /// ````text
2956    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2957    /// ````
2958    ///
2959    /// Sets the *delegate* property to the given value.
2960    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteAddCall<'a, C> {
2961        self._delegate = Some(new_value);
2962        self
2963    }
2964
2965    /// Set any additional parameter of the query string used in the request.
2966    /// It should be used to set parameters which are not yet available through their own
2967    /// setters.
2968    ///
2969    /// Please note that this method must not be used to set any of the known parameters
2970    /// which have their own setter method. If done anyway, the request will fail.
2971    ///
2972    /// # Additional Parameters
2973    ///
2974    /// * *$.xgafv* (query-string) - V1 error format.
2975    /// * *access_token* (query-string) - OAuth access token.
2976    /// * *alt* (query-string) - Data format for response.
2977    /// * *callback* (query-string) - JSONP
2978    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2979    /// * *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.
2980    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2981    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2982    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2983    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2984    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2985    pub fn param<T>(mut self, name: T, value: T) -> SiteAddCall<'a, C>
2986    where
2987        T: AsRef<str>,
2988    {
2989        self._additional_params
2990            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2991        self
2992    }
2993
2994    /// Identifies the authorization scope for the method you are building.
2995    ///
2996    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2997    /// [`Scope::Webmaster`].
2998    ///
2999    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3000    /// tokens for more than one scope.
3001    ///
3002    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3003    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3004    /// sufficient, a read-write scope will do as well.
3005    pub fn add_scope<St>(mut self, scope: St) -> SiteAddCall<'a, C>
3006    where
3007        St: AsRef<str>,
3008    {
3009        self._scopes.insert(String::from(scope.as_ref()));
3010        self
3011    }
3012    /// Identifies the authorization scope(s) for the method you are building.
3013    ///
3014    /// See [`Self::add_scope()`] for details.
3015    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteAddCall<'a, C>
3016    where
3017        I: IntoIterator<Item = St>,
3018        St: AsRef<str>,
3019    {
3020        self._scopes
3021            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3022        self
3023    }
3024
3025    /// Removes all scopes, and no default scope will be used either.
3026    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3027    /// for details).
3028    pub fn clear_scopes(mut self) -> SiteAddCall<'a, C> {
3029        self._scopes.clear();
3030        self
3031    }
3032}
3033
3034///  Removes a site from the set of the user's Search Console sites.
3035///
3036/// A builder for the *delete* method supported by a *site* resource.
3037/// It is not used directly, but through a [`SiteMethods`] instance.
3038///
3039/// # Example
3040///
3041/// Instantiate a resource method builder
3042///
3043/// ```test_harness,no_run
3044/// # extern crate hyper;
3045/// # extern crate hyper_rustls;
3046/// # extern crate google_searchconsole1 as searchconsole1;
3047/// # async fn dox() {
3048/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3049///
3050/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3051/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3052/// #     secret,
3053/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3054/// # ).build().await.unwrap();
3055///
3056/// # let client = hyper_util::client::legacy::Client::builder(
3057/// #     hyper_util::rt::TokioExecutor::new()
3058/// # )
3059/// # .build(
3060/// #     hyper_rustls::HttpsConnectorBuilder::new()
3061/// #         .with_native_roots()
3062/// #         .unwrap()
3063/// #         .https_or_http()
3064/// #         .enable_http1()
3065/// #         .build()
3066/// # );
3067/// # let mut hub = SearchConsole::new(client, auth);
3068/// // You can configure optional parameters by calling the respective setters at will, and
3069/// // execute the final call using `doit()`.
3070/// // Values shown here are possibly random and not representative !
3071/// let result = hub.sites().delete("siteUrl")
3072///              .doit().await;
3073/// # }
3074/// ```
3075pub struct SiteDeleteCall<'a, C>
3076where
3077    C: 'a,
3078{
3079    hub: &'a SearchConsole<C>,
3080    _site_url: String,
3081    _delegate: Option<&'a mut dyn common::Delegate>,
3082    _additional_params: HashMap<String, String>,
3083    _scopes: BTreeSet<String>,
3084}
3085
3086impl<'a, C> common::CallBuilder for SiteDeleteCall<'a, C> {}
3087
3088impl<'a, C> SiteDeleteCall<'a, C>
3089where
3090    C: common::Connector,
3091{
3092    /// Perform the operation you have build so far.
3093    pub async fn doit(mut self) -> common::Result<common::Response> {
3094        use std::borrow::Cow;
3095        use std::io::{Read, Seek};
3096
3097        use common::{url::Params, ToParts};
3098        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3099
3100        let mut dd = common::DefaultDelegate;
3101        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3102        dlg.begin(common::MethodInfo {
3103            id: "webmasters.sites.delete",
3104            http_method: hyper::Method::DELETE,
3105        });
3106
3107        for &field in ["siteUrl"].iter() {
3108            if self._additional_params.contains_key(field) {
3109                dlg.finished(false);
3110                return Err(common::Error::FieldClash(field));
3111            }
3112        }
3113
3114        let mut params = Params::with_capacity(2 + self._additional_params.len());
3115        params.push("siteUrl", self._site_url);
3116
3117        params.extend(self._additional_params.iter());
3118
3119        let mut url = self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}";
3120        if self._scopes.is_empty() {
3121            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
3122        }
3123
3124        #[allow(clippy::single_element_loop)]
3125        for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
3126            url = params.uri_replacement(url, param_name, find_this, false);
3127        }
3128        {
3129            let to_remove = ["siteUrl"];
3130            params.remove_params(&to_remove);
3131        }
3132
3133        let url = params.parse_with_url(&url);
3134
3135        loop {
3136            let token = match self
3137                .hub
3138                .auth
3139                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3140                .await
3141            {
3142                Ok(token) => token,
3143                Err(e) => match dlg.token(e) {
3144                    Ok(token) => token,
3145                    Err(e) => {
3146                        dlg.finished(false);
3147                        return Err(common::Error::MissingToken(e));
3148                    }
3149                },
3150            };
3151            let mut req_result = {
3152                let client = &self.hub.client;
3153                dlg.pre_request();
3154                let mut req_builder = hyper::Request::builder()
3155                    .method(hyper::Method::DELETE)
3156                    .uri(url.as_str())
3157                    .header(USER_AGENT, self.hub._user_agent.clone());
3158
3159                if let Some(token) = token.as_ref() {
3160                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3161                }
3162
3163                let request = req_builder
3164                    .header(CONTENT_LENGTH, 0_u64)
3165                    .body(common::to_body::<String>(None));
3166
3167                client.request(request.unwrap()).await
3168            };
3169
3170            match req_result {
3171                Err(err) => {
3172                    if let common::Retry::After(d) = dlg.http_error(&err) {
3173                        sleep(d).await;
3174                        continue;
3175                    }
3176                    dlg.finished(false);
3177                    return Err(common::Error::HttpError(err));
3178                }
3179                Ok(res) => {
3180                    let (mut parts, body) = res.into_parts();
3181                    let mut body = common::Body::new(body);
3182                    if !parts.status.is_success() {
3183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3184                        let error = serde_json::from_str(&common::to_string(&bytes));
3185                        let response = common::to_response(parts, bytes.into());
3186
3187                        if let common::Retry::After(d) =
3188                            dlg.http_failure(&response, error.as_ref().ok())
3189                        {
3190                            sleep(d).await;
3191                            continue;
3192                        }
3193
3194                        dlg.finished(false);
3195
3196                        return Err(match error {
3197                            Ok(value) => common::Error::BadRequest(value),
3198                            _ => common::Error::Failure(response),
3199                        });
3200                    }
3201                    let response = common::Response::from_parts(parts, body);
3202
3203                    dlg.finished(true);
3204                    return Ok(response);
3205                }
3206            }
3207        }
3208    }
3209
3210    /// The URI of the property as defined in Search Console. **Examples:** `http://www.example.com/` or `sc-domain:example.com`.
3211    ///
3212    /// Sets the *site url* path property to the given value.
3213    ///
3214    /// Even though the property as already been set when instantiating this call,
3215    /// we provide this method for API completeness.
3216    pub fn site_url(mut self, new_value: &str) -> SiteDeleteCall<'a, C> {
3217        self._site_url = new_value.to_string();
3218        self
3219    }
3220    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3221    /// while executing the actual API request.
3222    ///
3223    /// ````text
3224    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3225    /// ````
3226    ///
3227    /// Sets the *delegate* property to the given value.
3228    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteDeleteCall<'a, C> {
3229        self._delegate = Some(new_value);
3230        self
3231    }
3232
3233    /// Set any additional parameter of the query string used in the request.
3234    /// It should be used to set parameters which are not yet available through their own
3235    /// setters.
3236    ///
3237    /// Please note that this method must not be used to set any of the known parameters
3238    /// which have their own setter method. If done anyway, the request will fail.
3239    ///
3240    /// # Additional Parameters
3241    ///
3242    /// * *$.xgafv* (query-string) - V1 error format.
3243    /// * *access_token* (query-string) - OAuth access token.
3244    /// * *alt* (query-string) - Data format for response.
3245    /// * *callback* (query-string) - JSONP
3246    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3247    /// * *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.
3248    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3249    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3250    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3251    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3252    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3253    pub fn param<T>(mut self, name: T, value: T) -> SiteDeleteCall<'a, C>
3254    where
3255        T: AsRef<str>,
3256    {
3257        self._additional_params
3258            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3259        self
3260    }
3261
3262    /// Identifies the authorization scope for the method you are building.
3263    ///
3264    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3265    /// [`Scope::Webmaster`].
3266    ///
3267    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3268    /// tokens for more than one scope.
3269    ///
3270    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3271    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3272    /// sufficient, a read-write scope will do as well.
3273    pub fn add_scope<St>(mut self, scope: St) -> SiteDeleteCall<'a, C>
3274    where
3275        St: AsRef<str>,
3276    {
3277        self._scopes.insert(String::from(scope.as_ref()));
3278        self
3279    }
3280    /// Identifies the authorization scope(s) for the method you are building.
3281    ///
3282    /// See [`Self::add_scope()`] for details.
3283    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteDeleteCall<'a, C>
3284    where
3285        I: IntoIterator<Item = St>,
3286        St: AsRef<str>,
3287    {
3288        self._scopes
3289            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3290        self
3291    }
3292
3293    /// Removes all scopes, and no default scope will be used either.
3294    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3295    /// for details).
3296    pub fn clear_scopes(mut self) -> SiteDeleteCall<'a, C> {
3297        self._scopes.clear();
3298        self
3299    }
3300}
3301
3302///  Retrieves information about specific site.
3303///
3304/// A builder for the *get* method supported by a *site* resource.
3305/// It is not used directly, but through a [`SiteMethods`] instance.
3306///
3307/// # Example
3308///
3309/// Instantiate a resource method builder
3310///
3311/// ```test_harness,no_run
3312/// # extern crate hyper;
3313/// # extern crate hyper_rustls;
3314/// # extern crate google_searchconsole1 as searchconsole1;
3315/// # async fn dox() {
3316/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3317///
3318/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3319/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3320/// #     secret,
3321/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3322/// # ).build().await.unwrap();
3323///
3324/// # let client = hyper_util::client::legacy::Client::builder(
3325/// #     hyper_util::rt::TokioExecutor::new()
3326/// # )
3327/// # .build(
3328/// #     hyper_rustls::HttpsConnectorBuilder::new()
3329/// #         .with_native_roots()
3330/// #         .unwrap()
3331/// #         .https_or_http()
3332/// #         .enable_http1()
3333/// #         .build()
3334/// # );
3335/// # let mut hub = SearchConsole::new(client, auth);
3336/// // You can configure optional parameters by calling the respective setters at will, and
3337/// // execute the final call using `doit()`.
3338/// // Values shown here are possibly random and not representative !
3339/// let result = hub.sites().get("siteUrl")
3340///              .doit().await;
3341/// # }
3342/// ```
3343pub struct SiteGetCall<'a, C>
3344where
3345    C: 'a,
3346{
3347    hub: &'a SearchConsole<C>,
3348    _site_url: String,
3349    _delegate: Option<&'a mut dyn common::Delegate>,
3350    _additional_params: HashMap<String, String>,
3351    _scopes: BTreeSet<String>,
3352}
3353
3354impl<'a, C> common::CallBuilder for SiteGetCall<'a, C> {}
3355
3356impl<'a, C> SiteGetCall<'a, C>
3357where
3358    C: common::Connector,
3359{
3360    /// Perform the operation you have build so far.
3361    pub async fn doit(mut self) -> common::Result<(common::Response, WmxSite)> {
3362        use std::borrow::Cow;
3363        use std::io::{Read, Seek};
3364
3365        use common::{url::Params, ToParts};
3366        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3367
3368        let mut dd = common::DefaultDelegate;
3369        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3370        dlg.begin(common::MethodInfo {
3371            id: "webmasters.sites.get",
3372            http_method: hyper::Method::GET,
3373        });
3374
3375        for &field in ["alt", "siteUrl"].iter() {
3376            if self._additional_params.contains_key(field) {
3377                dlg.finished(false);
3378                return Err(common::Error::FieldClash(field));
3379            }
3380        }
3381
3382        let mut params = Params::with_capacity(3 + self._additional_params.len());
3383        params.push("siteUrl", self._site_url);
3384
3385        params.extend(self._additional_params.iter());
3386
3387        params.push("alt", "json");
3388        let mut url = self.hub._base_url.clone() + "webmasters/v3/sites/{siteUrl}";
3389        if self._scopes.is_empty() {
3390            self._scopes
3391                .insert(Scope::WebmasterReadonly.as_ref().to_string());
3392        }
3393
3394        #[allow(clippy::single_element_loop)]
3395        for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
3396            url = params.uri_replacement(url, param_name, find_this, false);
3397        }
3398        {
3399            let to_remove = ["siteUrl"];
3400            params.remove_params(&to_remove);
3401        }
3402
3403        let url = params.parse_with_url(&url);
3404
3405        loop {
3406            let token = match self
3407                .hub
3408                .auth
3409                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3410                .await
3411            {
3412                Ok(token) => token,
3413                Err(e) => match dlg.token(e) {
3414                    Ok(token) => token,
3415                    Err(e) => {
3416                        dlg.finished(false);
3417                        return Err(common::Error::MissingToken(e));
3418                    }
3419                },
3420            };
3421            let mut req_result = {
3422                let client = &self.hub.client;
3423                dlg.pre_request();
3424                let mut req_builder = hyper::Request::builder()
3425                    .method(hyper::Method::GET)
3426                    .uri(url.as_str())
3427                    .header(USER_AGENT, self.hub._user_agent.clone());
3428
3429                if let Some(token) = token.as_ref() {
3430                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3431                }
3432
3433                let request = req_builder
3434                    .header(CONTENT_LENGTH, 0_u64)
3435                    .body(common::to_body::<String>(None));
3436
3437                client.request(request.unwrap()).await
3438            };
3439
3440            match req_result {
3441                Err(err) => {
3442                    if let common::Retry::After(d) = dlg.http_error(&err) {
3443                        sleep(d).await;
3444                        continue;
3445                    }
3446                    dlg.finished(false);
3447                    return Err(common::Error::HttpError(err));
3448                }
3449                Ok(res) => {
3450                    let (mut parts, body) = res.into_parts();
3451                    let mut body = common::Body::new(body);
3452                    if !parts.status.is_success() {
3453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3454                        let error = serde_json::from_str(&common::to_string(&bytes));
3455                        let response = common::to_response(parts, bytes.into());
3456
3457                        if let common::Retry::After(d) =
3458                            dlg.http_failure(&response, error.as_ref().ok())
3459                        {
3460                            sleep(d).await;
3461                            continue;
3462                        }
3463
3464                        dlg.finished(false);
3465
3466                        return Err(match error {
3467                            Ok(value) => common::Error::BadRequest(value),
3468                            _ => common::Error::Failure(response),
3469                        });
3470                    }
3471                    let response = {
3472                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3473                        let encoded = common::to_string(&bytes);
3474                        match serde_json::from_str(&encoded) {
3475                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3476                            Err(error) => {
3477                                dlg.response_json_decode_error(&encoded, &error);
3478                                return Err(common::Error::JsonDecodeError(
3479                                    encoded.to_string(),
3480                                    error,
3481                                ));
3482                            }
3483                        }
3484                    };
3485
3486                    dlg.finished(true);
3487                    return Ok(response);
3488                }
3489            }
3490        }
3491    }
3492
3493    /// The URI of the property as defined in Search Console. **Examples:** `http://www.example.com/` or `sc-domain:example.com`.
3494    ///
3495    /// Sets the *site url* path property to the given value.
3496    ///
3497    /// Even though the property as already been set when instantiating this call,
3498    /// we provide this method for API completeness.
3499    pub fn site_url(mut self, new_value: &str) -> SiteGetCall<'a, C> {
3500        self._site_url = new_value.to_string();
3501        self
3502    }
3503    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3504    /// while executing the actual API request.
3505    ///
3506    /// ````text
3507    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3508    /// ````
3509    ///
3510    /// Sets the *delegate* property to the given value.
3511    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteGetCall<'a, C> {
3512        self._delegate = Some(new_value);
3513        self
3514    }
3515
3516    /// Set any additional parameter of the query string used in the request.
3517    /// It should be used to set parameters which are not yet available through their own
3518    /// setters.
3519    ///
3520    /// Please note that this method must not be used to set any of the known parameters
3521    /// which have their own setter method. If done anyway, the request will fail.
3522    ///
3523    /// # Additional Parameters
3524    ///
3525    /// * *$.xgafv* (query-string) - V1 error format.
3526    /// * *access_token* (query-string) - OAuth access token.
3527    /// * *alt* (query-string) - Data format for response.
3528    /// * *callback* (query-string) - JSONP
3529    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3530    /// * *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.
3531    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3532    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3533    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3534    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3535    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3536    pub fn param<T>(mut self, name: T, value: T) -> SiteGetCall<'a, C>
3537    where
3538        T: AsRef<str>,
3539    {
3540        self._additional_params
3541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3542        self
3543    }
3544
3545    /// Identifies the authorization scope for the method you are building.
3546    ///
3547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3548    /// [`Scope::WebmasterReadonly`].
3549    ///
3550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3551    /// tokens for more than one scope.
3552    ///
3553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3555    /// sufficient, a read-write scope will do as well.
3556    pub fn add_scope<St>(mut self, scope: St) -> SiteGetCall<'a, C>
3557    where
3558        St: AsRef<str>,
3559    {
3560        self._scopes.insert(String::from(scope.as_ref()));
3561        self
3562    }
3563    /// Identifies the authorization scope(s) for the method you are building.
3564    ///
3565    /// See [`Self::add_scope()`] for details.
3566    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteGetCall<'a, C>
3567    where
3568        I: IntoIterator<Item = St>,
3569        St: AsRef<str>,
3570    {
3571        self._scopes
3572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3573        self
3574    }
3575
3576    /// Removes all scopes, and no default scope will be used either.
3577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3578    /// for details).
3579    pub fn clear_scopes(mut self) -> SiteGetCall<'a, C> {
3580        self._scopes.clear();
3581        self
3582    }
3583}
3584
3585///  Lists the user's Search Console sites.
3586///
3587/// A builder for the *list* method supported by a *site* resource.
3588/// It is not used directly, but through a [`SiteMethods`] instance.
3589///
3590/// # Example
3591///
3592/// Instantiate a resource method builder
3593///
3594/// ```test_harness,no_run
3595/// # extern crate hyper;
3596/// # extern crate hyper_rustls;
3597/// # extern crate google_searchconsole1 as searchconsole1;
3598/// # async fn dox() {
3599/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3600///
3601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3602/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3603/// #     secret,
3604/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3605/// # ).build().await.unwrap();
3606///
3607/// # let client = hyper_util::client::legacy::Client::builder(
3608/// #     hyper_util::rt::TokioExecutor::new()
3609/// # )
3610/// # .build(
3611/// #     hyper_rustls::HttpsConnectorBuilder::new()
3612/// #         .with_native_roots()
3613/// #         .unwrap()
3614/// #         .https_or_http()
3615/// #         .enable_http1()
3616/// #         .build()
3617/// # );
3618/// # let mut hub = SearchConsole::new(client, auth);
3619/// // You can configure optional parameters by calling the respective setters at will, and
3620/// // execute the final call using `doit()`.
3621/// // Values shown here are possibly random and not representative !
3622/// let result = hub.sites().list()
3623///              .doit().await;
3624/// # }
3625/// ```
3626pub struct SiteListCall<'a, C>
3627where
3628    C: 'a,
3629{
3630    hub: &'a SearchConsole<C>,
3631    _delegate: Option<&'a mut dyn common::Delegate>,
3632    _additional_params: HashMap<String, String>,
3633    _scopes: BTreeSet<String>,
3634}
3635
3636impl<'a, C> common::CallBuilder for SiteListCall<'a, C> {}
3637
3638impl<'a, C> SiteListCall<'a, C>
3639where
3640    C: common::Connector,
3641{
3642    /// Perform the operation you have build so far.
3643    pub async fn doit(mut self) -> common::Result<(common::Response, SitesListResponse)> {
3644        use std::borrow::Cow;
3645        use std::io::{Read, Seek};
3646
3647        use common::{url::Params, ToParts};
3648        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3649
3650        let mut dd = common::DefaultDelegate;
3651        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3652        dlg.begin(common::MethodInfo {
3653            id: "webmasters.sites.list",
3654            http_method: hyper::Method::GET,
3655        });
3656
3657        for &field in ["alt"].iter() {
3658            if self._additional_params.contains_key(field) {
3659                dlg.finished(false);
3660                return Err(common::Error::FieldClash(field));
3661            }
3662        }
3663
3664        let mut params = Params::with_capacity(2 + self._additional_params.len());
3665
3666        params.extend(self._additional_params.iter());
3667
3668        params.push("alt", "json");
3669        let mut url = self.hub._base_url.clone() + "webmasters/v3/sites";
3670        if self._scopes.is_empty() {
3671            self._scopes
3672                .insert(Scope::WebmasterReadonly.as_ref().to_string());
3673        }
3674
3675        let url = params.parse_with_url(&url);
3676
3677        loop {
3678            let token = match self
3679                .hub
3680                .auth
3681                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3682                .await
3683            {
3684                Ok(token) => token,
3685                Err(e) => match dlg.token(e) {
3686                    Ok(token) => token,
3687                    Err(e) => {
3688                        dlg.finished(false);
3689                        return Err(common::Error::MissingToken(e));
3690                    }
3691                },
3692            };
3693            let mut req_result = {
3694                let client = &self.hub.client;
3695                dlg.pre_request();
3696                let mut req_builder = hyper::Request::builder()
3697                    .method(hyper::Method::GET)
3698                    .uri(url.as_str())
3699                    .header(USER_AGENT, self.hub._user_agent.clone());
3700
3701                if let Some(token) = token.as_ref() {
3702                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3703                }
3704
3705                let request = req_builder
3706                    .header(CONTENT_LENGTH, 0_u64)
3707                    .body(common::to_body::<String>(None));
3708
3709                client.request(request.unwrap()).await
3710            };
3711
3712            match req_result {
3713                Err(err) => {
3714                    if let common::Retry::After(d) = dlg.http_error(&err) {
3715                        sleep(d).await;
3716                        continue;
3717                    }
3718                    dlg.finished(false);
3719                    return Err(common::Error::HttpError(err));
3720                }
3721                Ok(res) => {
3722                    let (mut parts, body) = res.into_parts();
3723                    let mut body = common::Body::new(body);
3724                    if !parts.status.is_success() {
3725                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3726                        let error = serde_json::from_str(&common::to_string(&bytes));
3727                        let response = common::to_response(parts, bytes.into());
3728
3729                        if let common::Retry::After(d) =
3730                            dlg.http_failure(&response, error.as_ref().ok())
3731                        {
3732                            sleep(d).await;
3733                            continue;
3734                        }
3735
3736                        dlg.finished(false);
3737
3738                        return Err(match error {
3739                            Ok(value) => common::Error::BadRequest(value),
3740                            _ => common::Error::Failure(response),
3741                        });
3742                    }
3743                    let response = {
3744                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3745                        let encoded = common::to_string(&bytes);
3746                        match serde_json::from_str(&encoded) {
3747                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3748                            Err(error) => {
3749                                dlg.response_json_decode_error(&encoded, &error);
3750                                return Err(common::Error::JsonDecodeError(
3751                                    encoded.to_string(),
3752                                    error,
3753                                ));
3754                            }
3755                        }
3756                    };
3757
3758                    dlg.finished(true);
3759                    return Ok(response);
3760                }
3761            }
3762        }
3763    }
3764
3765    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3766    /// while executing the actual API request.
3767    ///
3768    /// ````text
3769    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3770    /// ````
3771    ///
3772    /// Sets the *delegate* property to the given value.
3773    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteListCall<'a, C> {
3774        self._delegate = Some(new_value);
3775        self
3776    }
3777
3778    /// Set any additional parameter of the query string used in the request.
3779    /// It should be used to set parameters which are not yet available through their own
3780    /// setters.
3781    ///
3782    /// Please note that this method must not be used to set any of the known parameters
3783    /// which have their own setter method. If done anyway, the request will fail.
3784    ///
3785    /// # Additional Parameters
3786    ///
3787    /// * *$.xgafv* (query-string) - V1 error format.
3788    /// * *access_token* (query-string) - OAuth access token.
3789    /// * *alt* (query-string) - Data format for response.
3790    /// * *callback* (query-string) - JSONP
3791    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3792    /// * *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.
3793    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3794    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3795    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3796    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3797    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3798    pub fn param<T>(mut self, name: T, value: T) -> SiteListCall<'a, C>
3799    where
3800        T: AsRef<str>,
3801    {
3802        self._additional_params
3803            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3804        self
3805    }
3806
3807    /// Identifies the authorization scope for the method you are building.
3808    ///
3809    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3810    /// [`Scope::WebmasterReadonly`].
3811    ///
3812    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3813    /// tokens for more than one scope.
3814    ///
3815    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3816    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3817    /// sufficient, a read-write scope will do as well.
3818    pub fn add_scope<St>(mut self, scope: St) -> SiteListCall<'a, C>
3819    where
3820        St: AsRef<str>,
3821    {
3822        self._scopes.insert(String::from(scope.as_ref()));
3823        self
3824    }
3825    /// Identifies the authorization scope(s) for the method you are building.
3826    ///
3827    /// See [`Self::add_scope()`] for details.
3828    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteListCall<'a, C>
3829    where
3830        I: IntoIterator<Item = St>,
3831        St: AsRef<str>,
3832    {
3833        self._scopes
3834            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3835        self
3836    }
3837
3838    /// Removes all scopes, and no default scope will be used either.
3839    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3840    /// for details).
3841    pub fn clear_scopes(mut self) -> SiteListCall<'a, C> {
3842        self._scopes.clear();
3843        self
3844    }
3845}
3846
3847/// Index inspection.
3848///
3849/// A builder for the *index.inspect* method supported by a *urlInspection* resource.
3850/// It is not used directly, but through a [`UrlInspectionMethods`] instance.
3851///
3852/// # Example
3853///
3854/// Instantiate a resource method builder
3855///
3856/// ```test_harness,no_run
3857/// # extern crate hyper;
3858/// # extern crate hyper_rustls;
3859/// # extern crate google_searchconsole1 as searchconsole1;
3860/// use searchconsole1::api::InspectUrlIndexRequest;
3861/// # async fn dox() {
3862/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3863///
3864/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3866/// #     secret,
3867/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3868/// # ).build().await.unwrap();
3869///
3870/// # let client = hyper_util::client::legacy::Client::builder(
3871/// #     hyper_util::rt::TokioExecutor::new()
3872/// # )
3873/// # .build(
3874/// #     hyper_rustls::HttpsConnectorBuilder::new()
3875/// #         .with_native_roots()
3876/// #         .unwrap()
3877/// #         .https_or_http()
3878/// #         .enable_http1()
3879/// #         .build()
3880/// # );
3881/// # let mut hub = SearchConsole::new(client, auth);
3882/// // As the method needs a request, you would usually fill it with the desired information
3883/// // into the respective structure. Some of the parts shown here might not be applicable !
3884/// // Values shown here are possibly random and not representative !
3885/// let mut req = InspectUrlIndexRequest::default();
3886///
3887/// // You can configure optional parameters by calling the respective setters at will, and
3888/// // execute the final call using `doit()`.
3889/// // Values shown here are possibly random and not representative !
3890/// let result = hub.url_inspection().index_inspect(req)
3891///              .doit().await;
3892/// # }
3893/// ```
3894pub struct UrlInspectionIndexInspectCall<'a, C>
3895where
3896    C: 'a,
3897{
3898    hub: &'a SearchConsole<C>,
3899    _request: InspectUrlIndexRequest,
3900    _delegate: Option<&'a mut dyn common::Delegate>,
3901    _additional_params: HashMap<String, String>,
3902    _scopes: BTreeSet<String>,
3903}
3904
3905impl<'a, C> common::CallBuilder for UrlInspectionIndexInspectCall<'a, C> {}
3906
3907impl<'a, C> UrlInspectionIndexInspectCall<'a, C>
3908where
3909    C: common::Connector,
3910{
3911    /// Perform the operation you have build so far.
3912    pub async fn doit(mut self) -> common::Result<(common::Response, InspectUrlIndexResponse)> {
3913        use std::borrow::Cow;
3914        use std::io::{Read, Seek};
3915
3916        use common::{url::Params, ToParts};
3917        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3918
3919        let mut dd = common::DefaultDelegate;
3920        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3921        dlg.begin(common::MethodInfo {
3922            id: "searchconsole.urlInspection.index.inspect",
3923            http_method: hyper::Method::POST,
3924        });
3925
3926        for &field in ["alt"].iter() {
3927            if self._additional_params.contains_key(field) {
3928                dlg.finished(false);
3929                return Err(common::Error::FieldClash(field));
3930            }
3931        }
3932
3933        let mut params = Params::with_capacity(3 + self._additional_params.len());
3934
3935        params.extend(self._additional_params.iter());
3936
3937        params.push("alt", "json");
3938        let mut url = self.hub._base_url.clone() + "v1/urlInspection/index:inspect";
3939        if self._scopes.is_empty() {
3940            self._scopes.insert(Scope::Webmaster.as_ref().to_string());
3941        }
3942
3943        let url = params.parse_with_url(&url);
3944
3945        let mut json_mime_type = mime::APPLICATION_JSON;
3946        let mut request_value_reader = {
3947            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3948            common::remove_json_null_values(&mut value);
3949            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3950            serde_json::to_writer(&mut dst, &value).unwrap();
3951            dst
3952        };
3953        let request_size = request_value_reader
3954            .seek(std::io::SeekFrom::End(0))
3955            .unwrap();
3956        request_value_reader
3957            .seek(std::io::SeekFrom::Start(0))
3958            .unwrap();
3959
3960        loop {
3961            let token = match self
3962                .hub
3963                .auth
3964                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3965                .await
3966            {
3967                Ok(token) => token,
3968                Err(e) => match dlg.token(e) {
3969                    Ok(token) => token,
3970                    Err(e) => {
3971                        dlg.finished(false);
3972                        return Err(common::Error::MissingToken(e));
3973                    }
3974                },
3975            };
3976            request_value_reader
3977                .seek(std::io::SeekFrom::Start(0))
3978                .unwrap();
3979            let mut req_result = {
3980                let client = &self.hub.client;
3981                dlg.pre_request();
3982                let mut req_builder = hyper::Request::builder()
3983                    .method(hyper::Method::POST)
3984                    .uri(url.as_str())
3985                    .header(USER_AGENT, self.hub._user_agent.clone());
3986
3987                if let Some(token) = token.as_ref() {
3988                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3989                }
3990
3991                let request = req_builder
3992                    .header(CONTENT_TYPE, json_mime_type.to_string())
3993                    .header(CONTENT_LENGTH, request_size as u64)
3994                    .body(common::to_body(
3995                        request_value_reader.get_ref().clone().into(),
3996                    ));
3997
3998                client.request(request.unwrap()).await
3999            };
4000
4001            match req_result {
4002                Err(err) => {
4003                    if let common::Retry::After(d) = dlg.http_error(&err) {
4004                        sleep(d).await;
4005                        continue;
4006                    }
4007                    dlg.finished(false);
4008                    return Err(common::Error::HttpError(err));
4009                }
4010                Ok(res) => {
4011                    let (mut parts, body) = res.into_parts();
4012                    let mut body = common::Body::new(body);
4013                    if !parts.status.is_success() {
4014                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4015                        let error = serde_json::from_str(&common::to_string(&bytes));
4016                        let response = common::to_response(parts, bytes.into());
4017
4018                        if let common::Retry::After(d) =
4019                            dlg.http_failure(&response, error.as_ref().ok())
4020                        {
4021                            sleep(d).await;
4022                            continue;
4023                        }
4024
4025                        dlg.finished(false);
4026
4027                        return Err(match error {
4028                            Ok(value) => common::Error::BadRequest(value),
4029                            _ => common::Error::Failure(response),
4030                        });
4031                    }
4032                    let response = {
4033                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4034                        let encoded = common::to_string(&bytes);
4035                        match serde_json::from_str(&encoded) {
4036                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4037                            Err(error) => {
4038                                dlg.response_json_decode_error(&encoded, &error);
4039                                return Err(common::Error::JsonDecodeError(
4040                                    encoded.to_string(),
4041                                    error,
4042                                ));
4043                            }
4044                        }
4045                    };
4046
4047                    dlg.finished(true);
4048                    return Ok(response);
4049                }
4050            }
4051        }
4052    }
4053
4054    ///
4055    /// Sets the *request* property to the given value.
4056    ///
4057    /// Even though the property as already been set when instantiating this call,
4058    /// we provide this method for API completeness.
4059    pub fn request(
4060        mut self,
4061        new_value: InspectUrlIndexRequest,
4062    ) -> UrlInspectionIndexInspectCall<'a, C> {
4063        self._request = new_value;
4064        self
4065    }
4066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4067    /// while executing the actual API request.
4068    ///
4069    /// ````text
4070    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4071    /// ````
4072    ///
4073    /// Sets the *delegate* property to the given value.
4074    pub fn delegate(
4075        mut self,
4076        new_value: &'a mut dyn common::Delegate,
4077    ) -> UrlInspectionIndexInspectCall<'a, C> {
4078        self._delegate = Some(new_value);
4079        self
4080    }
4081
4082    /// Set any additional parameter of the query string used in the request.
4083    /// It should be used to set parameters which are not yet available through their own
4084    /// setters.
4085    ///
4086    /// Please note that this method must not be used to set any of the known parameters
4087    /// which have their own setter method. If done anyway, the request will fail.
4088    ///
4089    /// # Additional Parameters
4090    ///
4091    /// * *$.xgafv* (query-string) - V1 error format.
4092    /// * *access_token* (query-string) - OAuth access token.
4093    /// * *alt* (query-string) - Data format for response.
4094    /// * *callback* (query-string) - JSONP
4095    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4096    /// * *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.
4097    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4098    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4099    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4100    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4101    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4102    pub fn param<T>(mut self, name: T, value: T) -> UrlInspectionIndexInspectCall<'a, C>
4103    where
4104        T: AsRef<str>,
4105    {
4106        self._additional_params
4107            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4108        self
4109    }
4110
4111    /// Identifies the authorization scope for the method you are building.
4112    ///
4113    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4114    /// [`Scope::Webmaster`].
4115    ///
4116    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4117    /// tokens for more than one scope.
4118    ///
4119    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4120    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4121    /// sufficient, a read-write scope will do as well.
4122    pub fn add_scope<St>(mut self, scope: St) -> UrlInspectionIndexInspectCall<'a, C>
4123    where
4124        St: AsRef<str>,
4125    {
4126        self._scopes.insert(String::from(scope.as_ref()));
4127        self
4128    }
4129    /// Identifies the authorization scope(s) for the method you are building.
4130    ///
4131    /// See [`Self::add_scope()`] for details.
4132    pub fn add_scopes<I, St>(mut self, scopes: I) -> UrlInspectionIndexInspectCall<'a, C>
4133    where
4134        I: IntoIterator<Item = St>,
4135        St: AsRef<str>,
4136    {
4137        self._scopes
4138            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4139        self
4140    }
4141
4142    /// Removes all scopes, and no default scope will be used either.
4143    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4144    /// for details).
4145    pub fn clear_scopes(mut self) -> UrlInspectionIndexInspectCall<'a, C> {
4146        self._scopes.clear();
4147        self
4148    }
4149}
4150
4151/// Runs Mobile-Friendly Test for a given URL.
4152///
4153/// A builder for the *mobileFriendlyTest.run* method supported by a *urlTestingTool* resource.
4154/// It is not used directly, but through a [`UrlTestingToolMethods`] instance.
4155///
4156/// # Example
4157///
4158/// Instantiate a resource method builder
4159///
4160/// ```test_harness,no_run
4161/// # extern crate hyper;
4162/// # extern crate hyper_rustls;
4163/// # extern crate google_searchconsole1 as searchconsole1;
4164/// use searchconsole1::api::RunMobileFriendlyTestRequest;
4165/// # async fn dox() {
4166/// # use searchconsole1::{SearchConsole, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4167///
4168/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4170/// #     secret,
4171/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4172/// # ).build().await.unwrap();
4173///
4174/// # let client = hyper_util::client::legacy::Client::builder(
4175/// #     hyper_util::rt::TokioExecutor::new()
4176/// # )
4177/// # .build(
4178/// #     hyper_rustls::HttpsConnectorBuilder::new()
4179/// #         .with_native_roots()
4180/// #         .unwrap()
4181/// #         .https_or_http()
4182/// #         .enable_http1()
4183/// #         .build()
4184/// # );
4185/// # let mut hub = SearchConsole::new(client, auth);
4186/// // As the method needs a request, you would usually fill it with the desired information
4187/// // into the respective structure. Some of the parts shown here might not be applicable !
4188/// // Values shown here are possibly random and not representative !
4189/// let mut req = RunMobileFriendlyTestRequest::default();
4190///
4191/// // You can configure optional parameters by calling the respective setters at will, and
4192/// // execute the final call using `doit()`.
4193/// // Values shown here are possibly random and not representative !
4194/// let result = hub.url_testing_tools().mobile_friendly_test_run(req)
4195///              .doit().await;
4196/// # }
4197/// ```
4198pub struct UrlTestingToolMobileFriendlyTestRunCall<'a, C>
4199where
4200    C: 'a,
4201{
4202    hub: &'a SearchConsole<C>,
4203    _request: RunMobileFriendlyTestRequest,
4204    _delegate: Option<&'a mut dyn common::Delegate>,
4205    _additional_params: HashMap<String, String>,
4206}
4207
4208impl<'a, C> common::CallBuilder for UrlTestingToolMobileFriendlyTestRunCall<'a, C> {}
4209
4210impl<'a, C> UrlTestingToolMobileFriendlyTestRunCall<'a, C>
4211where
4212    C: common::Connector,
4213{
4214    /// Perform the operation you have build so far.
4215    pub async fn doit(
4216        mut self,
4217    ) -> common::Result<(common::Response, RunMobileFriendlyTestResponse)> {
4218        use std::borrow::Cow;
4219        use std::io::{Read, Seek};
4220
4221        use common::{url::Params, ToParts};
4222        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4223
4224        let mut dd = common::DefaultDelegate;
4225        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4226        dlg.begin(common::MethodInfo {
4227            id: "searchconsole.urlTestingTools.mobileFriendlyTest.run",
4228            http_method: hyper::Method::POST,
4229        });
4230
4231        for &field in ["alt"].iter() {
4232            if self._additional_params.contains_key(field) {
4233                dlg.finished(false);
4234                return Err(common::Error::FieldClash(field));
4235            }
4236        }
4237
4238        let mut params = Params::with_capacity(3 + self._additional_params.len());
4239
4240        params.extend(self._additional_params.iter());
4241
4242        params.push("alt", "json");
4243        let mut url = self.hub._base_url.clone() + "v1/urlTestingTools/mobileFriendlyTest:run";
4244
4245        match dlg.api_key() {
4246            Some(value) => params.push("key", value),
4247            None => {
4248                dlg.finished(false);
4249                return Err(common::Error::MissingAPIKey);
4250            }
4251        }
4252
4253        let url = params.parse_with_url(&url);
4254
4255        let mut json_mime_type = mime::APPLICATION_JSON;
4256        let mut request_value_reader = {
4257            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4258            common::remove_json_null_values(&mut value);
4259            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4260            serde_json::to_writer(&mut dst, &value).unwrap();
4261            dst
4262        };
4263        let request_size = request_value_reader
4264            .seek(std::io::SeekFrom::End(0))
4265            .unwrap();
4266        request_value_reader
4267            .seek(std::io::SeekFrom::Start(0))
4268            .unwrap();
4269
4270        loop {
4271            request_value_reader
4272                .seek(std::io::SeekFrom::Start(0))
4273                .unwrap();
4274            let mut req_result = {
4275                let client = &self.hub.client;
4276                dlg.pre_request();
4277                let mut req_builder = hyper::Request::builder()
4278                    .method(hyper::Method::POST)
4279                    .uri(url.as_str())
4280                    .header(USER_AGENT, self.hub._user_agent.clone());
4281
4282                let request = req_builder
4283                    .header(CONTENT_TYPE, json_mime_type.to_string())
4284                    .header(CONTENT_LENGTH, request_size as u64)
4285                    .body(common::to_body(
4286                        request_value_reader.get_ref().clone().into(),
4287                    ));
4288
4289                client.request(request.unwrap()).await
4290            };
4291
4292            match req_result {
4293                Err(err) => {
4294                    if let common::Retry::After(d) = dlg.http_error(&err) {
4295                        sleep(d).await;
4296                        continue;
4297                    }
4298                    dlg.finished(false);
4299                    return Err(common::Error::HttpError(err));
4300                }
4301                Ok(res) => {
4302                    let (mut parts, body) = res.into_parts();
4303                    let mut body = common::Body::new(body);
4304                    if !parts.status.is_success() {
4305                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4306                        let error = serde_json::from_str(&common::to_string(&bytes));
4307                        let response = common::to_response(parts, bytes.into());
4308
4309                        if let common::Retry::After(d) =
4310                            dlg.http_failure(&response, error.as_ref().ok())
4311                        {
4312                            sleep(d).await;
4313                            continue;
4314                        }
4315
4316                        dlg.finished(false);
4317
4318                        return Err(match error {
4319                            Ok(value) => common::Error::BadRequest(value),
4320                            _ => common::Error::Failure(response),
4321                        });
4322                    }
4323                    let response = {
4324                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4325                        let encoded = common::to_string(&bytes);
4326                        match serde_json::from_str(&encoded) {
4327                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4328                            Err(error) => {
4329                                dlg.response_json_decode_error(&encoded, &error);
4330                                return Err(common::Error::JsonDecodeError(
4331                                    encoded.to_string(),
4332                                    error,
4333                                ));
4334                            }
4335                        }
4336                    };
4337
4338                    dlg.finished(true);
4339                    return Ok(response);
4340                }
4341            }
4342        }
4343    }
4344
4345    ///
4346    /// Sets the *request* property to the given value.
4347    ///
4348    /// Even though the property as already been set when instantiating this call,
4349    /// we provide this method for API completeness.
4350    pub fn request(
4351        mut self,
4352        new_value: RunMobileFriendlyTestRequest,
4353    ) -> UrlTestingToolMobileFriendlyTestRunCall<'a, C> {
4354        self._request = new_value;
4355        self
4356    }
4357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4358    /// while executing the actual API request.
4359    ///
4360    /// ````text
4361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4362    /// ````
4363    ///
4364    /// Sets the *delegate* property to the given value.
4365    pub fn delegate(
4366        mut self,
4367        new_value: &'a mut dyn common::Delegate,
4368    ) -> UrlTestingToolMobileFriendlyTestRunCall<'a, C> {
4369        self._delegate = Some(new_value);
4370        self
4371    }
4372
4373    /// Set any additional parameter of the query string used in the request.
4374    /// It should be used to set parameters which are not yet available through their own
4375    /// setters.
4376    ///
4377    /// Please note that this method must not be used to set any of the known parameters
4378    /// which have their own setter method. If done anyway, the request will fail.
4379    ///
4380    /// # Additional Parameters
4381    ///
4382    /// * *$.xgafv* (query-string) - V1 error format.
4383    /// * *access_token* (query-string) - OAuth access token.
4384    /// * *alt* (query-string) - Data format for response.
4385    /// * *callback* (query-string) - JSONP
4386    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4387    /// * *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.
4388    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4389    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4390    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4391    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4392    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4393    pub fn param<T>(mut self, name: T, value: T) -> UrlTestingToolMobileFriendlyTestRunCall<'a, C>
4394    where
4395        T: AsRef<str>,
4396    {
4397        self._additional_params
4398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4399        self
4400    }
4401}