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