Skip to main content

google_adexperiencereport1/
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// ########
12// HUB ###
13// ######
14
15/// Central instance to access all AdExperienceReport related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_adexperiencereport1 as adexperiencereport1;
25/// use adexperiencereport1::{Result, Error};
26/// # async fn dox() {
27/// use adexperiencereport1::{AdExperienceReport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28///
29/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
30/// // `client_secret`, among other things.
31/// let secret: yup_oauth2::ApplicationSecret = Default::default();
32/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
33/// // unless you replace  `None` with the desired Flow.
34/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
35/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
36/// // retrieve them from storage.
37/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
38///     .with_native_roots()
39///     .unwrap()
40///     .https_only()
41///     .enable_http2()
42///     .build();
43///
44/// let executor = hyper_util::rt::TokioExecutor::new();
45/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
46///     secret,
47///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48///     yup_oauth2::client::CustomHyperClientBuilder::from(
49///         hyper_util::client::legacy::Client::builder(executor).build(connector),
50///     ),
51/// ).build().await.unwrap();
52///
53/// let client = hyper_util::client::legacy::Client::builder(
54///     hyper_util::rt::TokioExecutor::new()
55/// )
56/// .build(
57///     hyper_rustls::HttpsConnectorBuilder::new()
58///         .with_native_roots()
59///         .unwrap()
60///         .https_or_http()
61///         .enable_http2()
62///         .build()
63/// );
64/// let mut hub = AdExperienceReport::new(client, auth);
65/// // You can configure optional parameters by calling the respective setters at will, and
66/// // execute the final call using `doit()`.
67/// // Values shown here are possibly random and not representative !
68/// let result = hub.sites().get("name")
69///              .doit().await;
70///
71/// match result {
72///     Err(e) => match e {
73///         // The Error enum provides details about what exactly happened.
74///         // You can also just use its `Debug`, `Display` or `Error` traits
75///          Error::HttpError(_)
76///         |Error::Io(_)
77///         |Error::MissingAPIKey
78///         |Error::MissingToken(_)
79///         |Error::Cancelled
80///         |Error::UploadSizeLimitExceeded(_, _)
81///         |Error::Failure(_)
82///         |Error::BadRequest(_)
83///         |Error::FieldClash(_)
84///         |Error::JsonDecodeError(_, _) => println!("{}", e),
85///     },
86///     Ok(res) => println!("Success: {:?}", res),
87/// }
88/// # }
89/// ```
90#[derive(Clone)]
91pub struct AdExperienceReport<C> {
92    pub client: common::Client<C>,
93    pub auth: Box<dyn common::GetToken>,
94    _user_agent: String,
95    _base_url: String,
96    _root_url: String,
97}
98
99impl<C> common::Hub for AdExperienceReport<C> {}
100
101impl<'a, C> AdExperienceReport<C> {
102    pub fn new<A: 'static + common::GetToken>(
103        client: common::Client<C>,
104        auth: A,
105    ) -> AdExperienceReport<C> {
106        AdExperienceReport {
107            client,
108            auth: Box::new(auth),
109            _user_agent: "google-api-rust-client/7.0.0".to_string(),
110            _base_url: "https://adexperiencereport.googleapis.com/".to_string(),
111            _root_url: "https://adexperiencereport.googleapis.com/".to_string(),
112        }
113    }
114
115    pub fn sites(&'a self) -> SiteMethods<'a, C> {
116        SiteMethods { hub: self }
117    }
118    pub fn violating_sites(&'a self) -> ViolatingSiteMethods<'a, C> {
119        ViolatingSiteMethods { hub: self }
120    }
121
122    /// Set the user-agent header field to use in all requests to the server.
123    /// It defaults to `google-api-rust-client/7.0.0`.
124    ///
125    /// Returns the previously set user-agent.
126    pub fn user_agent(&mut self, agent_name: String) -> String {
127        std::mem::replace(&mut self._user_agent, agent_name)
128    }
129
130    /// Set the base url to use in all requests to the server.
131    /// It defaults to `https://adexperiencereport.googleapis.com/`.
132    ///
133    /// Returns the previously set base url.
134    pub fn base_url(&mut self, new_base_url: String) -> String {
135        std::mem::replace(&mut self._base_url, new_base_url)
136    }
137
138    /// Set the root url to use in all requests to the server.
139    /// It defaults to `https://adexperiencereport.googleapis.com/`.
140    ///
141    /// Returns the previously set root url.
142    pub fn root_url(&mut self, new_root_url: String) -> String {
143        std::mem::replace(&mut self._root_url, new_root_url)
144    }
145}
146
147// ############
148// SCHEMAS ###
149// ##########
150/// A site's Ad Experience Report summary on a single platform.
151///
152/// This type is not used in any activity, and only used as *part* of another schema.
153///
154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
155#[serde_with::serde_as]
156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
157pub struct PlatformSummary {
158    /// The site's Ad Experience Report status on this platform.
159    #[serde(rename = "betterAdsStatus")]
160    pub better_ads_status: Option<String>,
161    /// The time at which [enforcement](https://support.google.com/webtools/answer/7308033) against the site began or will begin on this platform. Not set when the filter_status is OFF.
162    #[serde(rename = "enforcementTime")]
163    pub enforcement_time: Option<chrono::DateTime<chrono::offset::Utc>>,
164    /// The site's [enforcement status](https://support.google.com/webtools/answer/7308033) on this platform.
165    #[serde(rename = "filterStatus")]
166    pub filter_status: Option<String>,
167    /// The time at which the site's status last changed on this platform.
168    #[serde(rename = "lastChangeTime")]
169    pub last_change_time: Option<chrono::DateTime<chrono::offset::Utc>>,
170    /// The site's regions on this platform. No longer populated, because there is no longer any semantic difference between sites in different regions.
171    pub region: Option<Vec<String>>,
172    /// A link to the full Ad Experience Report for the site on this platform.. Not set in ViolatingSitesResponse. Note that you must complete the [Search Console verification process](https://support.google.com/webmasters/answer/9008080) for the site before you can access the full report.
173    #[serde(rename = "reportUrl")]
174    pub report_url: Option<String>,
175    /// Whether the site is currently under review on this platform.
176    #[serde(rename = "underReview")]
177    pub under_review: Option<bool>,
178}
179
180impl common::Part for PlatformSummary {}
181
182/// Response message for GetSiteSummary.
183///
184/// # Activities
185///
186/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
187/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
188///
189/// * [get sites](SiteGetCall) (response)
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct SiteSummaryResponse {
194    /// The site's Ad Experience Report summary on desktop.
195    #[serde(rename = "desktopSummary")]
196    pub desktop_summary: Option<PlatformSummary>,
197    /// The site's Ad Experience Report summary on mobile.
198    #[serde(rename = "mobileSummary")]
199    pub mobile_summary: Option<PlatformSummary>,
200    /// The name of the reviewed site, e.g. `google.com`.
201    #[serde(rename = "reviewedSite")]
202    pub reviewed_site: Option<String>,
203}
204
205impl common::ResponseResult for SiteSummaryResponse {}
206
207/// Response message for ListViolatingSites.
208///
209/// # Activities
210///
211/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
212/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
213///
214/// * [list violating sites](ViolatingSiteListCall) (response)
215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
216#[serde_with::serde_as]
217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
218pub struct ViolatingSitesResponse {
219    /// The list of violating sites.
220    #[serde(rename = "violatingSites")]
221    pub violating_sites: Option<Vec<SiteSummaryResponse>>,
222}
223
224impl common::ResponseResult for ViolatingSitesResponse {}
225
226// ###################
227// MethodBuilders ###
228// #################
229
230/// A builder providing access to all methods supported on *site* resources.
231/// It is not used directly, but through the [`AdExperienceReport`] hub.
232///
233/// # Example
234///
235/// Instantiate a resource builder
236///
237/// ```test_harness,no_run
238/// extern crate hyper;
239/// extern crate hyper_rustls;
240/// extern crate google_adexperiencereport1 as adexperiencereport1;
241///
242/// # async fn dox() {
243/// use adexperiencereport1::{AdExperienceReport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
244///
245/// let secret: yup_oauth2::ApplicationSecret = Default::default();
246/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
247///     .with_native_roots()
248///     .unwrap()
249///     .https_only()
250///     .enable_http2()
251///     .build();
252///
253/// let executor = hyper_util::rt::TokioExecutor::new();
254/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
255///     secret,
256///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
257///     yup_oauth2::client::CustomHyperClientBuilder::from(
258///         hyper_util::client::legacy::Client::builder(executor).build(connector),
259///     ),
260/// ).build().await.unwrap();
261///
262/// let client = hyper_util::client::legacy::Client::builder(
263///     hyper_util::rt::TokioExecutor::new()
264/// )
265/// .build(
266///     hyper_rustls::HttpsConnectorBuilder::new()
267///         .with_native_roots()
268///         .unwrap()
269///         .https_or_http()
270///         .enable_http2()
271///         .build()
272/// );
273/// let mut hub = AdExperienceReport::new(client, auth);
274/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
275/// // like `get(...)`
276/// // to build up your call.
277/// let rb = hub.sites();
278/// # }
279/// ```
280pub struct SiteMethods<'a, C>
281where
282    C: 'a,
283{
284    hub: &'a AdExperienceReport<C>,
285}
286
287impl<'a, C> common::MethodsBuilder for SiteMethods<'a, C> {}
288
289impl<'a, C> SiteMethods<'a, C> {
290    /// Create a builder to help you perform the following task:
291    ///
292    /// Gets a site's Ad Experience Report summary.
293    ///
294    /// # Arguments
295    ///
296    /// * `name` - Required. The name of the site whose summary to get, e.g. `sites/http%3A%2F%2Fwww.google.com%2F`. Format: `sites/{site}`
297    pub fn get(&self, name: &str) -> SiteGetCall<'a, C> {
298        SiteGetCall {
299            hub: self.hub,
300            _name: name.to_string(),
301            _delegate: Default::default(),
302            _additional_params: Default::default(),
303        }
304    }
305}
306
307/// A builder providing access to all methods supported on *violatingSite* resources.
308/// It is not used directly, but through the [`AdExperienceReport`] hub.
309///
310/// # Example
311///
312/// Instantiate a resource builder
313///
314/// ```test_harness,no_run
315/// extern crate hyper;
316/// extern crate hyper_rustls;
317/// extern crate google_adexperiencereport1 as adexperiencereport1;
318///
319/// # async fn dox() {
320/// use adexperiencereport1::{AdExperienceReport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
321///
322/// let secret: yup_oauth2::ApplicationSecret = Default::default();
323/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
324///     .with_native_roots()
325///     .unwrap()
326///     .https_only()
327///     .enable_http2()
328///     .build();
329///
330/// let executor = hyper_util::rt::TokioExecutor::new();
331/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
332///     secret,
333///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
334///     yup_oauth2::client::CustomHyperClientBuilder::from(
335///         hyper_util::client::legacy::Client::builder(executor).build(connector),
336///     ),
337/// ).build().await.unwrap();
338///
339/// let client = hyper_util::client::legacy::Client::builder(
340///     hyper_util::rt::TokioExecutor::new()
341/// )
342/// .build(
343///     hyper_rustls::HttpsConnectorBuilder::new()
344///         .with_native_roots()
345///         .unwrap()
346///         .https_or_http()
347///         .enable_http2()
348///         .build()
349/// );
350/// let mut hub = AdExperienceReport::new(client, auth);
351/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
352/// // like `list(...)`
353/// // to build up your call.
354/// let rb = hub.violating_sites();
355/// # }
356/// ```
357pub struct ViolatingSiteMethods<'a, C>
358where
359    C: 'a,
360{
361    hub: &'a AdExperienceReport<C>,
362}
363
364impl<'a, C> common::MethodsBuilder for ViolatingSiteMethods<'a, C> {}
365
366impl<'a, C> ViolatingSiteMethods<'a, C> {
367    /// Create a builder to help you perform the following task:
368    ///
369    /// Lists sites that are failing in the Ad Experience Report on at least one platform.
370    pub fn list(&self) -> ViolatingSiteListCall<'a, C> {
371        ViolatingSiteListCall {
372            hub: self.hub,
373            _delegate: Default::default(),
374            _additional_params: Default::default(),
375        }
376    }
377}
378
379// ###################
380// CallBuilders   ###
381// #################
382
383/// Gets a site's Ad Experience Report summary.
384///
385/// A builder for the *get* method supported by a *site* resource.
386/// It is not used directly, but through a [`SiteMethods`] instance.
387///
388/// # Example
389///
390/// Instantiate a resource method builder
391///
392/// ```test_harness,no_run
393/// # extern crate hyper;
394/// # extern crate hyper_rustls;
395/// # extern crate google_adexperiencereport1 as adexperiencereport1;
396/// # async fn dox() {
397/// # use adexperiencereport1::{AdExperienceReport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
398///
399/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
400/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
401/// #     .with_native_roots()
402/// #     .unwrap()
403/// #     .https_only()
404/// #     .enable_http2()
405/// #     .build();
406///
407/// # let executor = hyper_util::rt::TokioExecutor::new();
408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
409/// #     secret,
410/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
411/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
412/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
413/// #     ),
414/// # ).build().await.unwrap();
415///
416/// # let client = hyper_util::client::legacy::Client::builder(
417/// #     hyper_util::rt::TokioExecutor::new()
418/// # )
419/// # .build(
420/// #     hyper_rustls::HttpsConnectorBuilder::new()
421/// #         .with_native_roots()
422/// #         .unwrap()
423/// #         .https_or_http()
424/// #         .enable_http2()
425/// #         .build()
426/// # );
427/// # let mut hub = AdExperienceReport::new(client, auth);
428/// // You can configure optional parameters by calling the respective setters at will, and
429/// // execute the final call using `doit()`.
430/// // Values shown here are possibly random and not representative !
431/// let result = hub.sites().get("name")
432///              .doit().await;
433/// # }
434/// ```
435pub struct SiteGetCall<'a, C>
436where
437    C: 'a,
438{
439    hub: &'a AdExperienceReport<C>,
440    _name: String,
441    _delegate: Option<&'a mut dyn common::Delegate>,
442    _additional_params: HashMap<String, String>,
443}
444
445impl<'a, C> common::CallBuilder for SiteGetCall<'a, C> {}
446
447impl<'a, C> SiteGetCall<'a, C>
448where
449    C: common::Connector,
450{
451    /// Perform the operation you have build so far.
452    pub async fn doit(mut self) -> common::Result<(common::Response, SiteSummaryResponse)> {
453        use std::borrow::Cow;
454        use std::io::{Read, Seek};
455
456        use common::{url::Params, ToParts};
457        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
458
459        let mut dd = common::DefaultDelegate;
460        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
461        dlg.begin(common::MethodInfo {
462            id: "adexperiencereport.sites.get",
463            http_method: hyper::Method::GET,
464        });
465
466        for &field in ["alt", "name"].iter() {
467            if self._additional_params.contains_key(field) {
468                dlg.finished(false);
469                return Err(common::Error::FieldClash(field));
470            }
471        }
472
473        let mut params = Params::with_capacity(3 + self._additional_params.len());
474        params.push("name", self._name);
475
476        params.extend(self._additional_params.iter());
477
478        params.push("alt", "json");
479        let mut url = self.hub._base_url.clone() + "v1/{+name}";
480
481        match dlg.api_key() {
482            Some(value) => params.push("key", value),
483            None => {
484                dlg.finished(false);
485                return Err(common::Error::MissingAPIKey);
486            }
487        }
488
489        #[allow(clippy::single_element_loop)]
490        for &(find_this, param_name) in [("{+name}", "name")].iter() {
491            url = params.uri_replacement(url, param_name, find_this, true);
492        }
493        {
494            let to_remove = ["name"];
495            params.remove_params(&to_remove);
496        }
497
498        let url = params.parse_with_url(&url);
499
500        loop {
501            let mut req_result = {
502                let client = &self.hub.client;
503                dlg.pre_request();
504                let mut req_builder = hyper::Request::builder()
505                    .method(hyper::Method::GET)
506                    .uri(url.as_str())
507                    .header(USER_AGENT, self.hub._user_agent.clone());
508
509                let request = req_builder
510                    .header(CONTENT_LENGTH, 0_u64)
511                    .body(common::to_body::<String>(None));
512
513                client.request(request.unwrap()).await
514            };
515
516            match req_result {
517                Err(err) => {
518                    if let common::Retry::After(d) = dlg.http_error(&err) {
519                        sleep(d).await;
520                        continue;
521                    }
522                    dlg.finished(false);
523                    return Err(common::Error::HttpError(err));
524                }
525                Ok(res) => {
526                    let (mut parts, body) = res.into_parts();
527                    let mut body = common::Body::new(body);
528                    if !parts.status.is_success() {
529                        let bytes = common::to_bytes(body).await.unwrap_or_default();
530                        let error = serde_json::from_str(&common::to_string(&bytes));
531                        let response = common::to_response(parts, bytes.into());
532
533                        if let common::Retry::After(d) =
534                            dlg.http_failure(&response, error.as_ref().ok())
535                        {
536                            sleep(d).await;
537                            continue;
538                        }
539
540                        dlg.finished(false);
541
542                        return Err(match error {
543                            Ok(value) => common::Error::BadRequest(value),
544                            _ => common::Error::Failure(response),
545                        });
546                    }
547                    let response = {
548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
549                        let encoded = common::to_string(&bytes);
550                        match serde_json::from_str(&encoded) {
551                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
552                            Err(error) => {
553                                dlg.response_json_decode_error(&encoded, &error);
554                                return Err(common::Error::JsonDecodeError(
555                                    encoded.to_string(),
556                                    error,
557                                ));
558                            }
559                        }
560                    };
561
562                    dlg.finished(true);
563                    return Ok(response);
564                }
565            }
566        }
567    }
568
569    /// Required. The name of the site whose summary to get, e.g. `sites/http%3A%2F%2Fwww.google.com%2F`. Format: `sites/{site}`
570    ///
571    /// Sets the *name* path property to the given value.
572    ///
573    /// Even though the property as already been set when instantiating this call,
574    /// we provide this method for API completeness.
575    pub fn name(mut self, new_value: &str) -> SiteGetCall<'a, C> {
576        self._name = new_value.to_string();
577        self
578    }
579    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
580    /// while executing the actual API request.
581    ///
582    /// ````text
583    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
584    /// ````
585    ///
586    /// Sets the *delegate* property to the given value.
587    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteGetCall<'a, C> {
588        self._delegate = Some(new_value);
589        self
590    }
591
592    /// Set any additional parameter of the query string used in the request.
593    /// It should be used to set parameters which are not yet available through their own
594    /// setters.
595    ///
596    /// Please note that this method must not be used to set any of the known parameters
597    /// which have their own setter method. If done anyway, the request will fail.
598    ///
599    /// # Additional Parameters
600    ///
601    /// * *$.xgafv* (query-string) - V1 error format.
602    /// * *access_token* (query-string) - OAuth access token.
603    /// * *alt* (query-string) - Data format for response.
604    /// * *callback* (query-string) - JSONP
605    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
606    /// * *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.
607    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
608    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
609    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
610    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
611    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
612    pub fn param<T>(mut self, name: T, value: T) -> SiteGetCall<'a, C>
613    where
614        T: AsRef<str>,
615    {
616        self._additional_params
617            .insert(name.as_ref().to_string(), value.as_ref().to_string());
618        self
619    }
620}
621
622/// Lists sites that are failing in the Ad Experience Report on at least one platform.
623///
624/// A builder for the *list* method supported by a *violatingSite* resource.
625/// It is not used directly, but through a [`ViolatingSiteMethods`] instance.
626///
627/// # Example
628///
629/// Instantiate a resource method builder
630///
631/// ```test_harness,no_run
632/// # extern crate hyper;
633/// # extern crate hyper_rustls;
634/// # extern crate google_adexperiencereport1 as adexperiencereport1;
635/// # async fn dox() {
636/// # use adexperiencereport1::{AdExperienceReport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
637///
638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
639/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
640/// #     .with_native_roots()
641/// #     .unwrap()
642/// #     .https_only()
643/// #     .enable_http2()
644/// #     .build();
645///
646/// # let executor = hyper_util::rt::TokioExecutor::new();
647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
648/// #     secret,
649/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
650/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
651/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
652/// #     ),
653/// # ).build().await.unwrap();
654///
655/// # let client = hyper_util::client::legacy::Client::builder(
656/// #     hyper_util::rt::TokioExecutor::new()
657/// # )
658/// # .build(
659/// #     hyper_rustls::HttpsConnectorBuilder::new()
660/// #         .with_native_roots()
661/// #         .unwrap()
662/// #         .https_or_http()
663/// #         .enable_http2()
664/// #         .build()
665/// # );
666/// # let mut hub = AdExperienceReport::new(client, auth);
667/// // You can configure optional parameters by calling the respective setters at will, and
668/// // execute the final call using `doit()`.
669/// // Values shown here are possibly random and not representative !
670/// let result = hub.violating_sites().list()
671///              .doit().await;
672/// # }
673/// ```
674pub struct ViolatingSiteListCall<'a, C>
675where
676    C: 'a,
677{
678    hub: &'a AdExperienceReport<C>,
679    _delegate: Option<&'a mut dyn common::Delegate>,
680    _additional_params: HashMap<String, String>,
681}
682
683impl<'a, C> common::CallBuilder for ViolatingSiteListCall<'a, C> {}
684
685impl<'a, C> ViolatingSiteListCall<'a, C>
686where
687    C: common::Connector,
688{
689    /// Perform the operation you have build so far.
690    pub async fn doit(mut self) -> common::Result<(common::Response, ViolatingSitesResponse)> {
691        use std::borrow::Cow;
692        use std::io::{Read, Seek};
693
694        use common::{url::Params, ToParts};
695        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
696
697        let mut dd = common::DefaultDelegate;
698        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
699        dlg.begin(common::MethodInfo {
700            id: "adexperiencereport.violatingSites.list",
701            http_method: hyper::Method::GET,
702        });
703
704        for &field in ["alt"].iter() {
705            if self._additional_params.contains_key(field) {
706                dlg.finished(false);
707                return Err(common::Error::FieldClash(field));
708            }
709        }
710
711        let mut params = Params::with_capacity(2 + self._additional_params.len());
712
713        params.extend(self._additional_params.iter());
714
715        params.push("alt", "json");
716        let mut url = self.hub._base_url.clone() + "v1/violatingSites";
717
718        match dlg.api_key() {
719            Some(value) => params.push("key", value),
720            None => {
721                dlg.finished(false);
722                return Err(common::Error::MissingAPIKey);
723            }
724        }
725
726        let url = params.parse_with_url(&url);
727
728        loop {
729            let mut req_result = {
730                let client = &self.hub.client;
731                dlg.pre_request();
732                let mut req_builder = hyper::Request::builder()
733                    .method(hyper::Method::GET)
734                    .uri(url.as_str())
735                    .header(USER_AGENT, self.hub._user_agent.clone());
736
737                let request = req_builder
738                    .header(CONTENT_LENGTH, 0_u64)
739                    .body(common::to_body::<String>(None));
740
741                client.request(request.unwrap()).await
742            };
743
744            match req_result {
745                Err(err) => {
746                    if let common::Retry::After(d) = dlg.http_error(&err) {
747                        sleep(d).await;
748                        continue;
749                    }
750                    dlg.finished(false);
751                    return Err(common::Error::HttpError(err));
752                }
753                Ok(res) => {
754                    let (mut parts, body) = res.into_parts();
755                    let mut body = common::Body::new(body);
756                    if !parts.status.is_success() {
757                        let bytes = common::to_bytes(body).await.unwrap_or_default();
758                        let error = serde_json::from_str(&common::to_string(&bytes));
759                        let response = common::to_response(parts, bytes.into());
760
761                        if let common::Retry::After(d) =
762                            dlg.http_failure(&response, error.as_ref().ok())
763                        {
764                            sleep(d).await;
765                            continue;
766                        }
767
768                        dlg.finished(false);
769
770                        return Err(match error {
771                            Ok(value) => common::Error::BadRequest(value),
772                            _ => common::Error::Failure(response),
773                        });
774                    }
775                    let response = {
776                        let bytes = common::to_bytes(body).await.unwrap_or_default();
777                        let encoded = common::to_string(&bytes);
778                        match serde_json::from_str(&encoded) {
779                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
780                            Err(error) => {
781                                dlg.response_json_decode_error(&encoded, &error);
782                                return Err(common::Error::JsonDecodeError(
783                                    encoded.to_string(),
784                                    error,
785                                ));
786                            }
787                        }
788                    };
789
790                    dlg.finished(true);
791                    return Ok(response);
792                }
793            }
794        }
795    }
796
797    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
798    /// while executing the actual API request.
799    ///
800    /// ````text
801    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
802    /// ````
803    ///
804    /// Sets the *delegate* property to the given value.
805    pub fn delegate(
806        mut self,
807        new_value: &'a mut dyn common::Delegate,
808    ) -> ViolatingSiteListCall<'a, C> {
809        self._delegate = Some(new_value);
810        self
811    }
812
813    /// Set any additional parameter of the query string used in the request.
814    /// It should be used to set parameters which are not yet available through their own
815    /// setters.
816    ///
817    /// Please note that this method must not be used to set any of the known parameters
818    /// which have their own setter method. If done anyway, the request will fail.
819    ///
820    /// # Additional Parameters
821    ///
822    /// * *$.xgafv* (query-string) - V1 error format.
823    /// * *access_token* (query-string) - OAuth access token.
824    /// * *alt* (query-string) - Data format for response.
825    /// * *callback* (query-string) - JSONP
826    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
827    /// * *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.
828    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
829    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
830    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
831    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
832    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
833    pub fn param<T>(mut self, name: T, value: T) -> ViolatingSiteListCall<'a, C>
834    where
835        T: AsRef<str>,
836    {
837        self._additional_params
838            .insert(name.as_ref().to_string(), value.as_ref().to_string());
839        self
840    }
841}