google_webmasters3/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 Full,
18
19 /// View Search Console data for your verified sites
20 Readonly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/webmasters",
27 Scope::Readonly => "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::Readonly
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Webmasters 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_webmasters3 as webmasters3;
53/// use webmasters3::api::SearchAnalyticsQueryRequest;
54/// use webmasters3::{Result, Error};
55/// # async fn dox() {
56/// use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67/// secret,
68/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72/// hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75/// hyper_rustls::HttpsConnectorBuilder::new()
76/// .with_native_roots()
77/// .unwrap()
78/// .https_or_http()
79/// .enable_http1()
80/// .build()
81/// );
82/// let mut hub = Webmasters::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = SearchAnalyticsQueryRequest::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.searchanalytics().query(req, "siteUrl")
92/// .doit().await;
93///
94/// match result {
95/// Err(e) => match e {
96/// // The Error enum provides details about what exactly happened.
97/// // You can also just use its `Debug`, `Display` or `Error` traits
98/// Error::HttpError(_)
99/// |Error::Io(_)
100/// |Error::MissingAPIKey
101/// |Error::MissingToken(_)
102/// |Error::Cancelled
103/// |Error::UploadSizeLimitExceeded(_, _)
104/// |Error::Failure(_)
105/// |Error::BadRequest(_)
106/// |Error::FieldClash(_)
107/// |Error::JsonDecodeError(_, _) => println!("{}", e),
108/// },
109/// Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct Webmasters<C> {
115 pub client: common::Client<C>,
116 pub auth: Box<dyn common::GetToken>,
117 _user_agent: String,
118 _base_url: String,
119 _root_url: String,
120}
121
122impl<C> common::Hub for Webmasters<C> {}
123
124impl<'a, C> Webmasters<C> {
125 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Webmasters<C> {
126 Webmasters {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://www.googleapis.com/webmasters/v3/".to_string(),
131 _root_url: "https://www.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn searchanalytics(&'a self) -> SearchanalyticMethods<'a, C> {
136 SearchanalyticMethods { hub: self }
137 }
138 pub fn sitemaps(&'a self) -> SitemapMethods<'a, C> {
139 SitemapMethods { hub: self }
140 }
141 pub fn sites(&'a self) -> SiteMethods<'a, C> {
142 SiteMethods { hub: self }
143 }
144
145 /// Set the user-agent header field to use in all requests to the server.
146 /// It defaults to `google-api-rust-client/6.0.0`.
147 ///
148 /// Returns the previously set user-agent.
149 pub fn user_agent(&mut self, agent_name: String) -> String {
150 std::mem::replace(&mut self._user_agent, agent_name)
151 }
152
153 /// Set the base url to use in all requests to the server.
154 /// It defaults to `https://www.googleapis.com/webmasters/v3/`.
155 ///
156 /// Returns the previously set base url.
157 pub fn base_url(&mut self, new_base_url: String) -> String {
158 std::mem::replace(&mut self._base_url, new_base_url)
159 }
160
161 /// Set the root url to use in all requests to the server.
162 /// It defaults to `https://www.googleapis.com/`.
163 ///
164 /// Returns the previously set root url.
165 pub fn root_url(&mut self, new_root_url: String) -> String {
166 std::mem::replace(&mut self._root_url, new_root_url)
167 }
168}
169
170// ############
171// SCHEMAS ###
172// ##########
173/// There is no detailed description.
174///
175/// This type is not used in any activity, and only used as *part* of another schema.
176///
177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
178#[serde_with::serde_as]
179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
180pub struct ApiDataRow {
181 /// no description provided
182 pub clicks: Option<f64>,
183 /// no description provided
184 pub ctr: Option<f64>,
185 /// no description provided
186 pub impressions: Option<f64>,
187 /// no description provided
188 pub keys: Option<Vec<String>>,
189 /// no description provided
190 pub position: Option<f64>,
191}
192
193impl common::Part for ApiDataRow {}
194
195/// There is no detailed description.
196///
197/// This type is not used in any activity, and only used as *part* of another schema.
198///
199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
200#[serde_with::serde_as]
201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
202pub struct ApiDimensionFilter {
203 /// no description provided
204 pub dimension: Option<String>,
205 /// no description provided
206 pub expression: Option<String>,
207 /// no description provided
208 pub operator: Option<String>,
209}
210
211impl common::Part for ApiDimensionFilter {}
212
213/// There is no detailed description.
214///
215/// This type is not used in any activity, and only used as *part* of another schema.
216///
217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
218#[serde_with::serde_as]
219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
220pub struct ApiDimensionFilterGroup {
221 /// no description provided
222 pub filters: Option<Vec<ApiDimensionFilter>>,
223 /// no description provided
224 #[serde(rename = "groupType")]
225 pub group_type: Option<String>,
226}
227
228impl common::Part for ApiDimensionFilterGroup {}
229
230/// There is no detailed description.
231///
232/// # Activities
233///
234/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
235/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
236///
237/// * [query searchanalytics](SearchanalyticQueryCall) (request)
238#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
239#[serde_with::serde_as]
240#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
241pub struct SearchAnalyticsQueryRequest {
242 /// [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.
243 ///
244 /// Note: If you group or filter by page, you cannot aggregate by property.
245 ///
246 /// 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.
247 #[serde(rename = "aggregationType")]
248 pub aggregation_type: Option<String>,
249 /// [Optional] If "all" (case-insensitive), data will include fresh data. If "final" (case-insensitive) or if this parameter is omitted, the returned data will include only finalized data.
250 #[serde(rename = "dataState")]
251 pub data_state: Option<String>,
252 /// [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.
253 #[serde(rename = "dimensionFilterGroups")]
254 pub dimension_filter_groups: Option<Vec<ApiDimensionFilterGroup>>,
255 /// [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.
256 pub dimensions: Option<Vec<String>>,
257 /// [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.
258 #[serde(rename = "endDate")]
259 pub end_date: Option<String>,
260 /// [Optional; Default is 1000] The maximum number of rows to return. Must be a number from 1 to 5,000 (inclusive).
261 #[serde(rename = "rowLimit")]
262 pub row_limit: Option<i32>,
263 /// [Optional; Default is "web"] The search type to filter for.
264 #[serde(rename = "searchType")]
265 pub search_type: Option<String>,
266 /// [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.
267 #[serde(rename = "startDate")]
268 pub start_date: Option<String>,
269 /// [Optional; Default is 0] Zero-based index of the first row in the response. Must be a non-negative number.
270 #[serde(rename = "startRow")]
271 pub start_row: Option<i32>,
272}
273
274impl common::RequestValue for SearchAnalyticsQueryRequest {}
275
276/// 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.
277///
278/// # Activities
279///
280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
282///
283/// * [query searchanalytics](SearchanalyticQueryCall) (response)
284#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
285#[serde_with::serde_as]
286#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
287pub struct SearchAnalyticsQueryResponse {
288 /// How the results were aggregated.
289 #[serde(rename = "responseAggregationType")]
290 pub response_aggregation_type: Option<String>,
291 /// A list of rows grouped by the key values in the order given in the query.
292 pub rows: Option<Vec<ApiDataRow>>,
293}
294
295impl common::ResponseResult for SearchAnalyticsQueryResponse {}
296
297/// List of sitemaps.
298///
299/// # Activities
300///
301/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
302/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
303///
304/// * [list sitemaps](SitemapListCall) (response)
305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
306#[serde_with::serde_as]
307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
308pub struct SitemapsListResponse {
309 /// Contains detailed information about a specific URL submitted as a sitemap.
310 pub sitemap: Option<Vec<WmxSitemap>>,
311}
312
313impl common::ResponseResult for SitemapsListResponse {}
314
315/// List of sites with access level information.
316///
317/// # Activities
318///
319/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
320/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
321///
322/// * [list sites](SiteListCall) (response)
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct SitesListResponse {
327 /// Contains permission level information about a Search Console site. For more information, see Permissions in Search Console.
328 #[serde(rename = "siteEntry")]
329 pub site_entry: Option<Vec<WmxSite>>,
330}
331
332impl common::ResponseResult for SitesListResponse {}
333
334/// Contains permission level information about a Search Console site. For more information, see Permissions in Search Console.
335///
336/// # Activities
337///
338/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
339/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
340///
341/// * [get sites](SiteGetCall) (response)
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct WmxSite {
346 /// The user's permission level for the site.
347 #[serde(rename = "permissionLevel")]
348 pub permission_level: Option<String>,
349 /// The URL of the site.
350 #[serde(rename = "siteUrl")]
351 pub site_url: Option<String>,
352}
353
354impl common::ResponseResult for WmxSite {}
355
356/// Contains detailed information about a specific URL submitted as a sitemap.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [get sitemaps](SitemapGetCall) (response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct WmxSitemap {
368 /// The various content types in the sitemap.
369 pub contents: Option<Vec<WmxSitemapContent>>,
370 /// Number of errors in the sitemap. These are issues with the sitemap itself that need to be fixed before it can be processed correctly.
371 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
372 pub errors: Option<i64>,
373 /// If true, the sitemap has not been processed.
374 #[serde(rename = "isPending")]
375 pub is_pending: Option<bool>,
376 /// If true, the sitemap is a collection of sitemaps.
377 #[serde(rename = "isSitemapsIndex")]
378 pub is_sitemaps_index: Option<bool>,
379 /// Date & time in which this sitemap was last downloaded. Date format is in RFC 3339 format (yyyy-mm-dd).
380 #[serde(rename = "lastDownloaded")]
381 pub last_downloaded: Option<chrono::DateTime<chrono::offset::Utc>>,
382 /// Date & time in which this sitemap was submitted. Date format is in RFC 3339 format (yyyy-mm-dd).
383 #[serde(rename = "lastSubmitted")]
384 pub last_submitted: Option<chrono::DateTime<chrono::offset::Utc>>,
385 /// The url of the sitemap.
386 pub path: Option<String>,
387 /// The type of the sitemap. For example: rssFeed.
388 #[serde(rename = "type")]
389 pub type_: Option<String>,
390 /// Number of warnings for the sitemap. These are generally non-critical issues with URLs in the sitemaps.
391 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
392 pub warnings: Option<i64>,
393}
394
395impl common::ResponseResult for WmxSitemap {}
396
397/// Information about the various content types in the sitemap.
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct WmxSitemapContent {
405 /// The number of URLs from the sitemap that were indexed (of the content type).
406 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
407 pub indexed: Option<i64>,
408 /// The number of URLs in the sitemap (of the content type).
409 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
410 pub submitted: Option<i64>,
411 /// The specific type of content in this sitemap. For example: web.
412 #[serde(rename = "type")]
413 pub type_: Option<String>,
414}
415
416impl common::Part for WmxSitemapContent {}
417
418// ###################
419// MethodBuilders ###
420// #################
421
422/// A builder providing access to all methods supported on *searchanalytic* resources.
423/// It is not used directly, but through the [`Webmasters`] hub.
424///
425/// # Example
426///
427/// Instantiate a resource builder
428///
429/// ```test_harness,no_run
430/// extern crate hyper;
431/// extern crate hyper_rustls;
432/// extern crate google_webmasters3 as webmasters3;
433///
434/// # async fn dox() {
435/// use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
436///
437/// let secret: yup_oauth2::ApplicationSecret = Default::default();
438/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
439/// secret,
440/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
441/// ).build().await.unwrap();
442///
443/// let client = hyper_util::client::legacy::Client::builder(
444/// hyper_util::rt::TokioExecutor::new()
445/// )
446/// .build(
447/// hyper_rustls::HttpsConnectorBuilder::new()
448/// .with_native_roots()
449/// .unwrap()
450/// .https_or_http()
451/// .enable_http1()
452/// .build()
453/// );
454/// let mut hub = Webmasters::new(client, auth);
455/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
456/// // like `query(...)`
457/// // to build up your call.
458/// let rb = hub.searchanalytics();
459/// # }
460/// ```
461pub struct SearchanalyticMethods<'a, C>
462where
463 C: 'a,
464{
465 hub: &'a Webmasters<C>,
466}
467
468impl<'a, C> common::MethodsBuilder for SearchanalyticMethods<'a, C> {}
469
470impl<'a, C> SearchanalyticMethods<'a, C> {
471 /// Create a builder to help you perform the following task:
472 ///
473 /// 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.
474 ///
475 /// 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.
476 ///
477 /// # Arguments
478 ///
479 /// * `request` - No description provided.
480 /// * `siteUrl` - The site's URL, including protocol. For example: http://www.example.com/
481 pub fn query(
482 &self,
483 request: SearchAnalyticsQueryRequest,
484 site_url: &str,
485 ) -> SearchanalyticQueryCall<'a, C> {
486 SearchanalyticQueryCall {
487 hub: self.hub,
488 _request: request,
489 _site_url: site_url.to_string(),
490 _delegate: Default::default(),
491 _additional_params: Default::default(),
492 _scopes: Default::default(),
493 }
494 }
495}
496
497/// A builder providing access to all methods supported on *sitemap* resources.
498/// It is not used directly, but through the [`Webmasters`] hub.
499///
500/// # Example
501///
502/// Instantiate a resource builder
503///
504/// ```test_harness,no_run
505/// extern crate hyper;
506/// extern crate hyper_rustls;
507/// extern crate google_webmasters3 as webmasters3;
508///
509/// # async fn dox() {
510/// use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
511///
512/// let secret: yup_oauth2::ApplicationSecret = Default::default();
513/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
514/// secret,
515/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
516/// ).build().await.unwrap();
517///
518/// let client = hyper_util::client::legacy::Client::builder(
519/// hyper_util::rt::TokioExecutor::new()
520/// )
521/// .build(
522/// hyper_rustls::HttpsConnectorBuilder::new()
523/// .with_native_roots()
524/// .unwrap()
525/// .https_or_http()
526/// .enable_http1()
527/// .build()
528/// );
529/// let mut hub = Webmasters::new(client, auth);
530/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
531/// // like `delete(...)`, `get(...)`, `list(...)` and `submit(...)`
532/// // to build up your call.
533/// let rb = hub.sitemaps();
534/// # }
535/// ```
536pub struct SitemapMethods<'a, C>
537where
538 C: 'a,
539{
540 hub: &'a Webmasters<C>,
541}
542
543impl<'a, C> common::MethodsBuilder for SitemapMethods<'a, C> {}
544
545impl<'a, C> SitemapMethods<'a, C> {
546 /// Create a builder to help you perform the following task:
547 ///
548 /// Deletes a sitemap from this site.
549 ///
550 /// # Arguments
551 ///
552 /// * `siteUrl` - The site's URL, including protocol. For example: http://www.example.com/
553 /// * `feedpath` - The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml
554 pub fn delete(&self, site_url: &str, feedpath: &str) -> SitemapDeleteCall<'a, C> {
555 SitemapDeleteCall {
556 hub: self.hub,
557 _site_url: site_url.to_string(),
558 _feedpath: feedpath.to_string(),
559 _delegate: Default::default(),
560 _additional_params: Default::default(),
561 _scopes: Default::default(),
562 }
563 }
564
565 /// Create a builder to help you perform the following task:
566 ///
567 /// Retrieves information about a specific sitemap.
568 ///
569 /// # Arguments
570 ///
571 /// * `siteUrl` - The site's URL, including protocol. For example: http://www.example.com/
572 /// * `feedpath` - The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml
573 pub fn get(&self, site_url: &str, feedpath: &str) -> SitemapGetCall<'a, C> {
574 SitemapGetCall {
575 hub: self.hub,
576 _site_url: site_url.to_string(),
577 _feedpath: feedpath.to_string(),
578 _delegate: Default::default(),
579 _additional_params: Default::default(),
580 _scopes: Default::default(),
581 }
582 }
583
584 /// Create a builder to help you perform the following task:
585 ///
586 /// Lists the sitemaps-entries submitted for this site, or included in the sitemap index file (if sitemapIndex is specified in the request).
587 ///
588 /// # Arguments
589 ///
590 /// * `siteUrl` - The site's URL, including protocol. For example: http://www.example.com/
591 pub fn list(&self, site_url: &str) -> SitemapListCall<'a, C> {
592 SitemapListCall {
593 hub: self.hub,
594 _site_url: site_url.to_string(),
595 _sitemap_index: Default::default(),
596 _delegate: Default::default(),
597 _additional_params: Default::default(),
598 _scopes: Default::default(),
599 }
600 }
601
602 /// Create a builder to help you perform the following task:
603 ///
604 /// Submits a sitemap for a site.
605 ///
606 /// # Arguments
607 ///
608 /// * `siteUrl` - The site's URL, including protocol. For example: http://www.example.com/
609 /// * `feedpath` - The URL of the sitemap to add. For example: http://www.example.com/sitemap.xml
610 pub fn submit(&self, site_url: &str, feedpath: &str) -> SitemapSubmitCall<'a, C> {
611 SitemapSubmitCall {
612 hub: self.hub,
613 _site_url: site_url.to_string(),
614 _feedpath: feedpath.to_string(),
615 _delegate: Default::default(),
616 _additional_params: Default::default(),
617 _scopes: Default::default(),
618 }
619 }
620}
621
622/// A builder providing access to all methods supported on *site* resources.
623/// It is not used directly, but through the [`Webmasters`] hub.
624///
625/// # Example
626///
627/// Instantiate a resource builder
628///
629/// ```test_harness,no_run
630/// extern crate hyper;
631/// extern crate hyper_rustls;
632/// extern crate google_webmasters3 as webmasters3;
633///
634/// # async fn dox() {
635/// use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
636///
637/// let secret: yup_oauth2::ApplicationSecret = Default::default();
638/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
639/// secret,
640/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
641/// ).build().await.unwrap();
642///
643/// let client = hyper_util::client::legacy::Client::builder(
644/// hyper_util::rt::TokioExecutor::new()
645/// )
646/// .build(
647/// hyper_rustls::HttpsConnectorBuilder::new()
648/// .with_native_roots()
649/// .unwrap()
650/// .https_or_http()
651/// .enable_http1()
652/// .build()
653/// );
654/// let mut hub = Webmasters::new(client, auth);
655/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
656/// // like `add(...)`, `delete(...)`, `get(...)` and `list(...)`
657/// // to build up your call.
658/// let rb = hub.sites();
659/// # }
660/// ```
661pub struct SiteMethods<'a, C>
662where
663 C: 'a,
664{
665 hub: &'a Webmasters<C>,
666}
667
668impl<'a, C> common::MethodsBuilder for SiteMethods<'a, C> {}
669
670impl<'a, C> SiteMethods<'a, C> {
671 /// Create a builder to help you perform the following task:
672 ///
673 /// Adds a site to the set of the user's sites in Search Console.
674 ///
675 /// # Arguments
676 ///
677 /// * `siteUrl` - The URL of the site to add.
678 pub fn add(&self, site_url: &str) -> SiteAddCall<'a, C> {
679 SiteAddCall {
680 hub: self.hub,
681 _site_url: site_url.to_string(),
682 _delegate: Default::default(),
683 _additional_params: Default::default(),
684 _scopes: Default::default(),
685 }
686 }
687
688 /// Create a builder to help you perform the following task:
689 ///
690 /// Removes a site from the set of the user's Search Console sites.
691 ///
692 /// # Arguments
693 ///
694 /// * `siteUrl` - The URI of the property as defined in Search Console. Examples: http://www.example.com/ or android-app://com.example/ Note: for property-sets, use the URI that starts with sc-set: which is used in Search Console URLs.
695 pub fn delete(&self, site_url: &str) -> SiteDeleteCall<'a, C> {
696 SiteDeleteCall {
697 hub: self.hub,
698 _site_url: site_url.to_string(),
699 _delegate: Default::default(),
700 _additional_params: Default::default(),
701 _scopes: Default::default(),
702 }
703 }
704
705 /// Create a builder to help you perform the following task:
706 ///
707 /// Retrieves information about specific site.
708 ///
709 /// # Arguments
710 ///
711 /// * `siteUrl` - The URI of the property as defined in Search Console. Examples: http://www.example.com/ or android-app://com.example/ Note: for property-sets, use the URI that starts with sc-set: which is used in Search Console URLs.
712 pub fn get(&self, site_url: &str) -> SiteGetCall<'a, C> {
713 SiteGetCall {
714 hub: self.hub,
715 _site_url: site_url.to_string(),
716 _delegate: Default::default(),
717 _additional_params: Default::default(),
718 _scopes: Default::default(),
719 }
720 }
721
722 /// Create a builder to help you perform the following task:
723 ///
724 /// Lists the user's Search Console sites.
725 pub fn list(&self) -> SiteListCall<'a, C> {
726 SiteListCall {
727 hub: self.hub,
728 _delegate: Default::default(),
729 _additional_params: Default::default(),
730 _scopes: Default::default(),
731 }
732 }
733}
734
735// ###################
736// CallBuilders ###
737// #################
738
739/// 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.
740///
741/// 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.
742///
743/// A builder for the *query* method supported by a *searchanalytic* resource.
744/// It is not used directly, but through a [`SearchanalyticMethods`] instance.
745///
746/// # Example
747///
748/// Instantiate a resource method builder
749///
750/// ```test_harness,no_run
751/// # extern crate hyper;
752/// # extern crate hyper_rustls;
753/// # extern crate google_webmasters3 as webmasters3;
754/// use webmasters3::api::SearchAnalyticsQueryRequest;
755/// # async fn dox() {
756/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
757///
758/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
760/// # secret,
761/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
762/// # ).build().await.unwrap();
763///
764/// # let client = hyper_util::client::legacy::Client::builder(
765/// # hyper_util::rt::TokioExecutor::new()
766/// # )
767/// # .build(
768/// # hyper_rustls::HttpsConnectorBuilder::new()
769/// # .with_native_roots()
770/// # .unwrap()
771/// # .https_or_http()
772/// # .enable_http1()
773/// # .build()
774/// # );
775/// # let mut hub = Webmasters::new(client, auth);
776/// // As the method needs a request, you would usually fill it with the desired information
777/// // into the respective structure. Some of the parts shown here might not be applicable !
778/// // Values shown here are possibly random and not representative !
779/// let mut req = SearchAnalyticsQueryRequest::default();
780///
781/// // You can configure optional parameters by calling the respective setters at will, and
782/// // execute the final call using `doit()`.
783/// // Values shown here are possibly random and not representative !
784/// let result = hub.searchanalytics().query(req, "siteUrl")
785/// .doit().await;
786/// # }
787/// ```
788pub struct SearchanalyticQueryCall<'a, C>
789where
790 C: 'a,
791{
792 hub: &'a Webmasters<C>,
793 _request: SearchAnalyticsQueryRequest,
794 _site_url: String,
795 _delegate: Option<&'a mut dyn common::Delegate>,
796 _additional_params: HashMap<String, String>,
797 _scopes: BTreeSet<String>,
798}
799
800impl<'a, C> common::CallBuilder for SearchanalyticQueryCall<'a, C> {}
801
802impl<'a, C> SearchanalyticQueryCall<'a, C>
803where
804 C: common::Connector,
805{
806 /// Perform the operation you have build so far.
807 pub async fn doit(
808 mut self,
809 ) -> common::Result<(common::Response, SearchAnalyticsQueryResponse)> {
810 use std::borrow::Cow;
811 use std::io::{Read, Seek};
812
813 use common::{url::Params, ToParts};
814 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
815
816 let mut dd = common::DefaultDelegate;
817 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
818 dlg.begin(common::MethodInfo {
819 id: "webmasters.searchanalytics.query",
820 http_method: hyper::Method::POST,
821 });
822
823 for &field in ["alt", "siteUrl"].iter() {
824 if self._additional_params.contains_key(field) {
825 dlg.finished(false);
826 return Err(common::Error::FieldClash(field));
827 }
828 }
829
830 let mut params = Params::with_capacity(4 + self._additional_params.len());
831 params.push("siteUrl", self._site_url);
832
833 params.extend(self._additional_params.iter());
834
835 params.push("alt", "json");
836 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}/searchAnalytics/query";
837 if self._scopes.is_empty() {
838 self._scopes.insert(Scope::Full.as_ref().to_string());
839 }
840
841 #[allow(clippy::single_element_loop)]
842 for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
843 url = params.uri_replacement(url, param_name, find_this, false);
844 }
845 {
846 let to_remove = ["siteUrl"];
847 params.remove_params(&to_remove);
848 }
849
850 let url = params.parse_with_url(&url);
851
852 let mut json_mime_type = mime::APPLICATION_JSON;
853 let mut request_value_reader = {
854 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
855 common::remove_json_null_values(&mut value);
856 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
857 serde_json::to_writer(&mut dst, &value).unwrap();
858 dst
859 };
860 let request_size = request_value_reader
861 .seek(std::io::SeekFrom::End(0))
862 .unwrap();
863 request_value_reader
864 .seek(std::io::SeekFrom::Start(0))
865 .unwrap();
866
867 loop {
868 let token = match self
869 .hub
870 .auth
871 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
872 .await
873 {
874 Ok(token) => token,
875 Err(e) => match dlg.token(e) {
876 Ok(token) => token,
877 Err(e) => {
878 dlg.finished(false);
879 return Err(common::Error::MissingToken(e));
880 }
881 },
882 };
883 request_value_reader
884 .seek(std::io::SeekFrom::Start(0))
885 .unwrap();
886 let mut req_result = {
887 let client = &self.hub.client;
888 dlg.pre_request();
889 let mut req_builder = hyper::Request::builder()
890 .method(hyper::Method::POST)
891 .uri(url.as_str())
892 .header(USER_AGENT, self.hub._user_agent.clone());
893
894 if let Some(token) = token.as_ref() {
895 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
896 }
897
898 let request = req_builder
899 .header(CONTENT_TYPE, json_mime_type.to_string())
900 .header(CONTENT_LENGTH, request_size as u64)
901 .body(common::to_body(
902 request_value_reader.get_ref().clone().into(),
903 ));
904
905 client.request(request.unwrap()).await
906 };
907
908 match req_result {
909 Err(err) => {
910 if let common::Retry::After(d) = dlg.http_error(&err) {
911 sleep(d).await;
912 continue;
913 }
914 dlg.finished(false);
915 return Err(common::Error::HttpError(err));
916 }
917 Ok(res) => {
918 let (mut parts, body) = res.into_parts();
919 let mut body = common::Body::new(body);
920 if !parts.status.is_success() {
921 let bytes = common::to_bytes(body).await.unwrap_or_default();
922 let error = serde_json::from_str(&common::to_string(&bytes));
923 let response = common::to_response(parts, bytes.into());
924
925 if let common::Retry::After(d) =
926 dlg.http_failure(&response, error.as_ref().ok())
927 {
928 sleep(d).await;
929 continue;
930 }
931
932 dlg.finished(false);
933
934 return Err(match error {
935 Ok(value) => common::Error::BadRequest(value),
936 _ => common::Error::Failure(response),
937 });
938 }
939 let response = {
940 let bytes = common::to_bytes(body).await.unwrap_or_default();
941 let encoded = common::to_string(&bytes);
942 match serde_json::from_str(&encoded) {
943 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
944 Err(error) => {
945 dlg.response_json_decode_error(&encoded, &error);
946 return Err(common::Error::JsonDecodeError(
947 encoded.to_string(),
948 error,
949 ));
950 }
951 }
952 };
953
954 dlg.finished(true);
955 return Ok(response);
956 }
957 }
958 }
959 }
960
961 ///
962 /// Sets the *request* property to the given value.
963 ///
964 /// Even though the property as already been set when instantiating this call,
965 /// we provide this method for API completeness.
966 pub fn request(
967 mut self,
968 new_value: SearchAnalyticsQueryRequest,
969 ) -> SearchanalyticQueryCall<'a, C> {
970 self._request = new_value;
971 self
972 }
973 /// The site's URL, including protocol. For example: http://www.example.com/
974 ///
975 /// Sets the *site url* path property to the given value.
976 ///
977 /// Even though the property as already been set when instantiating this call,
978 /// we provide this method for API completeness.
979 pub fn site_url(mut self, new_value: &str) -> SearchanalyticQueryCall<'a, C> {
980 self._site_url = new_value.to_string();
981 self
982 }
983 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
984 /// while executing the actual API request.
985 ///
986 /// ````text
987 /// It should be used to handle progress information, and to implement a certain level of resilience.
988 /// ````
989 ///
990 /// Sets the *delegate* property to the given value.
991 pub fn delegate(
992 mut self,
993 new_value: &'a mut dyn common::Delegate,
994 ) -> SearchanalyticQueryCall<'a, C> {
995 self._delegate = Some(new_value);
996 self
997 }
998
999 /// Set any additional parameter of the query string used in the request.
1000 /// It should be used to set parameters which are not yet available through their own
1001 /// setters.
1002 ///
1003 /// Please note that this method must not be used to set any of the known parameters
1004 /// which have their own setter method. If done anyway, the request will fail.
1005 ///
1006 /// # Additional Parameters
1007 ///
1008 /// * *alt* (query-string) - Data format for the response.
1009 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1010 /// * *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.
1011 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1012 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1013 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1014 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1015 pub fn param<T>(mut self, name: T, value: T) -> SearchanalyticQueryCall<'a, C>
1016 where
1017 T: AsRef<str>,
1018 {
1019 self._additional_params
1020 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1021 self
1022 }
1023
1024 /// Identifies the authorization scope for the method you are building.
1025 ///
1026 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1027 /// [`Scope::Full`].
1028 ///
1029 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1030 /// tokens for more than one scope.
1031 ///
1032 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1033 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1034 /// sufficient, a read-write scope will do as well.
1035 pub fn add_scope<St>(mut self, scope: St) -> SearchanalyticQueryCall<'a, C>
1036 where
1037 St: AsRef<str>,
1038 {
1039 self._scopes.insert(String::from(scope.as_ref()));
1040 self
1041 }
1042 /// Identifies the authorization scope(s) for the method you are building.
1043 ///
1044 /// See [`Self::add_scope()`] for details.
1045 pub fn add_scopes<I, St>(mut self, scopes: I) -> SearchanalyticQueryCall<'a, C>
1046 where
1047 I: IntoIterator<Item = St>,
1048 St: AsRef<str>,
1049 {
1050 self._scopes
1051 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1052 self
1053 }
1054
1055 /// Removes all scopes, and no default scope will be used either.
1056 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1057 /// for details).
1058 pub fn clear_scopes(mut self) -> SearchanalyticQueryCall<'a, C> {
1059 self._scopes.clear();
1060 self
1061 }
1062}
1063
1064/// Deletes a sitemap from this site.
1065///
1066/// A builder for the *delete* method supported by a *sitemap* resource.
1067/// It is not used directly, but through a [`SitemapMethods`] instance.
1068///
1069/// # Example
1070///
1071/// Instantiate a resource method builder
1072///
1073/// ```test_harness,no_run
1074/// # extern crate hyper;
1075/// # extern crate hyper_rustls;
1076/// # extern crate google_webmasters3 as webmasters3;
1077/// # async fn dox() {
1078/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1079///
1080/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1081/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1082/// # secret,
1083/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1084/// # ).build().await.unwrap();
1085///
1086/// # let client = hyper_util::client::legacy::Client::builder(
1087/// # hyper_util::rt::TokioExecutor::new()
1088/// # )
1089/// # .build(
1090/// # hyper_rustls::HttpsConnectorBuilder::new()
1091/// # .with_native_roots()
1092/// # .unwrap()
1093/// # .https_or_http()
1094/// # .enable_http1()
1095/// # .build()
1096/// # );
1097/// # let mut hub = Webmasters::new(client, auth);
1098/// // You can configure optional parameters by calling the respective setters at will, and
1099/// // execute the final call using `doit()`.
1100/// // Values shown here are possibly random and not representative !
1101/// let result = hub.sitemaps().delete("siteUrl", "feedpath")
1102/// .doit().await;
1103/// # }
1104/// ```
1105pub struct SitemapDeleteCall<'a, C>
1106where
1107 C: 'a,
1108{
1109 hub: &'a Webmasters<C>,
1110 _site_url: String,
1111 _feedpath: String,
1112 _delegate: Option<&'a mut dyn common::Delegate>,
1113 _additional_params: HashMap<String, String>,
1114 _scopes: BTreeSet<String>,
1115}
1116
1117impl<'a, C> common::CallBuilder for SitemapDeleteCall<'a, C> {}
1118
1119impl<'a, C> SitemapDeleteCall<'a, C>
1120where
1121 C: common::Connector,
1122{
1123 /// Perform the operation you have build so far.
1124 pub async fn doit(mut self) -> common::Result<common::Response> {
1125 use std::borrow::Cow;
1126 use std::io::{Read, Seek};
1127
1128 use common::{url::Params, ToParts};
1129 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1130
1131 let mut dd = common::DefaultDelegate;
1132 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1133 dlg.begin(common::MethodInfo {
1134 id: "webmasters.sitemaps.delete",
1135 http_method: hyper::Method::DELETE,
1136 });
1137
1138 for &field in ["siteUrl", "feedpath"].iter() {
1139 if self._additional_params.contains_key(field) {
1140 dlg.finished(false);
1141 return Err(common::Error::FieldClash(field));
1142 }
1143 }
1144
1145 let mut params = Params::with_capacity(3 + self._additional_params.len());
1146 params.push("siteUrl", self._site_url);
1147 params.push("feedpath", self._feedpath);
1148
1149 params.extend(self._additional_params.iter());
1150
1151 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}/sitemaps/{feedpath}";
1152 if self._scopes.is_empty() {
1153 self._scopes.insert(Scope::Full.as_ref().to_string());
1154 }
1155
1156 #[allow(clippy::single_element_loop)]
1157 for &(find_this, param_name) in
1158 [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
1159 {
1160 url = params.uri_replacement(url, param_name, find_this, false);
1161 }
1162 {
1163 let to_remove = ["feedpath", "siteUrl"];
1164 params.remove_params(&to_remove);
1165 }
1166
1167 let url = params.parse_with_url(&url);
1168
1169 loop {
1170 let token = match self
1171 .hub
1172 .auth
1173 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1174 .await
1175 {
1176 Ok(token) => token,
1177 Err(e) => match dlg.token(e) {
1178 Ok(token) => token,
1179 Err(e) => {
1180 dlg.finished(false);
1181 return Err(common::Error::MissingToken(e));
1182 }
1183 },
1184 };
1185 let mut req_result = {
1186 let client = &self.hub.client;
1187 dlg.pre_request();
1188 let mut req_builder = hyper::Request::builder()
1189 .method(hyper::Method::DELETE)
1190 .uri(url.as_str())
1191 .header(USER_AGENT, self.hub._user_agent.clone());
1192
1193 if let Some(token) = token.as_ref() {
1194 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1195 }
1196
1197 let request = req_builder
1198 .header(CONTENT_LENGTH, 0_u64)
1199 .body(common::to_body::<String>(None));
1200
1201 client.request(request.unwrap()).await
1202 };
1203
1204 match req_result {
1205 Err(err) => {
1206 if let common::Retry::After(d) = dlg.http_error(&err) {
1207 sleep(d).await;
1208 continue;
1209 }
1210 dlg.finished(false);
1211 return Err(common::Error::HttpError(err));
1212 }
1213 Ok(res) => {
1214 let (mut parts, body) = res.into_parts();
1215 let mut body = common::Body::new(body);
1216 if !parts.status.is_success() {
1217 let bytes = common::to_bytes(body).await.unwrap_or_default();
1218 let error = serde_json::from_str(&common::to_string(&bytes));
1219 let response = common::to_response(parts, bytes.into());
1220
1221 if let common::Retry::After(d) =
1222 dlg.http_failure(&response, error.as_ref().ok())
1223 {
1224 sleep(d).await;
1225 continue;
1226 }
1227
1228 dlg.finished(false);
1229
1230 return Err(match error {
1231 Ok(value) => common::Error::BadRequest(value),
1232 _ => common::Error::Failure(response),
1233 });
1234 }
1235 let response = common::Response::from_parts(parts, body);
1236
1237 dlg.finished(true);
1238 return Ok(response);
1239 }
1240 }
1241 }
1242 }
1243
1244 /// The site's URL, including protocol. For example: http://www.example.com/
1245 ///
1246 /// Sets the *site url* path property to the given value.
1247 ///
1248 /// Even though the property as already been set when instantiating this call,
1249 /// we provide this method for API completeness.
1250 pub fn site_url(mut self, new_value: &str) -> SitemapDeleteCall<'a, C> {
1251 self._site_url = new_value.to_string();
1252 self
1253 }
1254 /// The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml
1255 ///
1256 /// Sets the *feedpath* path property to the given value.
1257 ///
1258 /// Even though the property as already been set when instantiating this call,
1259 /// we provide this method for API completeness.
1260 pub fn feedpath(mut self, new_value: &str) -> SitemapDeleteCall<'a, C> {
1261 self._feedpath = new_value.to_string();
1262 self
1263 }
1264 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1265 /// while executing the actual API request.
1266 ///
1267 /// ````text
1268 /// It should be used to handle progress information, and to implement a certain level of resilience.
1269 /// ````
1270 ///
1271 /// Sets the *delegate* property to the given value.
1272 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapDeleteCall<'a, C> {
1273 self._delegate = Some(new_value);
1274 self
1275 }
1276
1277 /// Set any additional parameter of the query string used in the request.
1278 /// It should be used to set parameters which are not yet available through their own
1279 /// setters.
1280 ///
1281 /// Please note that this method must not be used to set any of the known parameters
1282 /// which have their own setter method. If done anyway, the request will fail.
1283 ///
1284 /// # Additional Parameters
1285 ///
1286 /// * *alt* (query-string) - Data format for the response.
1287 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1288 /// * *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.
1289 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1290 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1291 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1292 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1293 pub fn param<T>(mut self, name: T, value: T) -> SitemapDeleteCall<'a, C>
1294 where
1295 T: AsRef<str>,
1296 {
1297 self._additional_params
1298 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1299 self
1300 }
1301
1302 /// Identifies the authorization scope for the method you are building.
1303 ///
1304 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1305 /// [`Scope::Full`].
1306 ///
1307 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1308 /// tokens for more than one scope.
1309 ///
1310 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1311 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1312 /// sufficient, a read-write scope will do as well.
1313 pub fn add_scope<St>(mut self, scope: St) -> SitemapDeleteCall<'a, C>
1314 where
1315 St: AsRef<str>,
1316 {
1317 self._scopes.insert(String::from(scope.as_ref()));
1318 self
1319 }
1320 /// Identifies the authorization scope(s) for the method you are building.
1321 ///
1322 /// See [`Self::add_scope()`] for details.
1323 pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapDeleteCall<'a, C>
1324 where
1325 I: IntoIterator<Item = St>,
1326 St: AsRef<str>,
1327 {
1328 self._scopes
1329 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1330 self
1331 }
1332
1333 /// Removes all scopes, and no default scope will be used either.
1334 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1335 /// for details).
1336 pub fn clear_scopes(mut self) -> SitemapDeleteCall<'a, C> {
1337 self._scopes.clear();
1338 self
1339 }
1340}
1341
1342/// Retrieves information about a specific sitemap.
1343///
1344/// A builder for the *get* method supported by a *sitemap* resource.
1345/// It is not used directly, but through a [`SitemapMethods`] instance.
1346///
1347/// # Example
1348///
1349/// Instantiate a resource method builder
1350///
1351/// ```test_harness,no_run
1352/// # extern crate hyper;
1353/// # extern crate hyper_rustls;
1354/// # extern crate google_webmasters3 as webmasters3;
1355/// # async fn dox() {
1356/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1357///
1358/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1359/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1360/// # secret,
1361/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1362/// # ).build().await.unwrap();
1363///
1364/// # let client = hyper_util::client::legacy::Client::builder(
1365/// # hyper_util::rt::TokioExecutor::new()
1366/// # )
1367/// # .build(
1368/// # hyper_rustls::HttpsConnectorBuilder::new()
1369/// # .with_native_roots()
1370/// # .unwrap()
1371/// # .https_or_http()
1372/// # .enable_http1()
1373/// # .build()
1374/// # );
1375/// # let mut hub = Webmasters::new(client, auth);
1376/// // You can configure optional parameters by calling the respective setters at will, and
1377/// // execute the final call using `doit()`.
1378/// // Values shown here are possibly random and not representative !
1379/// let result = hub.sitemaps().get("siteUrl", "feedpath")
1380/// .doit().await;
1381/// # }
1382/// ```
1383pub struct SitemapGetCall<'a, C>
1384where
1385 C: 'a,
1386{
1387 hub: &'a Webmasters<C>,
1388 _site_url: String,
1389 _feedpath: String,
1390 _delegate: Option<&'a mut dyn common::Delegate>,
1391 _additional_params: HashMap<String, String>,
1392 _scopes: BTreeSet<String>,
1393}
1394
1395impl<'a, C> common::CallBuilder for SitemapGetCall<'a, C> {}
1396
1397impl<'a, C> SitemapGetCall<'a, C>
1398where
1399 C: common::Connector,
1400{
1401 /// Perform the operation you have build so far.
1402 pub async fn doit(mut self) -> common::Result<(common::Response, WmxSitemap)> {
1403 use std::borrow::Cow;
1404 use std::io::{Read, Seek};
1405
1406 use common::{url::Params, ToParts};
1407 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1408
1409 let mut dd = common::DefaultDelegate;
1410 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1411 dlg.begin(common::MethodInfo {
1412 id: "webmasters.sitemaps.get",
1413 http_method: hyper::Method::GET,
1414 });
1415
1416 for &field in ["alt", "siteUrl", "feedpath"].iter() {
1417 if self._additional_params.contains_key(field) {
1418 dlg.finished(false);
1419 return Err(common::Error::FieldClash(field));
1420 }
1421 }
1422
1423 let mut params = Params::with_capacity(4 + self._additional_params.len());
1424 params.push("siteUrl", self._site_url);
1425 params.push("feedpath", self._feedpath);
1426
1427 params.extend(self._additional_params.iter());
1428
1429 params.push("alt", "json");
1430 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}/sitemaps/{feedpath}";
1431 if self._scopes.is_empty() {
1432 self._scopes.insert(Scope::Readonly.as_ref().to_string());
1433 }
1434
1435 #[allow(clippy::single_element_loop)]
1436 for &(find_this, param_name) in
1437 [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
1438 {
1439 url = params.uri_replacement(url, param_name, find_this, false);
1440 }
1441 {
1442 let to_remove = ["feedpath", "siteUrl"];
1443 params.remove_params(&to_remove);
1444 }
1445
1446 let url = params.parse_with_url(&url);
1447
1448 loop {
1449 let token = match self
1450 .hub
1451 .auth
1452 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1453 .await
1454 {
1455 Ok(token) => token,
1456 Err(e) => match dlg.token(e) {
1457 Ok(token) => token,
1458 Err(e) => {
1459 dlg.finished(false);
1460 return Err(common::Error::MissingToken(e));
1461 }
1462 },
1463 };
1464 let mut req_result = {
1465 let client = &self.hub.client;
1466 dlg.pre_request();
1467 let mut req_builder = hyper::Request::builder()
1468 .method(hyper::Method::GET)
1469 .uri(url.as_str())
1470 .header(USER_AGENT, self.hub._user_agent.clone());
1471
1472 if let Some(token) = token.as_ref() {
1473 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1474 }
1475
1476 let request = req_builder
1477 .header(CONTENT_LENGTH, 0_u64)
1478 .body(common::to_body::<String>(None));
1479
1480 client.request(request.unwrap()).await
1481 };
1482
1483 match req_result {
1484 Err(err) => {
1485 if let common::Retry::After(d) = dlg.http_error(&err) {
1486 sleep(d).await;
1487 continue;
1488 }
1489 dlg.finished(false);
1490 return Err(common::Error::HttpError(err));
1491 }
1492 Ok(res) => {
1493 let (mut parts, body) = res.into_parts();
1494 let mut body = common::Body::new(body);
1495 if !parts.status.is_success() {
1496 let bytes = common::to_bytes(body).await.unwrap_or_default();
1497 let error = serde_json::from_str(&common::to_string(&bytes));
1498 let response = common::to_response(parts, bytes.into());
1499
1500 if let common::Retry::After(d) =
1501 dlg.http_failure(&response, error.as_ref().ok())
1502 {
1503 sleep(d).await;
1504 continue;
1505 }
1506
1507 dlg.finished(false);
1508
1509 return Err(match error {
1510 Ok(value) => common::Error::BadRequest(value),
1511 _ => common::Error::Failure(response),
1512 });
1513 }
1514 let response = {
1515 let bytes = common::to_bytes(body).await.unwrap_or_default();
1516 let encoded = common::to_string(&bytes);
1517 match serde_json::from_str(&encoded) {
1518 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1519 Err(error) => {
1520 dlg.response_json_decode_error(&encoded, &error);
1521 return Err(common::Error::JsonDecodeError(
1522 encoded.to_string(),
1523 error,
1524 ));
1525 }
1526 }
1527 };
1528
1529 dlg.finished(true);
1530 return Ok(response);
1531 }
1532 }
1533 }
1534 }
1535
1536 /// The site's URL, including protocol. For example: http://www.example.com/
1537 ///
1538 /// Sets the *site url* path property to the given value.
1539 ///
1540 /// Even though the property as already been set when instantiating this call,
1541 /// we provide this method for API completeness.
1542 pub fn site_url(mut self, new_value: &str) -> SitemapGetCall<'a, C> {
1543 self._site_url = new_value.to_string();
1544 self
1545 }
1546 /// The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml
1547 ///
1548 /// Sets the *feedpath* path property to the given value.
1549 ///
1550 /// Even though the property as already been set when instantiating this call,
1551 /// we provide this method for API completeness.
1552 pub fn feedpath(mut self, new_value: &str) -> SitemapGetCall<'a, C> {
1553 self._feedpath = new_value.to_string();
1554 self
1555 }
1556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1557 /// while executing the actual API request.
1558 ///
1559 /// ````text
1560 /// It should be used to handle progress information, and to implement a certain level of resilience.
1561 /// ````
1562 ///
1563 /// Sets the *delegate* property to the given value.
1564 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapGetCall<'a, C> {
1565 self._delegate = Some(new_value);
1566 self
1567 }
1568
1569 /// Set any additional parameter of the query string used in the request.
1570 /// It should be used to set parameters which are not yet available through their own
1571 /// setters.
1572 ///
1573 /// Please note that this method must not be used to set any of the known parameters
1574 /// which have their own setter method. If done anyway, the request will fail.
1575 ///
1576 /// # Additional Parameters
1577 ///
1578 /// * *alt* (query-string) - Data format for the response.
1579 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1580 /// * *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.
1581 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1582 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1583 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1584 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1585 pub fn param<T>(mut self, name: T, value: T) -> SitemapGetCall<'a, C>
1586 where
1587 T: AsRef<str>,
1588 {
1589 self._additional_params
1590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1591 self
1592 }
1593
1594 /// Identifies the authorization scope for the method you are building.
1595 ///
1596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1597 /// [`Scope::Readonly`].
1598 ///
1599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1600 /// tokens for more than one scope.
1601 ///
1602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1604 /// sufficient, a read-write scope will do as well.
1605 pub fn add_scope<St>(mut self, scope: St) -> SitemapGetCall<'a, C>
1606 where
1607 St: AsRef<str>,
1608 {
1609 self._scopes.insert(String::from(scope.as_ref()));
1610 self
1611 }
1612 /// Identifies the authorization scope(s) for the method you are building.
1613 ///
1614 /// See [`Self::add_scope()`] for details.
1615 pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapGetCall<'a, C>
1616 where
1617 I: IntoIterator<Item = St>,
1618 St: AsRef<str>,
1619 {
1620 self._scopes
1621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1622 self
1623 }
1624
1625 /// Removes all scopes, and no default scope will be used either.
1626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1627 /// for details).
1628 pub fn clear_scopes(mut self) -> SitemapGetCall<'a, C> {
1629 self._scopes.clear();
1630 self
1631 }
1632}
1633
1634/// Lists the sitemaps-entries submitted for this site, or included in the sitemap index file (if sitemapIndex is specified in the request).
1635///
1636/// A builder for the *list* method supported by a *sitemap* resource.
1637/// It is not used directly, but through a [`SitemapMethods`] instance.
1638///
1639/// # Example
1640///
1641/// Instantiate a resource method builder
1642///
1643/// ```test_harness,no_run
1644/// # extern crate hyper;
1645/// # extern crate hyper_rustls;
1646/// # extern crate google_webmasters3 as webmasters3;
1647/// # async fn dox() {
1648/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1649///
1650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1652/// # secret,
1653/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1654/// # ).build().await.unwrap();
1655///
1656/// # let client = hyper_util::client::legacy::Client::builder(
1657/// # hyper_util::rt::TokioExecutor::new()
1658/// # )
1659/// # .build(
1660/// # hyper_rustls::HttpsConnectorBuilder::new()
1661/// # .with_native_roots()
1662/// # .unwrap()
1663/// # .https_or_http()
1664/// # .enable_http1()
1665/// # .build()
1666/// # );
1667/// # let mut hub = Webmasters::new(client, auth);
1668/// // You can configure optional parameters by calling the respective setters at will, and
1669/// // execute the final call using `doit()`.
1670/// // Values shown here are possibly random and not representative !
1671/// let result = hub.sitemaps().list("siteUrl")
1672/// .sitemap_index("takimata")
1673/// .doit().await;
1674/// # }
1675/// ```
1676pub struct SitemapListCall<'a, C>
1677where
1678 C: 'a,
1679{
1680 hub: &'a Webmasters<C>,
1681 _site_url: String,
1682 _sitemap_index: Option<String>,
1683 _delegate: Option<&'a mut dyn common::Delegate>,
1684 _additional_params: HashMap<String, String>,
1685 _scopes: BTreeSet<String>,
1686}
1687
1688impl<'a, C> common::CallBuilder for SitemapListCall<'a, C> {}
1689
1690impl<'a, C> SitemapListCall<'a, C>
1691where
1692 C: common::Connector,
1693{
1694 /// Perform the operation you have build so far.
1695 pub async fn doit(mut self) -> common::Result<(common::Response, SitemapsListResponse)> {
1696 use std::borrow::Cow;
1697 use std::io::{Read, Seek};
1698
1699 use common::{url::Params, ToParts};
1700 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1701
1702 let mut dd = common::DefaultDelegate;
1703 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1704 dlg.begin(common::MethodInfo {
1705 id: "webmasters.sitemaps.list",
1706 http_method: hyper::Method::GET,
1707 });
1708
1709 for &field in ["alt", "siteUrl", "sitemapIndex"].iter() {
1710 if self._additional_params.contains_key(field) {
1711 dlg.finished(false);
1712 return Err(common::Error::FieldClash(field));
1713 }
1714 }
1715
1716 let mut params = Params::with_capacity(4 + self._additional_params.len());
1717 params.push("siteUrl", self._site_url);
1718 if let Some(value) = self._sitemap_index.as_ref() {
1719 params.push("sitemapIndex", value);
1720 }
1721
1722 params.extend(self._additional_params.iter());
1723
1724 params.push("alt", "json");
1725 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}/sitemaps";
1726 if self._scopes.is_empty() {
1727 self._scopes.insert(Scope::Readonly.as_ref().to_string());
1728 }
1729
1730 #[allow(clippy::single_element_loop)]
1731 for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
1732 url = params.uri_replacement(url, param_name, find_this, false);
1733 }
1734 {
1735 let to_remove = ["siteUrl"];
1736 params.remove_params(&to_remove);
1737 }
1738
1739 let url = params.parse_with_url(&url);
1740
1741 loop {
1742 let token = match self
1743 .hub
1744 .auth
1745 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1746 .await
1747 {
1748 Ok(token) => token,
1749 Err(e) => match dlg.token(e) {
1750 Ok(token) => token,
1751 Err(e) => {
1752 dlg.finished(false);
1753 return Err(common::Error::MissingToken(e));
1754 }
1755 },
1756 };
1757 let mut req_result = {
1758 let client = &self.hub.client;
1759 dlg.pre_request();
1760 let mut req_builder = hyper::Request::builder()
1761 .method(hyper::Method::GET)
1762 .uri(url.as_str())
1763 .header(USER_AGENT, self.hub._user_agent.clone());
1764
1765 if let Some(token) = token.as_ref() {
1766 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1767 }
1768
1769 let request = req_builder
1770 .header(CONTENT_LENGTH, 0_u64)
1771 .body(common::to_body::<String>(None));
1772
1773 client.request(request.unwrap()).await
1774 };
1775
1776 match req_result {
1777 Err(err) => {
1778 if let common::Retry::After(d) = dlg.http_error(&err) {
1779 sleep(d).await;
1780 continue;
1781 }
1782 dlg.finished(false);
1783 return Err(common::Error::HttpError(err));
1784 }
1785 Ok(res) => {
1786 let (mut parts, body) = res.into_parts();
1787 let mut body = common::Body::new(body);
1788 if !parts.status.is_success() {
1789 let bytes = common::to_bytes(body).await.unwrap_or_default();
1790 let error = serde_json::from_str(&common::to_string(&bytes));
1791 let response = common::to_response(parts, bytes.into());
1792
1793 if let common::Retry::After(d) =
1794 dlg.http_failure(&response, error.as_ref().ok())
1795 {
1796 sleep(d).await;
1797 continue;
1798 }
1799
1800 dlg.finished(false);
1801
1802 return Err(match error {
1803 Ok(value) => common::Error::BadRequest(value),
1804 _ => common::Error::Failure(response),
1805 });
1806 }
1807 let response = {
1808 let bytes = common::to_bytes(body).await.unwrap_or_default();
1809 let encoded = common::to_string(&bytes);
1810 match serde_json::from_str(&encoded) {
1811 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1812 Err(error) => {
1813 dlg.response_json_decode_error(&encoded, &error);
1814 return Err(common::Error::JsonDecodeError(
1815 encoded.to_string(),
1816 error,
1817 ));
1818 }
1819 }
1820 };
1821
1822 dlg.finished(true);
1823 return Ok(response);
1824 }
1825 }
1826 }
1827 }
1828
1829 /// The site's URL, including protocol. For example: http://www.example.com/
1830 ///
1831 /// Sets the *site url* path property to the given value.
1832 ///
1833 /// Even though the property as already been set when instantiating this call,
1834 /// we provide this method for API completeness.
1835 pub fn site_url(mut self, new_value: &str) -> SitemapListCall<'a, C> {
1836 self._site_url = new_value.to_string();
1837 self
1838 }
1839 /// A URL of a site's sitemap index. For example: http://www.example.com/sitemapindex.xml
1840 ///
1841 /// Sets the *sitemap index* query property to the given value.
1842 pub fn sitemap_index(mut self, new_value: &str) -> SitemapListCall<'a, C> {
1843 self._sitemap_index = Some(new_value.to_string());
1844 self
1845 }
1846 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1847 /// while executing the actual API request.
1848 ///
1849 /// ````text
1850 /// It should be used to handle progress information, and to implement a certain level of resilience.
1851 /// ````
1852 ///
1853 /// Sets the *delegate* property to the given value.
1854 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapListCall<'a, C> {
1855 self._delegate = Some(new_value);
1856 self
1857 }
1858
1859 /// Set any additional parameter of the query string used in the request.
1860 /// It should be used to set parameters which are not yet available through their own
1861 /// setters.
1862 ///
1863 /// Please note that this method must not be used to set any of the known parameters
1864 /// which have their own setter method. If done anyway, the request will fail.
1865 ///
1866 /// # Additional Parameters
1867 ///
1868 /// * *alt* (query-string) - Data format for the response.
1869 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1870 /// * *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.
1871 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1872 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1873 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1874 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1875 pub fn param<T>(mut self, name: T, value: T) -> SitemapListCall<'a, C>
1876 where
1877 T: AsRef<str>,
1878 {
1879 self._additional_params
1880 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1881 self
1882 }
1883
1884 /// Identifies the authorization scope for the method you are building.
1885 ///
1886 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1887 /// [`Scope::Readonly`].
1888 ///
1889 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1890 /// tokens for more than one scope.
1891 ///
1892 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1893 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1894 /// sufficient, a read-write scope will do as well.
1895 pub fn add_scope<St>(mut self, scope: St) -> SitemapListCall<'a, C>
1896 where
1897 St: AsRef<str>,
1898 {
1899 self._scopes.insert(String::from(scope.as_ref()));
1900 self
1901 }
1902 /// Identifies the authorization scope(s) for the method you are building.
1903 ///
1904 /// See [`Self::add_scope()`] for details.
1905 pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapListCall<'a, C>
1906 where
1907 I: IntoIterator<Item = St>,
1908 St: AsRef<str>,
1909 {
1910 self._scopes
1911 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1912 self
1913 }
1914
1915 /// Removes all scopes, and no default scope will be used either.
1916 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1917 /// for details).
1918 pub fn clear_scopes(mut self) -> SitemapListCall<'a, C> {
1919 self._scopes.clear();
1920 self
1921 }
1922}
1923
1924/// Submits a sitemap for a site.
1925///
1926/// A builder for the *submit* method supported by a *sitemap* resource.
1927/// It is not used directly, but through a [`SitemapMethods`] instance.
1928///
1929/// # Example
1930///
1931/// Instantiate a resource method builder
1932///
1933/// ```test_harness,no_run
1934/// # extern crate hyper;
1935/// # extern crate hyper_rustls;
1936/// # extern crate google_webmasters3 as webmasters3;
1937/// # async fn dox() {
1938/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1939///
1940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1942/// # secret,
1943/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1944/// # ).build().await.unwrap();
1945///
1946/// # let client = hyper_util::client::legacy::Client::builder(
1947/// # hyper_util::rt::TokioExecutor::new()
1948/// # )
1949/// # .build(
1950/// # hyper_rustls::HttpsConnectorBuilder::new()
1951/// # .with_native_roots()
1952/// # .unwrap()
1953/// # .https_or_http()
1954/// # .enable_http1()
1955/// # .build()
1956/// # );
1957/// # let mut hub = Webmasters::new(client, auth);
1958/// // You can configure optional parameters by calling the respective setters at will, and
1959/// // execute the final call using `doit()`.
1960/// // Values shown here are possibly random and not representative !
1961/// let result = hub.sitemaps().submit("siteUrl", "feedpath")
1962/// .doit().await;
1963/// # }
1964/// ```
1965pub struct SitemapSubmitCall<'a, C>
1966where
1967 C: 'a,
1968{
1969 hub: &'a Webmasters<C>,
1970 _site_url: String,
1971 _feedpath: String,
1972 _delegate: Option<&'a mut dyn common::Delegate>,
1973 _additional_params: HashMap<String, String>,
1974 _scopes: BTreeSet<String>,
1975}
1976
1977impl<'a, C> common::CallBuilder for SitemapSubmitCall<'a, C> {}
1978
1979impl<'a, C> SitemapSubmitCall<'a, C>
1980where
1981 C: common::Connector,
1982{
1983 /// Perform the operation you have build so far.
1984 pub async fn doit(mut self) -> common::Result<common::Response> {
1985 use std::borrow::Cow;
1986 use std::io::{Read, Seek};
1987
1988 use common::{url::Params, ToParts};
1989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1990
1991 let mut dd = common::DefaultDelegate;
1992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1993 dlg.begin(common::MethodInfo {
1994 id: "webmasters.sitemaps.submit",
1995 http_method: hyper::Method::PUT,
1996 });
1997
1998 for &field in ["siteUrl", "feedpath"].iter() {
1999 if self._additional_params.contains_key(field) {
2000 dlg.finished(false);
2001 return Err(common::Error::FieldClash(field));
2002 }
2003 }
2004
2005 let mut params = Params::with_capacity(3 + self._additional_params.len());
2006 params.push("siteUrl", self._site_url);
2007 params.push("feedpath", self._feedpath);
2008
2009 params.extend(self._additional_params.iter());
2010
2011 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}/sitemaps/{feedpath}";
2012 if self._scopes.is_empty() {
2013 self._scopes.insert(Scope::Full.as_ref().to_string());
2014 }
2015
2016 #[allow(clippy::single_element_loop)]
2017 for &(find_this, param_name) in
2018 [("{siteUrl}", "siteUrl"), ("{feedpath}", "feedpath")].iter()
2019 {
2020 url = params.uri_replacement(url, param_name, find_this, false);
2021 }
2022 {
2023 let to_remove = ["feedpath", "siteUrl"];
2024 params.remove_params(&to_remove);
2025 }
2026
2027 let url = params.parse_with_url(&url);
2028
2029 loop {
2030 let token = match self
2031 .hub
2032 .auth
2033 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2034 .await
2035 {
2036 Ok(token) => token,
2037 Err(e) => match dlg.token(e) {
2038 Ok(token) => token,
2039 Err(e) => {
2040 dlg.finished(false);
2041 return Err(common::Error::MissingToken(e));
2042 }
2043 },
2044 };
2045 let mut req_result = {
2046 let client = &self.hub.client;
2047 dlg.pre_request();
2048 let mut req_builder = hyper::Request::builder()
2049 .method(hyper::Method::PUT)
2050 .uri(url.as_str())
2051 .header(USER_AGENT, self.hub._user_agent.clone());
2052
2053 if let Some(token) = token.as_ref() {
2054 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2055 }
2056
2057 let request = req_builder
2058 .header(CONTENT_LENGTH, 0_u64)
2059 .body(common::to_body::<String>(None));
2060
2061 client.request(request.unwrap()).await
2062 };
2063
2064 match req_result {
2065 Err(err) => {
2066 if let common::Retry::After(d) = dlg.http_error(&err) {
2067 sleep(d).await;
2068 continue;
2069 }
2070 dlg.finished(false);
2071 return Err(common::Error::HttpError(err));
2072 }
2073 Ok(res) => {
2074 let (mut parts, body) = res.into_parts();
2075 let mut body = common::Body::new(body);
2076 if !parts.status.is_success() {
2077 let bytes = common::to_bytes(body).await.unwrap_or_default();
2078 let error = serde_json::from_str(&common::to_string(&bytes));
2079 let response = common::to_response(parts, bytes.into());
2080
2081 if let common::Retry::After(d) =
2082 dlg.http_failure(&response, error.as_ref().ok())
2083 {
2084 sleep(d).await;
2085 continue;
2086 }
2087
2088 dlg.finished(false);
2089
2090 return Err(match error {
2091 Ok(value) => common::Error::BadRequest(value),
2092 _ => common::Error::Failure(response),
2093 });
2094 }
2095 let response = common::Response::from_parts(parts, body);
2096
2097 dlg.finished(true);
2098 return Ok(response);
2099 }
2100 }
2101 }
2102 }
2103
2104 /// The site's URL, including protocol. For example: http://www.example.com/
2105 ///
2106 /// Sets the *site url* path property to the given value.
2107 ///
2108 /// Even though the property as already been set when instantiating this call,
2109 /// we provide this method for API completeness.
2110 pub fn site_url(mut self, new_value: &str) -> SitemapSubmitCall<'a, C> {
2111 self._site_url = new_value.to_string();
2112 self
2113 }
2114 /// The URL of the sitemap to add. For example: http://www.example.com/sitemap.xml
2115 ///
2116 /// Sets the *feedpath* path property to the given value.
2117 ///
2118 /// Even though the property as already been set when instantiating this call,
2119 /// we provide this method for API completeness.
2120 pub fn feedpath(mut self, new_value: &str) -> SitemapSubmitCall<'a, C> {
2121 self._feedpath = new_value.to_string();
2122 self
2123 }
2124 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2125 /// while executing the actual API request.
2126 ///
2127 /// ````text
2128 /// It should be used to handle progress information, and to implement a certain level of resilience.
2129 /// ````
2130 ///
2131 /// Sets the *delegate* property to the given value.
2132 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitemapSubmitCall<'a, C> {
2133 self._delegate = Some(new_value);
2134 self
2135 }
2136
2137 /// Set any additional parameter of the query string used in the request.
2138 /// It should be used to set parameters which are not yet available through their own
2139 /// setters.
2140 ///
2141 /// Please note that this method must not be used to set any of the known parameters
2142 /// which have their own setter method. If done anyway, the request will fail.
2143 ///
2144 /// # Additional Parameters
2145 ///
2146 /// * *alt* (query-string) - Data format for the response.
2147 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2148 /// * *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.
2149 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2150 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2151 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2152 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2153 pub fn param<T>(mut self, name: T, value: T) -> SitemapSubmitCall<'a, C>
2154 where
2155 T: AsRef<str>,
2156 {
2157 self._additional_params
2158 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2159 self
2160 }
2161
2162 /// Identifies the authorization scope for the method you are building.
2163 ///
2164 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2165 /// [`Scope::Full`].
2166 ///
2167 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2168 /// tokens for more than one scope.
2169 ///
2170 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2171 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2172 /// sufficient, a read-write scope will do as well.
2173 pub fn add_scope<St>(mut self, scope: St) -> SitemapSubmitCall<'a, C>
2174 where
2175 St: AsRef<str>,
2176 {
2177 self._scopes.insert(String::from(scope.as_ref()));
2178 self
2179 }
2180 /// Identifies the authorization scope(s) for the method you are building.
2181 ///
2182 /// See [`Self::add_scope()`] for details.
2183 pub fn add_scopes<I, St>(mut self, scopes: I) -> SitemapSubmitCall<'a, C>
2184 where
2185 I: IntoIterator<Item = St>,
2186 St: AsRef<str>,
2187 {
2188 self._scopes
2189 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2190 self
2191 }
2192
2193 /// Removes all scopes, and no default scope will be used either.
2194 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2195 /// for details).
2196 pub fn clear_scopes(mut self) -> SitemapSubmitCall<'a, C> {
2197 self._scopes.clear();
2198 self
2199 }
2200}
2201
2202/// Adds a site to the set of the user's sites in Search Console.
2203///
2204/// A builder for the *add* method supported by a *site* resource.
2205/// It is not used directly, but through a [`SiteMethods`] instance.
2206///
2207/// # Example
2208///
2209/// Instantiate a resource method builder
2210///
2211/// ```test_harness,no_run
2212/// # extern crate hyper;
2213/// # extern crate hyper_rustls;
2214/// # extern crate google_webmasters3 as webmasters3;
2215/// # async fn dox() {
2216/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2217///
2218/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2219/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2220/// # secret,
2221/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2222/// # ).build().await.unwrap();
2223///
2224/// # let client = hyper_util::client::legacy::Client::builder(
2225/// # hyper_util::rt::TokioExecutor::new()
2226/// # )
2227/// # .build(
2228/// # hyper_rustls::HttpsConnectorBuilder::new()
2229/// # .with_native_roots()
2230/// # .unwrap()
2231/// # .https_or_http()
2232/// # .enable_http1()
2233/// # .build()
2234/// # );
2235/// # let mut hub = Webmasters::new(client, auth);
2236/// // You can configure optional parameters by calling the respective setters at will, and
2237/// // execute the final call using `doit()`.
2238/// // Values shown here are possibly random and not representative !
2239/// let result = hub.sites().add("siteUrl")
2240/// .doit().await;
2241/// # }
2242/// ```
2243pub struct SiteAddCall<'a, C>
2244where
2245 C: 'a,
2246{
2247 hub: &'a Webmasters<C>,
2248 _site_url: String,
2249 _delegate: Option<&'a mut dyn common::Delegate>,
2250 _additional_params: HashMap<String, String>,
2251 _scopes: BTreeSet<String>,
2252}
2253
2254impl<'a, C> common::CallBuilder for SiteAddCall<'a, C> {}
2255
2256impl<'a, C> SiteAddCall<'a, C>
2257where
2258 C: common::Connector,
2259{
2260 /// Perform the operation you have build so far.
2261 pub async fn doit(mut self) -> common::Result<common::Response> {
2262 use std::borrow::Cow;
2263 use std::io::{Read, Seek};
2264
2265 use common::{url::Params, ToParts};
2266 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2267
2268 let mut dd = common::DefaultDelegate;
2269 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2270 dlg.begin(common::MethodInfo {
2271 id: "webmasters.sites.add",
2272 http_method: hyper::Method::PUT,
2273 });
2274
2275 for &field in ["siteUrl"].iter() {
2276 if self._additional_params.contains_key(field) {
2277 dlg.finished(false);
2278 return Err(common::Error::FieldClash(field));
2279 }
2280 }
2281
2282 let mut params = Params::with_capacity(2 + self._additional_params.len());
2283 params.push("siteUrl", self._site_url);
2284
2285 params.extend(self._additional_params.iter());
2286
2287 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}";
2288 if self._scopes.is_empty() {
2289 self._scopes.insert(Scope::Full.as_ref().to_string());
2290 }
2291
2292 #[allow(clippy::single_element_loop)]
2293 for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
2294 url = params.uri_replacement(url, param_name, find_this, false);
2295 }
2296 {
2297 let to_remove = ["siteUrl"];
2298 params.remove_params(&to_remove);
2299 }
2300
2301 let url = params.parse_with_url(&url);
2302
2303 loop {
2304 let token = match self
2305 .hub
2306 .auth
2307 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2308 .await
2309 {
2310 Ok(token) => token,
2311 Err(e) => match dlg.token(e) {
2312 Ok(token) => token,
2313 Err(e) => {
2314 dlg.finished(false);
2315 return Err(common::Error::MissingToken(e));
2316 }
2317 },
2318 };
2319 let mut req_result = {
2320 let client = &self.hub.client;
2321 dlg.pre_request();
2322 let mut req_builder = hyper::Request::builder()
2323 .method(hyper::Method::PUT)
2324 .uri(url.as_str())
2325 .header(USER_AGENT, self.hub._user_agent.clone());
2326
2327 if let Some(token) = token.as_ref() {
2328 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2329 }
2330
2331 let request = req_builder
2332 .header(CONTENT_LENGTH, 0_u64)
2333 .body(common::to_body::<String>(None));
2334
2335 client.request(request.unwrap()).await
2336 };
2337
2338 match req_result {
2339 Err(err) => {
2340 if let common::Retry::After(d) = dlg.http_error(&err) {
2341 sleep(d).await;
2342 continue;
2343 }
2344 dlg.finished(false);
2345 return Err(common::Error::HttpError(err));
2346 }
2347 Ok(res) => {
2348 let (mut parts, body) = res.into_parts();
2349 let mut body = common::Body::new(body);
2350 if !parts.status.is_success() {
2351 let bytes = common::to_bytes(body).await.unwrap_or_default();
2352 let error = serde_json::from_str(&common::to_string(&bytes));
2353 let response = common::to_response(parts, bytes.into());
2354
2355 if let common::Retry::After(d) =
2356 dlg.http_failure(&response, error.as_ref().ok())
2357 {
2358 sleep(d).await;
2359 continue;
2360 }
2361
2362 dlg.finished(false);
2363
2364 return Err(match error {
2365 Ok(value) => common::Error::BadRequest(value),
2366 _ => common::Error::Failure(response),
2367 });
2368 }
2369 let response = common::Response::from_parts(parts, body);
2370
2371 dlg.finished(true);
2372 return Ok(response);
2373 }
2374 }
2375 }
2376 }
2377
2378 /// The URL of the site to add.
2379 ///
2380 /// Sets the *site url* path property to the given value.
2381 ///
2382 /// Even though the property as already been set when instantiating this call,
2383 /// we provide this method for API completeness.
2384 pub fn site_url(mut self, new_value: &str) -> SiteAddCall<'a, C> {
2385 self._site_url = new_value.to_string();
2386 self
2387 }
2388 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2389 /// while executing the actual API request.
2390 ///
2391 /// ````text
2392 /// It should be used to handle progress information, and to implement a certain level of resilience.
2393 /// ````
2394 ///
2395 /// Sets the *delegate* property to the given value.
2396 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteAddCall<'a, C> {
2397 self._delegate = Some(new_value);
2398 self
2399 }
2400
2401 /// Set any additional parameter of the query string used in the request.
2402 /// It should be used to set parameters which are not yet available through their own
2403 /// setters.
2404 ///
2405 /// Please note that this method must not be used to set any of the known parameters
2406 /// which have their own setter method. If done anyway, the request will fail.
2407 ///
2408 /// # Additional Parameters
2409 ///
2410 /// * *alt* (query-string) - Data format for the response.
2411 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2412 /// * *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.
2413 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2414 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2415 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2416 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2417 pub fn param<T>(mut self, name: T, value: T) -> SiteAddCall<'a, C>
2418 where
2419 T: AsRef<str>,
2420 {
2421 self._additional_params
2422 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2423 self
2424 }
2425
2426 /// Identifies the authorization scope for the method you are building.
2427 ///
2428 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2429 /// [`Scope::Full`].
2430 ///
2431 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2432 /// tokens for more than one scope.
2433 ///
2434 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2435 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2436 /// sufficient, a read-write scope will do as well.
2437 pub fn add_scope<St>(mut self, scope: St) -> SiteAddCall<'a, C>
2438 where
2439 St: AsRef<str>,
2440 {
2441 self._scopes.insert(String::from(scope.as_ref()));
2442 self
2443 }
2444 /// Identifies the authorization scope(s) for the method you are building.
2445 ///
2446 /// See [`Self::add_scope()`] for details.
2447 pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteAddCall<'a, C>
2448 where
2449 I: IntoIterator<Item = St>,
2450 St: AsRef<str>,
2451 {
2452 self._scopes
2453 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2454 self
2455 }
2456
2457 /// Removes all scopes, and no default scope will be used either.
2458 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2459 /// for details).
2460 pub fn clear_scopes(mut self) -> SiteAddCall<'a, C> {
2461 self._scopes.clear();
2462 self
2463 }
2464}
2465
2466/// Removes a site from the set of the user's Search Console sites.
2467///
2468/// A builder for the *delete* method supported by a *site* resource.
2469/// It is not used directly, but through a [`SiteMethods`] instance.
2470///
2471/// # Example
2472///
2473/// Instantiate a resource method builder
2474///
2475/// ```test_harness,no_run
2476/// # extern crate hyper;
2477/// # extern crate hyper_rustls;
2478/// # extern crate google_webmasters3 as webmasters3;
2479/// # async fn dox() {
2480/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2481///
2482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2484/// # secret,
2485/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2486/// # ).build().await.unwrap();
2487///
2488/// # let client = hyper_util::client::legacy::Client::builder(
2489/// # hyper_util::rt::TokioExecutor::new()
2490/// # )
2491/// # .build(
2492/// # hyper_rustls::HttpsConnectorBuilder::new()
2493/// # .with_native_roots()
2494/// # .unwrap()
2495/// # .https_or_http()
2496/// # .enable_http1()
2497/// # .build()
2498/// # );
2499/// # let mut hub = Webmasters::new(client, auth);
2500/// // You can configure optional parameters by calling the respective setters at will, and
2501/// // execute the final call using `doit()`.
2502/// // Values shown here are possibly random and not representative !
2503/// let result = hub.sites().delete("siteUrl")
2504/// .doit().await;
2505/// # }
2506/// ```
2507pub struct SiteDeleteCall<'a, C>
2508where
2509 C: 'a,
2510{
2511 hub: &'a Webmasters<C>,
2512 _site_url: String,
2513 _delegate: Option<&'a mut dyn common::Delegate>,
2514 _additional_params: HashMap<String, String>,
2515 _scopes: BTreeSet<String>,
2516}
2517
2518impl<'a, C> common::CallBuilder for SiteDeleteCall<'a, C> {}
2519
2520impl<'a, C> SiteDeleteCall<'a, C>
2521where
2522 C: common::Connector,
2523{
2524 /// Perform the operation you have build so far.
2525 pub async fn doit(mut self) -> common::Result<common::Response> {
2526 use std::borrow::Cow;
2527 use std::io::{Read, Seek};
2528
2529 use common::{url::Params, ToParts};
2530 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2531
2532 let mut dd = common::DefaultDelegate;
2533 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2534 dlg.begin(common::MethodInfo {
2535 id: "webmasters.sites.delete",
2536 http_method: hyper::Method::DELETE,
2537 });
2538
2539 for &field in ["siteUrl"].iter() {
2540 if self._additional_params.contains_key(field) {
2541 dlg.finished(false);
2542 return Err(common::Error::FieldClash(field));
2543 }
2544 }
2545
2546 let mut params = Params::with_capacity(2 + self._additional_params.len());
2547 params.push("siteUrl", self._site_url);
2548
2549 params.extend(self._additional_params.iter());
2550
2551 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}";
2552 if self._scopes.is_empty() {
2553 self._scopes.insert(Scope::Full.as_ref().to_string());
2554 }
2555
2556 #[allow(clippy::single_element_loop)]
2557 for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
2558 url = params.uri_replacement(url, param_name, find_this, false);
2559 }
2560 {
2561 let to_remove = ["siteUrl"];
2562 params.remove_params(&to_remove);
2563 }
2564
2565 let url = params.parse_with_url(&url);
2566
2567 loop {
2568 let token = match self
2569 .hub
2570 .auth
2571 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2572 .await
2573 {
2574 Ok(token) => token,
2575 Err(e) => match dlg.token(e) {
2576 Ok(token) => token,
2577 Err(e) => {
2578 dlg.finished(false);
2579 return Err(common::Error::MissingToken(e));
2580 }
2581 },
2582 };
2583 let mut req_result = {
2584 let client = &self.hub.client;
2585 dlg.pre_request();
2586 let mut req_builder = hyper::Request::builder()
2587 .method(hyper::Method::DELETE)
2588 .uri(url.as_str())
2589 .header(USER_AGENT, self.hub._user_agent.clone());
2590
2591 if let Some(token) = token.as_ref() {
2592 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2593 }
2594
2595 let request = req_builder
2596 .header(CONTENT_LENGTH, 0_u64)
2597 .body(common::to_body::<String>(None));
2598
2599 client.request(request.unwrap()).await
2600 };
2601
2602 match req_result {
2603 Err(err) => {
2604 if let common::Retry::After(d) = dlg.http_error(&err) {
2605 sleep(d).await;
2606 continue;
2607 }
2608 dlg.finished(false);
2609 return Err(common::Error::HttpError(err));
2610 }
2611 Ok(res) => {
2612 let (mut parts, body) = res.into_parts();
2613 let mut body = common::Body::new(body);
2614 if !parts.status.is_success() {
2615 let bytes = common::to_bytes(body).await.unwrap_or_default();
2616 let error = serde_json::from_str(&common::to_string(&bytes));
2617 let response = common::to_response(parts, bytes.into());
2618
2619 if let common::Retry::After(d) =
2620 dlg.http_failure(&response, error.as_ref().ok())
2621 {
2622 sleep(d).await;
2623 continue;
2624 }
2625
2626 dlg.finished(false);
2627
2628 return Err(match error {
2629 Ok(value) => common::Error::BadRequest(value),
2630 _ => common::Error::Failure(response),
2631 });
2632 }
2633 let response = common::Response::from_parts(parts, body);
2634
2635 dlg.finished(true);
2636 return Ok(response);
2637 }
2638 }
2639 }
2640 }
2641
2642 /// The URI of the property as defined in Search Console. Examples: http://www.example.com/ or android-app://com.example/ Note: for property-sets, use the URI that starts with sc-set: which is used in Search Console URLs.
2643 ///
2644 /// Sets the *site url* path property to the given value.
2645 ///
2646 /// Even though the property as already been set when instantiating this call,
2647 /// we provide this method for API completeness.
2648 pub fn site_url(mut self, new_value: &str) -> SiteDeleteCall<'a, C> {
2649 self._site_url = new_value.to_string();
2650 self
2651 }
2652 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2653 /// while executing the actual API request.
2654 ///
2655 /// ````text
2656 /// It should be used to handle progress information, and to implement a certain level of resilience.
2657 /// ````
2658 ///
2659 /// Sets the *delegate* property to the given value.
2660 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteDeleteCall<'a, C> {
2661 self._delegate = Some(new_value);
2662 self
2663 }
2664
2665 /// Set any additional parameter of the query string used in the request.
2666 /// It should be used to set parameters which are not yet available through their own
2667 /// setters.
2668 ///
2669 /// Please note that this method must not be used to set any of the known parameters
2670 /// which have their own setter method. If done anyway, the request will fail.
2671 ///
2672 /// # Additional Parameters
2673 ///
2674 /// * *alt* (query-string) - Data format for the response.
2675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2676 /// * *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.
2677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2679 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2680 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2681 pub fn param<T>(mut self, name: T, value: T) -> SiteDeleteCall<'a, C>
2682 where
2683 T: AsRef<str>,
2684 {
2685 self._additional_params
2686 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2687 self
2688 }
2689
2690 /// Identifies the authorization scope for the method you are building.
2691 ///
2692 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2693 /// [`Scope::Full`].
2694 ///
2695 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2696 /// tokens for more than one scope.
2697 ///
2698 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2699 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2700 /// sufficient, a read-write scope will do as well.
2701 pub fn add_scope<St>(mut self, scope: St) -> SiteDeleteCall<'a, C>
2702 where
2703 St: AsRef<str>,
2704 {
2705 self._scopes.insert(String::from(scope.as_ref()));
2706 self
2707 }
2708 /// Identifies the authorization scope(s) for the method you are building.
2709 ///
2710 /// See [`Self::add_scope()`] for details.
2711 pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteDeleteCall<'a, C>
2712 where
2713 I: IntoIterator<Item = St>,
2714 St: AsRef<str>,
2715 {
2716 self._scopes
2717 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2718 self
2719 }
2720
2721 /// Removes all scopes, and no default scope will be used either.
2722 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2723 /// for details).
2724 pub fn clear_scopes(mut self) -> SiteDeleteCall<'a, C> {
2725 self._scopes.clear();
2726 self
2727 }
2728}
2729
2730/// Retrieves information about specific site.
2731///
2732/// A builder for the *get* method supported by a *site* resource.
2733/// It is not used directly, but through a [`SiteMethods`] instance.
2734///
2735/// # Example
2736///
2737/// Instantiate a resource method builder
2738///
2739/// ```test_harness,no_run
2740/// # extern crate hyper;
2741/// # extern crate hyper_rustls;
2742/// # extern crate google_webmasters3 as webmasters3;
2743/// # async fn dox() {
2744/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2745///
2746/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2747/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2748/// # secret,
2749/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2750/// # ).build().await.unwrap();
2751///
2752/// # let client = hyper_util::client::legacy::Client::builder(
2753/// # hyper_util::rt::TokioExecutor::new()
2754/// # )
2755/// # .build(
2756/// # hyper_rustls::HttpsConnectorBuilder::new()
2757/// # .with_native_roots()
2758/// # .unwrap()
2759/// # .https_or_http()
2760/// # .enable_http1()
2761/// # .build()
2762/// # );
2763/// # let mut hub = Webmasters::new(client, auth);
2764/// // You can configure optional parameters by calling the respective setters at will, and
2765/// // execute the final call using `doit()`.
2766/// // Values shown here are possibly random and not representative !
2767/// let result = hub.sites().get("siteUrl")
2768/// .doit().await;
2769/// # }
2770/// ```
2771pub struct SiteGetCall<'a, C>
2772where
2773 C: 'a,
2774{
2775 hub: &'a Webmasters<C>,
2776 _site_url: String,
2777 _delegate: Option<&'a mut dyn common::Delegate>,
2778 _additional_params: HashMap<String, String>,
2779 _scopes: BTreeSet<String>,
2780}
2781
2782impl<'a, C> common::CallBuilder for SiteGetCall<'a, C> {}
2783
2784impl<'a, C> SiteGetCall<'a, C>
2785where
2786 C: common::Connector,
2787{
2788 /// Perform the operation you have build so far.
2789 pub async fn doit(mut self) -> common::Result<(common::Response, WmxSite)> {
2790 use std::borrow::Cow;
2791 use std::io::{Read, Seek};
2792
2793 use common::{url::Params, ToParts};
2794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2795
2796 let mut dd = common::DefaultDelegate;
2797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2798 dlg.begin(common::MethodInfo {
2799 id: "webmasters.sites.get",
2800 http_method: hyper::Method::GET,
2801 });
2802
2803 for &field in ["alt", "siteUrl"].iter() {
2804 if self._additional_params.contains_key(field) {
2805 dlg.finished(false);
2806 return Err(common::Error::FieldClash(field));
2807 }
2808 }
2809
2810 let mut params = Params::with_capacity(3 + self._additional_params.len());
2811 params.push("siteUrl", self._site_url);
2812
2813 params.extend(self._additional_params.iter());
2814
2815 params.push("alt", "json");
2816 let mut url = self.hub._base_url.clone() + "sites/{siteUrl}";
2817 if self._scopes.is_empty() {
2818 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2819 }
2820
2821 #[allow(clippy::single_element_loop)]
2822 for &(find_this, param_name) in [("{siteUrl}", "siteUrl")].iter() {
2823 url = params.uri_replacement(url, param_name, find_this, false);
2824 }
2825 {
2826 let to_remove = ["siteUrl"];
2827 params.remove_params(&to_remove);
2828 }
2829
2830 let url = params.parse_with_url(&url);
2831
2832 loop {
2833 let token = match self
2834 .hub
2835 .auth
2836 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2837 .await
2838 {
2839 Ok(token) => token,
2840 Err(e) => match dlg.token(e) {
2841 Ok(token) => token,
2842 Err(e) => {
2843 dlg.finished(false);
2844 return Err(common::Error::MissingToken(e));
2845 }
2846 },
2847 };
2848 let mut req_result = {
2849 let client = &self.hub.client;
2850 dlg.pre_request();
2851 let mut req_builder = hyper::Request::builder()
2852 .method(hyper::Method::GET)
2853 .uri(url.as_str())
2854 .header(USER_AGENT, self.hub._user_agent.clone());
2855
2856 if let Some(token) = token.as_ref() {
2857 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2858 }
2859
2860 let request = req_builder
2861 .header(CONTENT_LENGTH, 0_u64)
2862 .body(common::to_body::<String>(None));
2863
2864 client.request(request.unwrap()).await
2865 };
2866
2867 match req_result {
2868 Err(err) => {
2869 if let common::Retry::After(d) = dlg.http_error(&err) {
2870 sleep(d).await;
2871 continue;
2872 }
2873 dlg.finished(false);
2874 return Err(common::Error::HttpError(err));
2875 }
2876 Ok(res) => {
2877 let (mut parts, body) = res.into_parts();
2878 let mut body = common::Body::new(body);
2879 if !parts.status.is_success() {
2880 let bytes = common::to_bytes(body).await.unwrap_or_default();
2881 let error = serde_json::from_str(&common::to_string(&bytes));
2882 let response = common::to_response(parts, bytes.into());
2883
2884 if let common::Retry::After(d) =
2885 dlg.http_failure(&response, error.as_ref().ok())
2886 {
2887 sleep(d).await;
2888 continue;
2889 }
2890
2891 dlg.finished(false);
2892
2893 return Err(match error {
2894 Ok(value) => common::Error::BadRequest(value),
2895 _ => common::Error::Failure(response),
2896 });
2897 }
2898 let response = {
2899 let bytes = common::to_bytes(body).await.unwrap_or_default();
2900 let encoded = common::to_string(&bytes);
2901 match serde_json::from_str(&encoded) {
2902 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2903 Err(error) => {
2904 dlg.response_json_decode_error(&encoded, &error);
2905 return Err(common::Error::JsonDecodeError(
2906 encoded.to_string(),
2907 error,
2908 ));
2909 }
2910 }
2911 };
2912
2913 dlg.finished(true);
2914 return Ok(response);
2915 }
2916 }
2917 }
2918 }
2919
2920 /// The URI of the property as defined in Search Console. Examples: http://www.example.com/ or android-app://com.example/ Note: for property-sets, use the URI that starts with sc-set: which is used in Search Console URLs.
2921 ///
2922 /// Sets the *site url* path property to the given value.
2923 ///
2924 /// Even though the property as already been set when instantiating this call,
2925 /// we provide this method for API completeness.
2926 pub fn site_url(mut self, new_value: &str) -> SiteGetCall<'a, C> {
2927 self._site_url = new_value.to_string();
2928 self
2929 }
2930 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2931 /// while executing the actual API request.
2932 ///
2933 /// ````text
2934 /// It should be used to handle progress information, and to implement a certain level of resilience.
2935 /// ````
2936 ///
2937 /// Sets the *delegate* property to the given value.
2938 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteGetCall<'a, C> {
2939 self._delegate = Some(new_value);
2940 self
2941 }
2942
2943 /// Set any additional parameter of the query string used in the request.
2944 /// It should be used to set parameters which are not yet available through their own
2945 /// setters.
2946 ///
2947 /// Please note that this method must not be used to set any of the known parameters
2948 /// which have their own setter method. If done anyway, the request will fail.
2949 ///
2950 /// # Additional Parameters
2951 ///
2952 /// * *alt* (query-string) - Data format for the response.
2953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2954 /// * *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.
2955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2957 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2958 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2959 pub fn param<T>(mut self, name: T, value: T) -> SiteGetCall<'a, C>
2960 where
2961 T: AsRef<str>,
2962 {
2963 self._additional_params
2964 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2965 self
2966 }
2967
2968 /// Identifies the authorization scope for the method you are building.
2969 ///
2970 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2971 /// [`Scope::Readonly`].
2972 ///
2973 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2974 /// tokens for more than one scope.
2975 ///
2976 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2977 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2978 /// sufficient, a read-write scope will do as well.
2979 pub fn add_scope<St>(mut self, scope: St) -> SiteGetCall<'a, C>
2980 where
2981 St: AsRef<str>,
2982 {
2983 self._scopes.insert(String::from(scope.as_ref()));
2984 self
2985 }
2986 /// Identifies the authorization scope(s) for the method you are building.
2987 ///
2988 /// See [`Self::add_scope()`] for details.
2989 pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteGetCall<'a, C>
2990 where
2991 I: IntoIterator<Item = St>,
2992 St: AsRef<str>,
2993 {
2994 self._scopes
2995 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2996 self
2997 }
2998
2999 /// Removes all scopes, and no default scope will be used either.
3000 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3001 /// for details).
3002 pub fn clear_scopes(mut self) -> SiteGetCall<'a, C> {
3003 self._scopes.clear();
3004 self
3005 }
3006}
3007
3008/// Lists the user's Search Console sites.
3009///
3010/// A builder for the *list* method supported by a *site* resource.
3011/// It is not used directly, but through a [`SiteMethods`] instance.
3012///
3013/// # Example
3014///
3015/// Instantiate a resource method builder
3016///
3017/// ```test_harness,no_run
3018/// # extern crate hyper;
3019/// # extern crate hyper_rustls;
3020/// # extern crate google_webmasters3 as webmasters3;
3021/// # async fn dox() {
3022/// # use webmasters3::{Webmasters, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3023///
3024/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3025/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3026/// # secret,
3027/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3028/// # ).build().await.unwrap();
3029///
3030/// # let client = hyper_util::client::legacy::Client::builder(
3031/// # hyper_util::rt::TokioExecutor::new()
3032/// # )
3033/// # .build(
3034/// # hyper_rustls::HttpsConnectorBuilder::new()
3035/// # .with_native_roots()
3036/// # .unwrap()
3037/// # .https_or_http()
3038/// # .enable_http1()
3039/// # .build()
3040/// # );
3041/// # let mut hub = Webmasters::new(client, auth);
3042/// // You can configure optional parameters by calling the respective setters at will, and
3043/// // execute the final call using `doit()`.
3044/// // Values shown here are possibly random and not representative !
3045/// let result = hub.sites().list()
3046/// .doit().await;
3047/// # }
3048/// ```
3049pub struct SiteListCall<'a, C>
3050where
3051 C: 'a,
3052{
3053 hub: &'a Webmasters<C>,
3054 _delegate: Option<&'a mut dyn common::Delegate>,
3055 _additional_params: HashMap<String, String>,
3056 _scopes: BTreeSet<String>,
3057}
3058
3059impl<'a, C> common::CallBuilder for SiteListCall<'a, C> {}
3060
3061impl<'a, C> SiteListCall<'a, C>
3062where
3063 C: common::Connector,
3064{
3065 /// Perform the operation you have build so far.
3066 pub async fn doit(mut self) -> common::Result<(common::Response, SitesListResponse)> {
3067 use std::borrow::Cow;
3068 use std::io::{Read, Seek};
3069
3070 use common::{url::Params, ToParts};
3071 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3072
3073 let mut dd = common::DefaultDelegate;
3074 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3075 dlg.begin(common::MethodInfo {
3076 id: "webmasters.sites.list",
3077 http_method: hyper::Method::GET,
3078 });
3079
3080 for &field in ["alt"].iter() {
3081 if self._additional_params.contains_key(field) {
3082 dlg.finished(false);
3083 return Err(common::Error::FieldClash(field));
3084 }
3085 }
3086
3087 let mut params = Params::with_capacity(2 + self._additional_params.len());
3088
3089 params.extend(self._additional_params.iter());
3090
3091 params.push("alt", "json");
3092 let mut url = self.hub._base_url.clone() + "sites";
3093 if self._scopes.is_empty() {
3094 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3095 }
3096
3097 let url = params.parse_with_url(&url);
3098
3099 loop {
3100 let token = match self
3101 .hub
3102 .auth
3103 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3104 .await
3105 {
3106 Ok(token) => token,
3107 Err(e) => match dlg.token(e) {
3108 Ok(token) => token,
3109 Err(e) => {
3110 dlg.finished(false);
3111 return Err(common::Error::MissingToken(e));
3112 }
3113 },
3114 };
3115 let mut req_result = {
3116 let client = &self.hub.client;
3117 dlg.pre_request();
3118 let mut req_builder = hyper::Request::builder()
3119 .method(hyper::Method::GET)
3120 .uri(url.as_str())
3121 .header(USER_AGENT, self.hub._user_agent.clone());
3122
3123 if let Some(token) = token.as_ref() {
3124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3125 }
3126
3127 let request = req_builder
3128 .header(CONTENT_LENGTH, 0_u64)
3129 .body(common::to_body::<String>(None));
3130
3131 client.request(request.unwrap()).await
3132 };
3133
3134 match req_result {
3135 Err(err) => {
3136 if let common::Retry::After(d) = dlg.http_error(&err) {
3137 sleep(d).await;
3138 continue;
3139 }
3140 dlg.finished(false);
3141 return Err(common::Error::HttpError(err));
3142 }
3143 Ok(res) => {
3144 let (mut parts, body) = res.into_parts();
3145 let mut body = common::Body::new(body);
3146 if !parts.status.is_success() {
3147 let bytes = common::to_bytes(body).await.unwrap_or_default();
3148 let error = serde_json::from_str(&common::to_string(&bytes));
3149 let response = common::to_response(parts, bytes.into());
3150
3151 if let common::Retry::After(d) =
3152 dlg.http_failure(&response, error.as_ref().ok())
3153 {
3154 sleep(d).await;
3155 continue;
3156 }
3157
3158 dlg.finished(false);
3159
3160 return Err(match error {
3161 Ok(value) => common::Error::BadRequest(value),
3162 _ => common::Error::Failure(response),
3163 });
3164 }
3165 let response = {
3166 let bytes = common::to_bytes(body).await.unwrap_or_default();
3167 let encoded = common::to_string(&bytes);
3168 match serde_json::from_str(&encoded) {
3169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3170 Err(error) => {
3171 dlg.response_json_decode_error(&encoded, &error);
3172 return Err(common::Error::JsonDecodeError(
3173 encoded.to_string(),
3174 error,
3175 ));
3176 }
3177 }
3178 };
3179
3180 dlg.finished(true);
3181 return Ok(response);
3182 }
3183 }
3184 }
3185 }
3186
3187 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3188 /// while executing the actual API request.
3189 ///
3190 /// ````text
3191 /// It should be used to handle progress information, and to implement a certain level of resilience.
3192 /// ````
3193 ///
3194 /// Sets the *delegate* property to the given value.
3195 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteListCall<'a, C> {
3196 self._delegate = Some(new_value);
3197 self
3198 }
3199
3200 /// Set any additional parameter of the query string used in the request.
3201 /// It should be used to set parameters which are not yet available through their own
3202 /// setters.
3203 ///
3204 /// Please note that this method must not be used to set any of the known parameters
3205 /// which have their own setter method. If done anyway, the request will fail.
3206 ///
3207 /// # Additional Parameters
3208 ///
3209 /// * *alt* (query-string) - Data format for the response.
3210 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3211 /// * *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.
3212 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3213 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3214 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3215 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3216 pub fn param<T>(mut self, name: T, value: T) -> SiteListCall<'a, C>
3217 where
3218 T: AsRef<str>,
3219 {
3220 self._additional_params
3221 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3222 self
3223 }
3224
3225 /// Identifies the authorization scope for the method you are building.
3226 ///
3227 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3228 /// [`Scope::Readonly`].
3229 ///
3230 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3231 /// tokens for more than one scope.
3232 ///
3233 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3234 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3235 /// sufficient, a read-write scope will do as well.
3236 pub fn add_scope<St>(mut self, scope: St) -> SiteListCall<'a, C>
3237 where
3238 St: AsRef<str>,
3239 {
3240 self._scopes.insert(String::from(scope.as_ref()));
3241 self
3242 }
3243 /// Identifies the authorization scope(s) for the method you are building.
3244 ///
3245 /// See [`Self::add_scope()`] for details.
3246 pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteListCall<'a, C>
3247 where
3248 I: IntoIterator<Item = St>,
3249 St: AsRef<str>,
3250 {
3251 self._scopes
3252 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3253 self
3254 }
3255
3256 /// Removes all scopes, and no default scope will be used either.
3257 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3258 /// for details).
3259 pub fn clear_scopes(mut self) -> SiteListCall<'a, C> {
3260 self._scopes.clear();
3261 self
3262 }
3263}