Skip to main content

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