google_adsense2/
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 your AdSense data
17    Full,
18
19    /// View your AdSense data
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/adsense",
27            Scope::Readonly => "https://www.googleapis.com/auth/adsense.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 Adsense 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_adsense2 as adsense2;
53/// use adsense2::{Result, Error};
54/// # async fn dox() {
55/// use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace  `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
66///     secret,
67///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
68/// ).build().await.unwrap();
69///
70/// let client = hyper_util::client::legacy::Client::builder(
71///     hyper_util::rt::TokioExecutor::new()
72/// )
73/// .build(
74///     hyper_rustls::HttpsConnectorBuilder::new()
75///         .with_native_roots()
76///         .unwrap()
77///         .https_or_http()
78///         .enable_http1()
79///         .build()
80/// );
81/// let mut hub = Adsense::new(client, auth);
82/// // You can configure optional parameters by calling the respective setters at will, and
83/// // execute the final call using `doit()`.
84/// // Values shown here are possibly random and not representative !
85/// let result = hub.accounts().reports_generate("account")
86///              .start_date_year(-17)
87///              .start_date_month(-99)
88///              .start_date_day(-56)
89///              .reporting_time_zone("eos")
90///              .add_order_by("labore")
91///              .add_metrics("sed")
92///              .limit(-70)
93///              .language_code("sed")
94///              .add_filters("no")
95///              .end_date_year(-15)
96///              .end_date_month(-13)
97///              .end_date_day(-24)
98///              .add_dimensions("sed")
99///              .date_range("et")
100///              .currency_code("et")
101///              .doit().await;
102///
103/// match result {
104///     Err(e) => match e {
105///         // The Error enum provides details about what exactly happened.
106///         // You can also just use its `Debug`, `Display` or `Error` traits
107///          Error::HttpError(_)
108///         |Error::Io(_)
109///         |Error::MissingAPIKey
110///         |Error::MissingToken(_)
111///         |Error::Cancelled
112///         |Error::UploadSizeLimitExceeded(_, _)
113///         |Error::Failure(_)
114///         |Error::BadRequest(_)
115///         |Error::FieldClash(_)
116///         |Error::JsonDecodeError(_, _) => println!("{}", e),
117///     },
118///     Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct Adsense<C> {
124    pub client: common::Client<C>,
125    pub auth: Box<dyn common::GetToken>,
126    _user_agent: String,
127    _base_url: String,
128    _root_url: String,
129}
130
131impl<C> common::Hub for Adsense<C> {}
132
133impl<'a, C> Adsense<C> {
134    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Adsense<C> {
135        Adsense {
136            client,
137            auth: Box::new(auth),
138            _user_agent: "google-api-rust-client/6.0.0".to_string(),
139            _base_url: "https://adsense.googleapis.com/".to_string(),
140            _root_url: "https://adsense.googleapis.com/".to_string(),
141        }
142    }
143
144    pub fn accounts(&'a self) -> AccountMethods<'a, C> {
145        AccountMethods { hub: self }
146    }
147
148    /// Set the user-agent header field to use in all requests to the server.
149    /// It defaults to `google-api-rust-client/6.0.0`.
150    ///
151    /// Returns the previously set user-agent.
152    pub fn user_agent(&mut self, agent_name: String) -> String {
153        std::mem::replace(&mut self._user_agent, agent_name)
154    }
155
156    /// Set the base url to use in all requests to the server.
157    /// It defaults to `https://adsense.googleapis.com/`.
158    ///
159    /// Returns the previously set base url.
160    pub fn base_url(&mut self, new_base_url: String) -> String {
161        std::mem::replace(&mut self._base_url, new_base_url)
162    }
163
164    /// Set the root url to use in all requests to the server.
165    /// It defaults to `https://adsense.googleapis.com/`.
166    ///
167    /// Returns the previously set root url.
168    pub fn root_url(&mut self, new_root_url: String) -> String {
169        std::mem::replace(&mut self._root_url, new_root_url)
170    }
171}
172
173// ############
174// SCHEMAS ###
175// ##########
176/// Representation of an account.
177///
178/// # Activities
179///
180/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
181/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
182///
183/// * [adclients adunits create accounts](AccountAdclientAdunitCreateCall) (none)
184/// * [adclients adunits get accounts](AccountAdclientAdunitGetCall) (none)
185/// * [adclients adunits get adcode accounts](AccountAdclientAdunitGetAdcodeCall) (none)
186/// * [adclients adunits list accounts](AccountAdclientAdunitListCall) (none)
187/// * [adclients adunits list linked custom channels accounts](AccountAdclientAdunitListLinkedCustomChannelCall) (none)
188/// * [adclients adunits patch accounts](AccountAdclientAdunitPatchCall) (none)
189/// * [adclients customchannels create accounts](AccountAdclientCustomchannelCreateCall) (none)
190/// * [adclients customchannels delete accounts](AccountAdclientCustomchannelDeleteCall) (none)
191/// * [adclients customchannels get accounts](AccountAdclientCustomchannelGetCall) (none)
192/// * [adclients customchannels list accounts](AccountAdclientCustomchannelListCall) (none)
193/// * [adclients customchannels list linked ad units accounts](AccountAdclientCustomchannelListLinkedAdUnitCall) (none)
194/// * [adclients customchannels patch accounts](AccountAdclientCustomchannelPatchCall) (none)
195/// * [adclients urlchannels get accounts](AccountAdclientUrlchannelGetCall) (none)
196/// * [adclients urlchannels list accounts](AccountAdclientUrlchannelListCall) (none)
197/// * [adclients get accounts](AccountAdclientGetCall) (none)
198/// * [adclients get adcode accounts](AccountAdclientGetAdcodeCall) (none)
199/// * [adclients list accounts](AccountAdclientListCall) (none)
200/// * [alerts list accounts](AccountAlertListCall) (none)
201/// * [payments list accounts](AccountPaymentListCall) (none)
202/// * [policy issues get accounts](AccountPolicyIssueGetCall) (none)
203/// * [policy issues list accounts](AccountPolicyIssueListCall) (none)
204/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (none)
205/// * [reports saved generate csv accounts](AccountReportSavedGenerateCsvCall) (none)
206/// * [reports saved list accounts](AccountReportSavedListCall) (none)
207/// * [reports generate accounts](AccountReportGenerateCall) (none)
208/// * [reports generate csv accounts](AccountReportGenerateCsvCall) (none)
209/// * [reports get saved accounts](AccountReportGetSavedCall) (none)
210/// * [sites get accounts](AccountSiteGetCall) (none)
211/// * [sites list accounts](AccountSiteListCall) (none)
212/// * [get accounts](AccountGetCall) (response)
213/// * [get ad blocking recovery tag accounts](AccountGetAdBlockingRecoveryTagCall) (none)
214/// * [list accounts](AccountListCall) (none)
215/// * [list child accounts accounts](AccountListChildAccountCall) (none)
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct Account {
220    /// Output only. Creation time of the account.
221    #[serde(rename = "createTime")]
222    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
223    /// Output only. Display name of this account.
224    #[serde(rename = "displayName")]
225    pub display_name: Option<String>,
226    /// Output only. Resource name of the account. Format: accounts/pub-[0-9]+
227    pub name: Option<String>,
228    /// Output only. Outstanding tasks that need to be completed as part of the sign-up process for a new account. e.g. "billing-profile-creation", "phone-pin-verification".
229    #[serde(rename = "pendingTasks")]
230    pub pending_tasks: Option<Vec<String>>,
231    /// Output only. Whether this account is premium.
232    pub premium: Option<bool>,
233    /// Output only. State of the account.
234    pub state: Option<String>,
235    /// The account time zone, as used by reporting. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
236    #[serde(rename = "timeZone")]
237    pub time_zone: Option<TimeZone>,
238}
239
240impl common::Resource for Account {}
241impl common::ResponseResult for Account {}
242
243/// Representation of an ad blocking recovery tag. See https://support.google.com/adsense/answer/11575177.
244///
245/// # Activities
246///
247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
249///
250/// * [get ad blocking recovery tag accounts](AccountGetAdBlockingRecoveryTagCall) (response)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct AdBlockingRecoveryTag {
255    /// Error protection code that can be used in conjunction with the tag. It'll display a message to users if an [ad blocking extension blocks their access to your site](https://support.google.com/adsense/answer/11575480).
256    #[serde(rename = "errorProtectionCode")]
257    pub error_protection_code: Option<String>,
258    /// The ad blocking recovery tag. Note that the message generated by the tag can be blocked by an ad blocking extension. If this is not your desired outcome, then you'll need to use it in conjunction with the error protection code.
259    pub tag: Option<String>,
260}
261
262impl common::ResponseResult for AdBlockingRecoveryTag {}
263
264/// Representation of an ad client. An ad client represents a user’s subscription with a specific AdSense product.
265///
266/// # Activities
267///
268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
270///
271/// * [adclients get accounts](AccountAdclientGetCall) (response)
272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
273#[serde_with::serde_as]
274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
275pub struct AdClient {
276    /// Output only. Resource name of the ad client. Format: accounts/{account}/adclients/{adclient}
277    pub name: Option<String>,
278    /// Output only. Reporting product code of the ad client. For example, "AFC" for AdSense for Content. Corresponds to the `PRODUCT_CODE` dimension, and present only if the ad client supports reporting.
279    #[serde(rename = "productCode")]
280    pub product_code: Option<String>,
281    /// Output only. Unique ID of the ad client as used in the `AD_CLIENT_ID` reporting dimension. Present only if the ad client supports reporting.
282    #[serde(rename = "reportingDimensionId")]
283    pub reporting_dimension_id: Option<String>,
284    /// Output only. State of the ad client.
285    pub state: Option<String>,
286}
287
288impl common::ResponseResult for AdClient {}
289
290/// Representation of the AdSense code for a given ad client. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
291///
292/// # Activities
293///
294/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
295/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
296///
297/// * [adclients get adcode accounts](AccountAdclientGetAdcodeCall) (response)
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct AdClientAdCode {
302    /// Output only. The AdSense code snippet to add to the head of an HTML page.
303    #[serde(rename = "adCode")]
304    pub ad_code: Option<String>,
305    /// Output only. The AdSense code snippet to add to the body of an AMP page.
306    #[serde(rename = "ampBody")]
307    pub amp_body: Option<String>,
308    /// Output only. The AdSense code snippet to add to the head of an AMP page.
309    #[serde(rename = "ampHead")]
310    pub amp_head: Option<String>,
311}
312
313impl common::ResponseResult for AdClientAdCode {}
314
315/// Representation of an ad unit. An ad unit represents a saved ad unit with a specific set of ad settings that have been customized within an account.
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/// * [adclients adunits create accounts](AccountAdclientAdunitCreateCall) (request|response)
323/// * [adclients adunits get accounts](AccountAdclientAdunitGetCall) (response)
324/// * [adclients adunits patch accounts](AccountAdclientAdunitPatchCall) (request|response)
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct AdUnit {
329    /// Required. Settings specific to content ads (AFC).
330    #[serde(rename = "contentAdsSettings")]
331    pub content_ads_settings: Option<ContentAdsSettings>,
332    /// Required. Display name of the ad unit, as provided when the ad unit was created.
333    #[serde(rename = "displayName")]
334    pub display_name: Option<String>,
335    /// Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
336    pub name: Option<String>,
337    /// Output only. Unique ID of the ad unit as used in the `AD_UNIT_ID` reporting dimension.
338    #[serde(rename = "reportingDimensionId")]
339    pub reporting_dimension_id: Option<String>,
340    /// Required. State of the ad unit.
341    pub state: Option<String>,
342}
343
344impl common::RequestValue for AdUnit {}
345impl common::ResponseResult for AdUnit {}
346
347/// Representation of the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
348///
349/// # Activities
350///
351/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
352/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
353///
354/// * [adclients adunits get adcode accounts](AccountAdclientAdunitGetAdcodeCall) (response)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct AdUnitAdCode {
359    /// Output only. The code snippet to add to the body of an HTML page.
360    #[serde(rename = "adCode")]
361    pub ad_code: Option<String>,
362}
363
364impl common::ResponseResult for AdUnitAdCode {}
365
366/// Representation of an alert.
367///
368/// This type is not used in any activity, and only used as *part* of another schema.
369///
370#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
371#[serde_with::serde_as]
372#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
373pub struct Alert {
374    /// Output only. The localized alert message. This may contain HTML markup, such as phrase elements or links.
375    pub message: Option<String>,
376    /// Output only. Resource name of the alert. Format: accounts/{account}/alerts/{alert}
377    pub name: Option<String>,
378    /// Output only. Severity of this alert.
379    pub severity: Option<String>,
380    /// Output only. Type of alert. This identifies the broad type of this alert, and provides a stable machine-readable identifier that will not be translated. For example, "payment-hold".
381    #[serde(rename = "type")]
382    pub type_: Option<String>,
383}
384
385impl common::Part for Alert {}
386
387/// Cell representation.
388///
389/// This type is not used in any activity, and only used as *part* of another schema.
390///
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct Cell {
395    /// Value in the cell. The dimension cells contain strings, and the metric cells contain numbers.
396    pub value: Option<String>,
397}
398
399impl common::Part for Cell {}
400
401/// Settings specific to content ads (AFC).
402///
403/// This type is not used in any activity, and only used as *part* of another schema.
404///
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct ContentAdsSettings {
409    /// Required. Size of the ad unit. e.g. "728x90", "1x3" (for responsive ad units).
410    pub size: Option<String>,
411    /// Required. Type of the ad unit.
412    #[serde(rename = "type")]
413    pub type_: Option<String>,
414}
415
416impl common::Part for ContentAdsSettings {}
417
418/// Representation of a custom channel.
419///
420/// # Activities
421///
422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
424///
425/// * [adclients customchannels create accounts](AccountAdclientCustomchannelCreateCall) (request|response)
426/// * [adclients customchannels get accounts](AccountAdclientCustomchannelGetCall) (response)
427/// * [adclients customchannels patch accounts](AccountAdclientCustomchannelPatchCall) (request|response)
428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
429#[serde_with::serde_as]
430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
431pub struct CustomChannel {
432    /// Whether the custom channel is active and collecting data. See https://support.google.com/adsense/answer/10077192.
433    pub active: Option<bool>,
434    /// Required. Display name of the custom channel.
435    #[serde(rename = "displayName")]
436    pub display_name: Option<String>,
437    /// Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
438    pub name: Option<String>,
439    /// Output only. Unique ID of the custom channel as used in the `CUSTOM_CHANNEL_ID` reporting dimension.
440    #[serde(rename = "reportingDimensionId")]
441    pub reporting_dimension_id: Option<String>,
442}
443
444impl common::RequestValue for CustomChannel {}
445impl common::ResponseResult for CustomChannel {}
446
447/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
448///
449/// This type is not used in any activity, and only used as *part* of another schema.
450///
451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
452#[serde_with::serde_as]
453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
454pub struct Date {
455    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
456    pub day: Option<i32>,
457    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
458    pub month: Option<i32>,
459    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
460    pub year: Option<i32>,
461}
462
463impl common::Part for Date {}
464
465/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
466///
467/// # Activities
468///
469/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
470/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
471///
472/// * [adclients customchannels delete accounts](AccountAdclientCustomchannelDeleteCall) (response)
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct Empty {
477    _never_set: Option<bool>,
478}
479
480impl common::ResponseResult for Empty {}
481
482/// The header information of the columns requested in the report.
483///
484/// This type is not used in any activity, and only used as *part* of another schema.
485///
486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
487#[serde_with::serde_as]
488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
489pub struct Header {
490    /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) of this column. Only present if the header type is METRIC_CURRENCY.
491    #[serde(rename = "currencyCode")]
492    pub currency_code: Option<String>,
493    /// Required. Name of the header.
494    pub name: Option<String>,
495    /// Required. Type of the header.
496    #[serde(rename = "type")]
497    pub type_: Option<String>,
498}
499
500impl common::Part for Header {}
501
502/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
503///
504/// # Activities
505///
506/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
507/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
508///
509/// * [reports saved generate csv accounts](AccountReportSavedGenerateCsvCall) (response)
510/// * [reports generate csv accounts](AccountReportGenerateCsvCall) (response)
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct HttpBody {
515    /// The HTTP Content-Type header value specifying the content type of the body.
516    #[serde(rename = "contentType")]
517    pub content_type: Option<String>,
518    /// The HTTP request/response body as raw binary.
519    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
520    pub data: Option<Vec<u8>>,
521    /// Application specific response metadata. Must be set in the first response for streaming APIs.
522    pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
523}
524
525impl common::ResponseResult for HttpBody {}
526
527/// Response definition for the account list rpc.
528///
529/// # Activities
530///
531/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
532/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
533///
534/// * [list accounts](AccountListCall) (response)
535#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
536#[serde_with::serde_as]
537#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
538pub struct ListAccountsResponse {
539    /// The accounts returned in this list response.
540    pub accounts: Option<Vec<Account>>,
541    /// Continuation token used to page through accounts. To retrieve the next page of the results, set the next request's "page_token" value to this.
542    #[serde(rename = "nextPageToken")]
543    pub next_page_token: Option<String>,
544}
545
546impl common::ResponseResult for ListAccountsResponse {}
547
548/// Response definition for the ad client list rpc.
549///
550/// # Activities
551///
552/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
553/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
554///
555/// * [adclients list accounts](AccountAdclientListCall) (response)
556#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
557#[serde_with::serde_as]
558#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
559pub struct ListAdClientsResponse {
560    /// The ad clients returned in this list response.
561    #[serde(rename = "adClients")]
562    pub ad_clients: Option<Vec<AdClient>>,
563    /// Continuation token used to page through ad clients. To retrieve the next page of the results, set the next request's "page_token" value to this.
564    #[serde(rename = "nextPageToken")]
565    pub next_page_token: Option<String>,
566}
567
568impl common::ResponseResult for ListAdClientsResponse {}
569
570/// Response definition for the adunit list rpc.
571///
572/// # Activities
573///
574/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
575/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
576///
577/// * [adclients adunits list accounts](AccountAdclientAdunitListCall) (response)
578#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
579#[serde_with::serde_as]
580#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
581pub struct ListAdUnitsResponse {
582    /// The ad units returned in the list response.
583    #[serde(rename = "adUnits")]
584    pub ad_units: Option<Vec<AdUnit>>,
585    /// Continuation token used to page through ad units. To retrieve the next page of the results, set the next request's "page_token" value to this.
586    #[serde(rename = "nextPageToken")]
587    pub next_page_token: Option<String>,
588}
589
590impl common::ResponseResult for ListAdUnitsResponse {}
591
592/// Response definition for the alerts list rpc.
593///
594/// # Activities
595///
596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
598///
599/// * [alerts list accounts](AccountAlertListCall) (response)
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct ListAlertsResponse {
604    /// The alerts returned in this list response.
605    pub alerts: Option<Vec<Alert>>,
606}
607
608impl common::ResponseResult for ListAlertsResponse {}
609
610/// Response definition for the child account list rpc.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [list child accounts accounts](AccountListChildAccountCall) (response)
618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
619#[serde_with::serde_as]
620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
621pub struct ListChildAccountsResponse {
622    /// The accounts returned in this list response.
623    pub accounts: Option<Vec<Account>>,
624    /// Continuation token used to page through accounts. To retrieve the next page of the results, set the next request's "page_token" value to this.
625    #[serde(rename = "nextPageToken")]
626    pub next_page_token: Option<String>,
627}
628
629impl common::ResponseResult for ListChildAccountsResponse {}
630
631/// Response definition for the custom channel list rpc.
632///
633/// # Activities
634///
635/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
636/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
637///
638/// * [adclients customchannels list accounts](AccountAdclientCustomchannelListCall) (response)
639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
640#[serde_with::serde_as]
641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
642pub struct ListCustomChannelsResponse {
643    /// The custom channels returned in this list response.
644    #[serde(rename = "customChannels")]
645    pub custom_channels: Option<Vec<CustomChannel>>,
646    /// Continuation token used to page through alerts. To retrieve the next page of the results, set the next request's "page_token" value to this.
647    #[serde(rename = "nextPageToken")]
648    pub next_page_token: Option<String>,
649}
650
651impl common::ResponseResult for ListCustomChannelsResponse {}
652
653/// Response definition for the ad units linked to a custom channel list rpc.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [adclients customchannels list linked ad units accounts](AccountAdclientCustomchannelListLinkedAdUnitCall) (response)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct ListLinkedAdUnitsResponse {
665    /// The ad units returned in the list response.
666    #[serde(rename = "adUnits")]
667    pub ad_units: Option<Vec<AdUnit>>,
668    /// Continuation token used to page through ad units. To retrieve the next page of the results, set the next request's "page_token" value to this.
669    #[serde(rename = "nextPageToken")]
670    pub next_page_token: Option<String>,
671}
672
673impl common::ResponseResult for ListLinkedAdUnitsResponse {}
674
675/// Response definition for the custom channels linked to an adunit list rpc.
676///
677/// # Activities
678///
679/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
680/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
681///
682/// * [adclients adunits list linked custom channels accounts](AccountAdclientAdunitListLinkedCustomChannelCall) (response)
683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
684#[serde_with::serde_as]
685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
686pub struct ListLinkedCustomChannelsResponse {
687    /// The custom channels returned in this list response.
688    #[serde(rename = "customChannels")]
689    pub custom_channels: Option<Vec<CustomChannel>>,
690    /// Continuation token used to page through alerts. To retrieve the next page of the results, set the next request's "page_token" value to this.
691    #[serde(rename = "nextPageToken")]
692    pub next_page_token: Option<String>,
693}
694
695impl common::ResponseResult for ListLinkedCustomChannelsResponse {}
696
697/// Response definition for the payments list rpc.
698///
699/// # Activities
700///
701/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
702/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
703///
704/// * [payments list accounts](AccountPaymentListCall) (response)
705#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
706#[serde_with::serde_as]
707#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
708pub struct ListPaymentsResponse {
709    /// The payments returned in this list response.
710    pub payments: Option<Vec<Payment>>,
711}
712
713impl common::ResponseResult for ListPaymentsResponse {}
714
715/// Response definition for the policy issues list rpc. Policy issues are reported only if the publisher has at least one AFC ad client in READY or GETTING_READY state. If the publisher has no such AFC ad client, the response will be an empty list.
716///
717/// # Activities
718///
719/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
720/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
721///
722/// * [policy issues list accounts](AccountPolicyIssueListCall) (response)
723#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
724#[serde_with::serde_as]
725#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
726pub struct ListPolicyIssuesResponse {
727    /// Continuation token used to page through policy issues. To retrieve the next page of the results, set the next request's "page_token" value to this.
728    #[serde(rename = "nextPageToken")]
729    pub next_page_token: Option<String>,
730    /// The policy issues returned in the list response.
731    #[serde(rename = "policyIssues")]
732    pub policy_issues: Option<Vec<PolicyIssue>>,
733}
734
735impl common::ResponseResult for ListPolicyIssuesResponse {}
736
737/// Response definition for the saved reports list rpc.
738///
739/// # Activities
740///
741/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
742/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
743///
744/// * [reports saved list accounts](AccountReportSavedListCall) (response)
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct ListSavedReportsResponse {
749    /// Continuation token used to page through reports. To retrieve the next page of the results, set the next request's "page_token" value to this.
750    #[serde(rename = "nextPageToken")]
751    pub next_page_token: Option<String>,
752    /// The reports returned in this list response.
753    #[serde(rename = "savedReports")]
754    pub saved_reports: Option<Vec<SavedReport>>,
755}
756
757impl common::ResponseResult for ListSavedReportsResponse {}
758
759/// Response definition for the sites list rpc.
760///
761/// # Activities
762///
763/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
764/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
765///
766/// * [sites list accounts](AccountSiteListCall) (response)
767#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
768#[serde_with::serde_as]
769#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
770pub struct ListSitesResponse {
771    /// Continuation token used to page through sites. To retrieve the next page of the results, set the next request's "page_token" value to this.
772    #[serde(rename = "nextPageToken")]
773    pub next_page_token: Option<String>,
774    /// The sites returned in this list response.
775    pub sites: Option<Vec<Site>>,
776}
777
778impl common::ResponseResult for ListSitesResponse {}
779
780/// Response definition for the url channels list rpc.
781///
782/// # Activities
783///
784/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
785/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
786///
787/// * [adclients urlchannels list accounts](AccountAdclientUrlchannelListCall) (response)
788#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
789#[serde_with::serde_as]
790#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
791pub struct ListUrlChannelsResponse {
792    /// Continuation token used to page through url channels. To retrieve the next page of the results, set the next request's "page_token" value to this.
793    #[serde(rename = "nextPageToken")]
794    pub next_page_token: Option<String>,
795    /// The url channels returned in this list response.
796    #[serde(rename = "urlChannels")]
797    pub url_channels: Option<Vec<UrlChannel>>,
798}
799
800impl common::ResponseResult for ListUrlChannelsResponse {}
801
802/// Representation of an unpaid or paid payment. See [Payment timelines for AdSense](https://support.google.com/adsense/answer/7164703) for more information about payments and the [YouTube homepage and payments account](https://support.google.com/adsense/answer/11622510) article for information about dedicated payments accounts for YouTube.
803///
804/// This type is not used in any activity, and only used as *part* of another schema.
805///
806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
807#[serde_with::serde_as]
808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
809pub struct Payment {
810    /// Output only. The amount of unpaid or paid earnings, as a formatted string, including the currency. E.g. "¥1,235 JPY", "$1,234.57", "£87.65".
811    pub amount: Option<String>,
812    /// Output only. For paid earnings, the date that the payment was credited. For unpaid earnings, this field is empty. Payment dates are always returned in the billing timezone (America/Los_Angeles).
813    pub date: Option<Date>,
814    /// Output only. Resource name of the payment. Format: - accounts/{account}/payments/unpaid for unpaid (current) AdSense earnings. - accounts/{account}/payments/youtube-unpaid for unpaid (current) YouTube earnings. - accounts/{account}/payments/yyyy-MM-dd for paid AdSense earnings. - accounts/{account}/payments/youtube-yyyy-MM-dd for paid YouTube earnings.
815    pub name: Option<String>,
816}
817
818impl common::Part for Payment {}
819
820/// Representation of a policy issue for a single entity (site, site-section, or page). All issues for a single entity are represented by a single PolicyIssue resource, though that PolicyIssue can have multiple causes (or “topics”) that can change over time. Policy issues are removed if there are no issues detected recently or if there’s a recent successful appeal for the entity.
821///
822/// # Activities
823///
824/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
825/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
826///
827/// * [policy issues get accounts](AccountPolicyIssueGetCall) (response)
828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
829#[serde_with::serde_as]
830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
831pub struct PolicyIssue {
832    /// Required. The most severe action taken on the entity over the past seven days.
833    pub action: Option<String>,
834    /// Optional. List of ad clients associated with the policy issue (either as the primary ad client or an associated host/secondary ad client). In the latter case, this will be an ad client that is not owned by the current account.
835    #[serde(rename = "adClients")]
836    pub ad_clients: Option<Vec<String>>,
837    /// Required. Total number of ad requests affected by the policy violations over the past seven days.
838    #[serde(rename = "adRequestCount")]
839    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
840    pub ad_request_count: Option<i64>,
841    /// Required. Type of the entity indicating if the entity is a site, site-section, or page.
842    #[serde(rename = "entityType")]
843    pub entity_type: Option<String>,
844    /// Required. The date (in the America/Los_Angeles timezone) when policy violations were first detected on the entity.
845    #[serde(rename = "firstDetectedDate")]
846    pub first_detected_date: Option<Date>,
847    /// Required. The date (in the America/Los_Angeles timezone) when policy violations were last detected on the entity.
848    #[serde(rename = "lastDetectedDate")]
849    pub last_detected_date: Option<Date>,
850    /// Required. Resource name of the entity with policy issues. Format: accounts/{account}/policyIssues/{policy_issue}
851    pub name: Option<String>,
852    /// Required. Unordered list. The policy topics that this entity was found to violate over the past seven days.
853    #[serde(rename = "policyTopics")]
854    pub policy_topics: Option<Vec<PolicyTopic>>,
855    /// Required. Hostname/domain of the entity (for example "foo.com" or "www.foo.com"). This _should_ be a bare domain/host name without any protocol. This will be present for all policy issues.
856    pub site: Option<String>,
857    /// Optional. Prefix of the site-section having policy issues (For example "foo.com/bar-section"). This will be present if the `entity_type` is `SITE_SECTION` and will be absent for other entity types.
858    #[serde(rename = "siteSection")]
859    pub site_section: Option<String>,
860    /// Optional. URI of the page having policy violations (for example "foo.com/bar" or "www.foo.com/bar"). This will be present if the `entity_type` is `PAGE` and will be absent for other entity types.
861    pub uri: Option<String>,
862    /// Optional. The date (in the America/Los_Angeles timezone) when the entity will have ad serving demand restricted or ad serving disabled. This is present only for issues with a `WARNED` enforcement action. See https://support.google.com/adsense/answer/11066888.
863    #[serde(rename = "warningEscalationDate")]
864    pub warning_escalation_date: Option<Date>,
865}
866
867impl common::ResponseResult for PolicyIssue {}
868
869/// Information about a particular policy topic. A policy topic represents a single class of policy issue that can impact ad serving for your site. For example, sexual content or having ads that obscure your content. A single policy issue can have multiple policy topics for a single entity.
870///
871/// This type is not used in any activity, and only used as *part* of another schema.
872///
873#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
874#[serde_with::serde_as]
875#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
876pub struct PolicyTopic {
877    /// Required. Indicates if this is a policy violation or not. When the value is true, issues that are instances of this topic must be addressed to remain in compliance with the partner's agreements with Google. A false value indicates that it's not mandatory to fix the issues but advertising demand might be restricted.
878    #[serde(rename = "mustFix")]
879    pub must_fix: Option<bool>,
880    /// Required. The policy topic. For example, "sexual-content" or "ads-obscuring-content"."
881    pub topic: Option<String>,
882}
883
884impl common::Part for PolicyTopic {}
885
886/// Result of a generated report.
887///
888/// # Activities
889///
890/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
891/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
892///
893/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (response)
894/// * [reports generate accounts](AccountReportGenerateCall) (response)
895#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
896#[serde_with::serde_as]
897#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
898pub struct ReportResult {
899    /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
900    pub averages: Option<Row>,
901    /// Required. End date of the range (inclusive).
902    #[serde(rename = "endDate")]
903    pub end_date: Option<Date>,
904    /// The header information; one for each dimension in the request, followed by one for each metric in the request.
905    pub headers: Option<Vec<Header>>,
906    /// The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request.
907    pub rows: Option<Vec<Row>>,
908    /// Required. Start date of the range (inclusive).
909    #[serde(rename = "startDate")]
910    pub start_date: Option<Date>,
911    /// The total number of rows matched by the report request.
912    #[serde(rename = "totalMatchedRows")]
913    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
914    pub total_matched_rows: Option<i64>,
915    /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
916    pub totals: Option<Row>,
917    /// Any warnings associated with generation of the report. These warnings are always returned in English.
918    pub warnings: Option<Vec<String>>,
919}
920
921impl common::ResponseResult for ReportResult {}
922
923/// Row representation.
924///
925/// This type is not used in any activity, and only used as *part* of another schema.
926///
927#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
928#[serde_with::serde_as]
929#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
930pub struct Row {
931    /// Cells in the row.
932    pub cells: Option<Vec<Cell>>,
933}
934
935impl common::Part for Row {}
936
937/// Representation of a saved report.
938///
939/// # Activities
940///
941/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
942/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
943///
944/// * [reports get saved accounts](AccountReportGetSavedCall) (response)
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct SavedReport {
949    /// Output only. Resource name of the report. Format: accounts/{account}/reports/{report}
950    pub name: Option<String>,
951    /// Report title as specified by publisher.
952    pub title: Option<String>,
953}
954
955impl common::ResponseResult for SavedReport {}
956
957/// Representation of a Site.
958///
959/// # Activities
960///
961/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
962/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
963///
964/// * [sites get accounts](AccountSiteGetCall) (response)
965#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
966#[serde_with::serde_as]
967#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
968pub struct Site {
969    /// Whether auto ads is turned on for the site.
970    #[serde(rename = "autoAdsEnabled")]
971    pub auto_ads_enabled: Option<bool>,
972    /// Domain (or subdomain) of the site, e.g. "example.com" or "www.example.com". This is used in the `OWNED_SITE_DOMAIN_NAME` reporting dimension.
973    pub domain: Option<String>,
974    /// Output only. Resource name of a site. Format: accounts/{account}/sites/{site}
975    pub name: Option<String>,
976    /// Output only. Unique ID of the site as used in the `OWNED_SITE_ID` reporting dimension.
977    #[serde(rename = "reportingDimensionId")]
978    pub reporting_dimension_id: Option<String>,
979    /// Output only. State of a site.
980    pub state: Option<String>,
981}
982
983impl common::ResponseResult for Site {}
984
985/// Represents a time zone from the [IANA Time Zone Database](https://www.iana.org/time-zones).
986///
987/// This type is not used in any activity, and only used as *part* of another schema.
988///
989#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
990#[serde_with::serde_as]
991#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
992pub struct TimeZone {
993    /// IANA Time Zone Database time zone, e.g. "America/New_York".
994    pub id: Option<String>,
995    /// Optional. IANA Time Zone Database version number, e.g. "2019a".
996    pub version: Option<String>,
997}
998
999impl common::Part for TimeZone {}
1000
1001/// Representation of a URL channel. URL channels allow you to track the performance of particular pages in your site; see [URL channels](https://support.google.com/adsense/answer/2923836) for more information.
1002///
1003/// # Activities
1004///
1005/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1006/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1007///
1008/// * [adclients urlchannels get accounts](AccountAdclientUrlchannelGetCall) (response)
1009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1010#[serde_with::serde_as]
1011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1012pub struct UrlChannel {
1013    /// Output only. Resource name of the URL channel. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
1014    pub name: Option<String>,
1015    /// Output only. Unique ID of the custom channel as used in the `URL_CHANNEL_ID` reporting dimension.
1016    #[serde(rename = "reportingDimensionId")]
1017    pub reporting_dimension_id: Option<String>,
1018    /// URI pattern of the channel. Does not include "http://" or "https://". Example: www.example.com/home
1019    #[serde(rename = "uriPattern")]
1020    pub uri_pattern: Option<String>,
1021}
1022
1023impl common::ResponseResult for UrlChannel {}
1024
1025// ###################
1026// MethodBuilders ###
1027// #################
1028
1029/// A builder providing access to all methods supported on *account* resources.
1030/// It is not used directly, but through the [`Adsense`] hub.
1031///
1032/// # Example
1033///
1034/// Instantiate a resource builder
1035///
1036/// ```test_harness,no_run
1037/// extern crate hyper;
1038/// extern crate hyper_rustls;
1039/// extern crate google_adsense2 as adsense2;
1040///
1041/// # async fn dox() {
1042/// use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1043///
1044/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1045/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1046///     secret,
1047///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1048/// ).build().await.unwrap();
1049///
1050/// let client = hyper_util::client::legacy::Client::builder(
1051///     hyper_util::rt::TokioExecutor::new()
1052/// )
1053/// .build(
1054///     hyper_rustls::HttpsConnectorBuilder::new()
1055///         .with_native_roots()
1056///         .unwrap()
1057///         .https_or_http()
1058///         .enable_http1()
1059///         .build()
1060/// );
1061/// let mut hub = Adsense::new(client, auth);
1062/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1063/// // like `adclients_adunits_create(...)`, `adclients_adunits_get(...)`, `adclients_adunits_get_adcode(...)`, `adclients_adunits_list(...)`, `adclients_adunits_list_linked_custom_channels(...)`, `adclients_adunits_patch(...)`, `adclients_customchannels_create(...)`, `adclients_customchannels_delete(...)`, `adclients_customchannels_get(...)`, `adclients_customchannels_list(...)`, `adclients_customchannels_list_linked_ad_units(...)`, `adclients_customchannels_patch(...)`, `adclients_get(...)`, `adclients_get_adcode(...)`, `adclients_list(...)`, `adclients_urlchannels_get(...)`, `adclients_urlchannels_list(...)`, `alerts_list(...)`, `get(...)`, `get_ad_blocking_recovery_tag(...)`, `list(...)`, `list_child_accounts(...)`, `payments_list(...)`, `policy_issues_get(...)`, `policy_issues_list(...)`, `reports_generate(...)`, `reports_generate_csv(...)`, `reports_get_saved(...)`, `reports_saved_generate(...)`, `reports_saved_generate_csv(...)`, `reports_saved_list(...)`, `sites_get(...)` and `sites_list(...)`
1064/// // to build up your call.
1065/// let rb = hub.accounts();
1066/// # }
1067/// ```
1068pub struct AccountMethods<'a, C>
1069where
1070    C: 'a,
1071{
1072    hub: &'a Adsense<C>,
1073}
1074
1075impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
1076
1077impl<'a, C> AccountMethods<'a, C> {
1078    /// Create a builder to help you perform the following task:
1079    ///
1080    /// Creates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. Note that ad units can only be created for ad clients with an “AFC” product code. For more info see the [AdClient resource](https://developers.google.com/adsense/management/reference/rest/v2/accounts.adclients). For now, this method can only be used to create `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1081    ///
1082    /// # Arguments
1083    ///
1084    /// * `request` - No description provided.
1085    /// * `parent` - Required. Ad client to create an ad unit under. Format: accounts/{account}/adclients/{adclient}
1086    pub fn adclients_adunits_create(
1087        &self,
1088        request: AdUnit,
1089        parent: &str,
1090    ) -> AccountAdclientAdunitCreateCall<'a, C> {
1091        AccountAdclientAdunitCreateCall {
1092            hub: self.hub,
1093            _request: request,
1094            _parent: parent.to_string(),
1095            _delegate: Default::default(),
1096            _additional_params: Default::default(),
1097            _scopes: Default::default(),
1098        }
1099    }
1100
1101    /// Create a builder to help you perform the following task:
1102    ///
1103    /// Gets an ad unit from a specified account and ad client.
1104    ///
1105    /// # Arguments
1106    ///
1107    /// * `name` - Required. AdUnit to get information about. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1108    pub fn adclients_adunits_get(&self, name: &str) -> AccountAdclientAdunitGetCall<'a, C> {
1109        AccountAdclientAdunitGetCall {
1110            hub: self.hub,
1111            _name: name.to_string(),
1112            _delegate: Default::default(),
1113            _additional_params: Default::default(),
1114            _scopes: Default::default(),
1115        }
1116    }
1117
1118    /// Create a builder to help you perform the following task:
1119    ///
1120    /// Gets the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
1121    ///
1122    /// # Arguments
1123    ///
1124    /// * `name` - Required. Name of the adunit for which to get the adcode. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1125    pub fn adclients_adunits_get_adcode(
1126        &self,
1127        name: &str,
1128    ) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
1129        AccountAdclientAdunitGetAdcodeCall {
1130            hub: self.hub,
1131            _name: name.to_string(),
1132            _delegate: Default::default(),
1133            _additional_params: Default::default(),
1134            _scopes: Default::default(),
1135        }
1136    }
1137
1138    /// Create a builder to help you perform the following task:
1139    ///
1140    /// Lists all ad units under a specified account and ad client.
1141    ///
1142    /// # Arguments
1143    ///
1144    /// * `parent` - Required. The ad client which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}
1145    pub fn adclients_adunits_list(&self, parent: &str) -> AccountAdclientAdunitListCall<'a, C> {
1146        AccountAdclientAdunitListCall {
1147            hub: self.hub,
1148            _parent: parent.to_string(),
1149            _page_token: Default::default(),
1150            _page_size: Default::default(),
1151            _delegate: Default::default(),
1152            _additional_params: Default::default(),
1153            _scopes: Default::default(),
1154        }
1155    }
1156
1157    /// Create a builder to help you perform the following task:
1158    ///
1159    /// Lists all the custom channels available for an ad unit.
1160    ///
1161    /// # Arguments
1162    ///
1163    /// * `parent` - Required. The ad unit which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1164    pub fn adclients_adunits_list_linked_custom_channels(
1165        &self,
1166        parent: &str,
1167    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
1168        AccountAdclientAdunitListLinkedCustomChannelCall {
1169            hub: self.hub,
1170            _parent: parent.to_string(),
1171            _page_token: Default::default(),
1172            _page_size: Default::default(),
1173            _delegate: Default::default(),
1174            _additional_params: Default::default(),
1175            _scopes: Default::default(),
1176        }
1177    }
1178
1179    /// Create a builder to help you perform the following task:
1180    ///
1181    /// Updates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. For now, this method can only be used to update `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1182    ///
1183    /// # Arguments
1184    ///
1185    /// * `request` - No description provided.
1186    /// * `name` - Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1187    pub fn adclients_adunits_patch(
1188        &self,
1189        request: AdUnit,
1190        name: &str,
1191    ) -> AccountAdclientAdunitPatchCall<'a, C> {
1192        AccountAdclientAdunitPatchCall {
1193            hub: self.hub,
1194            _request: request,
1195            _name: name.to_string(),
1196            _update_mask: Default::default(),
1197            _delegate: Default::default(),
1198            _additional_params: Default::default(),
1199            _scopes: Default::default(),
1200        }
1201    }
1202
1203    /// Create a builder to help you perform the following task:
1204    ///
1205    /// Creates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1206    ///
1207    /// # Arguments
1208    ///
1209    /// * `request` - No description provided.
1210    /// * `parent` - Required. The ad client to create a custom channel under. Format: accounts/{account}/adclients/{adclient}
1211    pub fn adclients_customchannels_create(
1212        &self,
1213        request: CustomChannel,
1214        parent: &str,
1215    ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
1216        AccountAdclientCustomchannelCreateCall {
1217            hub: self.hub,
1218            _request: request,
1219            _parent: parent.to_string(),
1220            _delegate: Default::default(),
1221            _additional_params: Default::default(),
1222            _scopes: Default::default(),
1223        }
1224    }
1225
1226    /// Create a builder to help you perform the following task:
1227    ///
1228    /// Deletes a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1229    ///
1230    /// # Arguments
1231    ///
1232    /// * `name` - Required. Name of the custom channel to delete. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1233    pub fn adclients_customchannels_delete(
1234        &self,
1235        name: &str,
1236    ) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
1237        AccountAdclientCustomchannelDeleteCall {
1238            hub: self.hub,
1239            _name: name.to_string(),
1240            _delegate: Default::default(),
1241            _additional_params: Default::default(),
1242            _scopes: Default::default(),
1243        }
1244    }
1245
1246    /// Create a builder to help you perform the following task:
1247    ///
1248    /// Gets information about the selected custom channel.
1249    ///
1250    /// # Arguments
1251    ///
1252    /// * `name` - Required. Name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1253    pub fn adclients_customchannels_get(
1254        &self,
1255        name: &str,
1256    ) -> AccountAdclientCustomchannelGetCall<'a, C> {
1257        AccountAdclientCustomchannelGetCall {
1258            hub: self.hub,
1259            _name: name.to_string(),
1260            _delegate: Default::default(),
1261            _additional_params: Default::default(),
1262            _scopes: Default::default(),
1263        }
1264    }
1265
1266    /// Create a builder to help you perform the following task:
1267    ///
1268    /// Lists all the custom channels available in an ad client.
1269    ///
1270    /// # Arguments
1271    ///
1272    /// * `parent` - Required. The ad client which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}
1273    pub fn adclients_customchannels_list(
1274        &self,
1275        parent: &str,
1276    ) -> AccountAdclientCustomchannelListCall<'a, C> {
1277        AccountAdclientCustomchannelListCall {
1278            hub: self.hub,
1279            _parent: parent.to_string(),
1280            _page_token: Default::default(),
1281            _page_size: Default::default(),
1282            _delegate: Default::default(),
1283            _additional_params: Default::default(),
1284            _scopes: Default::default(),
1285        }
1286    }
1287
1288    /// Create a builder to help you perform the following task:
1289    ///
1290    /// Lists all the ad units available for a custom channel.
1291    ///
1292    /// # Arguments
1293    ///
1294    /// * `parent` - Required. The custom channel which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1295    pub fn adclients_customchannels_list_linked_ad_units(
1296        &self,
1297        parent: &str,
1298    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
1299        AccountAdclientCustomchannelListLinkedAdUnitCall {
1300            hub: self.hub,
1301            _parent: parent.to_string(),
1302            _page_token: Default::default(),
1303            _page_size: Default::default(),
1304            _delegate: Default::default(),
1305            _additional_params: Default::default(),
1306            _scopes: Default::default(),
1307        }
1308    }
1309
1310    /// Create a builder to help you perform the following task:
1311    ///
1312    /// Updates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1313    ///
1314    /// # Arguments
1315    ///
1316    /// * `request` - No description provided.
1317    /// * `name` - Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1318    pub fn adclients_customchannels_patch(
1319        &self,
1320        request: CustomChannel,
1321        name: &str,
1322    ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
1323        AccountAdclientCustomchannelPatchCall {
1324            hub: self.hub,
1325            _request: request,
1326            _name: name.to_string(),
1327            _update_mask: Default::default(),
1328            _delegate: Default::default(),
1329            _additional_params: Default::default(),
1330            _scopes: Default::default(),
1331        }
1332    }
1333
1334    /// Create a builder to help you perform the following task:
1335    ///
1336    /// Gets information about the selected url channel.
1337    ///
1338    /// # Arguments
1339    ///
1340    /// * `name` - Required. The name of the url channel to retrieve. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
1341    pub fn adclients_urlchannels_get(&self, name: &str) -> AccountAdclientUrlchannelGetCall<'a, C> {
1342        AccountAdclientUrlchannelGetCall {
1343            hub: self.hub,
1344            _name: name.to_string(),
1345            _delegate: Default::default(),
1346            _additional_params: Default::default(),
1347            _scopes: Default::default(),
1348        }
1349    }
1350
1351    /// Create a builder to help you perform the following task:
1352    ///
1353    /// Lists active url channels.
1354    ///
1355    /// # Arguments
1356    ///
1357    /// * `parent` - Required. The ad client which owns the collection of url channels. Format: accounts/{account}/adclients/{adclient}
1358    pub fn adclients_urlchannels_list(
1359        &self,
1360        parent: &str,
1361    ) -> AccountAdclientUrlchannelListCall<'a, C> {
1362        AccountAdclientUrlchannelListCall {
1363            hub: self.hub,
1364            _parent: parent.to_string(),
1365            _page_token: Default::default(),
1366            _page_size: Default::default(),
1367            _delegate: Default::default(),
1368            _additional_params: Default::default(),
1369            _scopes: Default::default(),
1370        }
1371    }
1372
1373    /// Create a builder to help you perform the following task:
1374    ///
1375    /// Gets the ad client from the given resource name.
1376    ///
1377    /// # Arguments
1378    ///
1379    /// * `name` - Required. The name of the ad client to retrieve. Format: accounts/{account}/adclients/{adclient}
1380    pub fn adclients_get(&self, name: &str) -> AccountAdclientGetCall<'a, C> {
1381        AccountAdclientGetCall {
1382            hub: self.hub,
1383            _name: name.to_string(),
1384            _delegate: Default::default(),
1385            _additional_params: Default::default(),
1386            _scopes: Default::default(),
1387        }
1388    }
1389
1390    /// Create a builder to help you perform the following task:
1391    ///
1392    /// Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
1393    ///
1394    /// # Arguments
1395    ///
1396    /// * `name` - Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
1397    pub fn adclients_get_adcode(&self, name: &str) -> AccountAdclientGetAdcodeCall<'a, C> {
1398        AccountAdclientGetAdcodeCall {
1399            hub: self.hub,
1400            _name: name.to_string(),
1401            _delegate: Default::default(),
1402            _additional_params: Default::default(),
1403            _scopes: Default::default(),
1404        }
1405    }
1406
1407    /// Create a builder to help you perform the following task:
1408    ///
1409    /// Lists all the ad clients available in an account.
1410    ///
1411    /// # Arguments
1412    ///
1413    /// * `parent` - Required. The account which owns the collection of ad clients. Format: accounts/{account}
1414    pub fn adclients_list(&self, parent: &str) -> AccountAdclientListCall<'a, C> {
1415        AccountAdclientListCall {
1416            hub: self.hub,
1417            _parent: parent.to_string(),
1418            _page_token: Default::default(),
1419            _page_size: Default::default(),
1420            _delegate: Default::default(),
1421            _additional_params: Default::default(),
1422            _scopes: Default::default(),
1423        }
1424    }
1425
1426    /// Create a builder to help you perform the following task:
1427    ///
1428    /// Lists all the alerts available in an account.
1429    ///
1430    /// # Arguments
1431    ///
1432    /// * `parent` - Required. The account which owns the collection of alerts. Format: accounts/{account}
1433    pub fn alerts_list(&self, parent: &str) -> AccountAlertListCall<'a, C> {
1434        AccountAlertListCall {
1435            hub: self.hub,
1436            _parent: parent.to_string(),
1437            _language_code: Default::default(),
1438            _delegate: Default::default(),
1439            _additional_params: Default::default(),
1440            _scopes: Default::default(),
1441        }
1442    }
1443
1444    /// Create a builder to help you perform the following task:
1445    ///
1446    /// Lists all the payments available for an account.
1447    ///
1448    /// # Arguments
1449    ///
1450    /// * `parent` - Required. The account which owns the collection of payments. Format: accounts/{account}
1451    pub fn payments_list(&self, parent: &str) -> AccountPaymentListCall<'a, C> {
1452        AccountPaymentListCall {
1453            hub: self.hub,
1454            _parent: parent.to_string(),
1455            _delegate: Default::default(),
1456            _additional_params: Default::default(),
1457            _scopes: Default::default(),
1458        }
1459    }
1460
1461    /// Create a builder to help you perform the following task:
1462    ///
1463    /// Gets information about the selected policy issue.
1464    ///
1465    /// # Arguments
1466    ///
1467    /// * `name` - Required. Name of the policy issue. Format: accounts/{account}/policyIssues/{policy_issue}
1468    pub fn policy_issues_get(&self, name: &str) -> AccountPolicyIssueGetCall<'a, C> {
1469        AccountPolicyIssueGetCall {
1470            hub: self.hub,
1471            _name: name.to_string(),
1472            _delegate: Default::default(),
1473            _additional_params: Default::default(),
1474            _scopes: Default::default(),
1475        }
1476    }
1477
1478    /// Create a builder to help you perform the following task:
1479    ///
1480    /// Lists all the policy issues where the specified account is involved, both directly and through any AFP child accounts.
1481    ///
1482    /// # Arguments
1483    ///
1484    /// * `parent` - Required. The account for which policy issues are being retrieved. Format: accounts/{account}
1485    pub fn policy_issues_list(&self, parent: &str) -> AccountPolicyIssueListCall<'a, C> {
1486        AccountPolicyIssueListCall {
1487            hub: self.hub,
1488            _parent: parent.to_string(),
1489            _page_token: Default::default(),
1490            _page_size: Default::default(),
1491            _delegate: Default::default(),
1492            _additional_params: Default::default(),
1493            _scopes: Default::default(),
1494        }
1495    }
1496
1497    /// Create a builder to help you perform the following task:
1498    ///
1499    /// Generates a saved report.
1500    ///
1501    /// # Arguments
1502    ///
1503    /// * `name` - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
1504    pub fn reports_saved_generate(&self, name: &str) -> AccountReportSavedGenerateCall<'a, C> {
1505        AccountReportSavedGenerateCall {
1506            hub: self.hub,
1507            _name: name.to_string(),
1508            _start_date_year: Default::default(),
1509            _start_date_month: Default::default(),
1510            _start_date_day: Default::default(),
1511            _reporting_time_zone: Default::default(),
1512            _language_code: Default::default(),
1513            _end_date_year: Default::default(),
1514            _end_date_month: Default::default(),
1515            _end_date_day: Default::default(),
1516            _date_range: Default::default(),
1517            _currency_code: Default::default(),
1518            _delegate: Default::default(),
1519            _additional_params: Default::default(),
1520            _scopes: Default::default(),
1521        }
1522    }
1523
1524    /// Create a builder to help you perform the following task:
1525    ///
1526    /// Generates a csv formatted saved report.
1527    ///
1528    /// # Arguments
1529    ///
1530    /// * `name` - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
1531    pub fn reports_saved_generate_csv(
1532        &self,
1533        name: &str,
1534    ) -> AccountReportSavedGenerateCsvCall<'a, C> {
1535        AccountReportSavedGenerateCsvCall {
1536            hub: self.hub,
1537            _name: name.to_string(),
1538            _start_date_year: Default::default(),
1539            _start_date_month: Default::default(),
1540            _start_date_day: Default::default(),
1541            _reporting_time_zone: Default::default(),
1542            _language_code: Default::default(),
1543            _end_date_year: Default::default(),
1544            _end_date_month: Default::default(),
1545            _end_date_day: Default::default(),
1546            _date_range: Default::default(),
1547            _currency_code: Default::default(),
1548            _delegate: Default::default(),
1549            _additional_params: Default::default(),
1550            _scopes: Default::default(),
1551        }
1552    }
1553
1554    /// Create a builder to help you perform the following task:
1555    ///
1556    /// Lists saved reports.
1557    ///
1558    /// # Arguments
1559    ///
1560    /// * `parent` - Required. The account which owns the collection of reports. Format: accounts/{account}
1561    pub fn reports_saved_list(&self, parent: &str) -> AccountReportSavedListCall<'a, C> {
1562        AccountReportSavedListCall {
1563            hub: self.hub,
1564            _parent: parent.to_string(),
1565            _page_token: Default::default(),
1566            _page_size: Default::default(),
1567            _delegate: Default::default(),
1568            _additional_params: Default::default(),
1569            _scopes: Default::default(),
1570        }
1571    }
1572
1573    /// Create a builder to help you perform the following task:
1574    ///
1575    /// Generates an ad hoc report.
1576    ///
1577    /// # Arguments
1578    ///
1579    /// * `account` - Required. The account which owns the collection of reports. Format: accounts/{account}
1580    pub fn reports_generate(&self, account: &str) -> AccountReportGenerateCall<'a, C> {
1581        AccountReportGenerateCall {
1582            hub: self.hub,
1583            _account: account.to_string(),
1584            _start_date_year: Default::default(),
1585            _start_date_month: Default::default(),
1586            _start_date_day: Default::default(),
1587            _reporting_time_zone: Default::default(),
1588            _order_by: Default::default(),
1589            _metrics: Default::default(),
1590            _limit: Default::default(),
1591            _language_code: Default::default(),
1592            _filters: Default::default(),
1593            _end_date_year: Default::default(),
1594            _end_date_month: Default::default(),
1595            _end_date_day: Default::default(),
1596            _dimensions: Default::default(),
1597            _date_range: Default::default(),
1598            _currency_code: Default::default(),
1599            _delegate: Default::default(),
1600            _additional_params: Default::default(),
1601            _scopes: Default::default(),
1602        }
1603    }
1604
1605    /// Create a builder to help you perform the following task:
1606    ///
1607    /// Generates a csv formatted ad hoc report.
1608    ///
1609    /// # Arguments
1610    ///
1611    /// * `account` - Required. The account which owns the collection of reports. Format: accounts/{account}
1612    pub fn reports_generate_csv(&self, account: &str) -> AccountReportGenerateCsvCall<'a, C> {
1613        AccountReportGenerateCsvCall {
1614            hub: self.hub,
1615            _account: account.to_string(),
1616            _start_date_year: Default::default(),
1617            _start_date_month: Default::default(),
1618            _start_date_day: Default::default(),
1619            _reporting_time_zone: Default::default(),
1620            _order_by: Default::default(),
1621            _metrics: Default::default(),
1622            _limit: Default::default(),
1623            _language_code: Default::default(),
1624            _filters: Default::default(),
1625            _end_date_year: Default::default(),
1626            _end_date_month: Default::default(),
1627            _end_date_day: Default::default(),
1628            _dimensions: Default::default(),
1629            _date_range: Default::default(),
1630            _currency_code: Default::default(),
1631            _delegate: Default::default(),
1632            _additional_params: Default::default(),
1633            _scopes: Default::default(),
1634        }
1635    }
1636
1637    /// Create a builder to help you perform the following task:
1638    ///
1639    /// Gets the saved report from the given resource name.
1640    ///
1641    /// # Arguments
1642    ///
1643    /// * `name` - Required. The name of the saved report to retrieve. Format: accounts/{account}/reports/{report}
1644    pub fn reports_get_saved(&self, name: &str) -> AccountReportGetSavedCall<'a, C> {
1645        AccountReportGetSavedCall {
1646            hub: self.hub,
1647            _name: name.to_string(),
1648            _delegate: Default::default(),
1649            _additional_params: Default::default(),
1650            _scopes: Default::default(),
1651        }
1652    }
1653
1654    /// Create a builder to help you perform the following task:
1655    ///
1656    /// Gets information about the selected site.
1657    ///
1658    /// # Arguments
1659    ///
1660    /// * `name` - Required. Name of the site. Format: accounts/{account}/sites/{site}
1661    pub fn sites_get(&self, name: &str) -> AccountSiteGetCall<'a, C> {
1662        AccountSiteGetCall {
1663            hub: self.hub,
1664            _name: name.to_string(),
1665            _delegate: Default::default(),
1666            _additional_params: Default::default(),
1667            _scopes: Default::default(),
1668        }
1669    }
1670
1671    /// Create a builder to help you perform the following task:
1672    ///
1673    /// Lists all the sites available in an account.
1674    ///
1675    /// # Arguments
1676    ///
1677    /// * `parent` - Required. The account which owns the collection of sites. Format: accounts/{account}
1678    pub fn sites_list(&self, parent: &str) -> AccountSiteListCall<'a, C> {
1679        AccountSiteListCall {
1680            hub: self.hub,
1681            _parent: parent.to_string(),
1682            _page_token: Default::default(),
1683            _page_size: Default::default(),
1684            _delegate: Default::default(),
1685            _additional_params: Default::default(),
1686            _scopes: Default::default(),
1687        }
1688    }
1689
1690    /// Create a builder to help you perform the following task:
1691    ///
1692    /// Gets information about the selected AdSense account.
1693    ///
1694    /// # Arguments
1695    ///
1696    /// * `name` - Required. Account to get information about. Format: accounts/{account}
1697    pub fn get(&self, name: &str) -> AccountGetCall<'a, C> {
1698        AccountGetCall {
1699            hub: self.hub,
1700            _name: name.to_string(),
1701            _delegate: Default::default(),
1702            _additional_params: Default::default(),
1703            _scopes: Default::default(),
1704        }
1705    }
1706
1707    /// Create a builder to help you perform the following task:
1708    ///
1709    /// Gets the ad blocking recovery tag of an account.
1710    ///
1711    /// # Arguments
1712    ///
1713    /// * `name` - Required. The name of the account to get the tag for. Format: accounts/{account}
1714    pub fn get_ad_blocking_recovery_tag(
1715        &self,
1716        name: &str,
1717    ) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
1718        AccountGetAdBlockingRecoveryTagCall {
1719            hub: self.hub,
1720            _name: name.to_string(),
1721            _delegate: Default::default(),
1722            _additional_params: Default::default(),
1723            _scopes: Default::default(),
1724        }
1725    }
1726
1727    /// Create a builder to help you perform the following task:
1728    ///
1729    /// Lists all accounts available to this user.
1730    pub fn list(&self) -> AccountListCall<'a, C> {
1731        AccountListCall {
1732            hub: self.hub,
1733            _page_token: Default::default(),
1734            _page_size: Default::default(),
1735            _delegate: Default::default(),
1736            _additional_params: Default::default(),
1737            _scopes: Default::default(),
1738        }
1739    }
1740
1741    /// Create a builder to help you perform the following task:
1742    ///
1743    /// Lists all accounts directly managed by the given AdSense account.
1744    ///
1745    /// # Arguments
1746    ///
1747    /// * `parent` - Required. The parent account, which owns the child accounts. Format: accounts/{account}
1748    pub fn list_child_accounts(&self, parent: &str) -> AccountListChildAccountCall<'a, C> {
1749        AccountListChildAccountCall {
1750            hub: self.hub,
1751            _parent: parent.to_string(),
1752            _page_token: Default::default(),
1753            _page_size: Default::default(),
1754            _delegate: Default::default(),
1755            _additional_params: Default::default(),
1756            _scopes: Default::default(),
1757        }
1758    }
1759}
1760
1761// ###################
1762// CallBuilders   ###
1763// #################
1764
1765/// Creates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. Note that ad units can only be created for ad clients with an “AFC” product code. For more info see the [AdClient resource](https://developers.google.com/adsense/management/reference/rest/v2/accounts.adclients). For now, this method can only be used to create `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1766///
1767/// A builder for the *adclients.adunits.create* method supported by a *account* resource.
1768/// It is not used directly, but through a [`AccountMethods`] instance.
1769///
1770/// # Example
1771///
1772/// Instantiate a resource method builder
1773///
1774/// ```test_harness,no_run
1775/// # extern crate hyper;
1776/// # extern crate hyper_rustls;
1777/// # extern crate google_adsense2 as adsense2;
1778/// use adsense2::api::AdUnit;
1779/// # async fn dox() {
1780/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1781///
1782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1783/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1784/// #     secret,
1785/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1786/// # ).build().await.unwrap();
1787///
1788/// # let client = hyper_util::client::legacy::Client::builder(
1789/// #     hyper_util::rt::TokioExecutor::new()
1790/// # )
1791/// # .build(
1792/// #     hyper_rustls::HttpsConnectorBuilder::new()
1793/// #         .with_native_roots()
1794/// #         .unwrap()
1795/// #         .https_or_http()
1796/// #         .enable_http1()
1797/// #         .build()
1798/// # );
1799/// # let mut hub = Adsense::new(client, auth);
1800/// // As the method needs a request, you would usually fill it with the desired information
1801/// // into the respective structure. Some of the parts shown here might not be applicable !
1802/// // Values shown here are possibly random and not representative !
1803/// let mut req = AdUnit::default();
1804///
1805/// // You can configure optional parameters by calling the respective setters at will, and
1806/// // execute the final call using `doit()`.
1807/// // Values shown here are possibly random and not representative !
1808/// let result = hub.accounts().adclients_adunits_create(req, "parent")
1809///              .doit().await;
1810/// # }
1811/// ```
1812pub struct AccountAdclientAdunitCreateCall<'a, C>
1813where
1814    C: 'a,
1815{
1816    hub: &'a Adsense<C>,
1817    _request: AdUnit,
1818    _parent: String,
1819    _delegate: Option<&'a mut dyn common::Delegate>,
1820    _additional_params: HashMap<String, String>,
1821    _scopes: BTreeSet<String>,
1822}
1823
1824impl<'a, C> common::CallBuilder for AccountAdclientAdunitCreateCall<'a, C> {}
1825
1826impl<'a, C> AccountAdclientAdunitCreateCall<'a, C>
1827where
1828    C: common::Connector,
1829{
1830    /// Perform the operation you have build so far.
1831    pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
1832        use std::borrow::Cow;
1833        use std::io::{Read, Seek};
1834
1835        use common::{url::Params, ToParts};
1836        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1837
1838        let mut dd = common::DefaultDelegate;
1839        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1840        dlg.begin(common::MethodInfo {
1841            id: "adsense.accounts.adclients.adunits.create",
1842            http_method: hyper::Method::POST,
1843        });
1844
1845        for &field in ["alt", "parent"].iter() {
1846            if self._additional_params.contains_key(field) {
1847                dlg.finished(false);
1848                return Err(common::Error::FieldClash(field));
1849            }
1850        }
1851
1852        let mut params = Params::with_capacity(4 + self._additional_params.len());
1853        params.push("parent", self._parent);
1854
1855        params.extend(self._additional_params.iter());
1856
1857        params.push("alt", "json");
1858        let mut url = self.hub._base_url.clone() + "v2/{+parent}/adunits";
1859        if self._scopes.is_empty() {
1860            self._scopes.insert(Scope::Full.as_ref().to_string());
1861        }
1862
1863        #[allow(clippy::single_element_loop)]
1864        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1865            url = params.uri_replacement(url, param_name, find_this, true);
1866        }
1867        {
1868            let to_remove = ["parent"];
1869            params.remove_params(&to_remove);
1870        }
1871
1872        let url = params.parse_with_url(&url);
1873
1874        let mut json_mime_type = mime::APPLICATION_JSON;
1875        let mut request_value_reader = {
1876            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1877            common::remove_json_null_values(&mut value);
1878            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1879            serde_json::to_writer(&mut dst, &value).unwrap();
1880            dst
1881        };
1882        let request_size = request_value_reader
1883            .seek(std::io::SeekFrom::End(0))
1884            .unwrap();
1885        request_value_reader
1886            .seek(std::io::SeekFrom::Start(0))
1887            .unwrap();
1888
1889        loop {
1890            let token = match self
1891                .hub
1892                .auth
1893                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1894                .await
1895            {
1896                Ok(token) => token,
1897                Err(e) => match dlg.token(e) {
1898                    Ok(token) => token,
1899                    Err(e) => {
1900                        dlg.finished(false);
1901                        return Err(common::Error::MissingToken(e));
1902                    }
1903                },
1904            };
1905            request_value_reader
1906                .seek(std::io::SeekFrom::Start(0))
1907                .unwrap();
1908            let mut req_result = {
1909                let client = &self.hub.client;
1910                dlg.pre_request();
1911                let mut req_builder = hyper::Request::builder()
1912                    .method(hyper::Method::POST)
1913                    .uri(url.as_str())
1914                    .header(USER_AGENT, self.hub._user_agent.clone());
1915
1916                if let Some(token) = token.as_ref() {
1917                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1918                }
1919
1920                let request = req_builder
1921                    .header(CONTENT_TYPE, json_mime_type.to_string())
1922                    .header(CONTENT_LENGTH, request_size as u64)
1923                    .body(common::to_body(
1924                        request_value_reader.get_ref().clone().into(),
1925                    ));
1926
1927                client.request(request.unwrap()).await
1928            };
1929
1930            match req_result {
1931                Err(err) => {
1932                    if let common::Retry::After(d) = dlg.http_error(&err) {
1933                        sleep(d).await;
1934                        continue;
1935                    }
1936                    dlg.finished(false);
1937                    return Err(common::Error::HttpError(err));
1938                }
1939                Ok(res) => {
1940                    let (mut parts, body) = res.into_parts();
1941                    let mut body = common::Body::new(body);
1942                    if !parts.status.is_success() {
1943                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1944                        let error = serde_json::from_str(&common::to_string(&bytes));
1945                        let response = common::to_response(parts, bytes.into());
1946
1947                        if let common::Retry::After(d) =
1948                            dlg.http_failure(&response, error.as_ref().ok())
1949                        {
1950                            sleep(d).await;
1951                            continue;
1952                        }
1953
1954                        dlg.finished(false);
1955
1956                        return Err(match error {
1957                            Ok(value) => common::Error::BadRequest(value),
1958                            _ => common::Error::Failure(response),
1959                        });
1960                    }
1961                    let response = {
1962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1963                        let encoded = common::to_string(&bytes);
1964                        match serde_json::from_str(&encoded) {
1965                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1966                            Err(error) => {
1967                                dlg.response_json_decode_error(&encoded, &error);
1968                                return Err(common::Error::JsonDecodeError(
1969                                    encoded.to_string(),
1970                                    error,
1971                                ));
1972                            }
1973                        }
1974                    };
1975
1976                    dlg.finished(true);
1977                    return Ok(response);
1978                }
1979            }
1980        }
1981    }
1982
1983    ///
1984    /// Sets the *request* property to the given value.
1985    ///
1986    /// Even though the property as already been set when instantiating this call,
1987    /// we provide this method for API completeness.
1988    pub fn request(mut self, new_value: AdUnit) -> AccountAdclientAdunitCreateCall<'a, C> {
1989        self._request = new_value;
1990        self
1991    }
1992    /// Required. Ad client to create an ad unit under. Format: accounts/{account}/adclients/{adclient}
1993    ///
1994    /// Sets the *parent* path property to the given value.
1995    ///
1996    /// Even though the property as already been set when instantiating this call,
1997    /// we provide this method for API completeness.
1998    pub fn parent(mut self, new_value: &str) -> AccountAdclientAdunitCreateCall<'a, C> {
1999        self._parent = new_value.to_string();
2000        self
2001    }
2002    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2003    /// while executing the actual API request.
2004    ///
2005    /// ````text
2006    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2007    /// ````
2008    ///
2009    /// Sets the *delegate* property to the given value.
2010    pub fn delegate(
2011        mut self,
2012        new_value: &'a mut dyn common::Delegate,
2013    ) -> AccountAdclientAdunitCreateCall<'a, C> {
2014        self._delegate = Some(new_value);
2015        self
2016    }
2017
2018    /// Set any additional parameter of the query string used in the request.
2019    /// It should be used to set parameters which are not yet available through their own
2020    /// setters.
2021    ///
2022    /// Please note that this method must not be used to set any of the known parameters
2023    /// which have their own setter method. If done anyway, the request will fail.
2024    ///
2025    /// # Additional Parameters
2026    ///
2027    /// * *$.xgafv* (query-string) - V1 error format.
2028    /// * *access_token* (query-string) - OAuth access token.
2029    /// * *alt* (query-string) - Data format for response.
2030    /// * *callback* (query-string) - JSONP
2031    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2032    /// * *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.
2033    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2034    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2035    /// * *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.
2036    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2037    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2038    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitCreateCall<'a, C>
2039    where
2040        T: AsRef<str>,
2041    {
2042        self._additional_params
2043            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2044        self
2045    }
2046
2047    /// Identifies the authorization scope for the method you are building.
2048    ///
2049    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2050    /// [`Scope::Full`].
2051    ///
2052    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2053    /// tokens for more than one scope.
2054    ///
2055    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2056    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2057    /// sufficient, a read-write scope will do as well.
2058    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitCreateCall<'a, C>
2059    where
2060        St: AsRef<str>,
2061    {
2062        self._scopes.insert(String::from(scope.as_ref()));
2063        self
2064    }
2065    /// Identifies the authorization scope(s) for the method you are building.
2066    ///
2067    /// See [`Self::add_scope()`] for details.
2068    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitCreateCall<'a, C>
2069    where
2070        I: IntoIterator<Item = St>,
2071        St: AsRef<str>,
2072    {
2073        self._scopes
2074            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2075        self
2076    }
2077
2078    /// Removes all scopes, and no default scope will be used either.
2079    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2080    /// for details).
2081    pub fn clear_scopes(mut self) -> AccountAdclientAdunitCreateCall<'a, C> {
2082        self._scopes.clear();
2083        self
2084    }
2085}
2086
2087/// Gets an ad unit from a specified account and ad client.
2088///
2089/// A builder for the *adclients.adunits.get* method supported by a *account* resource.
2090/// It is not used directly, but through a [`AccountMethods`] instance.
2091///
2092/// # Example
2093///
2094/// Instantiate a resource method builder
2095///
2096/// ```test_harness,no_run
2097/// # extern crate hyper;
2098/// # extern crate hyper_rustls;
2099/// # extern crate google_adsense2 as adsense2;
2100/// # async fn dox() {
2101/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2102///
2103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2104/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2105/// #     secret,
2106/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2107/// # ).build().await.unwrap();
2108///
2109/// # let client = hyper_util::client::legacy::Client::builder(
2110/// #     hyper_util::rt::TokioExecutor::new()
2111/// # )
2112/// # .build(
2113/// #     hyper_rustls::HttpsConnectorBuilder::new()
2114/// #         .with_native_roots()
2115/// #         .unwrap()
2116/// #         .https_or_http()
2117/// #         .enable_http1()
2118/// #         .build()
2119/// # );
2120/// # let mut hub = Adsense::new(client, auth);
2121/// // You can configure optional parameters by calling the respective setters at will, and
2122/// // execute the final call using `doit()`.
2123/// // Values shown here are possibly random and not representative !
2124/// let result = hub.accounts().adclients_adunits_get("name")
2125///              .doit().await;
2126/// # }
2127/// ```
2128pub struct AccountAdclientAdunitGetCall<'a, C>
2129where
2130    C: 'a,
2131{
2132    hub: &'a Adsense<C>,
2133    _name: String,
2134    _delegate: Option<&'a mut dyn common::Delegate>,
2135    _additional_params: HashMap<String, String>,
2136    _scopes: BTreeSet<String>,
2137}
2138
2139impl<'a, C> common::CallBuilder for AccountAdclientAdunitGetCall<'a, C> {}
2140
2141impl<'a, C> AccountAdclientAdunitGetCall<'a, C>
2142where
2143    C: common::Connector,
2144{
2145    /// Perform the operation you have build so far.
2146    pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
2147        use std::borrow::Cow;
2148        use std::io::{Read, Seek};
2149
2150        use common::{url::Params, ToParts};
2151        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2152
2153        let mut dd = common::DefaultDelegate;
2154        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2155        dlg.begin(common::MethodInfo {
2156            id: "adsense.accounts.adclients.adunits.get",
2157            http_method: hyper::Method::GET,
2158        });
2159
2160        for &field in ["alt", "name"].iter() {
2161            if self._additional_params.contains_key(field) {
2162                dlg.finished(false);
2163                return Err(common::Error::FieldClash(field));
2164            }
2165        }
2166
2167        let mut params = Params::with_capacity(3 + self._additional_params.len());
2168        params.push("name", self._name);
2169
2170        params.extend(self._additional_params.iter());
2171
2172        params.push("alt", "json");
2173        let mut url = self.hub._base_url.clone() + "v2/{+name}";
2174        if self._scopes.is_empty() {
2175            self._scopes.insert(Scope::Readonly.as_ref().to_string());
2176        }
2177
2178        #[allow(clippy::single_element_loop)]
2179        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2180            url = params.uri_replacement(url, param_name, find_this, true);
2181        }
2182        {
2183            let to_remove = ["name"];
2184            params.remove_params(&to_remove);
2185        }
2186
2187        let url = params.parse_with_url(&url);
2188
2189        loop {
2190            let token = match self
2191                .hub
2192                .auth
2193                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2194                .await
2195            {
2196                Ok(token) => token,
2197                Err(e) => match dlg.token(e) {
2198                    Ok(token) => token,
2199                    Err(e) => {
2200                        dlg.finished(false);
2201                        return Err(common::Error::MissingToken(e));
2202                    }
2203                },
2204            };
2205            let mut req_result = {
2206                let client = &self.hub.client;
2207                dlg.pre_request();
2208                let mut req_builder = hyper::Request::builder()
2209                    .method(hyper::Method::GET)
2210                    .uri(url.as_str())
2211                    .header(USER_AGENT, self.hub._user_agent.clone());
2212
2213                if let Some(token) = token.as_ref() {
2214                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2215                }
2216
2217                let request = req_builder
2218                    .header(CONTENT_LENGTH, 0_u64)
2219                    .body(common::to_body::<String>(None));
2220
2221                client.request(request.unwrap()).await
2222            };
2223
2224            match req_result {
2225                Err(err) => {
2226                    if let common::Retry::After(d) = dlg.http_error(&err) {
2227                        sleep(d).await;
2228                        continue;
2229                    }
2230                    dlg.finished(false);
2231                    return Err(common::Error::HttpError(err));
2232                }
2233                Ok(res) => {
2234                    let (mut parts, body) = res.into_parts();
2235                    let mut body = common::Body::new(body);
2236                    if !parts.status.is_success() {
2237                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2238                        let error = serde_json::from_str(&common::to_string(&bytes));
2239                        let response = common::to_response(parts, bytes.into());
2240
2241                        if let common::Retry::After(d) =
2242                            dlg.http_failure(&response, error.as_ref().ok())
2243                        {
2244                            sleep(d).await;
2245                            continue;
2246                        }
2247
2248                        dlg.finished(false);
2249
2250                        return Err(match error {
2251                            Ok(value) => common::Error::BadRequest(value),
2252                            _ => common::Error::Failure(response),
2253                        });
2254                    }
2255                    let response = {
2256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2257                        let encoded = common::to_string(&bytes);
2258                        match serde_json::from_str(&encoded) {
2259                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2260                            Err(error) => {
2261                                dlg.response_json_decode_error(&encoded, &error);
2262                                return Err(common::Error::JsonDecodeError(
2263                                    encoded.to_string(),
2264                                    error,
2265                                ));
2266                            }
2267                        }
2268                    };
2269
2270                    dlg.finished(true);
2271                    return Ok(response);
2272                }
2273            }
2274        }
2275    }
2276
2277    /// Required. AdUnit to get information about. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
2278    ///
2279    /// Sets the *name* path property to the given value.
2280    ///
2281    /// Even though the property as already been set when instantiating this call,
2282    /// we provide this method for API completeness.
2283    pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitGetCall<'a, C> {
2284        self._name = new_value.to_string();
2285        self
2286    }
2287    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2288    /// while executing the actual API request.
2289    ///
2290    /// ````text
2291    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2292    /// ````
2293    ///
2294    /// Sets the *delegate* property to the given value.
2295    pub fn delegate(
2296        mut self,
2297        new_value: &'a mut dyn common::Delegate,
2298    ) -> AccountAdclientAdunitGetCall<'a, C> {
2299        self._delegate = Some(new_value);
2300        self
2301    }
2302
2303    /// Set any additional parameter of the query string used in the request.
2304    /// It should be used to set parameters which are not yet available through their own
2305    /// setters.
2306    ///
2307    /// Please note that this method must not be used to set any of the known parameters
2308    /// which have their own setter method. If done anyway, the request will fail.
2309    ///
2310    /// # Additional Parameters
2311    ///
2312    /// * *$.xgafv* (query-string) - V1 error format.
2313    /// * *access_token* (query-string) - OAuth access token.
2314    /// * *alt* (query-string) - Data format for response.
2315    /// * *callback* (query-string) - JSONP
2316    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2317    /// * *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.
2318    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2319    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2320    /// * *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.
2321    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2322    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2323    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitGetCall<'a, C>
2324    where
2325        T: AsRef<str>,
2326    {
2327        self._additional_params
2328            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2329        self
2330    }
2331
2332    /// Identifies the authorization scope for the method you are building.
2333    ///
2334    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2335    /// [`Scope::Readonly`].
2336    ///
2337    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2338    /// tokens for more than one scope.
2339    ///
2340    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2341    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2342    /// sufficient, a read-write scope will do as well.
2343    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitGetCall<'a, C>
2344    where
2345        St: AsRef<str>,
2346    {
2347        self._scopes.insert(String::from(scope.as_ref()));
2348        self
2349    }
2350    /// Identifies the authorization scope(s) for the method you are building.
2351    ///
2352    /// See [`Self::add_scope()`] for details.
2353    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitGetCall<'a, C>
2354    where
2355        I: IntoIterator<Item = St>,
2356        St: AsRef<str>,
2357    {
2358        self._scopes
2359            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2360        self
2361    }
2362
2363    /// Removes all scopes, and no default scope will be used either.
2364    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2365    /// for details).
2366    pub fn clear_scopes(mut self) -> AccountAdclientAdunitGetCall<'a, C> {
2367        self._scopes.clear();
2368        self
2369    }
2370}
2371
2372/// Gets the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
2373///
2374/// A builder for the *adclients.adunits.getAdcode* method supported by a *account* resource.
2375/// It is not used directly, but through a [`AccountMethods`] instance.
2376///
2377/// # Example
2378///
2379/// Instantiate a resource method builder
2380///
2381/// ```test_harness,no_run
2382/// # extern crate hyper;
2383/// # extern crate hyper_rustls;
2384/// # extern crate google_adsense2 as adsense2;
2385/// # async fn dox() {
2386/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2387///
2388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2389/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2390/// #     secret,
2391/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2392/// # ).build().await.unwrap();
2393///
2394/// # let client = hyper_util::client::legacy::Client::builder(
2395/// #     hyper_util::rt::TokioExecutor::new()
2396/// # )
2397/// # .build(
2398/// #     hyper_rustls::HttpsConnectorBuilder::new()
2399/// #         .with_native_roots()
2400/// #         .unwrap()
2401/// #         .https_or_http()
2402/// #         .enable_http1()
2403/// #         .build()
2404/// # );
2405/// # let mut hub = Adsense::new(client, auth);
2406/// // You can configure optional parameters by calling the respective setters at will, and
2407/// // execute the final call using `doit()`.
2408/// // Values shown here are possibly random and not representative !
2409/// let result = hub.accounts().adclients_adunits_get_adcode("name")
2410///              .doit().await;
2411/// # }
2412/// ```
2413pub struct AccountAdclientAdunitGetAdcodeCall<'a, C>
2414where
2415    C: 'a,
2416{
2417    hub: &'a Adsense<C>,
2418    _name: String,
2419    _delegate: Option<&'a mut dyn common::Delegate>,
2420    _additional_params: HashMap<String, String>,
2421    _scopes: BTreeSet<String>,
2422}
2423
2424impl<'a, C> common::CallBuilder for AccountAdclientAdunitGetAdcodeCall<'a, C> {}
2425
2426impl<'a, C> AccountAdclientAdunitGetAdcodeCall<'a, C>
2427where
2428    C: common::Connector,
2429{
2430    /// Perform the operation you have build so far.
2431    pub async fn doit(mut self) -> common::Result<(common::Response, AdUnitAdCode)> {
2432        use std::borrow::Cow;
2433        use std::io::{Read, Seek};
2434
2435        use common::{url::Params, ToParts};
2436        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2437
2438        let mut dd = common::DefaultDelegate;
2439        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2440        dlg.begin(common::MethodInfo {
2441            id: "adsense.accounts.adclients.adunits.getAdcode",
2442            http_method: hyper::Method::GET,
2443        });
2444
2445        for &field in ["alt", "name"].iter() {
2446            if self._additional_params.contains_key(field) {
2447                dlg.finished(false);
2448                return Err(common::Error::FieldClash(field));
2449            }
2450        }
2451
2452        let mut params = Params::with_capacity(3 + self._additional_params.len());
2453        params.push("name", self._name);
2454
2455        params.extend(self._additional_params.iter());
2456
2457        params.push("alt", "json");
2458        let mut url = self.hub._base_url.clone() + "v2/{+name}/adcode";
2459        if self._scopes.is_empty() {
2460            self._scopes.insert(Scope::Readonly.as_ref().to_string());
2461        }
2462
2463        #[allow(clippy::single_element_loop)]
2464        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2465            url = params.uri_replacement(url, param_name, find_this, true);
2466        }
2467        {
2468            let to_remove = ["name"];
2469            params.remove_params(&to_remove);
2470        }
2471
2472        let url = params.parse_with_url(&url);
2473
2474        loop {
2475            let token = match self
2476                .hub
2477                .auth
2478                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2479                .await
2480            {
2481                Ok(token) => token,
2482                Err(e) => match dlg.token(e) {
2483                    Ok(token) => token,
2484                    Err(e) => {
2485                        dlg.finished(false);
2486                        return Err(common::Error::MissingToken(e));
2487                    }
2488                },
2489            };
2490            let mut req_result = {
2491                let client = &self.hub.client;
2492                dlg.pre_request();
2493                let mut req_builder = hyper::Request::builder()
2494                    .method(hyper::Method::GET)
2495                    .uri(url.as_str())
2496                    .header(USER_AGENT, self.hub._user_agent.clone());
2497
2498                if let Some(token) = token.as_ref() {
2499                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2500                }
2501
2502                let request = req_builder
2503                    .header(CONTENT_LENGTH, 0_u64)
2504                    .body(common::to_body::<String>(None));
2505
2506                client.request(request.unwrap()).await
2507            };
2508
2509            match req_result {
2510                Err(err) => {
2511                    if let common::Retry::After(d) = dlg.http_error(&err) {
2512                        sleep(d).await;
2513                        continue;
2514                    }
2515                    dlg.finished(false);
2516                    return Err(common::Error::HttpError(err));
2517                }
2518                Ok(res) => {
2519                    let (mut parts, body) = res.into_parts();
2520                    let mut body = common::Body::new(body);
2521                    if !parts.status.is_success() {
2522                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2523                        let error = serde_json::from_str(&common::to_string(&bytes));
2524                        let response = common::to_response(parts, bytes.into());
2525
2526                        if let common::Retry::After(d) =
2527                            dlg.http_failure(&response, error.as_ref().ok())
2528                        {
2529                            sleep(d).await;
2530                            continue;
2531                        }
2532
2533                        dlg.finished(false);
2534
2535                        return Err(match error {
2536                            Ok(value) => common::Error::BadRequest(value),
2537                            _ => common::Error::Failure(response),
2538                        });
2539                    }
2540                    let response = {
2541                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2542                        let encoded = common::to_string(&bytes);
2543                        match serde_json::from_str(&encoded) {
2544                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2545                            Err(error) => {
2546                                dlg.response_json_decode_error(&encoded, &error);
2547                                return Err(common::Error::JsonDecodeError(
2548                                    encoded.to_string(),
2549                                    error,
2550                                ));
2551                            }
2552                        }
2553                    };
2554
2555                    dlg.finished(true);
2556                    return Ok(response);
2557                }
2558            }
2559        }
2560    }
2561
2562    /// Required. Name of the adunit for which to get the adcode. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
2563    ///
2564    /// Sets the *name* path property to the given value.
2565    ///
2566    /// Even though the property as already been set when instantiating this call,
2567    /// we provide this method for API completeness.
2568    pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2569        self._name = new_value.to_string();
2570        self
2571    }
2572    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2573    /// while executing the actual API request.
2574    ///
2575    /// ````text
2576    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2577    /// ````
2578    ///
2579    /// Sets the *delegate* property to the given value.
2580    pub fn delegate(
2581        mut self,
2582        new_value: &'a mut dyn common::Delegate,
2583    ) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2584        self._delegate = Some(new_value);
2585        self
2586    }
2587
2588    /// Set any additional parameter of the query string used in the request.
2589    /// It should be used to set parameters which are not yet available through their own
2590    /// setters.
2591    ///
2592    /// Please note that this method must not be used to set any of the known parameters
2593    /// which have their own setter method. If done anyway, the request will fail.
2594    ///
2595    /// # Additional Parameters
2596    ///
2597    /// * *$.xgafv* (query-string) - V1 error format.
2598    /// * *access_token* (query-string) - OAuth access token.
2599    /// * *alt* (query-string) - Data format for response.
2600    /// * *callback* (query-string) - JSONP
2601    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2602    /// * *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.
2603    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2604    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2605    /// * *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.
2606    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2607    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2608    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2609    where
2610        T: AsRef<str>,
2611    {
2612        self._additional_params
2613            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2614        self
2615    }
2616
2617    /// Identifies the authorization scope for the method you are building.
2618    ///
2619    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2620    /// [`Scope::Readonly`].
2621    ///
2622    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2623    /// tokens for more than one scope.
2624    ///
2625    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2626    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2627    /// sufficient, a read-write scope will do as well.
2628    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2629    where
2630        St: AsRef<str>,
2631    {
2632        self._scopes.insert(String::from(scope.as_ref()));
2633        self
2634    }
2635    /// Identifies the authorization scope(s) for the method you are building.
2636    ///
2637    /// See [`Self::add_scope()`] for details.
2638    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2639    where
2640        I: IntoIterator<Item = St>,
2641        St: AsRef<str>,
2642    {
2643        self._scopes
2644            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2645        self
2646    }
2647
2648    /// Removes all scopes, and no default scope will be used either.
2649    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2650    /// for details).
2651    pub fn clear_scopes(mut self) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2652        self._scopes.clear();
2653        self
2654    }
2655}
2656
2657/// Lists all ad units under a specified account and ad client.
2658///
2659/// A builder for the *adclients.adunits.list* method supported by a *account* resource.
2660/// It is not used directly, but through a [`AccountMethods`] instance.
2661///
2662/// # Example
2663///
2664/// Instantiate a resource method builder
2665///
2666/// ```test_harness,no_run
2667/// # extern crate hyper;
2668/// # extern crate hyper_rustls;
2669/// # extern crate google_adsense2 as adsense2;
2670/// # async fn dox() {
2671/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2672///
2673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2674/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2675/// #     secret,
2676/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2677/// # ).build().await.unwrap();
2678///
2679/// # let client = hyper_util::client::legacy::Client::builder(
2680/// #     hyper_util::rt::TokioExecutor::new()
2681/// # )
2682/// # .build(
2683/// #     hyper_rustls::HttpsConnectorBuilder::new()
2684/// #         .with_native_roots()
2685/// #         .unwrap()
2686/// #         .https_or_http()
2687/// #         .enable_http1()
2688/// #         .build()
2689/// # );
2690/// # let mut hub = Adsense::new(client, auth);
2691/// // You can configure optional parameters by calling the respective setters at will, and
2692/// // execute the final call using `doit()`.
2693/// // Values shown here are possibly random and not representative !
2694/// let result = hub.accounts().adclients_adunits_list("parent")
2695///              .page_token("dolore")
2696///              .page_size(-22)
2697///              .doit().await;
2698/// # }
2699/// ```
2700pub struct AccountAdclientAdunitListCall<'a, C>
2701where
2702    C: 'a,
2703{
2704    hub: &'a Adsense<C>,
2705    _parent: String,
2706    _page_token: Option<String>,
2707    _page_size: Option<i32>,
2708    _delegate: Option<&'a mut dyn common::Delegate>,
2709    _additional_params: HashMap<String, String>,
2710    _scopes: BTreeSet<String>,
2711}
2712
2713impl<'a, C> common::CallBuilder for AccountAdclientAdunitListCall<'a, C> {}
2714
2715impl<'a, C> AccountAdclientAdunitListCall<'a, C>
2716where
2717    C: common::Connector,
2718{
2719    /// Perform the operation you have build so far.
2720    pub async fn doit(mut self) -> common::Result<(common::Response, ListAdUnitsResponse)> {
2721        use std::borrow::Cow;
2722        use std::io::{Read, Seek};
2723
2724        use common::{url::Params, ToParts};
2725        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2726
2727        let mut dd = common::DefaultDelegate;
2728        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2729        dlg.begin(common::MethodInfo {
2730            id: "adsense.accounts.adclients.adunits.list",
2731            http_method: hyper::Method::GET,
2732        });
2733
2734        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2735            if self._additional_params.contains_key(field) {
2736                dlg.finished(false);
2737                return Err(common::Error::FieldClash(field));
2738            }
2739        }
2740
2741        let mut params = Params::with_capacity(5 + self._additional_params.len());
2742        params.push("parent", self._parent);
2743        if let Some(value) = self._page_token.as_ref() {
2744            params.push("pageToken", value);
2745        }
2746        if let Some(value) = self._page_size.as_ref() {
2747            params.push("pageSize", value.to_string());
2748        }
2749
2750        params.extend(self._additional_params.iter());
2751
2752        params.push("alt", "json");
2753        let mut url = self.hub._base_url.clone() + "v2/{+parent}/adunits";
2754        if self._scopes.is_empty() {
2755            self._scopes.insert(Scope::Readonly.as_ref().to_string());
2756        }
2757
2758        #[allow(clippy::single_element_loop)]
2759        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2760            url = params.uri_replacement(url, param_name, find_this, true);
2761        }
2762        {
2763            let to_remove = ["parent"];
2764            params.remove_params(&to_remove);
2765        }
2766
2767        let url = params.parse_with_url(&url);
2768
2769        loop {
2770            let token = match self
2771                .hub
2772                .auth
2773                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2774                .await
2775            {
2776                Ok(token) => token,
2777                Err(e) => match dlg.token(e) {
2778                    Ok(token) => token,
2779                    Err(e) => {
2780                        dlg.finished(false);
2781                        return Err(common::Error::MissingToken(e));
2782                    }
2783                },
2784            };
2785            let mut req_result = {
2786                let client = &self.hub.client;
2787                dlg.pre_request();
2788                let mut req_builder = hyper::Request::builder()
2789                    .method(hyper::Method::GET)
2790                    .uri(url.as_str())
2791                    .header(USER_AGENT, self.hub._user_agent.clone());
2792
2793                if let Some(token) = token.as_ref() {
2794                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2795                }
2796
2797                let request = req_builder
2798                    .header(CONTENT_LENGTH, 0_u64)
2799                    .body(common::to_body::<String>(None));
2800
2801                client.request(request.unwrap()).await
2802            };
2803
2804            match req_result {
2805                Err(err) => {
2806                    if let common::Retry::After(d) = dlg.http_error(&err) {
2807                        sleep(d).await;
2808                        continue;
2809                    }
2810                    dlg.finished(false);
2811                    return Err(common::Error::HttpError(err));
2812                }
2813                Ok(res) => {
2814                    let (mut parts, body) = res.into_parts();
2815                    let mut body = common::Body::new(body);
2816                    if !parts.status.is_success() {
2817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2818                        let error = serde_json::from_str(&common::to_string(&bytes));
2819                        let response = common::to_response(parts, bytes.into());
2820
2821                        if let common::Retry::After(d) =
2822                            dlg.http_failure(&response, error.as_ref().ok())
2823                        {
2824                            sleep(d).await;
2825                            continue;
2826                        }
2827
2828                        dlg.finished(false);
2829
2830                        return Err(match error {
2831                            Ok(value) => common::Error::BadRequest(value),
2832                            _ => common::Error::Failure(response),
2833                        });
2834                    }
2835                    let response = {
2836                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2837                        let encoded = common::to_string(&bytes);
2838                        match serde_json::from_str(&encoded) {
2839                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2840                            Err(error) => {
2841                                dlg.response_json_decode_error(&encoded, &error);
2842                                return Err(common::Error::JsonDecodeError(
2843                                    encoded.to_string(),
2844                                    error,
2845                                ));
2846                            }
2847                        }
2848                    };
2849
2850                    dlg.finished(true);
2851                    return Ok(response);
2852                }
2853            }
2854        }
2855    }
2856
2857    /// Required. The ad client which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}
2858    ///
2859    /// Sets the *parent* path property to the given value.
2860    ///
2861    /// Even though the property as already been set when instantiating this call,
2862    /// we provide this method for API completeness.
2863    pub fn parent(mut self, new_value: &str) -> AccountAdclientAdunitListCall<'a, C> {
2864        self._parent = new_value.to_string();
2865        self
2866    }
2867    /// A page token, received from a previous `ListAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdUnits` must match the call that provided the page token.
2868    ///
2869    /// Sets the *page token* query property to the given value.
2870    pub fn page_token(mut self, new_value: &str) -> AccountAdclientAdunitListCall<'a, C> {
2871        self._page_token = Some(new_value.to_string());
2872        self
2873    }
2874    /// The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
2875    ///
2876    /// Sets the *page size* query property to the given value.
2877    pub fn page_size(mut self, new_value: i32) -> AccountAdclientAdunitListCall<'a, C> {
2878        self._page_size = Some(new_value);
2879        self
2880    }
2881    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2882    /// while executing the actual API request.
2883    ///
2884    /// ````text
2885    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2886    /// ````
2887    ///
2888    /// Sets the *delegate* property to the given value.
2889    pub fn delegate(
2890        mut self,
2891        new_value: &'a mut dyn common::Delegate,
2892    ) -> AccountAdclientAdunitListCall<'a, C> {
2893        self._delegate = Some(new_value);
2894        self
2895    }
2896
2897    /// Set any additional parameter of the query string used in the request.
2898    /// It should be used to set parameters which are not yet available through their own
2899    /// setters.
2900    ///
2901    /// Please note that this method must not be used to set any of the known parameters
2902    /// which have their own setter method. If done anyway, the request will fail.
2903    ///
2904    /// # Additional Parameters
2905    ///
2906    /// * *$.xgafv* (query-string) - V1 error format.
2907    /// * *access_token* (query-string) - OAuth access token.
2908    /// * *alt* (query-string) - Data format for response.
2909    /// * *callback* (query-string) - JSONP
2910    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2911    /// * *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.
2912    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2913    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2914    /// * *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.
2915    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2916    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2917    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitListCall<'a, C>
2918    where
2919        T: AsRef<str>,
2920    {
2921        self._additional_params
2922            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2923        self
2924    }
2925
2926    /// Identifies the authorization scope for the method you are building.
2927    ///
2928    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2929    /// [`Scope::Readonly`].
2930    ///
2931    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2932    /// tokens for more than one scope.
2933    ///
2934    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2935    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2936    /// sufficient, a read-write scope will do as well.
2937    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitListCall<'a, C>
2938    where
2939        St: AsRef<str>,
2940    {
2941        self._scopes.insert(String::from(scope.as_ref()));
2942        self
2943    }
2944    /// Identifies the authorization scope(s) for the method you are building.
2945    ///
2946    /// See [`Self::add_scope()`] for details.
2947    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitListCall<'a, C>
2948    where
2949        I: IntoIterator<Item = St>,
2950        St: AsRef<str>,
2951    {
2952        self._scopes
2953            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2954        self
2955    }
2956
2957    /// Removes all scopes, and no default scope will be used either.
2958    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2959    /// for details).
2960    pub fn clear_scopes(mut self) -> AccountAdclientAdunitListCall<'a, C> {
2961        self._scopes.clear();
2962        self
2963    }
2964}
2965
2966/// Lists all the custom channels available for an ad unit.
2967///
2968/// A builder for the *adclients.adunits.listLinkedCustomChannels* method supported by a *account* resource.
2969/// It is not used directly, but through a [`AccountMethods`] instance.
2970///
2971/// # Example
2972///
2973/// Instantiate a resource method builder
2974///
2975/// ```test_harness,no_run
2976/// # extern crate hyper;
2977/// # extern crate hyper_rustls;
2978/// # extern crate google_adsense2 as adsense2;
2979/// # async fn dox() {
2980/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2981///
2982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2984/// #     secret,
2985/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2986/// # ).build().await.unwrap();
2987///
2988/// # let client = hyper_util::client::legacy::Client::builder(
2989/// #     hyper_util::rt::TokioExecutor::new()
2990/// # )
2991/// # .build(
2992/// #     hyper_rustls::HttpsConnectorBuilder::new()
2993/// #         .with_native_roots()
2994/// #         .unwrap()
2995/// #         .https_or_http()
2996/// #         .enable_http1()
2997/// #         .build()
2998/// # );
2999/// # let mut hub = Adsense::new(client, auth);
3000/// // You can configure optional parameters by calling the respective setters at will, and
3001/// // execute the final call using `doit()`.
3002/// // Values shown here are possibly random and not representative !
3003/// let result = hub.accounts().adclients_adunits_list_linked_custom_channels("parent")
3004///              .page_token("amet.")
3005///              .page_size(-96)
3006///              .doit().await;
3007/// # }
3008/// ```
3009pub struct AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3010where
3011    C: 'a,
3012{
3013    hub: &'a Adsense<C>,
3014    _parent: String,
3015    _page_token: Option<String>,
3016    _page_size: Option<i32>,
3017    _delegate: Option<&'a mut dyn common::Delegate>,
3018    _additional_params: HashMap<String, String>,
3019    _scopes: BTreeSet<String>,
3020}
3021
3022impl<'a, C> common::CallBuilder for AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {}
3023
3024impl<'a, C> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3025where
3026    C: common::Connector,
3027{
3028    /// Perform the operation you have build so far.
3029    pub async fn doit(
3030        mut self,
3031    ) -> common::Result<(common::Response, ListLinkedCustomChannelsResponse)> {
3032        use std::borrow::Cow;
3033        use std::io::{Read, Seek};
3034
3035        use common::{url::Params, ToParts};
3036        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3037
3038        let mut dd = common::DefaultDelegate;
3039        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3040        dlg.begin(common::MethodInfo {
3041            id: "adsense.accounts.adclients.adunits.listLinkedCustomChannels",
3042            http_method: hyper::Method::GET,
3043        });
3044
3045        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3046            if self._additional_params.contains_key(field) {
3047                dlg.finished(false);
3048                return Err(common::Error::FieldClash(field));
3049            }
3050        }
3051
3052        let mut params = Params::with_capacity(5 + self._additional_params.len());
3053        params.push("parent", self._parent);
3054        if let Some(value) = self._page_token.as_ref() {
3055            params.push("pageToken", value);
3056        }
3057        if let Some(value) = self._page_size.as_ref() {
3058            params.push("pageSize", value.to_string());
3059        }
3060
3061        params.extend(self._additional_params.iter());
3062
3063        params.push("alt", "json");
3064        let mut url = self.hub._base_url.clone() + "v2/{+parent}:listLinkedCustomChannels";
3065        if self._scopes.is_empty() {
3066            self._scopes.insert(Scope::Readonly.as_ref().to_string());
3067        }
3068
3069        #[allow(clippy::single_element_loop)]
3070        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3071            url = params.uri_replacement(url, param_name, find_this, true);
3072        }
3073        {
3074            let to_remove = ["parent"];
3075            params.remove_params(&to_remove);
3076        }
3077
3078        let url = params.parse_with_url(&url);
3079
3080        loop {
3081            let token = match self
3082                .hub
3083                .auth
3084                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3085                .await
3086            {
3087                Ok(token) => token,
3088                Err(e) => match dlg.token(e) {
3089                    Ok(token) => token,
3090                    Err(e) => {
3091                        dlg.finished(false);
3092                        return Err(common::Error::MissingToken(e));
3093                    }
3094                },
3095            };
3096            let mut req_result = {
3097                let client = &self.hub.client;
3098                dlg.pre_request();
3099                let mut req_builder = hyper::Request::builder()
3100                    .method(hyper::Method::GET)
3101                    .uri(url.as_str())
3102                    .header(USER_AGENT, self.hub._user_agent.clone());
3103
3104                if let Some(token) = token.as_ref() {
3105                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3106                }
3107
3108                let request = req_builder
3109                    .header(CONTENT_LENGTH, 0_u64)
3110                    .body(common::to_body::<String>(None));
3111
3112                client.request(request.unwrap()).await
3113            };
3114
3115            match req_result {
3116                Err(err) => {
3117                    if let common::Retry::After(d) = dlg.http_error(&err) {
3118                        sleep(d).await;
3119                        continue;
3120                    }
3121                    dlg.finished(false);
3122                    return Err(common::Error::HttpError(err));
3123                }
3124                Ok(res) => {
3125                    let (mut parts, body) = res.into_parts();
3126                    let mut body = common::Body::new(body);
3127                    if !parts.status.is_success() {
3128                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3129                        let error = serde_json::from_str(&common::to_string(&bytes));
3130                        let response = common::to_response(parts, bytes.into());
3131
3132                        if let common::Retry::After(d) =
3133                            dlg.http_failure(&response, error.as_ref().ok())
3134                        {
3135                            sleep(d).await;
3136                            continue;
3137                        }
3138
3139                        dlg.finished(false);
3140
3141                        return Err(match error {
3142                            Ok(value) => common::Error::BadRequest(value),
3143                            _ => common::Error::Failure(response),
3144                        });
3145                    }
3146                    let response = {
3147                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3148                        let encoded = common::to_string(&bytes);
3149                        match serde_json::from_str(&encoded) {
3150                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3151                            Err(error) => {
3152                                dlg.response_json_decode_error(&encoded, &error);
3153                                return Err(common::Error::JsonDecodeError(
3154                                    encoded.to_string(),
3155                                    error,
3156                                ));
3157                            }
3158                        }
3159                    };
3160
3161                    dlg.finished(true);
3162                    return Ok(response);
3163                }
3164            }
3165        }
3166    }
3167
3168    /// Required. The ad unit which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
3169    ///
3170    /// Sets the *parent* path property to the given value.
3171    ///
3172    /// Even though the property as already been set when instantiating this call,
3173    /// we provide this method for API completeness.
3174    pub fn parent(
3175        mut self,
3176        new_value: &str,
3177    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3178        self._parent = new_value.to_string();
3179        self
3180    }
3181    /// A page token, received from a previous `ListLinkedCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedCustomChannels` must match the call that provided the page token.
3182    ///
3183    /// Sets the *page token* query property to the given value.
3184    pub fn page_token(
3185        mut self,
3186        new_value: &str,
3187    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3188        self._page_token = Some(new_value.to_string());
3189        self
3190    }
3191    /// The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
3192    ///
3193    /// Sets the *page size* query property to the given value.
3194    pub fn page_size(
3195        mut self,
3196        new_value: i32,
3197    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3198        self._page_size = Some(new_value);
3199        self
3200    }
3201    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3202    /// while executing the actual API request.
3203    ///
3204    /// ````text
3205    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3206    /// ````
3207    ///
3208    /// Sets the *delegate* property to the given value.
3209    pub fn delegate(
3210        mut self,
3211        new_value: &'a mut dyn common::Delegate,
3212    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3213        self._delegate = Some(new_value);
3214        self
3215    }
3216
3217    /// Set any additional parameter of the query string used in the request.
3218    /// It should be used to set parameters which are not yet available through their own
3219    /// setters.
3220    ///
3221    /// Please note that this method must not be used to set any of the known parameters
3222    /// which have their own setter method. If done anyway, the request will fail.
3223    ///
3224    /// # Additional Parameters
3225    ///
3226    /// * *$.xgafv* (query-string) - V1 error format.
3227    /// * *access_token* (query-string) - OAuth access token.
3228    /// * *alt* (query-string) - Data format for response.
3229    /// * *callback* (query-string) - JSONP
3230    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3231    /// * *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.
3232    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3233    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3234    /// * *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.
3235    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3236    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3237    pub fn param<T>(
3238        mut self,
3239        name: T,
3240        value: T,
3241    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3242    where
3243        T: AsRef<str>,
3244    {
3245        self._additional_params
3246            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3247        self
3248    }
3249
3250    /// Identifies the authorization scope for the method you are building.
3251    ///
3252    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3253    /// [`Scope::Readonly`].
3254    ///
3255    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3256    /// tokens for more than one scope.
3257    ///
3258    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3259    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3260    /// sufficient, a read-write scope will do as well.
3261    pub fn add_scope<St>(
3262        mut self,
3263        scope: St,
3264    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3265    where
3266        St: AsRef<str>,
3267    {
3268        self._scopes.insert(String::from(scope.as_ref()));
3269        self
3270    }
3271    /// Identifies the authorization scope(s) for the method you are building.
3272    ///
3273    /// See [`Self::add_scope()`] for details.
3274    pub fn add_scopes<I, St>(
3275        mut self,
3276        scopes: I,
3277    ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3278    where
3279        I: IntoIterator<Item = St>,
3280        St: AsRef<str>,
3281    {
3282        self._scopes
3283            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3284        self
3285    }
3286
3287    /// Removes all scopes, and no default scope will be used either.
3288    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3289    /// for details).
3290    pub fn clear_scopes(mut self) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3291        self._scopes.clear();
3292        self
3293    }
3294}
3295
3296/// Updates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. For now, this method can only be used to update `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
3297///
3298/// A builder for the *adclients.adunits.patch* method supported by a *account* resource.
3299/// It is not used directly, but through a [`AccountMethods`] instance.
3300///
3301/// # Example
3302///
3303/// Instantiate a resource method builder
3304///
3305/// ```test_harness,no_run
3306/// # extern crate hyper;
3307/// # extern crate hyper_rustls;
3308/// # extern crate google_adsense2 as adsense2;
3309/// use adsense2::api::AdUnit;
3310/// # async fn dox() {
3311/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3312///
3313/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3314/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3315/// #     secret,
3316/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3317/// # ).build().await.unwrap();
3318///
3319/// # let client = hyper_util::client::legacy::Client::builder(
3320/// #     hyper_util::rt::TokioExecutor::new()
3321/// # )
3322/// # .build(
3323/// #     hyper_rustls::HttpsConnectorBuilder::new()
3324/// #         .with_native_roots()
3325/// #         .unwrap()
3326/// #         .https_or_http()
3327/// #         .enable_http1()
3328/// #         .build()
3329/// # );
3330/// # let mut hub = Adsense::new(client, auth);
3331/// // As the method needs a request, you would usually fill it with the desired information
3332/// // into the respective structure. Some of the parts shown here might not be applicable !
3333/// // Values shown here are possibly random and not representative !
3334/// let mut req = AdUnit::default();
3335///
3336/// // You can configure optional parameters by calling the respective setters at will, and
3337/// // execute the final call using `doit()`.
3338/// // Values shown here are possibly random and not representative !
3339/// let result = hub.accounts().adclients_adunits_patch(req, "name")
3340///              .update_mask(FieldMask::new::<&str>(&[]))
3341///              .doit().await;
3342/// # }
3343/// ```
3344pub struct AccountAdclientAdunitPatchCall<'a, C>
3345where
3346    C: 'a,
3347{
3348    hub: &'a Adsense<C>,
3349    _request: AdUnit,
3350    _name: String,
3351    _update_mask: Option<common::FieldMask>,
3352    _delegate: Option<&'a mut dyn common::Delegate>,
3353    _additional_params: HashMap<String, String>,
3354    _scopes: BTreeSet<String>,
3355}
3356
3357impl<'a, C> common::CallBuilder for AccountAdclientAdunitPatchCall<'a, C> {}
3358
3359impl<'a, C> AccountAdclientAdunitPatchCall<'a, C>
3360where
3361    C: common::Connector,
3362{
3363    /// Perform the operation you have build so far.
3364    pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
3365        use std::borrow::Cow;
3366        use std::io::{Read, Seek};
3367
3368        use common::{url::Params, ToParts};
3369        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3370
3371        let mut dd = common::DefaultDelegate;
3372        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3373        dlg.begin(common::MethodInfo {
3374            id: "adsense.accounts.adclients.adunits.patch",
3375            http_method: hyper::Method::PATCH,
3376        });
3377
3378        for &field in ["alt", "name", "updateMask"].iter() {
3379            if self._additional_params.contains_key(field) {
3380                dlg.finished(false);
3381                return Err(common::Error::FieldClash(field));
3382            }
3383        }
3384
3385        let mut params = Params::with_capacity(5 + self._additional_params.len());
3386        params.push("name", self._name);
3387        if let Some(value) = self._update_mask.as_ref() {
3388            params.push("updateMask", value.to_string());
3389        }
3390
3391        params.extend(self._additional_params.iter());
3392
3393        params.push("alt", "json");
3394        let mut url = self.hub._base_url.clone() + "v2/{+name}";
3395        if self._scopes.is_empty() {
3396            self._scopes.insert(Scope::Full.as_ref().to_string());
3397        }
3398
3399        #[allow(clippy::single_element_loop)]
3400        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3401            url = params.uri_replacement(url, param_name, find_this, true);
3402        }
3403        {
3404            let to_remove = ["name"];
3405            params.remove_params(&to_remove);
3406        }
3407
3408        let url = params.parse_with_url(&url);
3409
3410        let mut json_mime_type = mime::APPLICATION_JSON;
3411        let mut request_value_reader = {
3412            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3413            common::remove_json_null_values(&mut value);
3414            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3415            serde_json::to_writer(&mut dst, &value).unwrap();
3416            dst
3417        };
3418        let request_size = request_value_reader
3419            .seek(std::io::SeekFrom::End(0))
3420            .unwrap();
3421        request_value_reader
3422            .seek(std::io::SeekFrom::Start(0))
3423            .unwrap();
3424
3425        loop {
3426            let token = match self
3427                .hub
3428                .auth
3429                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3430                .await
3431            {
3432                Ok(token) => token,
3433                Err(e) => match dlg.token(e) {
3434                    Ok(token) => token,
3435                    Err(e) => {
3436                        dlg.finished(false);
3437                        return Err(common::Error::MissingToken(e));
3438                    }
3439                },
3440            };
3441            request_value_reader
3442                .seek(std::io::SeekFrom::Start(0))
3443                .unwrap();
3444            let mut req_result = {
3445                let client = &self.hub.client;
3446                dlg.pre_request();
3447                let mut req_builder = hyper::Request::builder()
3448                    .method(hyper::Method::PATCH)
3449                    .uri(url.as_str())
3450                    .header(USER_AGENT, self.hub._user_agent.clone());
3451
3452                if let Some(token) = token.as_ref() {
3453                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3454                }
3455
3456                let request = req_builder
3457                    .header(CONTENT_TYPE, json_mime_type.to_string())
3458                    .header(CONTENT_LENGTH, request_size as u64)
3459                    .body(common::to_body(
3460                        request_value_reader.get_ref().clone().into(),
3461                    ));
3462
3463                client.request(request.unwrap()).await
3464            };
3465
3466            match req_result {
3467                Err(err) => {
3468                    if let common::Retry::After(d) = dlg.http_error(&err) {
3469                        sleep(d).await;
3470                        continue;
3471                    }
3472                    dlg.finished(false);
3473                    return Err(common::Error::HttpError(err));
3474                }
3475                Ok(res) => {
3476                    let (mut parts, body) = res.into_parts();
3477                    let mut body = common::Body::new(body);
3478                    if !parts.status.is_success() {
3479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3480                        let error = serde_json::from_str(&common::to_string(&bytes));
3481                        let response = common::to_response(parts, bytes.into());
3482
3483                        if let common::Retry::After(d) =
3484                            dlg.http_failure(&response, error.as_ref().ok())
3485                        {
3486                            sleep(d).await;
3487                            continue;
3488                        }
3489
3490                        dlg.finished(false);
3491
3492                        return Err(match error {
3493                            Ok(value) => common::Error::BadRequest(value),
3494                            _ => common::Error::Failure(response),
3495                        });
3496                    }
3497                    let response = {
3498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3499                        let encoded = common::to_string(&bytes);
3500                        match serde_json::from_str(&encoded) {
3501                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3502                            Err(error) => {
3503                                dlg.response_json_decode_error(&encoded, &error);
3504                                return Err(common::Error::JsonDecodeError(
3505                                    encoded.to_string(),
3506                                    error,
3507                                ));
3508                            }
3509                        }
3510                    };
3511
3512                    dlg.finished(true);
3513                    return Ok(response);
3514                }
3515            }
3516        }
3517    }
3518
3519    ///
3520    /// Sets the *request* property to the given value.
3521    ///
3522    /// Even though the property as already been set when instantiating this call,
3523    /// we provide this method for API completeness.
3524    pub fn request(mut self, new_value: AdUnit) -> AccountAdclientAdunitPatchCall<'a, C> {
3525        self._request = new_value;
3526        self
3527    }
3528    /// Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
3529    ///
3530    /// Sets the *name* path property to the given value.
3531    ///
3532    /// Even though the property as already been set when instantiating this call,
3533    /// we provide this method for API completeness.
3534    pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitPatchCall<'a, C> {
3535        self._name = new_value.to_string();
3536        self
3537    }
3538    /// The list of fields to update. If empty, a full update is performed.
3539    ///
3540    /// Sets the *update mask* query property to the given value.
3541    pub fn update_mask(
3542        mut self,
3543        new_value: common::FieldMask,
3544    ) -> AccountAdclientAdunitPatchCall<'a, C> {
3545        self._update_mask = Some(new_value);
3546        self
3547    }
3548    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3549    /// while executing the actual API request.
3550    ///
3551    /// ````text
3552    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3553    /// ````
3554    ///
3555    /// Sets the *delegate* property to the given value.
3556    pub fn delegate(
3557        mut self,
3558        new_value: &'a mut dyn common::Delegate,
3559    ) -> AccountAdclientAdunitPatchCall<'a, C> {
3560        self._delegate = Some(new_value);
3561        self
3562    }
3563
3564    /// Set any additional parameter of the query string used in the request.
3565    /// It should be used to set parameters which are not yet available through their own
3566    /// setters.
3567    ///
3568    /// Please note that this method must not be used to set any of the known parameters
3569    /// which have their own setter method. If done anyway, the request will fail.
3570    ///
3571    /// # Additional Parameters
3572    ///
3573    /// * *$.xgafv* (query-string) - V1 error format.
3574    /// * *access_token* (query-string) - OAuth access token.
3575    /// * *alt* (query-string) - Data format for response.
3576    /// * *callback* (query-string) - JSONP
3577    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3578    /// * *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.
3579    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3580    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3581    /// * *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.
3582    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3583    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3584    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitPatchCall<'a, C>
3585    where
3586        T: AsRef<str>,
3587    {
3588        self._additional_params
3589            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3590        self
3591    }
3592
3593    /// Identifies the authorization scope for the method you are building.
3594    ///
3595    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3596    /// [`Scope::Full`].
3597    ///
3598    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3599    /// tokens for more than one scope.
3600    ///
3601    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3602    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3603    /// sufficient, a read-write scope will do as well.
3604    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitPatchCall<'a, C>
3605    where
3606        St: AsRef<str>,
3607    {
3608        self._scopes.insert(String::from(scope.as_ref()));
3609        self
3610    }
3611    /// Identifies the authorization scope(s) for the method you are building.
3612    ///
3613    /// See [`Self::add_scope()`] for details.
3614    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitPatchCall<'a, C>
3615    where
3616        I: IntoIterator<Item = St>,
3617        St: AsRef<str>,
3618    {
3619        self._scopes
3620            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3621        self
3622    }
3623
3624    /// Removes all scopes, and no default scope will be used either.
3625    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3626    /// for details).
3627    pub fn clear_scopes(mut self) -> AccountAdclientAdunitPatchCall<'a, C> {
3628        self._scopes.clear();
3629        self
3630    }
3631}
3632
3633/// Creates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
3634///
3635/// A builder for the *adclients.customchannels.create* method supported by a *account* resource.
3636/// It is not used directly, but through a [`AccountMethods`] instance.
3637///
3638/// # Example
3639///
3640/// Instantiate a resource method builder
3641///
3642/// ```test_harness,no_run
3643/// # extern crate hyper;
3644/// # extern crate hyper_rustls;
3645/// # extern crate google_adsense2 as adsense2;
3646/// use adsense2::api::CustomChannel;
3647/// # async fn dox() {
3648/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3649///
3650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3652/// #     secret,
3653/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3654/// # ).build().await.unwrap();
3655///
3656/// # let client = hyper_util::client::legacy::Client::builder(
3657/// #     hyper_util::rt::TokioExecutor::new()
3658/// # )
3659/// # .build(
3660/// #     hyper_rustls::HttpsConnectorBuilder::new()
3661/// #         .with_native_roots()
3662/// #         .unwrap()
3663/// #         .https_or_http()
3664/// #         .enable_http1()
3665/// #         .build()
3666/// # );
3667/// # let mut hub = Adsense::new(client, auth);
3668/// // As the method needs a request, you would usually fill it with the desired information
3669/// // into the respective structure. Some of the parts shown here might not be applicable !
3670/// // Values shown here are possibly random and not representative !
3671/// let mut req = CustomChannel::default();
3672///
3673/// // You can configure optional parameters by calling the respective setters at will, and
3674/// // execute the final call using `doit()`.
3675/// // Values shown here are possibly random and not representative !
3676/// let result = hub.accounts().adclients_customchannels_create(req, "parent")
3677///              .doit().await;
3678/// # }
3679/// ```
3680pub struct AccountAdclientCustomchannelCreateCall<'a, C>
3681where
3682    C: 'a,
3683{
3684    hub: &'a Adsense<C>,
3685    _request: CustomChannel,
3686    _parent: String,
3687    _delegate: Option<&'a mut dyn common::Delegate>,
3688    _additional_params: HashMap<String, String>,
3689    _scopes: BTreeSet<String>,
3690}
3691
3692impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelCreateCall<'a, C> {}
3693
3694impl<'a, C> AccountAdclientCustomchannelCreateCall<'a, C>
3695where
3696    C: common::Connector,
3697{
3698    /// Perform the operation you have build so far.
3699    pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
3700        use std::borrow::Cow;
3701        use std::io::{Read, Seek};
3702
3703        use common::{url::Params, ToParts};
3704        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3705
3706        let mut dd = common::DefaultDelegate;
3707        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3708        dlg.begin(common::MethodInfo {
3709            id: "adsense.accounts.adclients.customchannels.create",
3710            http_method: hyper::Method::POST,
3711        });
3712
3713        for &field in ["alt", "parent"].iter() {
3714            if self._additional_params.contains_key(field) {
3715                dlg.finished(false);
3716                return Err(common::Error::FieldClash(field));
3717            }
3718        }
3719
3720        let mut params = Params::with_capacity(4 + self._additional_params.len());
3721        params.push("parent", self._parent);
3722
3723        params.extend(self._additional_params.iter());
3724
3725        params.push("alt", "json");
3726        let mut url = self.hub._base_url.clone() + "v2/{+parent}/customchannels";
3727        if self._scopes.is_empty() {
3728            self._scopes.insert(Scope::Full.as_ref().to_string());
3729        }
3730
3731        #[allow(clippy::single_element_loop)]
3732        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3733            url = params.uri_replacement(url, param_name, find_this, true);
3734        }
3735        {
3736            let to_remove = ["parent"];
3737            params.remove_params(&to_remove);
3738        }
3739
3740        let url = params.parse_with_url(&url);
3741
3742        let mut json_mime_type = mime::APPLICATION_JSON;
3743        let mut request_value_reader = {
3744            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3745            common::remove_json_null_values(&mut value);
3746            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3747            serde_json::to_writer(&mut dst, &value).unwrap();
3748            dst
3749        };
3750        let request_size = request_value_reader
3751            .seek(std::io::SeekFrom::End(0))
3752            .unwrap();
3753        request_value_reader
3754            .seek(std::io::SeekFrom::Start(0))
3755            .unwrap();
3756
3757        loop {
3758            let token = match self
3759                .hub
3760                .auth
3761                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3762                .await
3763            {
3764                Ok(token) => token,
3765                Err(e) => match dlg.token(e) {
3766                    Ok(token) => token,
3767                    Err(e) => {
3768                        dlg.finished(false);
3769                        return Err(common::Error::MissingToken(e));
3770                    }
3771                },
3772            };
3773            request_value_reader
3774                .seek(std::io::SeekFrom::Start(0))
3775                .unwrap();
3776            let mut req_result = {
3777                let client = &self.hub.client;
3778                dlg.pre_request();
3779                let mut req_builder = hyper::Request::builder()
3780                    .method(hyper::Method::POST)
3781                    .uri(url.as_str())
3782                    .header(USER_AGENT, self.hub._user_agent.clone());
3783
3784                if let Some(token) = token.as_ref() {
3785                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3786                }
3787
3788                let request = req_builder
3789                    .header(CONTENT_TYPE, json_mime_type.to_string())
3790                    .header(CONTENT_LENGTH, request_size as u64)
3791                    .body(common::to_body(
3792                        request_value_reader.get_ref().clone().into(),
3793                    ));
3794
3795                client.request(request.unwrap()).await
3796            };
3797
3798            match req_result {
3799                Err(err) => {
3800                    if let common::Retry::After(d) = dlg.http_error(&err) {
3801                        sleep(d).await;
3802                        continue;
3803                    }
3804                    dlg.finished(false);
3805                    return Err(common::Error::HttpError(err));
3806                }
3807                Ok(res) => {
3808                    let (mut parts, body) = res.into_parts();
3809                    let mut body = common::Body::new(body);
3810                    if !parts.status.is_success() {
3811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3812                        let error = serde_json::from_str(&common::to_string(&bytes));
3813                        let response = common::to_response(parts, bytes.into());
3814
3815                        if let common::Retry::After(d) =
3816                            dlg.http_failure(&response, error.as_ref().ok())
3817                        {
3818                            sleep(d).await;
3819                            continue;
3820                        }
3821
3822                        dlg.finished(false);
3823
3824                        return Err(match error {
3825                            Ok(value) => common::Error::BadRequest(value),
3826                            _ => common::Error::Failure(response),
3827                        });
3828                    }
3829                    let response = {
3830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3831                        let encoded = common::to_string(&bytes);
3832                        match serde_json::from_str(&encoded) {
3833                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3834                            Err(error) => {
3835                                dlg.response_json_decode_error(&encoded, &error);
3836                                return Err(common::Error::JsonDecodeError(
3837                                    encoded.to_string(),
3838                                    error,
3839                                ));
3840                            }
3841                        }
3842                    };
3843
3844                    dlg.finished(true);
3845                    return Ok(response);
3846                }
3847            }
3848        }
3849    }
3850
3851    ///
3852    /// Sets the *request* property to the given value.
3853    ///
3854    /// Even though the property as already been set when instantiating this call,
3855    /// we provide this method for API completeness.
3856    pub fn request(
3857        mut self,
3858        new_value: CustomChannel,
3859    ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3860        self._request = new_value;
3861        self
3862    }
3863    /// Required. The ad client to create a custom channel under. Format: accounts/{account}/adclients/{adclient}
3864    ///
3865    /// Sets the *parent* path property to the given value.
3866    ///
3867    /// Even though the property as already been set when instantiating this call,
3868    /// we provide this method for API completeness.
3869    pub fn parent(mut self, new_value: &str) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3870        self._parent = new_value.to_string();
3871        self
3872    }
3873    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3874    /// while executing the actual API request.
3875    ///
3876    /// ````text
3877    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3878    /// ````
3879    ///
3880    /// Sets the *delegate* property to the given value.
3881    pub fn delegate(
3882        mut self,
3883        new_value: &'a mut dyn common::Delegate,
3884    ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3885        self._delegate = Some(new_value);
3886        self
3887    }
3888
3889    /// Set any additional parameter of the query string used in the request.
3890    /// It should be used to set parameters which are not yet available through their own
3891    /// setters.
3892    ///
3893    /// Please note that this method must not be used to set any of the known parameters
3894    /// which have their own setter method. If done anyway, the request will fail.
3895    ///
3896    /// # Additional Parameters
3897    ///
3898    /// * *$.xgafv* (query-string) - V1 error format.
3899    /// * *access_token* (query-string) - OAuth access token.
3900    /// * *alt* (query-string) - Data format for response.
3901    /// * *callback* (query-string) - JSONP
3902    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3903    /// * *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.
3904    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3905    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3906    /// * *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.
3907    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3908    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3909    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelCreateCall<'a, C>
3910    where
3911        T: AsRef<str>,
3912    {
3913        self._additional_params
3914            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3915        self
3916    }
3917
3918    /// Identifies the authorization scope for the method you are building.
3919    ///
3920    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3921    /// [`Scope::Full`].
3922    ///
3923    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3924    /// tokens for more than one scope.
3925    ///
3926    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3927    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3928    /// sufficient, a read-write scope will do as well.
3929    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelCreateCall<'a, C>
3930    where
3931        St: AsRef<str>,
3932    {
3933        self._scopes.insert(String::from(scope.as_ref()));
3934        self
3935    }
3936    /// Identifies the authorization scope(s) for the method you are building.
3937    ///
3938    /// See [`Self::add_scope()`] for details.
3939    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelCreateCall<'a, C>
3940    where
3941        I: IntoIterator<Item = St>,
3942        St: AsRef<str>,
3943    {
3944        self._scopes
3945            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3946        self
3947    }
3948
3949    /// Removes all scopes, and no default scope will be used either.
3950    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3951    /// for details).
3952    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3953        self._scopes.clear();
3954        self
3955    }
3956}
3957
3958/// Deletes a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
3959///
3960/// A builder for the *adclients.customchannels.delete* method supported by a *account* resource.
3961/// It is not used directly, but through a [`AccountMethods`] instance.
3962///
3963/// # Example
3964///
3965/// Instantiate a resource method builder
3966///
3967/// ```test_harness,no_run
3968/// # extern crate hyper;
3969/// # extern crate hyper_rustls;
3970/// # extern crate google_adsense2 as adsense2;
3971/// # async fn dox() {
3972/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3973///
3974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3975/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3976/// #     secret,
3977/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3978/// # ).build().await.unwrap();
3979///
3980/// # let client = hyper_util::client::legacy::Client::builder(
3981/// #     hyper_util::rt::TokioExecutor::new()
3982/// # )
3983/// # .build(
3984/// #     hyper_rustls::HttpsConnectorBuilder::new()
3985/// #         .with_native_roots()
3986/// #         .unwrap()
3987/// #         .https_or_http()
3988/// #         .enable_http1()
3989/// #         .build()
3990/// # );
3991/// # let mut hub = Adsense::new(client, auth);
3992/// // You can configure optional parameters by calling the respective setters at will, and
3993/// // execute the final call using `doit()`.
3994/// // Values shown here are possibly random and not representative !
3995/// let result = hub.accounts().adclients_customchannels_delete("name")
3996///              .doit().await;
3997/// # }
3998/// ```
3999pub struct AccountAdclientCustomchannelDeleteCall<'a, C>
4000where
4001    C: 'a,
4002{
4003    hub: &'a Adsense<C>,
4004    _name: String,
4005    _delegate: Option<&'a mut dyn common::Delegate>,
4006    _additional_params: HashMap<String, String>,
4007    _scopes: BTreeSet<String>,
4008}
4009
4010impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelDeleteCall<'a, C> {}
4011
4012impl<'a, C> AccountAdclientCustomchannelDeleteCall<'a, C>
4013where
4014    C: common::Connector,
4015{
4016    /// Perform the operation you have build so far.
4017    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4018        use std::borrow::Cow;
4019        use std::io::{Read, Seek};
4020
4021        use common::{url::Params, ToParts};
4022        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4023
4024        let mut dd = common::DefaultDelegate;
4025        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4026        dlg.begin(common::MethodInfo {
4027            id: "adsense.accounts.adclients.customchannels.delete",
4028            http_method: hyper::Method::DELETE,
4029        });
4030
4031        for &field in ["alt", "name"].iter() {
4032            if self._additional_params.contains_key(field) {
4033                dlg.finished(false);
4034                return Err(common::Error::FieldClash(field));
4035            }
4036        }
4037
4038        let mut params = Params::with_capacity(3 + self._additional_params.len());
4039        params.push("name", self._name);
4040
4041        params.extend(self._additional_params.iter());
4042
4043        params.push("alt", "json");
4044        let mut url = self.hub._base_url.clone() + "v2/{+name}";
4045        if self._scopes.is_empty() {
4046            self._scopes.insert(Scope::Full.as_ref().to_string());
4047        }
4048
4049        #[allow(clippy::single_element_loop)]
4050        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4051            url = params.uri_replacement(url, param_name, find_this, true);
4052        }
4053        {
4054            let to_remove = ["name"];
4055            params.remove_params(&to_remove);
4056        }
4057
4058        let url = params.parse_with_url(&url);
4059
4060        loop {
4061            let token = match self
4062                .hub
4063                .auth
4064                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4065                .await
4066            {
4067                Ok(token) => token,
4068                Err(e) => match dlg.token(e) {
4069                    Ok(token) => token,
4070                    Err(e) => {
4071                        dlg.finished(false);
4072                        return Err(common::Error::MissingToken(e));
4073                    }
4074                },
4075            };
4076            let mut req_result = {
4077                let client = &self.hub.client;
4078                dlg.pre_request();
4079                let mut req_builder = hyper::Request::builder()
4080                    .method(hyper::Method::DELETE)
4081                    .uri(url.as_str())
4082                    .header(USER_AGENT, self.hub._user_agent.clone());
4083
4084                if let Some(token) = token.as_ref() {
4085                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4086                }
4087
4088                let request = req_builder
4089                    .header(CONTENT_LENGTH, 0_u64)
4090                    .body(common::to_body::<String>(None));
4091
4092                client.request(request.unwrap()).await
4093            };
4094
4095            match req_result {
4096                Err(err) => {
4097                    if let common::Retry::After(d) = dlg.http_error(&err) {
4098                        sleep(d).await;
4099                        continue;
4100                    }
4101                    dlg.finished(false);
4102                    return Err(common::Error::HttpError(err));
4103                }
4104                Ok(res) => {
4105                    let (mut parts, body) = res.into_parts();
4106                    let mut body = common::Body::new(body);
4107                    if !parts.status.is_success() {
4108                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4109                        let error = serde_json::from_str(&common::to_string(&bytes));
4110                        let response = common::to_response(parts, bytes.into());
4111
4112                        if let common::Retry::After(d) =
4113                            dlg.http_failure(&response, error.as_ref().ok())
4114                        {
4115                            sleep(d).await;
4116                            continue;
4117                        }
4118
4119                        dlg.finished(false);
4120
4121                        return Err(match error {
4122                            Ok(value) => common::Error::BadRequest(value),
4123                            _ => common::Error::Failure(response),
4124                        });
4125                    }
4126                    let response = {
4127                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4128                        let encoded = common::to_string(&bytes);
4129                        match serde_json::from_str(&encoded) {
4130                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4131                            Err(error) => {
4132                                dlg.response_json_decode_error(&encoded, &error);
4133                                return Err(common::Error::JsonDecodeError(
4134                                    encoded.to_string(),
4135                                    error,
4136                                ));
4137                            }
4138                        }
4139                    };
4140
4141                    dlg.finished(true);
4142                    return Ok(response);
4143                }
4144            }
4145        }
4146    }
4147
4148    /// Required. Name of the custom channel to delete. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
4149    ///
4150    /// Sets the *name* path property to the given value.
4151    ///
4152    /// Even though the property as already been set when instantiating this call,
4153    /// we provide this method for API completeness.
4154    pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4155        self._name = new_value.to_string();
4156        self
4157    }
4158    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4159    /// while executing the actual API request.
4160    ///
4161    /// ````text
4162    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4163    /// ````
4164    ///
4165    /// Sets the *delegate* property to the given value.
4166    pub fn delegate(
4167        mut self,
4168        new_value: &'a mut dyn common::Delegate,
4169    ) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4170        self._delegate = Some(new_value);
4171        self
4172    }
4173
4174    /// Set any additional parameter of the query string used in the request.
4175    /// It should be used to set parameters which are not yet available through their own
4176    /// setters.
4177    ///
4178    /// Please note that this method must not be used to set any of the known parameters
4179    /// which have their own setter method. If done anyway, the request will fail.
4180    ///
4181    /// # Additional Parameters
4182    ///
4183    /// * *$.xgafv* (query-string) - V1 error format.
4184    /// * *access_token* (query-string) - OAuth access token.
4185    /// * *alt* (query-string) - Data format for response.
4186    /// * *callback* (query-string) - JSONP
4187    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4188    /// * *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.
4189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4190    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4191    /// * *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.
4192    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4193    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4194    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4195    where
4196        T: AsRef<str>,
4197    {
4198        self._additional_params
4199            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4200        self
4201    }
4202
4203    /// Identifies the authorization scope for the method you are building.
4204    ///
4205    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4206    /// [`Scope::Full`].
4207    ///
4208    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4209    /// tokens for more than one scope.
4210    ///
4211    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4212    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4213    /// sufficient, a read-write scope will do as well.
4214    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4215    where
4216        St: AsRef<str>,
4217    {
4218        self._scopes.insert(String::from(scope.as_ref()));
4219        self
4220    }
4221    /// Identifies the authorization scope(s) for the method you are building.
4222    ///
4223    /// See [`Self::add_scope()`] for details.
4224    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4225    where
4226        I: IntoIterator<Item = St>,
4227        St: AsRef<str>,
4228    {
4229        self._scopes
4230            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4231        self
4232    }
4233
4234    /// Removes all scopes, and no default scope will be used either.
4235    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4236    /// for details).
4237    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4238        self._scopes.clear();
4239        self
4240    }
4241}
4242
4243/// Gets information about the selected custom channel.
4244///
4245/// A builder for the *adclients.customchannels.get* method supported by a *account* resource.
4246/// It is not used directly, but through a [`AccountMethods`] instance.
4247///
4248/// # Example
4249///
4250/// Instantiate a resource method builder
4251///
4252/// ```test_harness,no_run
4253/// # extern crate hyper;
4254/// # extern crate hyper_rustls;
4255/// # extern crate google_adsense2 as adsense2;
4256/// # async fn dox() {
4257/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4258///
4259/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4260/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4261/// #     secret,
4262/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4263/// # ).build().await.unwrap();
4264///
4265/// # let client = hyper_util::client::legacy::Client::builder(
4266/// #     hyper_util::rt::TokioExecutor::new()
4267/// # )
4268/// # .build(
4269/// #     hyper_rustls::HttpsConnectorBuilder::new()
4270/// #         .with_native_roots()
4271/// #         .unwrap()
4272/// #         .https_or_http()
4273/// #         .enable_http1()
4274/// #         .build()
4275/// # );
4276/// # let mut hub = Adsense::new(client, auth);
4277/// // You can configure optional parameters by calling the respective setters at will, and
4278/// // execute the final call using `doit()`.
4279/// // Values shown here are possibly random and not representative !
4280/// let result = hub.accounts().adclients_customchannels_get("name")
4281///              .doit().await;
4282/// # }
4283/// ```
4284pub struct AccountAdclientCustomchannelGetCall<'a, C>
4285where
4286    C: 'a,
4287{
4288    hub: &'a Adsense<C>,
4289    _name: String,
4290    _delegate: Option<&'a mut dyn common::Delegate>,
4291    _additional_params: HashMap<String, String>,
4292    _scopes: BTreeSet<String>,
4293}
4294
4295impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelGetCall<'a, C> {}
4296
4297impl<'a, C> AccountAdclientCustomchannelGetCall<'a, C>
4298where
4299    C: common::Connector,
4300{
4301    /// Perform the operation you have build so far.
4302    pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
4303        use std::borrow::Cow;
4304        use std::io::{Read, Seek};
4305
4306        use common::{url::Params, ToParts};
4307        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4308
4309        let mut dd = common::DefaultDelegate;
4310        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4311        dlg.begin(common::MethodInfo {
4312            id: "adsense.accounts.adclients.customchannels.get",
4313            http_method: hyper::Method::GET,
4314        });
4315
4316        for &field in ["alt", "name"].iter() {
4317            if self._additional_params.contains_key(field) {
4318                dlg.finished(false);
4319                return Err(common::Error::FieldClash(field));
4320            }
4321        }
4322
4323        let mut params = Params::with_capacity(3 + self._additional_params.len());
4324        params.push("name", self._name);
4325
4326        params.extend(self._additional_params.iter());
4327
4328        params.push("alt", "json");
4329        let mut url = self.hub._base_url.clone() + "v2/{+name}";
4330        if self._scopes.is_empty() {
4331            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4332        }
4333
4334        #[allow(clippy::single_element_loop)]
4335        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4336            url = params.uri_replacement(url, param_name, find_this, true);
4337        }
4338        {
4339            let to_remove = ["name"];
4340            params.remove_params(&to_remove);
4341        }
4342
4343        let url = params.parse_with_url(&url);
4344
4345        loop {
4346            let token = match self
4347                .hub
4348                .auth
4349                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4350                .await
4351            {
4352                Ok(token) => token,
4353                Err(e) => match dlg.token(e) {
4354                    Ok(token) => token,
4355                    Err(e) => {
4356                        dlg.finished(false);
4357                        return Err(common::Error::MissingToken(e));
4358                    }
4359                },
4360            };
4361            let mut req_result = {
4362                let client = &self.hub.client;
4363                dlg.pre_request();
4364                let mut req_builder = hyper::Request::builder()
4365                    .method(hyper::Method::GET)
4366                    .uri(url.as_str())
4367                    .header(USER_AGENT, self.hub._user_agent.clone());
4368
4369                if let Some(token) = token.as_ref() {
4370                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4371                }
4372
4373                let request = req_builder
4374                    .header(CONTENT_LENGTH, 0_u64)
4375                    .body(common::to_body::<String>(None));
4376
4377                client.request(request.unwrap()).await
4378            };
4379
4380            match req_result {
4381                Err(err) => {
4382                    if let common::Retry::After(d) = dlg.http_error(&err) {
4383                        sleep(d).await;
4384                        continue;
4385                    }
4386                    dlg.finished(false);
4387                    return Err(common::Error::HttpError(err));
4388                }
4389                Ok(res) => {
4390                    let (mut parts, body) = res.into_parts();
4391                    let mut body = common::Body::new(body);
4392                    if !parts.status.is_success() {
4393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4394                        let error = serde_json::from_str(&common::to_string(&bytes));
4395                        let response = common::to_response(parts, bytes.into());
4396
4397                        if let common::Retry::After(d) =
4398                            dlg.http_failure(&response, error.as_ref().ok())
4399                        {
4400                            sleep(d).await;
4401                            continue;
4402                        }
4403
4404                        dlg.finished(false);
4405
4406                        return Err(match error {
4407                            Ok(value) => common::Error::BadRequest(value),
4408                            _ => common::Error::Failure(response),
4409                        });
4410                    }
4411                    let response = {
4412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4413                        let encoded = common::to_string(&bytes);
4414                        match serde_json::from_str(&encoded) {
4415                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4416                            Err(error) => {
4417                                dlg.response_json_decode_error(&encoded, &error);
4418                                return Err(common::Error::JsonDecodeError(
4419                                    encoded.to_string(),
4420                                    error,
4421                                ));
4422                            }
4423                        }
4424                    };
4425
4426                    dlg.finished(true);
4427                    return Ok(response);
4428                }
4429            }
4430        }
4431    }
4432
4433    /// Required. Name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
4434    ///
4435    /// Sets the *name* path property to the given value.
4436    ///
4437    /// Even though the property as already been set when instantiating this call,
4438    /// we provide this method for API completeness.
4439    pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelGetCall<'a, C> {
4440        self._name = new_value.to_string();
4441        self
4442    }
4443    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4444    /// while executing the actual API request.
4445    ///
4446    /// ````text
4447    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4448    /// ````
4449    ///
4450    /// Sets the *delegate* property to the given value.
4451    pub fn delegate(
4452        mut self,
4453        new_value: &'a mut dyn common::Delegate,
4454    ) -> AccountAdclientCustomchannelGetCall<'a, C> {
4455        self._delegate = Some(new_value);
4456        self
4457    }
4458
4459    /// Set any additional parameter of the query string used in the request.
4460    /// It should be used to set parameters which are not yet available through their own
4461    /// setters.
4462    ///
4463    /// Please note that this method must not be used to set any of the known parameters
4464    /// which have their own setter method. If done anyway, the request will fail.
4465    ///
4466    /// # Additional Parameters
4467    ///
4468    /// * *$.xgafv* (query-string) - V1 error format.
4469    /// * *access_token* (query-string) - OAuth access token.
4470    /// * *alt* (query-string) - Data format for response.
4471    /// * *callback* (query-string) - JSONP
4472    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4473    /// * *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.
4474    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4475    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4476    /// * *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.
4477    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4478    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4479    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelGetCall<'a, C>
4480    where
4481        T: AsRef<str>,
4482    {
4483        self._additional_params
4484            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4485        self
4486    }
4487
4488    /// Identifies the authorization scope for the method you are building.
4489    ///
4490    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4491    /// [`Scope::Readonly`].
4492    ///
4493    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4494    /// tokens for more than one scope.
4495    ///
4496    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4497    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4498    /// sufficient, a read-write scope will do as well.
4499    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelGetCall<'a, C>
4500    where
4501        St: AsRef<str>,
4502    {
4503        self._scopes.insert(String::from(scope.as_ref()));
4504        self
4505    }
4506    /// Identifies the authorization scope(s) for the method you are building.
4507    ///
4508    /// See [`Self::add_scope()`] for details.
4509    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelGetCall<'a, C>
4510    where
4511        I: IntoIterator<Item = St>,
4512        St: AsRef<str>,
4513    {
4514        self._scopes
4515            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4516        self
4517    }
4518
4519    /// Removes all scopes, and no default scope will be used either.
4520    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4521    /// for details).
4522    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelGetCall<'a, C> {
4523        self._scopes.clear();
4524        self
4525    }
4526}
4527
4528/// Lists all the custom channels available in an ad client.
4529///
4530/// A builder for the *adclients.customchannels.list* method supported by a *account* resource.
4531/// It is not used directly, but through a [`AccountMethods`] instance.
4532///
4533/// # Example
4534///
4535/// Instantiate a resource method builder
4536///
4537/// ```test_harness,no_run
4538/// # extern crate hyper;
4539/// # extern crate hyper_rustls;
4540/// # extern crate google_adsense2 as adsense2;
4541/// # async fn dox() {
4542/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4543///
4544/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4545/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4546/// #     secret,
4547/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4548/// # ).build().await.unwrap();
4549///
4550/// # let client = hyper_util::client::legacy::Client::builder(
4551/// #     hyper_util::rt::TokioExecutor::new()
4552/// # )
4553/// # .build(
4554/// #     hyper_rustls::HttpsConnectorBuilder::new()
4555/// #         .with_native_roots()
4556/// #         .unwrap()
4557/// #         .https_or_http()
4558/// #         .enable_http1()
4559/// #         .build()
4560/// # );
4561/// # let mut hub = Adsense::new(client, auth);
4562/// // You can configure optional parameters by calling the respective setters at will, and
4563/// // execute the final call using `doit()`.
4564/// // Values shown here are possibly random and not representative !
4565/// let result = hub.accounts().adclients_customchannels_list("parent")
4566///              .page_token("Stet")
4567///              .page_size(-99)
4568///              .doit().await;
4569/// # }
4570/// ```
4571pub struct AccountAdclientCustomchannelListCall<'a, C>
4572where
4573    C: 'a,
4574{
4575    hub: &'a Adsense<C>,
4576    _parent: String,
4577    _page_token: Option<String>,
4578    _page_size: Option<i32>,
4579    _delegate: Option<&'a mut dyn common::Delegate>,
4580    _additional_params: HashMap<String, String>,
4581    _scopes: BTreeSet<String>,
4582}
4583
4584impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelListCall<'a, C> {}
4585
4586impl<'a, C> AccountAdclientCustomchannelListCall<'a, C>
4587where
4588    C: common::Connector,
4589{
4590    /// Perform the operation you have build so far.
4591    pub async fn doit(mut self) -> common::Result<(common::Response, ListCustomChannelsResponse)> {
4592        use std::borrow::Cow;
4593        use std::io::{Read, Seek};
4594
4595        use common::{url::Params, ToParts};
4596        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4597
4598        let mut dd = common::DefaultDelegate;
4599        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4600        dlg.begin(common::MethodInfo {
4601            id: "adsense.accounts.adclients.customchannels.list",
4602            http_method: hyper::Method::GET,
4603        });
4604
4605        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4606            if self._additional_params.contains_key(field) {
4607                dlg.finished(false);
4608                return Err(common::Error::FieldClash(field));
4609            }
4610        }
4611
4612        let mut params = Params::with_capacity(5 + self._additional_params.len());
4613        params.push("parent", self._parent);
4614        if let Some(value) = self._page_token.as_ref() {
4615            params.push("pageToken", value);
4616        }
4617        if let Some(value) = self._page_size.as_ref() {
4618            params.push("pageSize", value.to_string());
4619        }
4620
4621        params.extend(self._additional_params.iter());
4622
4623        params.push("alt", "json");
4624        let mut url = self.hub._base_url.clone() + "v2/{+parent}/customchannels";
4625        if self._scopes.is_empty() {
4626            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4627        }
4628
4629        #[allow(clippy::single_element_loop)]
4630        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4631            url = params.uri_replacement(url, param_name, find_this, true);
4632        }
4633        {
4634            let to_remove = ["parent"];
4635            params.remove_params(&to_remove);
4636        }
4637
4638        let url = params.parse_with_url(&url);
4639
4640        loop {
4641            let token = match self
4642                .hub
4643                .auth
4644                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4645                .await
4646            {
4647                Ok(token) => token,
4648                Err(e) => match dlg.token(e) {
4649                    Ok(token) => token,
4650                    Err(e) => {
4651                        dlg.finished(false);
4652                        return Err(common::Error::MissingToken(e));
4653                    }
4654                },
4655            };
4656            let mut req_result = {
4657                let client = &self.hub.client;
4658                dlg.pre_request();
4659                let mut req_builder = hyper::Request::builder()
4660                    .method(hyper::Method::GET)
4661                    .uri(url.as_str())
4662                    .header(USER_AGENT, self.hub._user_agent.clone());
4663
4664                if let Some(token) = token.as_ref() {
4665                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4666                }
4667
4668                let request = req_builder
4669                    .header(CONTENT_LENGTH, 0_u64)
4670                    .body(common::to_body::<String>(None));
4671
4672                client.request(request.unwrap()).await
4673            };
4674
4675            match req_result {
4676                Err(err) => {
4677                    if let common::Retry::After(d) = dlg.http_error(&err) {
4678                        sleep(d).await;
4679                        continue;
4680                    }
4681                    dlg.finished(false);
4682                    return Err(common::Error::HttpError(err));
4683                }
4684                Ok(res) => {
4685                    let (mut parts, body) = res.into_parts();
4686                    let mut body = common::Body::new(body);
4687                    if !parts.status.is_success() {
4688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4689                        let error = serde_json::from_str(&common::to_string(&bytes));
4690                        let response = common::to_response(parts, bytes.into());
4691
4692                        if let common::Retry::After(d) =
4693                            dlg.http_failure(&response, error.as_ref().ok())
4694                        {
4695                            sleep(d).await;
4696                            continue;
4697                        }
4698
4699                        dlg.finished(false);
4700
4701                        return Err(match error {
4702                            Ok(value) => common::Error::BadRequest(value),
4703                            _ => common::Error::Failure(response),
4704                        });
4705                    }
4706                    let response = {
4707                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4708                        let encoded = common::to_string(&bytes);
4709                        match serde_json::from_str(&encoded) {
4710                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4711                            Err(error) => {
4712                                dlg.response_json_decode_error(&encoded, &error);
4713                                return Err(common::Error::JsonDecodeError(
4714                                    encoded.to_string(),
4715                                    error,
4716                                ));
4717                            }
4718                        }
4719                    };
4720
4721                    dlg.finished(true);
4722                    return Ok(response);
4723                }
4724            }
4725        }
4726    }
4727
4728    /// Required. The ad client which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}
4729    ///
4730    /// Sets the *parent* path property to the given value.
4731    ///
4732    /// Even though the property as already been set when instantiating this call,
4733    /// we provide this method for API completeness.
4734    pub fn parent(mut self, new_value: &str) -> AccountAdclientCustomchannelListCall<'a, C> {
4735        self._parent = new_value.to_string();
4736        self
4737    }
4738    /// A page token, received from a previous `ListCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCustomChannels` must match the call that provided the page token.
4739    ///
4740    /// Sets the *page token* query property to the given value.
4741    pub fn page_token(mut self, new_value: &str) -> AccountAdclientCustomchannelListCall<'a, C> {
4742        self._page_token = Some(new_value.to_string());
4743        self
4744    }
4745    /// The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
4746    ///
4747    /// Sets the *page size* query property to the given value.
4748    pub fn page_size(mut self, new_value: i32) -> AccountAdclientCustomchannelListCall<'a, C> {
4749        self._page_size = Some(new_value);
4750        self
4751    }
4752    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4753    /// while executing the actual API request.
4754    ///
4755    /// ````text
4756    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4757    /// ````
4758    ///
4759    /// Sets the *delegate* property to the given value.
4760    pub fn delegate(
4761        mut self,
4762        new_value: &'a mut dyn common::Delegate,
4763    ) -> AccountAdclientCustomchannelListCall<'a, C> {
4764        self._delegate = Some(new_value);
4765        self
4766    }
4767
4768    /// Set any additional parameter of the query string used in the request.
4769    /// It should be used to set parameters which are not yet available through their own
4770    /// setters.
4771    ///
4772    /// Please note that this method must not be used to set any of the known parameters
4773    /// which have their own setter method. If done anyway, the request will fail.
4774    ///
4775    /// # Additional Parameters
4776    ///
4777    /// * *$.xgafv* (query-string) - V1 error format.
4778    /// * *access_token* (query-string) - OAuth access token.
4779    /// * *alt* (query-string) - Data format for response.
4780    /// * *callback* (query-string) - JSONP
4781    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4782    /// * *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.
4783    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4784    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4785    /// * *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.
4786    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4787    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4788    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelListCall<'a, C>
4789    where
4790        T: AsRef<str>,
4791    {
4792        self._additional_params
4793            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4794        self
4795    }
4796
4797    /// Identifies the authorization scope for the method you are building.
4798    ///
4799    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4800    /// [`Scope::Readonly`].
4801    ///
4802    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4803    /// tokens for more than one scope.
4804    ///
4805    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4806    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4807    /// sufficient, a read-write scope will do as well.
4808    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelListCall<'a, C>
4809    where
4810        St: AsRef<str>,
4811    {
4812        self._scopes.insert(String::from(scope.as_ref()));
4813        self
4814    }
4815    /// Identifies the authorization scope(s) for the method you are building.
4816    ///
4817    /// See [`Self::add_scope()`] for details.
4818    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelListCall<'a, C>
4819    where
4820        I: IntoIterator<Item = St>,
4821        St: AsRef<str>,
4822    {
4823        self._scopes
4824            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4825        self
4826    }
4827
4828    /// Removes all scopes, and no default scope will be used either.
4829    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4830    /// for details).
4831    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelListCall<'a, C> {
4832        self._scopes.clear();
4833        self
4834    }
4835}
4836
4837/// Lists all the ad units available for a custom channel.
4838///
4839/// A builder for the *adclients.customchannels.listLinkedAdUnits* method supported by a *account* resource.
4840/// It is not used directly, but through a [`AccountMethods`] instance.
4841///
4842/// # Example
4843///
4844/// Instantiate a resource method builder
4845///
4846/// ```test_harness,no_run
4847/// # extern crate hyper;
4848/// # extern crate hyper_rustls;
4849/// # extern crate google_adsense2 as adsense2;
4850/// # async fn dox() {
4851/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4852///
4853/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4854/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4855/// #     secret,
4856/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4857/// # ).build().await.unwrap();
4858///
4859/// # let client = hyper_util::client::legacy::Client::builder(
4860/// #     hyper_util::rt::TokioExecutor::new()
4861/// # )
4862/// # .build(
4863/// #     hyper_rustls::HttpsConnectorBuilder::new()
4864/// #         .with_native_roots()
4865/// #         .unwrap()
4866/// #         .https_or_http()
4867/// #         .enable_http1()
4868/// #         .build()
4869/// # );
4870/// # let mut hub = Adsense::new(client, auth);
4871/// // You can configure optional parameters by calling the respective setters at will, and
4872/// // execute the final call using `doit()`.
4873/// // Values shown here are possibly random and not representative !
4874/// let result = hub.accounts().adclients_customchannels_list_linked_ad_units("parent")
4875///              .page_token("vero")
4876///              .page_size(-76)
4877///              .doit().await;
4878/// # }
4879/// ```
4880pub struct AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
4881where
4882    C: 'a,
4883{
4884    hub: &'a Adsense<C>,
4885    _parent: String,
4886    _page_token: Option<String>,
4887    _page_size: Option<i32>,
4888    _delegate: Option<&'a mut dyn common::Delegate>,
4889    _additional_params: HashMap<String, String>,
4890    _scopes: BTreeSet<String>,
4891}
4892
4893impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {}
4894
4895impl<'a, C> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
4896where
4897    C: common::Connector,
4898{
4899    /// Perform the operation you have build so far.
4900    pub async fn doit(mut self) -> common::Result<(common::Response, ListLinkedAdUnitsResponse)> {
4901        use std::borrow::Cow;
4902        use std::io::{Read, Seek};
4903
4904        use common::{url::Params, ToParts};
4905        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4906
4907        let mut dd = common::DefaultDelegate;
4908        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4909        dlg.begin(common::MethodInfo {
4910            id: "adsense.accounts.adclients.customchannels.listLinkedAdUnits",
4911            http_method: hyper::Method::GET,
4912        });
4913
4914        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4915            if self._additional_params.contains_key(field) {
4916                dlg.finished(false);
4917                return Err(common::Error::FieldClash(field));
4918            }
4919        }
4920
4921        let mut params = Params::with_capacity(5 + self._additional_params.len());
4922        params.push("parent", self._parent);
4923        if let Some(value) = self._page_token.as_ref() {
4924            params.push("pageToken", value);
4925        }
4926        if let Some(value) = self._page_size.as_ref() {
4927            params.push("pageSize", value.to_string());
4928        }
4929
4930        params.extend(self._additional_params.iter());
4931
4932        params.push("alt", "json");
4933        let mut url = self.hub._base_url.clone() + "v2/{+parent}:listLinkedAdUnits";
4934        if self._scopes.is_empty() {
4935            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4936        }
4937
4938        #[allow(clippy::single_element_loop)]
4939        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4940            url = params.uri_replacement(url, param_name, find_this, true);
4941        }
4942        {
4943            let to_remove = ["parent"];
4944            params.remove_params(&to_remove);
4945        }
4946
4947        let url = params.parse_with_url(&url);
4948
4949        loop {
4950            let token = match self
4951                .hub
4952                .auth
4953                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4954                .await
4955            {
4956                Ok(token) => token,
4957                Err(e) => match dlg.token(e) {
4958                    Ok(token) => token,
4959                    Err(e) => {
4960                        dlg.finished(false);
4961                        return Err(common::Error::MissingToken(e));
4962                    }
4963                },
4964            };
4965            let mut req_result = {
4966                let client = &self.hub.client;
4967                dlg.pre_request();
4968                let mut req_builder = hyper::Request::builder()
4969                    .method(hyper::Method::GET)
4970                    .uri(url.as_str())
4971                    .header(USER_AGENT, self.hub._user_agent.clone());
4972
4973                if let Some(token) = token.as_ref() {
4974                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4975                }
4976
4977                let request = req_builder
4978                    .header(CONTENT_LENGTH, 0_u64)
4979                    .body(common::to_body::<String>(None));
4980
4981                client.request(request.unwrap()).await
4982            };
4983
4984            match req_result {
4985                Err(err) => {
4986                    if let common::Retry::After(d) = dlg.http_error(&err) {
4987                        sleep(d).await;
4988                        continue;
4989                    }
4990                    dlg.finished(false);
4991                    return Err(common::Error::HttpError(err));
4992                }
4993                Ok(res) => {
4994                    let (mut parts, body) = res.into_parts();
4995                    let mut body = common::Body::new(body);
4996                    if !parts.status.is_success() {
4997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4998                        let error = serde_json::from_str(&common::to_string(&bytes));
4999                        let response = common::to_response(parts, bytes.into());
5000
5001                        if let common::Retry::After(d) =
5002                            dlg.http_failure(&response, error.as_ref().ok())
5003                        {
5004                            sleep(d).await;
5005                            continue;
5006                        }
5007
5008                        dlg.finished(false);
5009
5010                        return Err(match error {
5011                            Ok(value) => common::Error::BadRequest(value),
5012                            _ => common::Error::Failure(response),
5013                        });
5014                    }
5015                    let response = {
5016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5017                        let encoded = common::to_string(&bytes);
5018                        match serde_json::from_str(&encoded) {
5019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5020                            Err(error) => {
5021                                dlg.response_json_decode_error(&encoded, &error);
5022                                return Err(common::Error::JsonDecodeError(
5023                                    encoded.to_string(),
5024                                    error,
5025                                ));
5026                            }
5027                        }
5028                    };
5029
5030                    dlg.finished(true);
5031                    return Ok(response);
5032                }
5033            }
5034        }
5035    }
5036
5037    /// Required. The custom channel which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
5038    ///
5039    /// Sets the *parent* path property to the given value.
5040    ///
5041    /// Even though the property as already been set when instantiating this call,
5042    /// we provide this method for API completeness.
5043    pub fn parent(
5044        mut self,
5045        new_value: &str,
5046    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5047        self._parent = new_value.to_string();
5048        self
5049    }
5050    /// A page token, received from a previous `ListLinkedAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedAdUnits` must match the call that provided the page token.
5051    ///
5052    /// Sets the *page token* query property to the given value.
5053    pub fn page_token(
5054        mut self,
5055        new_value: &str,
5056    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5057        self._page_token = Some(new_value.to_string());
5058        self
5059    }
5060    /// The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
5061    ///
5062    /// Sets the *page size* query property to the given value.
5063    pub fn page_size(
5064        mut self,
5065        new_value: i32,
5066    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5067        self._page_size = Some(new_value);
5068        self
5069    }
5070    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5071    /// while executing the actual API request.
5072    ///
5073    /// ````text
5074    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5075    /// ````
5076    ///
5077    /// Sets the *delegate* property to the given value.
5078    pub fn delegate(
5079        mut self,
5080        new_value: &'a mut dyn common::Delegate,
5081    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5082        self._delegate = Some(new_value);
5083        self
5084    }
5085
5086    /// Set any additional parameter of the query string used in the request.
5087    /// It should be used to set parameters which are not yet available through their own
5088    /// setters.
5089    ///
5090    /// Please note that this method must not be used to set any of the known parameters
5091    /// which have their own setter method. If done anyway, the request will fail.
5092    ///
5093    /// # Additional Parameters
5094    ///
5095    /// * *$.xgafv* (query-string) - V1 error format.
5096    /// * *access_token* (query-string) - OAuth access token.
5097    /// * *alt* (query-string) - Data format for response.
5098    /// * *callback* (query-string) - JSONP
5099    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5100    /// * *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.
5101    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5102    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5103    /// * *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.
5104    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5105    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5106    pub fn param<T>(
5107        mut self,
5108        name: T,
5109        value: T,
5110    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5111    where
5112        T: AsRef<str>,
5113    {
5114        self._additional_params
5115            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5116        self
5117    }
5118
5119    /// Identifies the authorization scope for the method you are building.
5120    ///
5121    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5122    /// [`Scope::Readonly`].
5123    ///
5124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5125    /// tokens for more than one scope.
5126    ///
5127    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5128    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5129    /// sufficient, a read-write scope will do as well.
5130    pub fn add_scope<St>(
5131        mut self,
5132        scope: St,
5133    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5134    where
5135        St: AsRef<str>,
5136    {
5137        self._scopes.insert(String::from(scope.as_ref()));
5138        self
5139    }
5140    /// Identifies the authorization scope(s) for the method you are building.
5141    ///
5142    /// See [`Self::add_scope()`] for details.
5143    pub fn add_scopes<I, St>(
5144        mut self,
5145        scopes: I,
5146    ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5147    where
5148        I: IntoIterator<Item = St>,
5149        St: AsRef<str>,
5150    {
5151        self._scopes
5152            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5153        self
5154    }
5155
5156    /// Removes all scopes, and no default scope will be used either.
5157    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5158    /// for details).
5159    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5160        self._scopes.clear();
5161        self
5162    }
5163}
5164
5165/// Updates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
5166///
5167/// A builder for the *adclients.customchannels.patch* method supported by a *account* resource.
5168/// It is not used directly, but through a [`AccountMethods`] instance.
5169///
5170/// # Example
5171///
5172/// Instantiate a resource method builder
5173///
5174/// ```test_harness,no_run
5175/// # extern crate hyper;
5176/// # extern crate hyper_rustls;
5177/// # extern crate google_adsense2 as adsense2;
5178/// use adsense2::api::CustomChannel;
5179/// # async fn dox() {
5180/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5181///
5182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5183/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5184/// #     secret,
5185/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5186/// # ).build().await.unwrap();
5187///
5188/// # let client = hyper_util::client::legacy::Client::builder(
5189/// #     hyper_util::rt::TokioExecutor::new()
5190/// # )
5191/// # .build(
5192/// #     hyper_rustls::HttpsConnectorBuilder::new()
5193/// #         .with_native_roots()
5194/// #         .unwrap()
5195/// #         .https_or_http()
5196/// #         .enable_http1()
5197/// #         .build()
5198/// # );
5199/// # let mut hub = Adsense::new(client, auth);
5200/// // As the method needs a request, you would usually fill it with the desired information
5201/// // into the respective structure. Some of the parts shown here might not be applicable !
5202/// // Values shown here are possibly random and not representative !
5203/// let mut req = CustomChannel::default();
5204///
5205/// // You can configure optional parameters by calling the respective setters at will, and
5206/// // execute the final call using `doit()`.
5207/// // Values shown here are possibly random and not representative !
5208/// let result = hub.accounts().adclients_customchannels_patch(req, "name")
5209///              .update_mask(FieldMask::new::<&str>(&[]))
5210///              .doit().await;
5211/// # }
5212/// ```
5213pub struct AccountAdclientCustomchannelPatchCall<'a, C>
5214where
5215    C: 'a,
5216{
5217    hub: &'a Adsense<C>,
5218    _request: CustomChannel,
5219    _name: String,
5220    _update_mask: Option<common::FieldMask>,
5221    _delegate: Option<&'a mut dyn common::Delegate>,
5222    _additional_params: HashMap<String, String>,
5223    _scopes: BTreeSet<String>,
5224}
5225
5226impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelPatchCall<'a, C> {}
5227
5228impl<'a, C> AccountAdclientCustomchannelPatchCall<'a, C>
5229where
5230    C: common::Connector,
5231{
5232    /// Perform the operation you have build so far.
5233    pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
5234        use std::borrow::Cow;
5235        use std::io::{Read, Seek};
5236
5237        use common::{url::Params, ToParts};
5238        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5239
5240        let mut dd = common::DefaultDelegate;
5241        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5242        dlg.begin(common::MethodInfo {
5243            id: "adsense.accounts.adclients.customchannels.patch",
5244            http_method: hyper::Method::PATCH,
5245        });
5246
5247        for &field in ["alt", "name", "updateMask"].iter() {
5248            if self._additional_params.contains_key(field) {
5249                dlg.finished(false);
5250                return Err(common::Error::FieldClash(field));
5251            }
5252        }
5253
5254        let mut params = Params::with_capacity(5 + self._additional_params.len());
5255        params.push("name", self._name);
5256        if let Some(value) = self._update_mask.as_ref() {
5257            params.push("updateMask", value.to_string());
5258        }
5259
5260        params.extend(self._additional_params.iter());
5261
5262        params.push("alt", "json");
5263        let mut url = self.hub._base_url.clone() + "v2/{+name}";
5264        if self._scopes.is_empty() {
5265            self._scopes.insert(Scope::Full.as_ref().to_string());
5266        }
5267
5268        #[allow(clippy::single_element_loop)]
5269        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5270            url = params.uri_replacement(url, param_name, find_this, true);
5271        }
5272        {
5273            let to_remove = ["name"];
5274            params.remove_params(&to_remove);
5275        }
5276
5277        let url = params.parse_with_url(&url);
5278
5279        let mut json_mime_type = mime::APPLICATION_JSON;
5280        let mut request_value_reader = {
5281            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5282            common::remove_json_null_values(&mut value);
5283            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5284            serde_json::to_writer(&mut dst, &value).unwrap();
5285            dst
5286        };
5287        let request_size = request_value_reader
5288            .seek(std::io::SeekFrom::End(0))
5289            .unwrap();
5290        request_value_reader
5291            .seek(std::io::SeekFrom::Start(0))
5292            .unwrap();
5293
5294        loop {
5295            let token = match self
5296                .hub
5297                .auth
5298                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5299                .await
5300            {
5301                Ok(token) => token,
5302                Err(e) => match dlg.token(e) {
5303                    Ok(token) => token,
5304                    Err(e) => {
5305                        dlg.finished(false);
5306                        return Err(common::Error::MissingToken(e));
5307                    }
5308                },
5309            };
5310            request_value_reader
5311                .seek(std::io::SeekFrom::Start(0))
5312                .unwrap();
5313            let mut req_result = {
5314                let client = &self.hub.client;
5315                dlg.pre_request();
5316                let mut req_builder = hyper::Request::builder()
5317                    .method(hyper::Method::PATCH)
5318                    .uri(url.as_str())
5319                    .header(USER_AGENT, self.hub._user_agent.clone());
5320
5321                if let Some(token) = token.as_ref() {
5322                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5323                }
5324
5325                let request = req_builder
5326                    .header(CONTENT_TYPE, json_mime_type.to_string())
5327                    .header(CONTENT_LENGTH, request_size as u64)
5328                    .body(common::to_body(
5329                        request_value_reader.get_ref().clone().into(),
5330                    ));
5331
5332                client.request(request.unwrap()).await
5333            };
5334
5335            match req_result {
5336                Err(err) => {
5337                    if let common::Retry::After(d) = dlg.http_error(&err) {
5338                        sleep(d).await;
5339                        continue;
5340                    }
5341                    dlg.finished(false);
5342                    return Err(common::Error::HttpError(err));
5343                }
5344                Ok(res) => {
5345                    let (mut parts, body) = res.into_parts();
5346                    let mut body = common::Body::new(body);
5347                    if !parts.status.is_success() {
5348                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5349                        let error = serde_json::from_str(&common::to_string(&bytes));
5350                        let response = common::to_response(parts, bytes.into());
5351
5352                        if let common::Retry::After(d) =
5353                            dlg.http_failure(&response, error.as_ref().ok())
5354                        {
5355                            sleep(d).await;
5356                            continue;
5357                        }
5358
5359                        dlg.finished(false);
5360
5361                        return Err(match error {
5362                            Ok(value) => common::Error::BadRequest(value),
5363                            _ => common::Error::Failure(response),
5364                        });
5365                    }
5366                    let response = {
5367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5368                        let encoded = common::to_string(&bytes);
5369                        match serde_json::from_str(&encoded) {
5370                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5371                            Err(error) => {
5372                                dlg.response_json_decode_error(&encoded, &error);
5373                                return Err(common::Error::JsonDecodeError(
5374                                    encoded.to_string(),
5375                                    error,
5376                                ));
5377                            }
5378                        }
5379                    };
5380
5381                    dlg.finished(true);
5382                    return Ok(response);
5383                }
5384            }
5385        }
5386    }
5387
5388    ///
5389    /// Sets the *request* property to the given value.
5390    ///
5391    /// Even though the property as already been set when instantiating this call,
5392    /// we provide this method for API completeness.
5393    pub fn request(
5394        mut self,
5395        new_value: CustomChannel,
5396    ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5397        self._request = new_value;
5398        self
5399    }
5400    /// Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
5401    ///
5402    /// Sets the *name* path property to the given value.
5403    ///
5404    /// Even though the property as already been set when instantiating this call,
5405    /// we provide this method for API completeness.
5406    pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5407        self._name = new_value.to_string();
5408        self
5409    }
5410    /// The list of fields to update. If empty, a full update is performed.
5411    ///
5412    /// Sets the *update mask* query property to the given value.
5413    pub fn update_mask(
5414        mut self,
5415        new_value: common::FieldMask,
5416    ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5417        self._update_mask = Some(new_value);
5418        self
5419    }
5420    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5421    /// while executing the actual API request.
5422    ///
5423    /// ````text
5424    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5425    /// ````
5426    ///
5427    /// Sets the *delegate* property to the given value.
5428    pub fn delegate(
5429        mut self,
5430        new_value: &'a mut dyn common::Delegate,
5431    ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5432        self._delegate = Some(new_value);
5433        self
5434    }
5435
5436    /// Set any additional parameter of the query string used in the request.
5437    /// It should be used to set parameters which are not yet available through their own
5438    /// setters.
5439    ///
5440    /// Please note that this method must not be used to set any of the known parameters
5441    /// which have their own setter method. If done anyway, the request will fail.
5442    ///
5443    /// # Additional Parameters
5444    ///
5445    /// * *$.xgafv* (query-string) - V1 error format.
5446    /// * *access_token* (query-string) - OAuth access token.
5447    /// * *alt* (query-string) - Data format for response.
5448    /// * *callback* (query-string) - JSONP
5449    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5450    /// * *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.
5451    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5452    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5453    /// * *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.
5454    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5455    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5456    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelPatchCall<'a, C>
5457    where
5458        T: AsRef<str>,
5459    {
5460        self._additional_params
5461            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5462        self
5463    }
5464
5465    /// Identifies the authorization scope for the method you are building.
5466    ///
5467    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5468    /// [`Scope::Full`].
5469    ///
5470    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5471    /// tokens for more than one scope.
5472    ///
5473    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5474    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5475    /// sufficient, a read-write scope will do as well.
5476    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelPatchCall<'a, C>
5477    where
5478        St: AsRef<str>,
5479    {
5480        self._scopes.insert(String::from(scope.as_ref()));
5481        self
5482    }
5483    /// Identifies the authorization scope(s) for the method you are building.
5484    ///
5485    /// See [`Self::add_scope()`] for details.
5486    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelPatchCall<'a, C>
5487    where
5488        I: IntoIterator<Item = St>,
5489        St: AsRef<str>,
5490    {
5491        self._scopes
5492            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5493        self
5494    }
5495
5496    /// Removes all scopes, and no default scope will be used either.
5497    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5498    /// for details).
5499    pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5500        self._scopes.clear();
5501        self
5502    }
5503}
5504
5505/// Gets information about the selected url channel.
5506///
5507/// A builder for the *adclients.urlchannels.get* method supported by a *account* resource.
5508/// It is not used directly, but through a [`AccountMethods`] instance.
5509///
5510/// # Example
5511///
5512/// Instantiate a resource method builder
5513///
5514/// ```test_harness,no_run
5515/// # extern crate hyper;
5516/// # extern crate hyper_rustls;
5517/// # extern crate google_adsense2 as adsense2;
5518/// # async fn dox() {
5519/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5520///
5521/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5523/// #     secret,
5524/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5525/// # ).build().await.unwrap();
5526///
5527/// # let client = hyper_util::client::legacy::Client::builder(
5528/// #     hyper_util::rt::TokioExecutor::new()
5529/// # )
5530/// # .build(
5531/// #     hyper_rustls::HttpsConnectorBuilder::new()
5532/// #         .with_native_roots()
5533/// #         .unwrap()
5534/// #         .https_or_http()
5535/// #         .enable_http1()
5536/// #         .build()
5537/// # );
5538/// # let mut hub = Adsense::new(client, auth);
5539/// // You can configure optional parameters by calling the respective setters at will, and
5540/// // execute the final call using `doit()`.
5541/// // Values shown here are possibly random and not representative !
5542/// let result = hub.accounts().adclients_urlchannels_get("name")
5543///              .doit().await;
5544/// # }
5545/// ```
5546pub struct AccountAdclientUrlchannelGetCall<'a, C>
5547where
5548    C: 'a,
5549{
5550    hub: &'a Adsense<C>,
5551    _name: String,
5552    _delegate: Option<&'a mut dyn common::Delegate>,
5553    _additional_params: HashMap<String, String>,
5554    _scopes: BTreeSet<String>,
5555}
5556
5557impl<'a, C> common::CallBuilder for AccountAdclientUrlchannelGetCall<'a, C> {}
5558
5559impl<'a, C> AccountAdclientUrlchannelGetCall<'a, C>
5560where
5561    C: common::Connector,
5562{
5563    /// Perform the operation you have build so far.
5564    pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannel)> {
5565        use std::borrow::Cow;
5566        use std::io::{Read, Seek};
5567
5568        use common::{url::Params, ToParts};
5569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5570
5571        let mut dd = common::DefaultDelegate;
5572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5573        dlg.begin(common::MethodInfo {
5574            id: "adsense.accounts.adclients.urlchannels.get",
5575            http_method: hyper::Method::GET,
5576        });
5577
5578        for &field in ["alt", "name"].iter() {
5579            if self._additional_params.contains_key(field) {
5580                dlg.finished(false);
5581                return Err(common::Error::FieldClash(field));
5582            }
5583        }
5584
5585        let mut params = Params::with_capacity(3 + self._additional_params.len());
5586        params.push("name", self._name);
5587
5588        params.extend(self._additional_params.iter());
5589
5590        params.push("alt", "json");
5591        let mut url = self.hub._base_url.clone() + "v2/{+name}";
5592        if self._scopes.is_empty() {
5593            self._scopes.insert(Scope::Readonly.as_ref().to_string());
5594        }
5595
5596        #[allow(clippy::single_element_loop)]
5597        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5598            url = params.uri_replacement(url, param_name, find_this, true);
5599        }
5600        {
5601            let to_remove = ["name"];
5602            params.remove_params(&to_remove);
5603        }
5604
5605        let url = params.parse_with_url(&url);
5606
5607        loop {
5608            let token = match self
5609                .hub
5610                .auth
5611                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5612                .await
5613            {
5614                Ok(token) => token,
5615                Err(e) => match dlg.token(e) {
5616                    Ok(token) => token,
5617                    Err(e) => {
5618                        dlg.finished(false);
5619                        return Err(common::Error::MissingToken(e));
5620                    }
5621                },
5622            };
5623            let mut req_result = {
5624                let client = &self.hub.client;
5625                dlg.pre_request();
5626                let mut req_builder = hyper::Request::builder()
5627                    .method(hyper::Method::GET)
5628                    .uri(url.as_str())
5629                    .header(USER_AGENT, self.hub._user_agent.clone());
5630
5631                if let Some(token) = token.as_ref() {
5632                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5633                }
5634
5635                let request = req_builder
5636                    .header(CONTENT_LENGTH, 0_u64)
5637                    .body(common::to_body::<String>(None));
5638
5639                client.request(request.unwrap()).await
5640            };
5641
5642            match req_result {
5643                Err(err) => {
5644                    if let common::Retry::After(d) = dlg.http_error(&err) {
5645                        sleep(d).await;
5646                        continue;
5647                    }
5648                    dlg.finished(false);
5649                    return Err(common::Error::HttpError(err));
5650                }
5651                Ok(res) => {
5652                    let (mut parts, body) = res.into_parts();
5653                    let mut body = common::Body::new(body);
5654                    if !parts.status.is_success() {
5655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5656                        let error = serde_json::from_str(&common::to_string(&bytes));
5657                        let response = common::to_response(parts, bytes.into());
5658
5659                        if let common::Retry::After(d) =
5660                            dlg.http_failure(&response, error.as_ref().ok())
5661                        {
5662                            sleep(d).await;
5663                            continue;
5664                        }
5665
5666                        dlg.finished(false);
5667
5668                        return Err(match error {
5669                            Ok(value) => common::Error::BadRequest(value),
5670                            _ => common::Error::Failure(response),
5671                        });
5672                    }
5673                    let response = {
5674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5675                        let encoded = common::to_string(&bytes);
5676                        match serde_json::from_str(&encoded) {
5677                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5678                            Err(error) => {
5679                                dlg.response_json_decode_error(&encoded, &error);
5680                                return Err(common::Error::JsonDecodeError(
5681                                    encoded.to_string(),
5682                                    error,
5683                                ));
5684                            }
5685                        }
5686                    };
5687
5688                    dlg.finished(true);
5689                    return Ok(response);
5690                }
5691            }
5692        }
5693    }
5694
5695    /// Required. The name of the url channel to retrieve. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
5696    ///
5697    /// Sets the *name* path property to the given value.
5698    ///
5699    /// Even though the property as already been set when instantiating this call,
5700    /// we provide this method for API completeness.
5701    pub fn name(mut self, new_value: &str) -> AccountAdclientUrlchannelGetCall<'a, C> {
5702        self._name = new_value.to_string();
5703        self
5704    }
5705    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5706    /// while executing the actual API request.
5707    ///
5708    /// ````text
5709    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5710    /// ````
5711    ///
5712    /// Sets the *delegate* property to the given value.
5713    pub fn delegate(
5714        mut self,
5715        new_value: &'a mut dyn common::Delegate,
5716    ) -> AccountAdclientUrlchannelGetCall<'a, C> {
5717        self._delegate = Some(new_value);
5718        self
5719    }
5720
5721    /// Set any additional parameter of the query string used in the request.
5722    /// It should be used to set parameters which are not yet available through their own
5723    /// setters.
5724    ///
5725    /// Please note that this method must not be used to set any of the known parameters
5726    /// which have their own setter method. If done anyway, the request will fail.
5727    ///
5728    /// # Additional Parameters
5729    ///
5730    /// * *$.xgafv* (query-string) - V1 error format.
5731    /// * *access_token* (query-string) - OAuth access token.
5732    /// * *alt* (query-string) - Data format for response.
5733    /// * *callback* (query-string) - JSONP
5734    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5735    /// * *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.
5736    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5737    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5738    /// * *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.
5739    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5740    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5741    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientUrlchannelGetCall<'a, C>
5742    where
5743        T: AsRef<str>,
5744    {
5745        self._additional_params
5746            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5747        self
5748    }
5749
5750    /// Identifies the authorization scope for the method you are building.
5751    ///
5752    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5753    /// [`Scope::Readonly`].
5754    ///
5755    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5756    /// tokens for more than one scope.
5757    ///
5758    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5759    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5760    /// sufficient, a read-write scope will do as well.
5761    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientUrlchannelGetCall<'a, C>
5762    where
5763        St: AsRef<str>,
5764    {
5765        self._scopes.insert(String::from(scope.as_ref()));
5766        self
5767    }
5768    /// Identifies the authorization scope(s) for the method you are building.
5769    ///
5770    /// See [`Self::add_scope()`] for details.
5771    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientUrlchannelGetCall<'a, C>
5772    where
5773        I: IntoIterator<Item = St>,
5774        St: AsRef<str>,
5775    {
5776        self._scopes
5777            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5778        self
5779    }
5780
5781    /// Removes all scopes, and no default scope will be used either.
5782    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5783    /// for details).
5784    pub fn clear_scopes(mut self) -> AccountAdclientUrlchannelGetCall<'a, C> {
5785        self._scopes.clear();
5786        self
5787    }
5788}
5789
5790/// Lists active url channels.
5791///
5792/// A builder for the *adclients.urlchannels.list* method supported by a *account* resource.
5793/// It is not used directly, but through a [`AccountMethods`] instance.
5794///
5795/// # Example
5796///
5797/// Instantiate a resource method builder
5798///
5799/// ```test_harness,no_run
5800/// # extern crate hyper;
5801/// # extern crate hyper_rustls;
5802/// # extern crate google_adsense2 as adsense2;
5803/// # async fn dox() {
5804/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5805///
5806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5807/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5808/// #     secret,
5809/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5810/// # ).build().await.unwrap();
5811///
5812/// # let client = hyper_util::client::legacy::Client::builder(
5813/// #     hyper_util::rt::TokioExecutor::new()
5814/// # )
5815/// # .build(
5816/// #     hyper_rustls::HttpsConnectorBuilder::new()
5817/// #         .with_native_roots()
5818/// #         .unwrap()
5819/// #         .https_or_http()
5820/// #         .enable_http1()
5821/// #         .build()
5822/// # );
5823/// # let mut hub = Adsense::new(client, auth);
5824/// // You can configure optional parameters by calling the respective setters at will, and
5825/// // execute the final call using `doit()`.
5826/// // Values shown here are possibly random and not representative !
5827/// let result = hub.accounts().adclients_urlchannels_list("parent")
5828///              .page_token("elitr")
5829///              .page_size(-6)
5830///              .doit().await;
5831/// # }
5832/// ```
5833pub struct AccountAdclientUrlchannelListCall<'a, C>
5834where
5835    C: 'a,
5836{
5837    hub: &'a Adsense<C>,
5838    _parent: String,
5839    _page_token: Option<String>,
5840    _page_size: Option<i32>,
5841    _delegate: Option<&'a mut dyn common::Delegate>,
5842    _additional_params: HashMap<String, String>,
5843    _scopes: BTreeSet<String>,
5844}
5845
5846impl<'a, C> common::CallBuilder for AccountAdclientUrlchannelListCall<'a, C> {}
5847
5848impl<'a, C> AccountAdclientUrlchannelListCall<'a, C>
5849where
5850    C: common::Connector,
5851{
5852    /// Perform the operation you have build so far.
5853    pub async fn doit(mut self) -> common::Result<(common::Response, ListUrlChannelsResponse)> {
5854        use std::borrow::Cow;
5855        use std::io::{Read, Seek};
5856
5857        use common::{url::Params, ToParts};
5858        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5859
5860        let mut dd = common::DefaultDelegate;
5861        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5862        dlg.begin(common::MethodInfo {
5863            id: "adsense.accounts.adclients.urlchannels.list",
5864            http_method: hyper::Method::GET,
5865        });
5866
5867        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5868            if self._additional_params.contains_key(field) {
5869                dlg.finished(false);
5870                return Err(common::Error::FieldClash(field));
5871            }
5872        }
5873
5874        let mut params = Params::with_capacity(5 + self._additional_params.len());
5875        params.push("parent", self._parent);
5876        if let Some(value) = self._page_token.as_ref() {
5877            params.push("pageToken", value);
5878        }
5879        if let Some(value) = self._page_size.as_ref() {
5880            params.push("pageSize", value.to_string());
5881        }
5882
5883        params.extend(self._additional_params.iter());
5884
5885        params.push("alt", "json");
5886        let mut url = self.hub._base_url.clone() + "v2/{+parent}/urlchannels";
5887        if self._scopes.is_empty() {
5888            self._scopes.insert(Scope::Readonly.as_ref().to_string());
5889        }
5890
5891        #[allow(clippy::single_element_loop)]
5892        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5893            url = params.uri_replacement(url, param_name, find_this, true);
5894        }
5895        {
5896            let to_remove = ["parent"];
5897            params.remove_params(&to_remove);
5898        }
5899
5900        let url = params.parse_with_url(&url);
5901
5902        loop {
5903            let token = match self
5904                .hub
5905                .auth
5906                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5907                .await
5908            {
5909                Ok(token) => token,
5910                Err(e) => match dlg.token(e) {
5911                    Ok(token) => token,
5912                    Err(e) => {
5913                        dlg.finished(false);
5914                        return Err(common::Error::MissingToken(e));
5915                    }
5916                },
5917            };
5918            let mut req_result = {
5919                let client = &self.hub.client;
5920                dlg.pre_request();
5921                let mut req_builder = hyper::Request::builder()
5922                    .method(hyper::Method::GET)
5923                    .uri(url.as_str())
5924                    .header(USER_AGENT, self.hub._user_agent.clone());
5925
5926                if let Some(token) = token.as_ref() {
5927                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5928                }
5929
5930                let request = req_builder
5931                    .header(CONTENT_LENGTH, 0_u64)
5932                    .body(common::to_body::<String>(None));
5933
5934                client.request(request.unwrap()).await
5935            };
5936
5937            match req_result {
5938                Err(err) => {
5939                    if let common::Retry::After(d) = dlg.http_error(&err) {
5940                        sleep(d).await;
5941                        continue;
5942                    }
5943                    dlg.finished(false);
5944                    return Err(common::Error::HttpError(err));
5945                }
5946                Ok(res) => {
5947                    let (mut parts, body) = res.into_parts();
5948                    let mut body = common::Body::new(body);
5949                    if !parts.status.is_success() {
5950                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5951                        let error = serde_json::from_str(&common::to_string(&bytes));
5952                        let response = common::to_response(parts, bytes.into());
5953
5954                        if let common::Retry::After(d) =
5955                            dlg.http_failure(&response, error.as_ref().ok())
5956                        {
5957                            sleep(d).await;
5958                            continue;
5959                        }
5960
5961                        dlg.finished(false);
5962
5963                        return Err(match error {
5964                            Ok(value) => common::Error::BadRequest(value),
5965                            _ => common::Error::Failure(response),
5966                        });
5967                    }
5968                    let response = {
5969                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5970                        let encoded = common::to_string(&bytes);
5971                        match serde_json::from_str(&encoded) {
5972                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5973                            Err(error) => {
5974                                dlg.response_json_decode_error(&encoded, &error);
5975                                return Err(common::Error::JsonDecodeError(
5976                                    encoded.to_string(),
5977                                    error,
5978                                ));
5979                            }
5980                        }
5981                    };
5982
5983                    dlg.finished(true);
5984                    return Ok(response);
5985                }
5986            }
5987        }
5988    }
5989
5990    /// Required. The ad client which owns the collection of url channels. Format: accounts/{account}/adclients/{adclient}
5991    ///
5992    /// Sets the *parent* path property to the given value.
5993    ///
5994    /// Even though the property as already been set when instantiating this call,
5995    /// we provide this method for API completeness.
5996    pub fn parent(mut self, new_value: &str) -> AccountAdclientUrlchannelListCall<'a, C> {
5997        self._parent = new_value.to_string();
5998        self
5999    }
6000    /// A page token, received from a previous `ListUrlChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUrlChannels` must match the call that provided the page token.
6001    ///
6002    /// Sets the *page token* query property to the given value.
6003    pub fn page_token(mut self, new_value: &str) -> AccountAdclientUrlchannelListCall<'a, C> {
6004        self._page_token = Some(new_value.to_string());
6005        self
6006    }
6007    /// The maximum number of url channels to include in the response, used for paging. If unspecified, at most 10000 url channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
6008    ///
6009    /// Sets the *page size* query property to the given value.
6010    pub fn page_size(mut self, new_value: i32) -> AccountAdclientUrlchannelListCall<'a, C> {
6011        self._page_size = Some(new_value);
6012        self
6013    }
6014    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6015    /// while executing the actual API request.
6016    ///
6017    /// ````text
6018    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6019    /// ````
6020    ///
6021    /// Sets the *delegate* property to the given value.
6022    pub fn delegate(
6023        mut self,
6024        new_value: &'a mut dyn common::Delegate,
6025    ) -> AccountAdclientUrlchannelListCall<'a, C> {
6026        self._delegate = Some(new_value);
6027        self
6028    }
6029
6030    /// Set any additional parameter of the query string used in the request.
6031    /// It should be used to set parameters which are not yet available through their own
6032    /// setters.
6033    ///
6034    /// Please note that this method must not be used to set any of the known parameters
6035    /// which have their own setter method. If done anyway, the request will fail.
6036    ///
6037    /// # Additional Parameters
6038    ///
6039    /// * *$.xgafv* (query-string) - V1 error format.
6040    /// * *access_token* (query-string) - OAuth access token.
6041    /// * *alt* (query-string) - Data format for response.
6042    /// * *callback* (query-string) - JSONP
6043    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6044    /// * *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.
6045    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6046    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6047    /// * *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.
6048    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6049    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6050    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientUrlchannelListCall<'a, C>
6051    where
6052        T: AsRef<str>,
6053    {
6054        self._additional_params
6055            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6056        self
6057    }
6058
6059    /// Identifies the authorization scope for the method you are building.
6060    ///
6061    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6062    /// [`Scope::Readonly`].
6063    ///
6064    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6065    /// tokens for more than one scope.
6066    ///
6067    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6068    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6069    /// sufficient, a read-write scope will do as well.
6070    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientUrlchannelListCall<'a, C>
6071    where
6072        St: AsRef<str>,
6073    {
6074        self._scopes.insert(String::from(scope.as_ref()));
6075        self
6076    }
6077    /// Identifies the authorization scope(s) for the method you are building.
6078    ///
6079    /// See [`Self::add_scope()`] for details.
6080    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientUrlchannelListCall<'a, C>
6081    where
6082        I: IntoIterator<Item = St>,
6083        St: AsRef<str>,
6084    {
6085        self._scopes
6086            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6087        self
6088    }
6089
6090    /// Removes all scopes, and no default scope will be used either.
6091    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6092    /// for details).
6093    pub fn clear_scopes(mut self) -> AccountAdclientUrlchannelListCall<'a, C> {
6094        self._scopes.clear();
6095        self
6096    }
6097}
6098
6099/// Gets the ad client from the given resource name.
6100///
6101/// A builder for the *adclients.get* method supported by a *account* resource.
6102/// It is not used directly, but through a [`AccountMethods`] instance.
6103///
6104/// # Example
6105///
6106/// Instantiate a resource method builder
6107///
6108/// ```test_harness,no_run
6109/// # extern crate hyper;
6110/// # extern crate hyper_rustls;
6111/// # extern crate google_adsense2 as adsense2;
6112/// # async fn dox() {
6113/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6114///
6115/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6117/// #     secret,
6118/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6119/// # ).build().await.unwrap();
6120///
6121/// # let client = hyper_util::client::legacy::Client::builder(
6122/// #     hyper_util::rt::TokioExecutor::new()
6123/// # )
6124/// # .build(
6125/// #     hyper_rustls::HttpsConnectorBuilder::new()
6126/// #         .with_native_roots()
6127/// #         .unwrap()
6128/// #         .https_or_http()
6129/// #         .enable_http1()
6130/// #         .build()
6131/// # );
6132/// # let mut hub = Adsense::new(client, auth);
6133/// // You can configure optional parameters by calling the respective setters at will, and
6134/// // execute the final call using `doit()`.
6135/// // Values shown here are possibly random and not representative !
6136/// let result = hub.accounts().adclients_get("name")
6137///              .doit().await;
6138/// # }
6139/// ```
6140pub struct AccountAdclientGetCall<'a, C>
6141where
6142    C: 'a,
6143{
6144    hub: &'a Adsense<C>,
6145    _name: String,
6146    _delegate: Option<&'a mut dyn common::Delegate>,
6147    _additional_params: HashMap<String, String>,
6148    _scopes: BTreeSet<String>,
6149}
6150
6151impl<'a, C> common::CallBuilder for AccountAdclientGetCall<'a, C> {}
6152
6153impl<'a, C> AccountAdclientGetCall<'a, C>
6154where
6155    C: common::Connector,
6156{
6157    /// Perform the operation you have build so far.
6158    pub async fn doit(mut self) -> common::Result<(common::Response, AdClient)> {
6159        use std::borrow::Cow;
6160        use std::io::{Read, Seek};
6161
6162        use common::{url::Params, ToParts};
6163        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6164
6165        let mut dd = common::DefaultDelegate;
6166        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6167        dlg.begin(common::MethodInfo {
6168            id: "adsense.accounts.adclients.get",
6169            http_method: hyper::Method::GET,
6170        });
6171
6172        for &field in ["alt", "name"].iter() {
6173            if self._additional_params.contains_key(field) {
6174                dlg.finished(false);
6175                return Err(common::Error::FieldClash(field));
6176            }
6177        }
6178
6179        let mut params = Params::with_capacity(3 + self._additional_params.len());
6180        params.push("name", self._name);
6181
6182        params.extend(self._additional_params.iter());
6183
6184        params.push("alt", "json");
6185        let mut url = self.hub._base_url.clone() + "v2/{+name}";
6186        if self._scopes.is_empty() {
6187            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6188        }
6189
6190        #[allow(clippy::single_element_loop)]
6191        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6192            url = params.uri_replacement(url, param_name, find_this, true);
6193        }
6194        {
6195            let to_remove = ["name"];
6196            params.remove_params(&to_remove);
6197        }
6198
6199        let url = params.parse_with_url(&url);
6200
6201        loop {
6202            let token = match self
6203                .hub
6204                .auth
6205                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6206                .await
6207            {
6208                Ok(token) => token,
6209                Err(e) => match dlg.token(e) {
6210                    Ok(token) => token,
6211                    Err(e) => {
6212                        dlg.finished(false);
6213                        return Err(common::Error::MissingToken(e));
6214                    }
6215                },
6216            };
6217            let mut req_result = {
6218                let client = &self.hub.client;
6219                dlg.pre_request();
6220                let mut req_builder = hyper::Request::builder()
6221                    .method(hyper::Method::GET)
6222                    .uri(url.as_str())
6223                    .header(USER_AGENT, self.hub._user_agent.clone());
6224
6225                if let Some(token) = token.as_ref() {
6226                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6227                }
6228
6229                let request = req_builder
6230                    .header(CONTENT_LENGTH, 0_u64)
6231                    .body(common::to_body::<String>(None));
6232
6233                client.request(request.unwrap()).await
6234            };
6235
6236            match req_result {
6237                Err(err) => {
6238                    if let common::Retry::After(d) = dlg.http_error(&err) {
6239                        sleep(d).await;
6240                        continue;
6241                    }
6242                    dlg.finished(false);
6243                    return Err(common::Error::HttpError(err));
6244                }
6245                Ok(res) => {
6246                    let (mut parts, body) = res.into_parts();
6247                    let mut body = common::Body::new(body);
6248                    if !parts.status.is_success() {
6249                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6250                        let error = serde_json::from_str(&common::to_string(&bytes));
6251                        let response = common::to_response(parts, bytes.into());
6252
6253                        if let common::Retry::After(d) =
6254                            dlg.http_failure(&response, error.as_ref().ok())
6255                        {
6256                            sleep(d).await;
6257                            continue;
6258                        }
6259
6260                        dlg.finished(false);
6261
6262                        return Err(match error {
6263                            Ok(value) => common::Error::BadRequest(value),
6264                            _ => common::Error::Failure(response),
6265                        });
6266                    }
6267                    let response = {
6268                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6269                        let encoded = common::to_string(&bytes);
6270                        match serde_json::from_str(&encoded) {
6271                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6272                            Err(error) => {
6273                                dlg.response_json_decode_error(&encoded, &error);
6274                                return Err(common::Error::JsonDecodeError(
6275                                    encoded.to_string(),
6276                                    error,
6277                                ));
6278                            }
6279                        }
6280                    };
6281
6282                    dlg.finished(true);
6283                    return Ok(response);
6284                }
6285            }
6286        }
6287    }
6288
6289    /// Required. The name of the ad client to retrieve. Format: accounts/{account}/adclients/{adclient}
6290    ///
6291    /// Sets the *name* path property to the given value.
6292    ///
6293    /// Even though the property as already been set when instantiating this call,
6294    /// we provide this method for API completeness.
6295    pub fn name(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C> {
6296        self._name = new_value.to_string();
6297        self
6298    }
6299    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6300    /// while executing the actual API request.
6301    ///
6302    /// ````text
6303    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6304    /// ````
6305    ///
6306    /// Sets the *delegate* property to the given value.
6307    pub fn delegate(
6308        mut self,
6309        new_value: &'a mut dyn common::Delegate,
6310    ) -> AccountAdclientGetCall<'a, C> {
6311        self._delegate = Some(new_value);
6312        self
6313    }
6314
6315    /// Set any additional parameter of the query string used in the request.
6316    /// It should be used to set parameters which are not yet available through their own
6317    /// setters.
6318    ///
6319    /// Please note that this method must not be used to set any of the known parameters
6320    /// which have their own setter method. If done anyway, the request will fail.
6321    ///
6322    /// # Additional Parameters
6323    ///
6324    /// * *$.xgafv* (query-string) - V1 error format.
6325    /// * *access_token* (query-string) - OAuth access token.
6326    /// * *alt* (query-string) - Data format for response.
6327    /// * *callback* (query-string) - JSONP
6328    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6329    /// * *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.
6330    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6331    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6332    /// * *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.
6333    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6334    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6335    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetCall<'a, C>
6336    where
6337        T: AsRef<str>,
6338    {
6339        self._additional_params
6340            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6341        self
6342    }
6343
6344    /// Identifies the authorization scope for the method you are building.
6345    ///
6346    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6347    /// [`Scope::Readonly`].
6348    ///
6349    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6350    /// tokens for more than one scope.
6351    ///
6352    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6353    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6354    /// sufficient, a read-write scope will do as well.
6355    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetCall<'a, C>
6356    where
6357        St: AsRef<str>,
6358    {
6359        self._scopes.insert(String::from(scope.as_ref()));
6360        self
6361    }
6362    /// Identifies the authorization scope(s) for the method you are building.
6363    ///
6364    /// See [`Self::add_scope()`] for details.
6365    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetCall<'a, C>
6366    where
6367        I: IntoIterator<Item = St>,
6368        St: AsRef<str>,
6369    {
6370        self._scopes
6371            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6372        self
6373    }
6374
6375    /// Removes all scopes, and no default scope will be used either.
6376    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6377    /// for details).
6378    pub fn clear_scopes(mut self) -> AccountAdclientGetCall<'a, C> {
6379        self._scopes.clear();
6380        self
6381    }
6382}
6383
6384/// Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
6385///
6386/// A builder for the *adclients.getAdcode* method supported by a *account* resource.
6387/// It is not used directly, but through a [`AccountMethods`] instance.
6388///
6389/// # Example
6390///
6391/// Instantiate a resource method builder
6392///
6393/// ```test_harness,no_run
6394/// # extern crate hyper;
6395/// # extern crate hyper_rustls;
6396/// # extern crate google_adsense2 as adsense2;
6397/// # async fn dox() {
6398/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6399///
6400/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6402/// #     secret,
6403/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6404/// # ).build().await.unwrap();
6405///
6406/// # let client = hyper_util::client::legacy::Client::builder(
6407/// #     hyper_util::rt::TokioExecutor::new()
6408/// # )
6409/// # .build(
6410/// #     hyper_rustls::HttpsConnectorBuilder::new()
6411/// #         .with_native_roots()
6412/// #         .unwrap()
6413/// #         .https_or_http()
6414/// #         .enable_http1()
6415/// #         .build()
6416/// # );
6417/// # let mut hub = Adsense::new(client, auth);
6418/// // You can configure optional parameters by calling the respective setters at will, and
6419/// // execute the final call using `doit()`.
6420/// // Values shown here are possibly random and not representative !
6421/// let result = hub.accounts().adclients_get_adcode("name")
6422///              .doit().await;
6423/// # }
6424/// ```
6425pub struct AccountAdclientGetAdcodeCall<'a, C>
6426where
6427    C: 'a,
6428{
6429    hub: &'a Adsense<C>,
6430    _name: String,
6431    _delegate: Option<&'a mut dyn common::Delegate>,
6432    _additional_params: HashMap<String, String>,
6433    _scopes: BTreeSet<String>,
6434}
6435
6436impl<'a, C> common::CallBuilder for AccountAdclientGetAdcodeCall<'a, C> {}
6437
6438impl<'a, C> AccountAdclientGetAdcodeCall<'a, C>
6439where
6440    C: common::Connector,
6441{
6442    /// Perform the operation you have build so far.
6443    pub async fn doit(mut self) -> common::Result<(common::Response, AdClientAdCode)> {
6444        use std::borrow::Cow;
6445        use std::io::{Read, Seek};
6446
6447        use common::{url::Params, ToParts};
6448        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6449
6450        let mut dd = common::DefaultDelegate;
6451        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6452        dlg.begin(common::MethodInfo {
6453            id: "adsense.accounts.adclients.getAdcode",
6454            http_method: hyper::Method::GET,
6455        });
6456
6457        for &field in ["alt", "name"].iter() {
6458            if self._additional_params.contains_key(field) {
6459                dlg.finished(false);
6460                return Err(common::Error::FieldClash(field));
6461            }
6462        }
6463
6464        let mut params = Params::with_capacity(3 + self._additional_params.len());
6465        params.push("name", self._name);
6466
6467        params.extend(self._additional_params.iter());
6468
6469        params.push("alt", "json");
6470        let mut url = self.hub._base_url.clone() + "v2/{+name}/adcode";
6471        if self._scopes.is_empty() {
6472            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6473        }
6474
6475        #[allow(clippy::single_element_loop)]
6476        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6477            url = params.uri_replacement(url, param_name, find_this, true);
6478        }
6479        {
6480            let to_remove = ["name"];
6481            params.remove_params(&to_remove);
6482        }
6483
6484        let url = params.parse_with_url(&url);
6485
6486        loop {
6487            let token = match self
6488                .hub
6489                .auth
6490                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6491                .await
6492            {
6493                Ok(token) => token,
6494                Err(e) => match dlg.token(e) {
6495                    Ok(token) => token,
6496                    Err(e) => {
6497                        dlg.finished(false);
6498                        return Err(common::Error::MissingToken(e));
6499                    }
6500                },
6501            };
6502            let mut req_result = {
6503                let client = &self.hub.client;
6504                dlg.pre_request();
6505                let mut req_builder = hyper::Request::builder()
6506                    .method(hyper::Method::GET)
6507                    .uri(url.as_str())
6508                    .header(USER_AGENT, self.hub._user_agent.clone());
6509
6510                if let Some(token) = token.as_ref() {
6511                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6512                }
6513
6514                let request = req_builder
6515                    .header(CONTENT_LENGTH, 0_u64)
6516                    .body(common::to_body::<String>(None));
6517
6518                client.request(request.unwrap()).await
6519            };
6520
6521            match req_result {
6522                Err(err) => {
6523                    if let common::Retry::After(d) = dlg.http_error(&err) {
6524                        sleep(d).await;
6525                        continue;
6526                    }
6527                    dlg.finished(false);
6528                    return Err(common::Error::HttpError(err));
6529                }
6530                Ok(res) => {
6531                    let (mut parts, body) = res.into_parts();
6532                    let mut body = common::Body::new(body);
6533                    if !parts.status.is_success() {
6534                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6535                        let error = serde_json::from_str(&common::to_string(&bytes));
6536                        let response = common::to_response(parts, bytes.into());
6537
6538                        if let common::Retry::After(d) =
6539                            dlg.http_failure(&response, error.as_ref().ok())
6540                        {
6541                            sleep(d).await;
6542                            continue;
6543                        }
6544
6545                        dlg.finished(false);
6546
6547                        return Err(match error {
6548                            Ok(value) => common::Error::BadRequest(value),
6549                            _ => common::Error::Failure(response),
6550                        });
6551                    }
6552                    let response = {
6553                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6554                        let encoded = common::to_string(&bytes);
6555                        match serde_json::from_str(&encoded) {
6556                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6557                            Err(error) => {
6558                                dlg.response_json_decode_error(&encoded, &error);
6559                                return Err(common::Error::JsonDecodeError(
6560                                    encoded.to_string(),
6561                                    error,
6562                                ));
6563                            }
6564                        }
6565                    };
6566
6567                    dlg.finished(true);
6568                    return Ok(response);
6569                }
6570            }
6571        }
6572    }
6573
6574    /// Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
6575    ///
6576    /// Sets the *name* path property to the given value.
6577    ///
6578    /// Even though the property as already been set when instantiating this call,
6579    /// we provide this method for API completeness.
6580    pub fn name(mut self, new_value: &str) -> AccountAdclientGetAdcodeCall<'a, C> {
6581        self._name = new_value.to_string();
6582        self
6583    }
6584    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6585    /// while executing the actual API request.
6586    ///
6587    /// ````text
6588    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6589    /// ````
6590    ///
6591    /// Sets the *delegate* property to the given value.
6592    pub fn delegate(
6593        mut self,
6594        new_value: &'a mut dyn common::Delegate,
6595    ) -> AccountAdclientGetAdcodeCall<'a, C> {
6596        self._delegate = Some(new_value);
6597        self
6598    }
6599
6600    /// Set any additional parameter of the query string used in the request.
6601    /// It should be used to set parameters which are not yet available through their own
6602    /// setters.
6603    ///
6604    /// Please note that this method must not be used to set any of the known parameters
6605    /// which have their own setter method. If done anyway, the request will fail.
6606    ///
6607    /// # Additional Parameters
6608    ///
6609    /// * *$.xgafv* (query-string) - V1 error format.
6610    /// * *access_token* (query-string) - OAuth access token.
6611    /// * *alt* (query-string) - Data format for response.
6612    /// * *callback* (query-string) - JSONP
6613    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6614    /// * *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.
6615    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6616    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6617    /// * *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.
6618    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6619    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6620    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetAdcodeCall<'a, C>
6621    where
6622        T: AsRef<str>,
6623    {
6624        self._additional_params
6625            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6626        self
6627    }
6628
6629    /// Identifies the authorization scope for the method you are building.
6630    ///
6631    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6632    /// [`Scope::Readonly`].
6633    ///
6634    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6635    /// tokens for more than one scope.
6636    ///
6637    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6638    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6639    /// sufficient, a read-write scope will do as well.
6640    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetAdcodeCall<'a, C>
6641    where
6642        St: AsRef<str>,
6643    {
6644        self._scopes.insert(String::from(scope.as_ref()));
6645        self
6646    }
6647    /// Identifies the authorization scope(s) for the method you are building.
6648    ///
6649    /// See [`Self::add_scope()`] for details.
6650    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetAdcodeCall<'a, C>
6651    where
6652        I: IntoIterator<Item = St>,
6653        St: AsRef<str>,
6654    {
6655        self._scopes
6656            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6657        self
6658    }
6659
6660    /// Removes all scopes, and no default scope will be used either.
6661    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6662    /// for details).
6663    pub fn clear_scopes(mut self) -> AccountAdclientGetAdcodeCall<'a, C> {
6664        self._scopes.clear();
6665        self
6666    }
6667}
6668
6669/// Lists all the ad clients available in an account.
6670///
6671/// A builder for the *adclients.list* method supported by a *account* resource.
6672/// It is not used directly, but through a [`AccountMethods`] instance.
6673///
6674/// # Example
6675///
6676/// Instantiate a resource method builder
6677///
6678/// ```test_harness,no_run
6679/// # extern crate hyper;
6680/// # extern crate hyper_rustls;
6681/// # extern crate google_adsense2 as adsense2;
6682/// # async fn dox() {
6683/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6684///
6685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6686/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6687/// #     secret,
6688/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6689/// # ).build().await.unwrap();
6690///
6691/// # let client = hyper_util::client::legacy::Client::builder(
6692/// #     hyper_util::rt::TokioExecutor::new()
6693/// # )
6694/// # .build(
6695/// #     hyper_rustls::HttpsConnectorBuilder::new()
6696/// #         .with_native_roots()
6697/// #         .unwrap()
6698/// #         .https_or_http()
6699/// #         .enable_http1()
6700/// #         .build()
6701/// # );
6702/// # let mut hub = Adsense::new(client, auth);
6703/// // You can configure optional parameters by calling the respective setters at will, and
6704/// // execute the final call using `doit()`.
6705/// // Values shown here are possibly random and not representative !
6706/// let result = hub.accounts().adclients_list("parent")
6707///              .page_token("accusam")
6708///              .page_size(-59)
6709///              .doit().await;
6710/// # }
6711/// ```
6712pub struct AccountAdclientListCall<'a, C>
6713where
6714    C: 'a,
6715{
6716    hub: &'a Adsense<C>,
6717    _parent: String,
6718    _page_token: Option<String>,
6719    _page_size: Option<i32>,
6720    _delegate: Option<&'a mut dyn common::Delegate>,
6721    _additional_params: HashMap<String, String>,
6722    _scopes: BTreeSet<String>,
6723}
6724
6725impl<'a, C> common::CallBuilder for AccountAdclientListCall<'a, C> {}
6726
6727impl<'a, C> AccountAdclientListCall<'a, C>
6728where
6729    C: common::Connector,
6730{
6731    /// Perform the operation you have build so far.
6732    pub async fn doit(mut self) -> common::Result<(common::Response, ListAdClientsResponse)> {
6733        use std::borrow::Cow;
6734        use std::io::{Read, Seek};
6735
6736        use common::{url::Params, ToParts};
6737        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6738
6739        let mut dd = common::DefaultDelegate;
6740        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6741        dlg.begin(common::MethodInfo {
6742            id: "adsense.accounts.adclients.list",
6743            http_method: hyper::Method::GET,
6744        });
6745
6746        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6747            if self._additional_params.contains_key(field) {
6748                dlg.finished(false);
6749                return Err(common::Error::FieldClash(field));
6750            }
6751        }
6752
6753        let mut params = Params::with_capacity(5 + self._additional_params.len());
6754        params.push("parent", self._parent);
6755        if let Some(value) = self._page_token.as_ref() {
6756            params.push("pageToken", value);
6757        }
6758        if let Some(value) = self._page_size.as_ref() {
6759            params.push("pageSize", value.to_string());
6760        }
6761
6762        params.extend(self._additional_params.iter());
6763
6764        params.push("alt", "json");
6765        let mut url = self.hub._base_url.clone() + "v2/{+parent}/adclients";
6766        if self._scopes.is_empty() {
6767            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6768        }
6769
6770        #[allow(clippy::single_element_loop)]
6771        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6772            url = params.uri_replacement(url, param_name, find_this, true);
6773        }
6774        {
6775            let to_remove = ["parent"];
6776            params.remove_params(&to_remove);
6777        }
6778
6779        let url = params.parse_with_url(&url);
6780
6781        loop {
6782            let token = match self
6783                .hub
6784                .auth
6785                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6786                .await
6787            {
6788                Ok(token) => token,
6789                Err(e) => match dlg.token(e) {
6790                    Ok(token) => token,
6791                    Err(e) => {
6792                        dlg.finished(false);
6793                        return Err(common::Error::MissingToken(e));
6794                    }
6795                },
6796            };
6797            let mut req_result = {
6798                let client = &self.hub.client;
6799                dlg.pre_request();
6800                let mut req_builder = hyper::Request::builder()
6801                    .method(hyper::Method::GET)
6802                    .uri(url.as_str())
6803                    .header(USER_AGENT, self.hub._user_agent.clone());
6804
6805                if let Some(token) = token.as_ref() {
6806                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6807                }
6808
6809                let request = req_builder
6810                    .header(CONTENT_LENGTH, 0_u64)
6811                    .body(common::to_body::<String>(None));
6812
6813                client.request(request.unwrap()).await
6814            };
6815
6816            match req_result {
6817                Err(err) => {
6818                    if let common::Retry::After(d) = dlg.http_error(&err) {
6819                        sleep(d).await;
6820                        continue;
6821                    }
6822                    dlg.finished(false);
6823                    return Err(common::Error::HttpError(err));
6824                }
6825                Ok(res) => {
6826                    let (mut parts, body) = res.into_parts();
6827                    let mut body = common::Body::new(body);
6828                    if !parts.status.is_success() {
6829                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6830                        let error = serde_json::from_str(&common::to_string(&bytes));
6831                        let response = common::to_response(parts, bytes.into());
6832
6833                        if let common::Retry::After(d) =
6834                            dlg.http_failure(&response, error.as_ref().ok())
6835                        {
6836                            sleep(d).await;
6837                            continue;
6838                        }
6839
6840                        dlg.finished(false);
6841
6842                        return Err(match error {
6843                            Ok(value) => common::Error::BadRequest(value),
6844                            _ => common::Error::Failure(response),
6845                        });
6846                    }
6847                    let response = {
6848                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6849                        let encoded = common::to_string(&bytes);
6850                        match serde_json::from_str(&encoded) {
6851                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6852                            Err(error) => {
6853                                dlg.response_json_decode_error(&encoded, &error);
6854                                return Err(common::Error::JsonDecodeError(
6855                                    encoded.to_string(),
6856                                    error,
6857                                ));
6858                            }
6859                        }
6860                    };
6861
6862                    dlg.finished(true);
6863                    return Ok(response);
6864                }
6865            }
6866        }
6867    }
6868
6869    /// Required. The account which owns the collection of ad clients. Format: accounts/{account}
6870    ///
6871    /// Sets the *parent* path property to the given value.
6872    ///
6873    /// Even though the property as already been set when instantiating this call,
6874    /// we provide this method for API completeness.
6875    pub fn parent(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
6876        self._parent = new_value.to_string();
6877        self
6878    }
6879    /// A page token, received from a previous `ListAdClients` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdClients` must match the call that provided the page token.
6880    ///
6881    /// Sets the *page token* query property to the given value.
6882    pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
6883        self._page_token = Some(new_value.to_string());
6884        self
6885    }
6886    /// The maximum number of ad clients to include in the response, used for paging. If unspecified, at most 10000 ad clients will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
6887    ///
6888    /// Sets the *page size* query property to the given value.
6889    pub fn page_size(mut self, new_value: i32) -> AccountAdclientListCall<'a, C> {
6890        self._page_size = Some(new_value);
6891        self
6892    }
6893    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6894    /// while executing the actual API request.
6895    ///
6896    /// ````text
6897    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6898    /// ````
6899    ///
6900    /// Sets the *delegate* property to the given value.
6901    pub fn delegate(
6902        mut self,
6903        new_value: &'a mut dyn common::Delegate,
6904    ) -> AccountAdclientListCall<'a, C> {
6905        self._delegate = Some(new_value);
6906        self
6907    }
6908
6909    /// Set any additional parameter of the query string used in the request.
6910    /// It should be used to set parameters which are not yet available through their own
6911    /// setters.
6912    ///
6913    /// Please note that this method must not be used to set any of the known parameters
6914    /// which have their own setter method. If done anyway, the request will fail.
6915    ///
6916    /// # Additional Parameters
6917    ///
6918    /// * *$.xgafv* (query-string) - V1 error format.
6919    /// * *access_token* (query-string) - OAuth access token.
6920    /// * *alt* (query-string) - Data format for response.
6921    /// * *callback* (query-string) - JSONP
6922    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6923    /// * *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.
6924    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6925    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6926    /// * *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.
6927    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6928    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6929    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientListCall<'a, C>
6930    where
6931        T: AsRef<str>,
6932    {
6933        self._additional_params
6934            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6935        self
6936    }
6937
6938    /// Identifies the authorization scope for the method you are building.
6939    ///
6940    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6941    /// [`Scope::Readonly`].
6942    ///
6943    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6944    /// tokens for more than one scope.
6945    ///
6946    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6947    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6948    /// sufficient, a read-write scope will do as well.
6949    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientListCall<'a, C>
6950    where
6951        St: AsRef<str>,
6952    {
6953        self._scopes.insert(String::from(scope.as_ref()));
6954        self
6955    }
6956    /// Identifies the authorization scope(s) for the method you are building.
6957    ///
6958    /// See [`Self::add_scope()`] for details.
6959    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientListCall<'a, C>
6960    where
6961        I: IntoIterator<Item = St>,
6962        St: AsRef<str>,
6963    {
6964        self._scopes
6965            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6966        self
6967    }
6968
6969    /// Removes all scopes, and no default scope will be used either.
6970    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6971    /// for details).
6972    pub fn clear_scopes(mut self) -> AccountAdclientListCall<'a, C> {
6973        self._scopes.clear();
6974        self
6975    }
6976}
6977
6978/// Lists all the alerts available in an account.
6979///
6980/// A builder for the *alerts.list* method supported by a *account* resource.
6981/// It is not used directly, but through a [`AccountMethods`] instance.
6982///
6983/// # Example
6984///
6985/// Instantiate a resource method builder
6986///
6987/// ```test_harness,no_run
6988/// # extern crate hyper;
6989/// # extern crate hyper_rustls;
6990/// # extern crate google_adsense2 as adsense2;
6991/// # async fn dox() {
6992/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6993///
6994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6996/// #     secret,
6997/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6998/// # ).build().await.unwrap();
6999///
7000/// # let client = hyper_util::client::legacy::Client::builder(
7001/// #     hyper_util::rt::TokioExecutor::new()
7002/// # )
7003/// # .build(
7004/// #     hyper_rustls::HttpsConnectorBuilder::new()
7005/// #         .with_native_roots()
7006/// #         .unwrap()
7007/// #         .https_or_http()
7008/// #         .enable_http1()
7009/// #         .build()
7010/// # );
7011/// # let mut hub = Adsense::new(client, auth);
7012/// // You can configure optional parameters by calling the respective setters at will, and
7013/// // execute the final call using `doit()`.
7014/// // Values shown here are possibly random and not representative !
7015/// let result = hub.accounts().alerts_list("parent")
7016///              .language_code("voluptua.")
7017///              .doit().await;
7018/// # }
7019/// ```
7020pub struct AccountAlertListCall<'a, C>
7021where
7022    C: 'a,
7023{
7024    hub: &'a Adsense<C>,
7025    _parent: String,
7026    _language_code: Option<String>,
7027    _delegate: Option<&'a mut dyn common::Delegate>,
7028    _additional_params: HashMap<String, String>,
7029    _scopes: BTreeSet<String>,
7030}
7031
7032impl<'a, C> common::CallBuilder for AccountAlertListCall<'a, C> {}
7033
7034impl<'a, C> AccountAlertListCall<'a, C>
7035where
7036    C: common::Connector,
7037{
7038    /// Perform the operation you have build so far.
7039    pub async fn doit(mut self) -> common::Result<(common::Response, ListAlertsResponse)> {
7040        use std::borrow::Cow;
7041        use std::io::{Read, Seek};
7042
7043        use common::{url::Params, ToParts};
7044        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7045
7046        let mut dd = common::DefaultDelegate;
7047        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7048        dlg.begin(common::MethodInfo {
7049            id: "adsense.accounts.alerts.list",
7050            http_method: hyper::Method::GET,
7051        });
7052
7053        for &field in ["alt", "parent", "languageCode"].iter() {
7054            if self._additional_params.contains_key(field) {
7055                dlg.finished(false);
7056                return Err(common::Error::FieldClash(field));
7057            }
7058        }
7059
7060        let mut params = Params::with_capacity(4 + self._additional_params.len());
7061        params.push("parent", self._parent);
7062        if let Some(value) = self._language_code.as_ref() {
7063            params.push("languageCode", value);
7064        }
7065
7066        params.extend(self._additional_params.iter());
7067
7068        params.push("alt", "json");
7069        let mut url = self.hub._base_url.clone() + "v2/{+parent}/alerts";
7070        if self._scopes.is_empty() {
7071            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7072        }
7073
7074        #[allow(clippy::single_element_loop)]
7075        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7076            url = params.uri_replacement(url, param_name, find_this, true);
7077        }
7078        {
7079            let to_remove = ["parent"];
7080            params.remove_params(&to_remove);
7081        }
7082
7083        let url = params.parse_with_url(&url);
7084
7085        loop {
7086            let token = match self
7087                .hub
7088                .auth
7089                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7090                .await
7091            {
7092                Ok(token) => token,
7093                Err(e) => match dlg.token(e) {
7094                    Ok(token) => token,
7095                    Err(e) => {
7096                        dlg.finished(false);
7097                        return Err(common::Error::MissingToken(e));
7098                    }
7099                },
7100            };
7101            let mut req_result = {
7102                let client = &self.hub.client;
7103                dlg.pre_request();
7104                let mut req_builder = hyper::Request::builder()
7105                    .method(hyper::Method::GET)
7106                    .uri(url.as_str())
7107                    .header(USER_AGENT, self.hub._user_agent.clone());
7108
7109                if let Some(token) = token.as_ref() {
7110                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7111                }
7112
7113                let request = req_builder
7114                    .header(CONTENT_LENGTH, 0_u64)
7115                    .body(common::to_body::<String>(None));
7116
7117                client.request(request.unwrap()).await
7118            };
7119
7120            match req_result {
7121                Err(err) => {
7122                    if let common::Retry::After(d) = dlg.http_error(&err) {
7123                        sleep(d).await;
7124                        continue;
7125                    }
7126                    dlg.finished(false);
7127                    return Err(common::Error::HttpError(err));
7128                }
7129                Ok(res) => {
7130                    let (mut parts, body) = res.into_parts();
7131                    let mut body = common::Body::new(body);
7132                    if !parts.status.is_success() {
7133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7134                        let error = serde_json::from_str(&common::to_string(&bytes));
7135                        let response = common::to_response(parts, bytes.into());
7136
7137                        if let common::Retry::After(d) =
7138                            dlg.http_failure(&response, error.as_ref().ok())
7139                        {
7140                            sleep(d).await;
7141                            continue;
7142                        }
7143
7144                        dlg.finished(false);
7145
7146                        return Err(match error {
7147                            Ok(value) => common::Error::BadRequest(value),
7148                            _ => common::Error::Failure(response),
7149                        });
7150                    }
7151                    let response = {
7152                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7153                        let encoded = common::to_string(&bytes);
7154                        match serde_json::from_str(&encoded) {
7155                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7156                            Err(error) => {
7157                                dlg.response_json_decode_error(&encoded, &error);
7158                                return Err(common::Error::JsonDecodeError(
7159                                    encoded.to_string(),
7160                                    error,
7161                                ));
7162                            }
7163                        }
7164                    };
7165
7166                    dlg.finished(true);
7167                    return Ok(response);
7168                }
7169            }
7170        }
7171    }
7172
7173    /// Required. The account which owns the collection of alerts. Format: accounts/{account}
7174    ///
7175    /// Sets the *parent* path property to the given value.
7176    ///
7177    /// Even though the property as already been set when instantiating this call,
7178    /// we provide this method for API completeness.
7179    pub fn parent(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
7180        self._parent = new_value.to_string();
7181        self
7182    }
7183    /// The language to use for translating alert messages. If unspecified, this defaults to the user's display language. If the given language is not supported, alerts will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
7184    ///
7185    /// Sets the *language code* query property to the given value.
7186    pub fn language_code(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
7187        self._language_code = Some(new_value.to_string());
7188        self
7189    }
7190    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7191    /// while executing the actual API request.
7192    ///
7193    /// ````text
7194    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7195    /// ````
7196    ///
7197    /// Sets the *delegate* property to the given value.
7198    pub fn delegate(
7199        mut self,
7200        new_value: &'a mut dyn common::Delegate,
7201    ) -> AccountAlertListCall<'a, C> {
7202        self._delegate = Some(new_value);
7203        self
7204    }
7205
7206    /// Set any additional parameter of the query string used in the request.
7207    /// It should be used to set parameters which are not yet available through their own
7208    /// setters.
7209    ///
7210    /// Please note that this method must not be used to set any of the known parameters
7211    /// which have their own setter method. If done anyway, the request will fail.
7212    ///
7213    /// # Additional Parameters
7214    ///
7215    /// * *$.xgafv* (query-string) - V1 error format.
7216    /// * *access_token* (query-string) - OAuth access token.
7217    /// * *alt* (query-string) - Data format for response.
7218    /// * *callback* (query-string) - JSONP
7219    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7220    /// * *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.
7221    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7222    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7223    /// * *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.
7224    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7225    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7226    pub fn param<T>(mut self, name: T, value: T) -> AccountAlertListCall<'a, C>
7227    where
7228        T: AsRef<str>,
7229    {
7230        self._additional_params
7231            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7232        self
7233    }
7234
7235    /// Identifies the authorization scope for the method you are building.
7236    ///
7237    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7238    /// [`Scope::Readonly`].
7239    ///
7240    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7241    /// tokens for more than one scope.
7242    ///
7243    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7244    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7245    /// sufficient, a read-write scope will do as well.
7246    pub fn add_scope<St>(mut self, scope: St) -> AccountAlertListCall<'a, C>
7247    where
7248        St: AsRef<str>,
7249    {
7250        self._scopes.insert(String::from(scope.as_ref()));
7251        self
7252    }
7253    /// Identifies the authorization scope(s) for the method you are building.
7254    ///
7255    /// See [`Self::add_scope()`] for details.
7256    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAlertListCall<'a, C>
7257    where
7258        I: IntoIterator<Item = St>,
7259        St: AsRef<str>,
7260    {
7261        self._scopes
7262            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7263        self
7264    }
7265
7266    /// Removes all scopes, and no default scope will be used either.
7267    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7268    /// for details).
7269    pub fn clear_scopes(mut self) -> AccountAlertListCall<'a, C> {
7270        self._scopes.clear();
7271        self
7272    }
7273}
7274
7275/// Lists all the payments available for an account.
7276///
7277/// A builder for the *payments.list* method supported by a *account* resource.
7278/// It is not used directly, but through a [`AccountMethods`] instance.
7279///
7280/// # Example
7281///
7282/// Instantiate a resource method builder
7283///
7284/// ```test_harness,no_run
7285/// # extern crate hyper;
7286/// # extern crate hyper_rustls;
7287/// # extern crate google_adsense2 as adsense2;
7288/// # async fn dox() {
7289/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7290///
7291/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7292/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7293/// #     secret,
7294/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7295/// # ).build().await.unwrap();
7296///
7297/// # let client = hyper_util::client::legacy::Client::builder(
7298/// #     hyper_util::rt::TokioExecutor::new()
7299/// # )
7300/// # .build(
7301/// #     hyper_rustls::HttpsConnectorBuilder::new()
7302/// #         .with_native_roots()
7303/// #         .unwrap()
7304/// #         .https_or_http()
7305/// #         .enable_http1()
7306/// #         .build()
7307/// # );
7308/// # let mut hub = Adsense::new(client, auth);
7309/// // You can configure optional parameters by calling the respective setters at will, and
7310/// // execute the final call using `doit()`.
7311/// // Values shown here are possibly random and not representative !
7312/// let result = hub.accounts().payments_list("parent")
7313///              .doit().await;
7314/// # }
7315/// ```
7316pub struct AccountPaymentListCall<'a, C>
7317where
7318    C: 'a,
7319{
7320    hub: &'a Adsense<C>,
7321    _parent: String,
7322    _delegate: Option<&'a mut dyn common::Delegate>,
7323    _additional_params: HashMap<String, String>,
7324    _scopes: BTreeSet<String>,
7325}
7326
7327impl<'a, C> common::CallBuilder for AccountPaymentListCall<'a, C> {}
7328
7329impl<'a, C> AccountPaymentListCall<'a, C>
7330where
7331    C: common::Connector,
7332{
7333    /// Perform the operation you have build so far.
7334    pub async fn doit(mut self) -> common::Result<(common::Response, ListPaymentsResponse)> {
7335        use std::borrow::Cow;
7336        use std::io::{Read, Seek};
7337
7338        use common::{url::Params, ToParts};
7339        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7340
7341        let mut dd = common::DefaultDelegate;
7342        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7343        dlg.begin(common::MethodInfo {
7344            id: "adsense.accounts.payments.list",
7345            http_method: hyper::Method::GET,
7346        });
7347
7348        for &field in ["alt", "parent"].iter() {
7349            if self._additional_params.contains_key(field) {
7350                dlg.finished(false);
7351                return Err(common::Error::FieldClash(field));
7352            }
7353        }
7354
7355        let mut params = Params::with_capacity(3 + self._additional_params.len());
7356        params.push("parent", self._parent);
7357
7358        params.extend(self._additional_params.iter());
7359
7360        params.push("alt", "json");
7361        let mut url = self.hub._base_url.clone() + "v2/{+parent}/payments";
7362        if self._scopes.is_empty() {
7363            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7364        }
7365
7366        #[allow(clippy::single_element_loop)]
7367        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7368            url = params.uri_replacement(url, param_name, find_this, true);
7369        }
7370        {
7371            let to_remove = ["parent"];
7372            params.remove_params(&to_remove);
7373        }
7374
7375        let url = params.parse_with_url(&url);
7376
7377        loop {
7378            let token = match self
7379                .hub
7380                .auth
7381                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7382                .await
7383            {
7384                Ok(token) => token,
7385                Err(e) => match dlg.token(e) {
7386                    Ok(token) => token,
7387                    Err(e) => {
7388                        dlg.finished(false);
7389                        return Err(common::Error::MissingToken(e));
7390                    }
7391                },
7392            };
7393            let mut req_result = {
7394                let client = &self.hub.client;
7395                dlg.pre_request();
7396                let mut req_builder = hyper::Request::builder()
7397                    .method(hyper::Method::GET)
7398                    .uri(url.as_str())
7399                    .header(USER_AGENT, self.hub._user_agent.clone());
7400
7401                if let Some(token) = token.as_ref() {
7402                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7403                }
7404
7405                let request = req_builder
7406                    .header(CONTENT_LENGTH, 0_u64)
7407                    .body(common::to_body::<String>(None));
7408
7409                client.request(request.unwrap()).await
7410            };
7411
7412            match req_result {
7413                Err(err) => {
7414                    if let common::Retry::After(d) = dlg.http_error(&err) {
7415                        sleep(d).await;
7416                        continue;
7417                    }
7418                    dlg.finished(false);
7419                    return Err(common::Error::HttpError(err));
7420                }
7421                Ok(res) => {
7422                    let (mut parts, body) = res.into_parts();
7423                    let mut body = common::Body::new(body);
7424                    if !parts.status.is_success() {
7425                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7426                        let error = serde_json::from_str(&common::to_string(&bytes));
7427                        let response = common::to_response(parts, bytes.into());
7428
7429                        if let common::Retry::After(d) =
7430                            dlg.http_failure(&response, error.as_ref().ok())
7431                        {
7432                            sleep(d).await;
7433                            continue;
7434                        }
7435
7436                        dlg.finished(false);
7437
7438                        return Err(match error {
7439                            Ok(value) => common::Error::BadRequest(value),
7440                            _ => common::Error::Failure(response),
7441                        });
7442                    }
7443                    let response = {
7444                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7445                        let encoded = common::to_string(&bytes);
7446                        match serde_json::from_str(&encoded) {
7447                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7448                            Err(error) => {
7449                                dlg.response_json_decode_error(&encoded, &error);
7450                                return Err(common::Error::JsonDecodeError(
7451                                    encoded.to_string(),
7452                                    error,
7453                                ));
7454                            }
7455                        }
7456                    };
7457
7458                    dlg.finished(true);
7459                    return Ok(response);
7460                }
7461            }
7462        }
7463    }
7464
7465    /// Required. The account which owns the collection of payments. Format: accounts/{account}
7466    ///
7467    /// Sets the *parent* path property to the given value.
7468    ///
7469    /// Even though the property as already been set when instantiating this call,
7470    /// we provide this method for API completeness.
7471    pub fn parent(mut self, new_value: &str) -> AccountPaymentListCall<'a, C> {
7472        self._parent = new_value.to_string();
7473        self
7474    }
7475    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7476    /// while executing the actual API request.
7477    ///
7478    /// ````text
7479    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7480    /// ````
7481    ///
7482    /// Sets the *delegate* property to the given value.
7483    pub fn delegate(
7484        mut self,
7485        new_value: &'a mut dyn common::Delegate,
7486    ) -> AccountPaymentListCall<'a, C> {
7487        self._delegate = Some(new_value);
7488        self
7489    }
7490
7491    /// Set any additional parameter of the query string used in the request.
7492    /// It should be used to set parameters which are not yet available through their own
7493    /// setters.
7494    ///
7495    /// Please note that this method must not be used to set any of the known parameters
7496    /// which have their own setter method. If done anyway, the request will fail.
7497    ///
7498    /// # Additional Parameters
7499    ///
7500    /// * *$.xgafv* (query-string) - V1 error format.
7501    /// * *access_token* (query-string) - OAuth access token.
7502    /// * *alt* (query-string) - Data format for response.
7503    /// * *callback* (query-string) - JSONP
7504    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7505    /// * *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.
7506    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7507    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7508    /// * *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.
7509    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7510    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7511    pub fn param<T>(mut self, name: T, value: T) -> AccountPaymentListCall<'a, C>
7512    where
7513        T: AsRef<str>,
7514    {
7515        self._additional_params
7516            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7517        self
7518    }
7519
7520    /// Identifies the authorization scope for the method you are building.
7521    ///
7522    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7523    /// [`Scope::Readonly`].
7524    ///
7525    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7526    /// tokens for more than one scope.
7527    ///
7528    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7529    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7530    /// sufficient, a read-write scope will do as well.
7531    pub fn add_scope<St>(mut self, scope: St) -> AccountPaymentListCall<'a, C>
7532    where
7533        St: AsRef<str>,
7534    {
7535        self._scopes.insert(String::from(scope.as_ref()));
7536        self
7537    }
7538    /// Identifies the authorization scope(s) for the method you are building.
7539    ///
7540    /// See [`Self::add_scope()`] for details.
7541    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPaymentListCall<'a, C>
7542    where
7543        I: IntoIterator<Item = St>,
7544        St: AsRef<str>,
7545    {
7546        self._scopes
7547            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7548        self
7549    }
7550
7551    /// Removes all scopes, and no default scope will be used either.
7552    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7553    /// for details).
7554    pub fn clear_scopes(mut self) -> AccountPaymentListCall<'a, C> {
7555        self._scopes.clear();
7556        self
7557    }
7558}
7559
7560/// Gets information about the selected policy issue.
7561///
7562/// A builder for the *policyIssues.get* method supported by a *account* resource.
7563/// It is not used directly, but through a [`AccountMethods`] instance.
7564///
7565/// # Example
7566///
7567/// Instantiate a resource method builder
7568///
7569/// ```test_harness,no_run
7570/// # extern crate hyper;
7571/// # extern crate hyper_rustls;
7572/// # extern crate google_adsense2 as adsense2;
7573/// # async fn dox() {
7574/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7575///
7576/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7577/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7578/// #     secret,
7579/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7580/// # ).build().await.unwrap();
7581///
7582/// # let client = hyper_util::client::legacy::Client::builder(
7583/// #     hyper_util::rt::TokioExecutor::new()
7584/// # )
7585/// # .build(
7586/// #     hyper_rustls::HttpsConnectorBuilder::new()
7587/// #         .with_native_roots()
7588/// #         .unwrap()
7589/// #         .https_or_http()
7590/// #         .enable_http1()
7591/// #         .build()
7592/// # );
7593/// # let mut hub = Adsense::new(client, auth);
7594/// // You can configure optional parameters by calling the respective setters at will, and
7595/// // execute the final call using `doit()`.
7596/// // Values shown here are possibly random and not representative !
7597/// let result = hub.accounts().policy_issues_get("name")
7598///              .doit().await;
7599/// # }
7600/// ```
7601pub struct AccountPolicyIssueGetCall<'a, C>
7602where
7603    C: 'a,
7604{
7605    hub: &'a Adsense<C>,
7606    _name: String,
7607    _delegate: Option<&'a mut dyn common::Delegate>,
7608    _additional_params: HashMap<String, String>,
7609    _scopes: BTreeSet<String>,
7610}
7611
7612impl<'a, C> common::CallBuilder for AccountPolicyIssueGetCall<'a, C> {}
7613
7614impl<'a, C> AccountPolicyIssueGetCall<'a, C>
7615where
7616    C: common::Connector,
7617{
7618    /// Perform the operation you have build so far.
7619    pub async fn doit(mut self) -> common::Result<(common::Response, PolicyIssue)> {
7620        use std::borrow::Cow;
7621        use std::io::{Read, Seek};
7622
7623        use common::{url::Params, ToParts};
7624        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7625
7626        let mut dd = common::DefaultDelegate;
7627        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7628        dlg.begin(common::MethodInfo {
7629            id: "adsense.accounts.policyIssues.get",
7630            http_method: hyper::Method::GET,
7631        });
7632
7633        for &field in ["alt", "name"].iter() {
7634            if self._additional_params.contains_key(field) {
7635                dlg.finished(false);
7636                return Err(common::Error::FieldClash(field));
7637            }
7638        }
7639
7640        let mut params = Params::with_capacity(3 + self._additional_params.len());
7641        params.push("name", self._name);
7642
7643        params.extend(self._additional_params.iter());
7644
7645        params.push("alt", "json");
7646        let mut url = self.hub._base_url.clone() + "v2/{+name}";
7647        if self._scopes.is_empty() {
7648            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7649        }
7650
7651        #[allow(clippy::single_element_loop)]
7652        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7653            url = params.uri_replacement(url, param_name, find_this, true);
7654        }
7655        {
7656            let to_remove = ["name"];
7657            params.remove_params(&to_remove);
7658        }
7659
7660        let url = params.parse_with_url(&url);
7661
7662        loop {
7663            let token = match self
7664                .hub
7665                .auth
7666                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7667                .await
7668            {
7669                Ok(token) => token,
7670                Err(e) => match dlg.token(e) {
7671                    Ok(token) => token,
7672                    Err(e) => {
7673                        dlg.finished(false);
7674                        return Err(common::Error::MissingToken(e));
7675                    }
7676                },
7677            };
7678            let mut req_result = {
7679                let client = &self.hub.client;
7680                dlg.pre_request();
7681                let mut req_builder = hyper::Request::builder()
7682                    .method(hyper::Method::GET)
7683                    .uri(url.as_str())
7684                    .header(USER_AGENT, self.hub._user_agent.clone());
7685
7686                if let Some(token) = token.as_ref() {
7687                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7688                }
7689
7690                let request = req_builder
7691                    .header(CONTENT_LENGTH, 0_u64)
7692                    .body(common::to_body::<String>(None));
7693
7694                client.request(request.unwrap()).await
7695            };
7696
7697            match req_result {
7698                Err(err) => {
7699                    if let common::Retry::After(d) = dlg.http_error(&err) {
7700                        sleep(d).await;
7701                        continue;
7702                    }
7703                    dlg.finished(false);
7704                    return Err(common::Error::HttpError(err));
7705                }
7706                Ok(res) => {
7707                    let (mut parts, body) = res.into_parts();
7708                    let mut body = common::Body::new(body);
7709                    if !parts.status.is_success() {
7710                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7711                        let error = serde_json::from_str(&common::to_string(&bytes));
7712                        let response = common::to_response(parts, bytes.into());
7713
7714                        if let common::Retry::After(d) =
7715                            dlg.http_failure(&response, error.as_ref().ok())
7716                        {
7717                            sleep(d).await;
7718                            continue;
7719                        }
7720
7721                        dlg.finished(false);
7722
7723                        return Err(match error {
7724                            Ok(value) => common::Error::BadRequest(value),
7725                            _ => common::Error::Failure(response),
7726                        });
7727                    }
7728                    let response = {
7729                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7730                        let encoded = common::to_string(&bytes);
7731                        match serde_json::from_str(&encoded) {
7732                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7733                            Err(error) => {
7734                                dlg.response_json_decode_error(&encoded, &error);
7735                                return Err(common::Error::JsonDecodeError(
7736                                    encoded.to_string(),
7737                                    error,
7738                                ));
7739                            }
7740                        }
7741                    };
7742
7743                    dlg.finished(true);
7744                    return Ok(response);
7745                }
7746            }
7747        }
7748    }
7749
7750    /// Required. Name of the policy issue. Format: accounts/{account}/policyIssues/{policy_issue}
7751    ///
7752    /// Sets the *name* path property to the given value.
7753    ///
7754    /// Even though the property as already been set when instantiating this call,
7755    /// we provide this method for API completeness.
7756    pub fn name(mut self, new_value: &str) -> AccountPolicyIssueGetCall<'a, C> {
7757        self._name = new_value.to_string();
7758        self
7759    }
7760    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7761    /// while executing the actual API request.
7762    ///
7763    /// ````text
7764    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7765    /// ````
7766    ///
7767    /// Sets the *delegate* property to the given value.
7768    pub fn delegate(
7769        mut self,
7770        new_value: &'a mut dyn common::Delegate,
7771    ) -> AccountPolicyIssueGetCall<'a, C> {
7772        self._delegate = Some(new_value);
7773        self
7774    }
7775
7776    /// Set any additional parameter of the query string used in the request.
7777    /// It should be used to set parameters which are not yet available through their own
7778    /// setters.
7779    ///
7780    /// Please note that this method must not be used to set any of the known parameters
7781    /// which have their own setter method. If done anyway, the request will fail.
7782    ///
7783    /// # Additional Parameters
7784    ///
7785    /// * *$.xgafv* (query-string) - V1 error format.
7786    /// * *access_token* (query-string) - OAuth access token.
7787    /// * *alt* (query-string) - Data format for response.
7788    /// * *callback* (query-string) - JSONP
7789    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7790    /// * *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.
7791    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7792    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7793    /// * *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.
7794    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7795    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7796    pub fn param<T>(mut self, name: T, value: T) -> AccountPolicyIssueGetCall<'a, C>
7797    where
7798        T: AsRef<str>,
7799    {
7800        self._additional_params
7801            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7802        self
7803    }
7804
7805    /// Identifies the authorization scope for the method you are building.
7806    ///
7807    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7808    /// [`Scope::Readonly`].
7809    ///
7810    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7811    /// tokens for more than one scope.
7812    ///
7813    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7814    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7815    /// sufficient, a read-write scope will do as well.
7816    pub fn add_scope<St>(mut self, scope: St) -> AccountPolicyIssueGetCall<'a, C>
7817    where
7818        St: AsRef<str>,
7819    {
7820        self._scopes.insert(String::from(scope.as_ref()));
7821        self
7822    }
7823    /// Identifies the authorization scope(s) for the method you are building.
7824    ///
7825    /// See [`Self::add_scope()`] for details.
7826    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPolicyIssueGetCall<'a, C>
7827    where
7828        I: IntoIterator<Item = St>,
7829        St: AsRef<str>,
7830    {
7831        self._scopes
7832            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7833        self
7834    }
7835
7836    /// Removes all scopes, and no default scope will be used either.
7837    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7838    /// for details).
7839    pub fn clear_scopes(mut self) -> AccountPolicyIssueGetCall<'a, C> {
7840        self._scopes.clear();
7841        self
7842    }
7843}
7844
7845/// Lists all the policy issues where the specified account is involved, both directly and through any AFP child accounts.
7846///
7847/// A builder for the *policyIssues.list* method supported by a *account* resource.
7848/// It is not used directly, but through a [`AccountMethods`] instance.
7849///
7850/// # Example
7851///
7852/// Instantiate a resource method builder
7853///
7854/// ```test_harness,no_run
7855/// # extern crate hyper;
7856/// # extern crate hyper_rustls;
7857/// # extern crate google_adsense2 as adsense2;
7858/// # async fn dox() {
7859/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7860///
7861/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7862/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7863/// #     secret,
7864/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7865/// # ).build().await.unwrap();
7866///
7867/// # let client = hyper_util::client::legacy::Client::builder(
7868/// #     hyper_util::rt::TokioExecutor::new()
7869/// # )
7870/// # .build(
7871/// #     hyper_rustls::HttpsConnectorBuilder::new()
7872/// #         .with_native_roots()
7873/// #         .unwrap()
7874/// #         .https_or_http()
7875/// #         .enable_http1()
7876/// #         .build()
7877/// # );
7878/// # let mut hub = Adsense::new(client, auth);
7879/// // You can configure optional parameters by calling the respective setters at will, and
7880/// // execute the final call using `doit()`.
7881/// // Values shown here are possibly random and not representative !
7882/// let result = hub.accounts().policy_issues_list("parent")
7883///              .page_token("amet.")
7884///              .page_size(-30)
7885///              .doit().await;
7886/// # }
7887/// ```
7888pub struct AccountPolicyIssueListCall<'a, C>
7889where
7890    C: 'a,
7891{
7892    hub: &'a Adsense<C>,
7893    _parent: String,
7894    _page_token: Option<String>,
7895    _page_size: Option<i32>,
7896    _delegate: Option<&'a mut dyn common::Delegate>,
7897    _additional_params: HashMap<String, String>,
7898    _scopes: BTreeSet<String>,
7899}
7900
7901impl<'a, C> common::CallBuilder for AccountPolicyIssueListCall<'a, C> {}
7902
7903impl<'a, C> AccountPolicyIssueListCall<'a, C>
7904where
7905    C: common::Connector,
7906{
7907    /// Perform the operation you have build so far.
7908    pub async fn doit(mut self) -> common::Result<(common::Response, ListPolicyIssuesResponse)> {
7909        use std::borrow::Cow;
7910        use std::io::{Read, Seek};
7911
7912        use common::{url::Params, ToParts};
7913        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7914
7915        let mut dd = common::DefaultDelegate;
7916        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7917        dlg.begin(common::MethodInfo {
7918            id: "adsense.accounts.policyIssues.list",
7919            http_method: hyper::Method::GET,
7920        });
7921
7922        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7923            if self._additional_params.contains_key(field) {
7924                dlg.finished(false);
7925                return Err(common::Error::FieldClash(field));
7926            }
7927        }
7928
7929        let mut params = Params::with_capacity(5 + self._additional_params.len());
7930        params.push("parent", self._parent);
7931        if let Some(value) = self._page_token.as_ref() {
7932            params.push("pageToken", value);
7933        }
7934        if let Some(value) = self._page_size.as_ref() {
7935            params.push("pageSize", value.to_string());
7936        }
7937
7938        params.extend(self._additional_params.iter());
7939
7940        params.push("alt", "json");
7941        let mut url = self.hub._base_url.clone() + "v2/{+parent}/policyIssues";
7942        if self._scopes.is_empty() {
7943            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7944        }
7945
7946        #[allow(clippy::single_element_loop)]
7947        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7948            url = params.uri_replacement(url, param_name, find_this, true);
7949        }
7950        {
7951            let to_remove = ["parent"];
7952            params.remove_params(&to_remove);
7953        }
7954
7955        let url = params.parse_with_url(&url);
7956
7957        loop {
7958            let token = match self
7959                .hub
7960                .auth
7961                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7962                .await
7963            {
7964                Ok(token) => token,
7965                Err(e) => match dlg.token(e) {
7966                    Ok(token) => token,
7967                    Err(e) => {
7968                        dlg.finished(false);
7969                        return Err(common::Error::MissingToken(e));
7970                    }
7971                },
7972            };
7973            let mut req_result = {
7974                let client = &self.hub.client;
7975                dlg.pre_request();
7976                let mut req_builder = hyper::Request::builder()
7977                    .method(hyper::Method::GET)
7978                    .uri(url.as_str())
7979                    .header(USER_AGENT, self.hub._user_agent.clone());
7980
7981                if let Some(token) = token.as_ref() {
7982                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7983                }
7984
7985                let request = req_builder
7986                    .header(CONTENT_LENGTH, 0_u64)
7987                    .body(common::to_body::<String>(None));
7988
7989                client.request(request.unwrap()).await
7990            };
7991
7992            match req_result {
7993                Err(err) => {
7994                    if let common::Retry::After(d) = dlg.http_error(&err) {
7995                        sleep(d).await;
7996                        continue;
7997                    }
7998                    dlg.finished(false);
7999                    return Err(common::Error::HttpError(err));
8000                }
8001                Ok(res) => {
8002                    let (mut parts, body) = res.into_parts();
8003                    let mut body = common::Body::new(body);
8004                    if !parts.status.is_success() {
8005                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8006                        let error = serde_json::from_str(&common::to_string(&bytes));
8007                        let response = common::to_response(parts, bytes.into());
8008
8009                        if let common::Retry::After(d) =
8010                            dlg.http_failure(&response, error.as_ref().ok())
8011                        {
8012                            sleep(d).await;
8013                            continue;
8014                        }
8015
8016                        dlg.finished(false);
8017
8018                        return Err(match error {
8019                            Ok(value) => common::Error::BadRequest(value),
8020                            _ => common::Error::Failure(response),
8021                        });
8022                    }
8023                    let response = {
8024                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8025                        let encoded = common::to_string(&bytes);
8026                        match serde_json::from_str(&encoded) {
8027                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8028                            Err(error) => {
8029                                dlg.response_json_decode_error(&encoded, &error);
8030                                return Err(common::Error::JsonDecodeError(
8031                                    encoded.to_string(),
8032                                    error,
8033                                ));
8034                            }
8035                        }
8036                    };
8037
8038                    dlg.finished(true);
8039                    return Ok(response);
8040                }
8041            }
8042        }
8043    }
8044
8045    /// Required. The account for which policy issues are being retrieved. Format: accounts/{account}
8046    ///
8047    /// Sets the *parent* path property to the given value.
8048    ///
8049    /// Even though the property as already been set when instantiating this call,
8050    /// we provide this method for API completeness.
8051    pub fn parent(mut self, new_value: &str) -> AccountPolicyIssueListCall<'a, C> {
8052        self._parent = new_value.to_string();
8053        self
8054    }
8055    /// A page token, received from a previous `ListPolicyIssues` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPolicyIssues` must match the call that provided the page token.
8056    ///
8057    /// Sets the *page token* query property to the given value.
8058    pub fn page_token(mut self, new_value: &str) -> AccountPolicyIssueListCall<'a, C> {
8059        self._page_token = Some(new_value.to_string());
8060        self
8061    }
8062    /// The maximum number of policy issues to include in the response, used for paging. If unspecified, at most 10000 policy issues will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
8063    ///
8064    /// Sets the *page size* query property to the given value.
8065    pub fn page_size(mut self, new_value: i32) -> AccountPolicyIssueListCall<'a, C> {
8066        self._page_size = Some(new_value);
8067        self
8068    }
8069    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8070    /// while executing the actual API request.
8071    ///
8072    /// ````text
8073    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8074    /// ````
8075    ///
8076    /// Sets the *delegate* property to the given value.
8077    pub fn delegate(
8078        mut self,
8079        new_value: &'a mut dyn common::Delegate,
8080    ) -> AccountPolicyIssueListCall<'a, C> {
8081        self._delegate = Some(new_value);
8082        self
8083    }
8084
8085    /// Set any additional parameter of the query string used in the request.
8086    /// It should be used to set parameters which are not yet available through their own
8087    /// setters.
8088    ///
8089    /// Please note that this method must not be used to set any of the known parameters
8090    /// which have their own setter method. If done anyway, the request will fail.
8091    ///
8092    /// # Additional Parameters
8093    ///
8094    /// * *$.xgafv* (query-string) - V1 error format.
8095    /// * *access_token* (query-string) - OAuth access token.
8096    /// * *alt* (query-string) - Data format for response.
8097    /// * *callback* (query-string) - JSONP
8098    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8099    /// * *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.
8100    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8101    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8102    /// * *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.
8103    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8104    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8105    pub fn param<T>(mut self, name: T, value: T) -> AccountPolicyIssueListCall<'a, C>
8106    where
8107        T: AsRef<str>,
8108    {
8109        self._additional_params
8110            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8111        self
8112    }
8113
8114    /// Identifies the authorization scope for the method you are building.
8115    ///
8116    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8117    /// [`Scope::Readonly`].
8118    ///
8119    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8120    /// tokens for more than one scope.
8121    ///
8122    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8123    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8124    /// sufficient, a read-write scope will do as well.
8125    pub fn add_scope<St>(mut self, scope: St) -> AccountPolicyIssueListCall<'a, C>
8126    where
8127        St: AsRef<str>,
8128    {
8129        self._scopes.insert(String::from(scope.as_ref()));
8130        self
8131    }
8132    /// Identifies the authorization scope(s) for the method you are building.
8133    ///
8134    /// See [`Self::add_scope()`] for details.
8135    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPolicyIssueListCall<'a, C>
8136    where
8137        I: IntoIterator<Item = St>,
8138        St: AsRef<str>,
8139    {
8140        self._scopes
8141            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8142        self
8143    }
8144
8145    /// Removes all scopes, and no default scope will be used either.
8146    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8147    /// for details).
8148    pub fn clear_scopes(mut self) -> AccountPolicyIssueListCall<'a, C> {
8149        self._scopes.clear();
8150        self
8151    }
8152}
8153
8154/// Generates a saved report.
8155///
8156/// A builder for the *reports.saved.generate* method supported by a *account* resource.
8157/// It is not used directly, but through a [`AccountMethods`] instance.
8158///
8159/// # Example
8160///
8161/// Instantiate a resource method builder
8162///
8163/// ```test_harness,no_run
8164/// # extern crate hyper;
8165/// # extern crate hyper_rustls;
8166/// # extern crate google_adsense2 as adsense2;
8167/// # async fn dox() {
8168/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8169///
8170/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8172/// #     secret,
8173/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8174/// # ).build().await.unwrap();
8175///
8176/// # let client = hyper_util::client::legacy::Client::builder(
8177/// #     hyper_util::rt::TokioExecutor::new()
8178/// # )
8179/// # .build(
8180/// #     hyper_rustls::HttpsConnectorBuilder::new()
8181/// #         .with_native_roots()
8182/// #         .unwrap()
8183/// #         .https_or_http()
8184/// #         .enable_http1()
8185/// #         .build()
8186/// # );
8187/// # let mut hub = Adsense::new(client, auth);
8188/// // You can configure optional parameters by calling the respective setters at will, and
8189/// // execute the final call using `doit()`.
8190/// // Values shown here are possibly random and not representative !
8191/// let result = hub.accounts().reports_saved_generate("name")
8192///              .start_date_year(-19)
8193///              .start_date_month(-62)
8194///              .start_date_day(-74)
8195///              .reporting_time_zone("accusam")
8196///              .language_code("voluptua.")
8197///              .end_date_year(-34)
8198///              .end_date_month(-34)
8199///              .end_date_day(-34)
8200///              .date_range("voluptua.")
8201///              .currency_code("amet.")
8202///              .doit().await;
8203/// # }
8204/// ```
8205pub struct AccountReportSavedGenerateCall<'a, C>
8206where
8207    C: 'a,
8208{
8209    hub: &'a Adsense<C>,
8210    _name: String,
8211    _start_date_year: Option<i32>,
8212    _start_date_month: Option<i32>,
8213    _start_date_day: Option<i32>,
8214    _reporting_time_zone: Option<String>,
8215    _language_code: Option<String>,
8216    _end_date_year: Option<i32>,
8217    _end_date_month: Option<i32>,
8218    _end_date_day: Option<i32>,
8219    _date_range: Option<String>,
8220    _currency_code: Option<String>,
8221    _delegate: Option<&'a mut dyn common::Delegate>,
8222    _additional_params: HashMap<String, String>,
8223    _scopes: BTreeSet<String>,
8224}
8225
8226impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCall<'a, C> {}
8227
8228impl<'a, C> AccountReportSavedGenerateCall<'a, C>
8229where
8230    C: common::Connector,
8231{
8232    /// Perform the operation you have build so far.
8233    pub async fn doit(mut self) -> common::Result<(common::Response, ReportResult)> {
8234        use std::borrow::Cow;
8235        use std::io::{Read, Seek};
8236
8237        use common::{url::Params, ToParts};
8238        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8239
8240        let mut dd = common::DefaultDelegate;
8241        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8242        dlg.begin(common::MethodInfo {
8243            id: "adsense.accounts.reports.saved.generate",
8244            http_method: hyper::Method::GET,
8245        });
8246
8247        for &field in [
8248            "alt",
8249            "name",
8250            "startDate.year",
8251            "startDate.month",
8252            "startDate.day",
8253            "reportingTimeZone",
8254            "languageCode",
8255            "endDate.year",
8256            "endDate.month",
8257            "endDate.day",
8258            "dateRange",
8259            "currencyCode",
8260        ]
8261        .iter()
8262        {
8263            if self._additional_params.contains_key(field) {
8264                dlg.finished(false);
8265                return Err(common::Error::FieldClash(field));
8266            }
8267        }
8268
8269        let mut params = Params::with_capacity(13 + self._additional_params.len());
8270        params.push("name", self._name);
8271        if let Some(value) = self._start_date_year.as_ref() {
8272            params.push("startDate.year", value.to_string());
8273        }
8274        if let Some(value) = self._start_date_month.as_ref() {
8275            params.push("startDate.month", value.to_string());
8276        }
8277        if let Some(value) = self._start_date_day.as_ref() {
8278            params.push("startDate.day", value.to_string());
8279        }
8280        if let Some(value) = self._reporting_time_zone.as_ref() {
8281            params.push("reportingTimeZone", value);
8282        }
8283        if let Some(value) = self._language_code.as_ref() {
8284            params.push("languageCode", value);
8285        }
8286        if let Some(value) = self._end_date_year.as_ref() {
8287            params.push("endDate.year", value.to_string());
8288        }
8289        if let Some(value) = self._end_date_month.as_ref() {
8290            params.push("endDate.month", value.to_string());
8291        }
8292        if let Some(value) = self._end_date_day.as_ref() {
8293            params.push("endDate.day", value.to_string());
8294        }
8295        if let Some(value) = self._date_range.as_ref() {
8296            params.push("dateRange", value);
8297        }
8298        if let Some(value) = self._currency_code.as_ref() {
8299            params.push("currencyCode", value);
8300        }
8301
8302        params.extend(self._additional_params.iter());
8303
8304        params.push("alt", "json");
8305        let mut url = self.hub._base_url.clone() + "v2/{+name}/saved:generate";
8306        if self._scopes.is_empty() {
8307            self._scopes.insert(Scope::Readonly.as_ref().to_string());
8308        }
8309
8310        #[allow(clippy::single_element_loop)]
8311        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8312            url = params.uri_replacement(url, param_name, find_this, true);
8313        }
8314        {
8315            let to_remove = ["name"];
8316            params.remove_params(&to_remove);
8317        }
8318
8319        let url = params.parse_with_url(&url);
8320
8321        loop {
8322            let token = match self
8323                .hub
8324                .auth
8325                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8326                .await
8327            {
8328                Ok(token) => token,
8329                Err(e) => match dlg.token(e) {
8330                    Ok(token) => token,
8331                    Err(e) => {
8332                        dlg.finished(false);
8333                        return Err(common::Error::MissingToken(e));
8334                    }
8335                },
8336            };
8337            let mut req_result = {
8338                let client = &self.hub.client;
8339                dlg.pre_request();
8340                let mut req_builder = hyper::Request::builder()
8341                    .method(hyper::Method::GET)
8342                    .uri(url.as_str())
8343                    .header(USER_AGENT, self.hub._user_agent.clone());
8344
8345                if let Some(token) = token.as_ref() {
8346                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8347                }
8348
8349                let request = req_builder
8350                    .header(CONTENT_LENGTH, 0_u64)
8351                    .body(common::to_body::<String>(None));
8352
8353                client.request(request.unwrap()).await
8354            };
8355
8356            match req_result {
8357                Err(err) => {
8358                    if let common::Retry::After(d) = dlg.http_error(&err) {
8359                        sleep(d).await;
8360                        continue;
8361                    }
8362                    dlg.finished(false);
8363                    return Err(common::Error::HttpError(err));
8364                }
8365                Ok(res) => {
8366                    let (mut parts, body) = res.into_parts();
8367                    let mut body = common::Body::new(body);
8368                    if !parts.status.is_success() {
8369                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8370                        let error = serde_json::from_str(&common::to_string(&bytes));
8371                        let response = common::to_response(parts, bytes.into());
8372
8373                        if let common::Retry::After(d) =
8374                            dlg.http_failure(&response, error.as_ref().ok())
8375                        {
8376                            sleep(d).await;
8377                            continue;
8378                        }
8379
8380                        dlg.finished(false);
8381
8382                        return Err(match error {
8383                            Ok(value) => common::Error::BadRequest(value),
8384                            _ => common::Error::Failure(response),
8385                        });
8386                    }
8387                    let response = {
8388                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8389                        let encoded = common::to_string(&bytes);
8390                        match serde_json::from_str(&encoded) {
8391                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8392                            Err(error) => {
8393                                dlg.response_json_decode_error(&encoded, &error);
8394                                return Err(common::Error::JsonDecodeError(
8395                                    encoded.to_string(),
8396                                    error,
8397                                ));
8398                            }
8399                        }
8400                    };
8401
8402                    dlg.finished(true);
8403                    return Ok(response);
8404                }
8405            }
8406        }
8407    }
8408
8409    /// Required. Name of the saved report. Format: accounts/{account}/reports/{report}
8410    ///
8411    /// Sets the *name* path property to the given value.
8412    ///
8413    /// Even though the property as already been set when instantiating this call,
8414    /// we provide this method for API completeness.
8415    pub fn name(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8416        self._name = new_value.to_string();
8417        self
8418    }
8419    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8420    ///
8421    /// Sets the *start date.year* query property to the given value.
8422    pub fn start_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8423        self._start_date_year = Some(new_value);
8424        self
8425    }
8426    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8427    ///
8428    /// Sets the *start date.month* query property to the given value.
8429    pub fn start_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8430        self._start_date_month = Some(new_value);
8431        self
8432    }
8433    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8434    ///
8435    /// Sets the *start date.day* query property to the given value.
8436    pub fn start_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8437        self._start_date_day = Some(new_value);
8438        self
8439    }
8440    /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
8441    ///
8442    /// Sets the *reporting time zone* query property to the given value.
8443    pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8444        self._reporting_time_zone = Some(new_value.to_string());
8445        self
8446    }
8447    /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
8448    ///
8449    /// Sets the *language code* query property to the given value.
8450    pub fn language_code(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8451        self._language_code = Some(new_value.to_string());
8452        self
8453    }
8454    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8455    ///
8456    /// Sets the *end date.year* query property to the given value.
8457    pub fn end_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8458        self._end_date_year = Some(new_value);
8459        self
8460    }
8461    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8462    ///
8463    /// Sets the *end date.month* query property to the given value.
8464    pub fn end_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8465        self._end_date_month = Some(new_value);
8466        self
8467    }
8468    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8469    ///
8470    /// Sets the *end date.day* query property to the given value.
8471    pub fn end_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8472        self._end_date_day = Some(new_value);
8473        self
8474    }
8475    /// Date range of the report, if unset the range will be considered CUSTOM.
8476    ///
8477    /// Sets the *date range* query property to the given value.
8478    pub fn date_range(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8479        self._date_range = Some(new_value.to_string());
8480        self
8481    }
8482    /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
8483    ///
8484    /// Sets the *currency code* query property to the given value.
8485    pub fn currency_code(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8486        self._currency_code = Some(new_value.to_string());
8487        self
8488    }
8489    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8490    /// while executing the actual API request.
8491    ///
8492    /// ````text
8493    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8494    /// ````
8495    ///
8496    /// Sets the *delegate* property to the given value.
8497    pub fn delegate(
8498        mut self,
8499        new_value: &'a mut dyn common::Delegate,
8500    ) -> AccountReportSavedGenerateCall<'a, C> {
8501        self._delegate = Some(new_value);
8502        self
8503    }
8504
8505    /// Set any additional parameter of the query string used in the request.
8506    /// It should be used to set parameters which are not yet available through their own
8507    /// setters.
8508    ///
8509    /// Please note that this method must not be used to set any of the known parameters
8510    /// which have their own setter method. If done anyway, the request will fail.
8511    ///
8512    /// # Additional Parameters
8513    ///
8514    /// * *$.xgafv* (query-string) - V1 error format.
8515    /// * *access_token* (query-string) - OAuth access token.
8516    /// * *alt* (query-string) - Data format for response.
8517    /// * *callback* (query-string) - JSONP
8518    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8519    /// * *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.
8520    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8521    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8522    /// * *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.
8523    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8524    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8525    pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCall<'a, C>
8526    where
8527        T: AsRef<str>,
8528    {
8529        self._additional_params
8530            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8531        self
8532    }
8533
8534    /// Identifies the authorization scope for the method you are building.
8535    ///
8536    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8537    /// [`Scope::Readonly`].
8538    ///
8539    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8540    /// tokens for more than one scope.
8541    ///
8542    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8543    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8544    /// sufficient, a read-write scope will do as well.
8545    pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCall<'a, C>
8546    where
8547        St: AsRef<str>,
8548    {
8549        self._scopes.insert(String::from(scope.as_ref()));
8550        self
8551    }
8552    /// Identifies the authorization scope(s) for the method you are building.
8553    ///
8554    /// See [`Self::add_scope()`] for details.
8555    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCall<'a, C>
8556    where
8557        I: IntoIterator<Item = St>,
8558        St: AsRef<str>,
8559    {
8560        self._scopes
8561            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8562        self
8563    }
8564
8565    /// Removes all scopes, and no default scope will be used either.
8566    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8567    /// for details).
8568    pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCall<'a, C> {
8569        self._scopes.clear();
8570        self
8571    }
8572}
8573
8574/// Generates a csv formatted saved report.
8575///
8576/// A builder for the *reports.saved.generateCsv* method supported by a *account* resource.
8577/// It is not used directly, but through a [`AccountMethods`] instance.
8578///
8579/// # Example
8580///
8581/// Instantiate a resource method builder
8582///
8583/// ```test_harness,no_run
8584/// # extern crate hyper;
8585/// # extern crate hyper_rustls;
8586/// # extern crate google_adsense2 as adsense2;
8587/// # async fn dox() {
8588/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8589///
8590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8592/// #     secret,
8593/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8594/// # ).build().await.unwrap();
8595///
8596/// # let client = hyper_util::client::legacy::Client::builder(
8597/// #     hyper_util::rt::TokioExecutor::new()
8598/// # )
8599/// # .build(
8600/// #     hyper_rustls::HttpsConnectorBuilder::new()
8601/// #         .with_native_roots()
8602/// #         .unwrap()
8603/// #         .https_or_http()
8604/// #         .enable_http1()
8605/// #         .build()
8606/// # );
8607/// # let mut hub = Adsense::new(client, auth);
8608/// // You can configure optional parameters by calling the respective setters at will, and
8609/// // execute the final call using `doit()`.
8610/// // Values shown here are possibly random and not representative !
8611/// let result = hub.accounts().reports_saved_generate_csv("name")
8612///              .start_date_year(-95)
8613///              .start_date_month(-6)
8614///              .start_date_day(-38)
8615///              .reporting_time_zone("no")
8616///              .language_code("est")
8617///              .end_date_year(-27)
8618///              .end_date_month(-43)
8619///              .end_date_day(-98)
8620///              .date_range("et")
8621///              .currency_code("tempor")
8622///              .doit().await;
8623/// # }
8624/// ```
8625pub struct AccountReportSavedGenerateCsvCall<'a, C>
8626where
8627    C: 'a,
8628{
8629    hub: &'a Adsense<C>,
8630    _name: String,
8631    _start_date_year: Option<i32>,
8632    _start_date_month: Option<i32>,
8633    _start_date_day: Option<i32>,
8634    _reporting_time_zone: Option<String>,
8635    _language_code: Option<String>,
8636    _end_date_year: Option<i32>,
8637    _end_date_month: Option<i32>,
8638    _end_date_day: Option<i32>,
8639    _date_range: Option<String>,
8640    _currency_code: Option<String>,
8641    _delegate: Option<&'a mut dyn common::Delegate>,
8642    _additional_params: HashMap<String, String>,
8643    _scopes: BTreeSet<String>,
8644}
8645
8646impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCsvCall<'a, C> {}
8647
8648impl<'a, C> AccountReportSavedGenerateCsvCall<'a, C>
8649where
8650    C: common::Connector,
8651{
8652    /// Perform the operation you have build so far.
8653    pub async fn doit(mut self) -> common::Result<(common::Response, HttpBody)> {
8654        use std::borrow::Cow;
8655        use std::io::{Read, Seek};
8656
8657        use common::{url::Params, ToParts};
8658        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8659
8660        let mut dd = common::DefaultDelegate;
8661        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8662        dlg.begin(common::MethodInfo {
8663            id: "adsense.accounts.reports.saved.generateCsv",
8664            http_method: hyper::Method::GET,
8665        });
8666
8667        for &field in [
8668            "alt",
8669            "name",
8670            "startDate.year",
8671            "startDate.month",
8672            "startDate.day",
8673            "reportingTimeZone",
8674            "languageCode",
8675            "endDate.year",
8676            "endDate.month",
8677            "endDate.day",
8678            "dateRange",
8679            "currencyCode",
8680        ]
8681        .iter()
8682        {
8683            if self._additional_params.contains_key(field) {
8684                dlg.finished(false);
8685                return Err(common::Error::FieldClash(field));
8686            }
8687        }
8688
8689        let mut params = Params::with_capacity(13 + self._additional_params.len());
8690        params.push("name", self._name);
8691        if let Some(value) = self._start_date_year.as_ref() {
8692            params.push("startDate.year", value.to_string());
8693        }
8694        if let Some(value) = self._start_date_month.as_ref() {
8695            params.push("startDate.month", value.to_string());
8696        }
8697        if let Some(value) = self._start_date_day.as_ref() {
8698            params.push("startDate.day", value.to_string());
8699        }
8700        if let Some(value) = self._reporting_time_zone.as_ref() {
8701            params.push("reportingTimeZone", value);
8702        }
8703        if let Some(value) = self._language_code.as_ref() {
8704            params.push("languageCode", value);
8705        }
8706        if let Some(value) = self._end_date_year.as_ref() {
8707            params.push("endDate.year", value.to_string());
8708        }
8709        if let Some(value) = self._end_date_month.as_ref() {
8710            params.push("endDate.month", value.to_string());
8711        }
8712        if let Some(value) = self._end_date_day.as_ref() {
8713            params.push("endDate.day", value.to_string());
8714        }
8715        if let Some(value) = self._date_range.as_ref() {
8716            params.push("dateRange", value);
8717        }
8718        if let Some(value) = self._currency_code.as_ref() {
8719            params.push("currencyCode", value);
8720        }
8721
8722        params.extend(self._additional_params.iter());
8723
8724        params.push("alt", "json");
8725        let mut url = self.hub._base_url.clone() + "v2/{+name}/saved:generateCsv";
8726        if self._scopes.is_empty() {
8727            self._scopes.insert(Scope::Readonly.as_ref().to_string());
8728        }
8729
8730        #[allow(clippy::single_element_loop)]
8731        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8732            url = params.uri_replacement(url, param_name, find_this, true);
8733        }
8734        {
8735            let to_remove = ["name"];
8736            params.remove_params(&to_remove);
8737        }
8738
8739        let url = params.parse_with_url(&url);
8740
8741        loop {
8742            let token = match self
8743                .hub
8744                .auth
8745                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8746                .await
8747            {
8748                Ok(token) => token,
8749                Err(e) => match dlg.token(e) {
8750                    Ok(token) => token,
8751                    Err(e) => {
8752                        dlg.finished(false);
8753                        return Err(common::Error::MissingToken(e));
8754                    }
8755                },
8756            };
8757            let mut req_result = {
8758                let client = &self.hub.client;
8759                dlg.pre_request();
8760                let mut req_builder = hyper::Request::builder()
8761                    .method(hyper::Method::GET)
8762                    .uri(url.as_str())
8763                    .header(USER_AGENT, self.hub._user_agent.clone());
8764
8765                if let Some(token) = token.as_ref() {
8766                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8767                }
8768
8769                let request = req_builder
8770                    .header(CONTENT_LENGTH, 0_u64)
8771                    .body(common::to_body::<String>(None));
8772
8773                client.request(request.unwrap()).await
8774            };
8775
8776            match req_result {
8777                Err(err) => {
8778                    if let common::Retry::After(d) = dlg.http_error(&err) {
8779                        sleep(d).await;
8780                        continue;
8781                    }
8782                    dlg.finished(false);
8783                    return Err(common::Error::HttpError(err));
8784                }
8785                Ok(res) => {
8786                    let (mut parts, body) = res.into_parts();
8787                    let mut body = common::Body::new(body);
8788                    if !parts.status.is_success() {
8789                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8790                        let error = serde_json::from_str(&common::to_string(&bytes));
8791                        let response = common::to_response(parts, bytes.into());
8792
8793                        if let common::Retry::After(d) =
8794                            dlg.http_failure(&response, error.as_ref().ok())
8795                        {
8796                            sleep(d).await;
8797                            continue;
8798                        }
8799
8800                        dlg.finished(false);
8801
8802                        return Err(match error {
8803                            Ok(value) => common::Error::BadRequest(value),
8804                            _ => common::Error::Failure(response),
8805                        });
8806                    }
8807                    let response = {
8808                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8809                        let encoded = common::to_string(&bytes);
8810                        match serde_json::from_str(&encoded) {
8811                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8812                            Err(error) => {
8813                                dlg.response_json_decode_error(&encoded, &error);
8814                                return Err(common::Error::JsonDecodeError(
8815                                    encoded.to_string(),
8816                                    error,
8817                                ));
8818                            }
8819                        }
8820                    };
8821
8822                    dlg.finished(true);
8823                    return Ok(response);
8824                }
8825            }
8826        }
8827    }
8828
8829    /// Required. Name of the saved report. Format: accounts/{account}/reports/{report}
8830    ///
8831    /// Sets the *name* path property to the given value.
8832    ///
8833    /// Even though the property as already been set when instantiating this call,
8834    /// we provide this method for API completeness.
8835    pub fn name(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
8836        self._name = new_value.to_string();
8837        self
8838    }
8839    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8840    ///
8841    /// Sets the *start date.year* query property to the given value.
8842    pub fn start_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8843        self._start_date_year = Some(new_value);
8844        self
8845    }
8846    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8847    ///
8848    /// Sets the *start date.month* query property to the given value.
8849    pub fn start_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8850        self._start_date_month = Some(new_value);
8851        self
8852    }
8853    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8854    ///
8855    /// Sets the *start date.day* query property to the given value.
8856    pub fn start_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8857        self._start_date_day = Some(new_value);
8858        self
8859    }
8860    /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
8861    ///
8862    /// Sets the *reporting time zone* query property to the given value.
8863    pub fn reporting_time_zone(
8864        mut self,
8865        new_value: &str,
8866    ) -> AccountReportSavedGenerateCsvCall<'a, C> {
8867        self._reporting_time_zone = Some(new_value.to_string());
8868        self
8869    }
8870    /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
8871    ///
8872    /// Sets the *language code* query property to the given value.
8873    pub fn language_code(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
8874        self._language_code = Some(new_value.to_string());
8875        self
8876    }
8877    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8878    ///
8879    /// Sets the *end date.year* query property to the given value.
8880    pub fn end_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8881        self._end_date_year = Some(new_value);
8882        self
8883    }
8884    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8885    ///
8886    /// Sets the *end date.month* query property to the given value.
8887    pub fn end_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8888        self._end_date_month = Some(new_value);
8889        self
8890    }
8891    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8892    ///
8893    /// Sets the *end date.day* query property to the given value.
8894    pub fn end_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
8895        self._end_date_day = Some(new_value);
8896        self
8897    }
8898    /// Date range of the report, if unset the range will be considered CUSTOM.
8899    ///
8900    /// Sets the *date range* query property to the given value.
8901    pub fn date_range(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
8902        self._date_range = Some(new_value.to_string());
8903        self
8904    }
8905    /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
8906    ///
8907    /// Sets the *currency code* query property to the given value.
8908    pub fn currency_code(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
8909        self._currency_code = Some(new_value.to_string());
8910        self
8911    }
8912    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8913    /// while executing the actual API request.
8914    ///
8915    /// ````text
8916    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8917    /// ````
8918    ///
8919    /// Sets the *delegate* property to the given value.
8920    pub fn delegate(
8921        mut self,
8922        new_value: &'a mut dyn common::Delegate,
8923    ) -> AccountReportSavedGenerateCsvCall<'a, C> {
8924        self._delegate = Some(new_value);
8925        self
8926    }
8927
8928    /// Set any additional parameter of the query string used in the request.
8929    /// It should be used to set parameters which are not yet available through their own
8930    /// setters.
8931    ///
8932    /// Please note that this method must not be used to set any of the known parameters
8933    /// which have their own setter method. If done anyway, the request will fail.
8934    ///
8935    /// # Additional Parameters
8936    ///
8937    /// * *$.xgafv* (query-string) - V1 error format.
8938    /// * *access_token* (query-string) - OAuth access token.
8939    /// * *alt* (query-string) - Data format for response.
8940    /// * *callback* (query-string) - JSONP
8941    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8942    /// * *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.
8943    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8944    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8945    /// * *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.
8946    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8947    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8948    pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCsvCall<'a, C>
8949    where
8950        T: AsRef<str>,
8951    {
8952        self._additional_params
8953            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8954        self
8955    }
8956
8957    /// Identifies the authorization scope for the method you are building.
8958    ///
8959    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8960    /// [`Scope::Readonly`].
8961    ///
8962    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8963    /// tokens for more than one scope.
8964    ///
8965    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8966    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8967    /// sufficient, a read-write scope will do as well.
8968    pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCsvCall<'a, C>
8969    where
8970        St: AsRef<str>,
8971    {
8972        self._scopes.insert(String::from(scope.as_ref()));
8973        self
8974    }
8975    /// Identifies the authorization scope(s) for the method you are building.
8976    ///
8977    /// See [`Self::add_scope()`] for details.
8978    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCsvCall<'a, C>
8979    where
8980        I: IntoIterator<Item = St>,
8981        St: AsRef<str>,
8982    {
8983        self._scopes
8984            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8985        self
8986    }
8987
8988    /// Removes all scopes, and no default scope will be used either.
8989    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8990    /// for details).
8991    pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCsvCall<'a, C> {
8992        self._scopes.clear();
8993        self
8994    }
8995}
8996
8997/// Lists saved reports.
8998///
8999/// A builder for the *reports.saved.list* method supported by a *account* resource.
9000/// It is not used directly, but through a [`AccountMethods`] instance.
9001///
9002/// # Example
9003///
9004/// Instantiate a resource method builder
9005///
9006/// ```test_harness,no_run
9007/// # extern crate hyper;
9008/// # extern crate hyper_rustls;
9009/// # extern crate google_adsense2 as adsense2;
9010/// # async fn dox() {
9011/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9012///
9013/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9014/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9015/// #     secret,
9016/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9017/// # ).build().await.unwrap();
9018///
9019/// # let client = hyper_util::client::legacy::Client::builder(
9020/// #     hyper_util::rt::TokioExecutor::new()
9021/// # )
9022/// # .build(
9023/// #     hyper_rustls::HttpsConnectorBuilder::new()
9024/// #         .with_native_roots()
9025/// #         .unwrap()
9026/// #         .https_or_http()
9027/// #         .enable_http1()
9028/// #         .build()
9029/// # );
9030/// # let mut hub = Adsense::new(client, auth);
9031/// // You can configure optional parameters by calling the respective setters at will, and
9032/// // execute the final call using `doit()`.
9033/// // Values shown here are possibly random and not representative !
9034/// let result = hub.accounts().reports_saved_list("parent")
9035///              .page_token("ipsum")
9036///              .page_size(-18)
9037///              .doit().await;
9038/// # }
9039/// ```
9040pub struct AccountReportSavedListCall<'a, C>
9041where
9042    C: 'a,
9043{
9044    hub: &'a Adsense<C>,
9045    _parent: String,
9046    _page_token: Option<String>,
9047    _page_size: Option<i32>,
9048    _delegate: Option<&'a mut dyn common::Delegate>,
9049    _additional_params: HashMap<String, String>,
9050    _scopes: BTreeSet<String>,
9051}
9052
9053impl<'a, C> common::CallBuilder for AccountReportSavedListCall<'a, C> {}
9054
9055impl<'a, C> AccountReportSavedListCall<'a, C>
9056where
9057    C: common::Connector,
9058{
9059    /// Perform the operation you have build so far.
9060    pub async fn doit(mut self) -> common::Result<(common::Response, ListSavedReportsResponse)> {
9061        use std::borrow::Cow;
9062        use std::io::{Read, Seek};
9063
9064        use common::{url::Params, ToParts};
9065        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9066
9067        let mut dd = common::DefaultDelegate;
9068        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9069        dlg.begin(common::MethodInfo {
9070            id: "adsense.accounts.reports.saved.list",
9071            http_method: hyper::Method::GET,
9072        });
9073
9074        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9075            if self._additional_params.contains_key(field) {
9076                dlg.finished(false);
9077                return Err(common::Error::FieldClash(field));
9078            }
9079        }
9080
9081        let mut params = Params::with_capacity(5 + self._additional_params.len());
9082        params.push("parent", self._parent);
9083        if let Some(value) = self._page_token.as_ref() {
9084            params.push("pageToken", value);
9085        }
9086        if let Some(value) = self._page_size.as_ref() {
9087            params.push("pageSize", value.to_string());
9088        }
9089
9090        params.extend(self._additional_params.iter());
9091
9092        params.push("alt", "json");
9093        let mut url = self.hub._base_url.clone() + "v2/{+parent}/reports/saved";
9094        if self._scopes.is_empty() {
9095            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9096        }
9097
9098        #[allow(clippy::single_element_loop)]
9099        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9100            url = params.uri_replacement(url, param_name, find_this, true);
9101        }
9102        {
9103            let to_remove = ["parent"];
9104            params.remove_params(&to_remove);
9105        }
9106
9107        let url = params.parse_with_url(&url);
9108
9109        loop {
9110            let token = match self
9111                .hub
9112                .auth
9113                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9114                .await
9115            {
9116                Ok(token) => token,
9117                Err(e) => match dlg.token(e) {
9118                    Ok(token) => token,
9119                    Err(e) => {
9120                        dlg.finished(false);
9121                        return Err(common::Error::MissingToken(e));
9122                    }
9123                },
9124            };
9125            let mut req_result = {
9126                let client = &self.hub.client;
9127                dlg.pre_request();
9128                let mut req_builder = hyper::Request::builder()
9129                    .method(hyper::Method::GET)
9130                    .uri(url.as_str())
9131                    .header(USER_AGENT, self.hub._user_agent.clone());
9132
9133                if let Some(token) = token.as_ref() {
9134                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9135                }
9136
9137                let request = req_builder
9138                    .header(CONTENT_LENGTH, 0_u64)
9139                    .body(common::to_body::<String>(None));
9140
9141                client.request(request.unwrap()).await
9142            };
9143
9144            match req_result {
9145                Err(err) => {
9146                    if let common::Retry::After(d) = dlg.http_error(&err) {
9147                        sleep(d).await;
9148                        continue;
9149                    }
9150                    dlg.finished(false);
9151                    return Err(common::Error::HttpError(err));
9152                }
9153                Ok(res) => {
9154                    let (mut parts, body) = res.into_parts();
9155                    let mut body = common::Body::new(body);
9156                    if !parts.status.is_success() {
9157                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9158                        let error = serde_json::from_str(&common::to_string(&bytes));
9159                        let response = common::to_response(parts, bytes.into());
9160
9161                        if let common::Retry::After(d) =
9162                            dlg.http_failure(&response, error.as_ref().ok())
9163                        {
9164                            sleep(d).await;
9165                            continue;
9166                        }
9167
9168                        dlg.finished(false);
9169
9170                        return Err(match error {
9171                            Ok(value) => common::Error::BadRequest(value),
9172                            _ => common::Error::Failure(response),
9173                        });
9174                    }
9175                    let response = {
9176                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9177                        let encoded = common::to_string(&bytes);
9178                        match serde_json::from_str(&encoded) {
9179                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9180                            Err(error) => {
9181                                dlg.response_json_decode_error(&encoded, &error);
9182                                return Err(common::Error::JsonDecodeError(
9183                                    encoded.to_string(),
9184                                    error,
9185                                ));
9186                            }
9187                        }
9188                    };
9189
9190                    dlg.finished(true);
9191                    return Ok(response);
9192                }
9193            }
9194        }
9195    }
9196
9197    /// Required. The account which owns the collection of reports. Format: accounts/{account}
9198    ///
9199    /// Sets the *parent* path property to the given value.
9200    ///
9201    /// Even though the property as already been set when instantiating this call,
9202    /// we provide this method for API completeness.
9203    pub fn parent(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
9204        self._parent = new_value.to_string();
9205        self
9206    }
9207    /// A page token, received from a previous `ListSavedReports` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSavedReports` must match the call that provided the page token.
9208    ///
9209    /// Sets the *page token* query property to the given value.
9210    pub fn page_token(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
9211        self._page_token = Some(new_value.to_string());
9212        self
9213    }
9214    /// The maximum number of reports to include in the response, used for paging. If unspecified, at most 10000 reports will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
9215    ///
9216    /// Sets the *page size* query property to the given value.
9217    pub fn page_size(mut self, new_value: i32) -> AccountReportSavedListCall<'a, C> {
9218        self._page_size = Some(new_value);
9219        self
9220    }
9221    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9222    /// while executing the actual API request.
9223    ///
9224    /// ````text
9225    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9226    /// ````
9227    ///
9228    /// Sets the *delegate* property to the given value.
9229    pub fn delegate(
9230        mut self,
9231        new_value: &'a mut dyn common::Delegate,
9232    ) -> AccountReportSavedListCall<'a, C> {
9233        self._delegate = Some(new_value);
9234        self
9235    }
9236
9237    /// Set any additional parameter of the query string used in the request.
9238    /// It should be used to set parameters which are not yet available through their own
9239    /// setters.
9240    ///
9241    /// Please note that this method must not be used to set any of the known parameters
9242    /// which have their own setter method. If done anyway, the request will fail.
9243    ///
9244    /// # Additional Parameters
9245    ///
9246    /// * *$.xgafv* (query-string) - V1 error format.
9247    /// * *access_token* (query-string) - OAuth access token.
9248    /// * *alt* (query-string) - Data format for response.
9249    /// * *callback* (query-string) - JSONP
9250    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9251    /// * *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.
9252    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9253    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9254    /// * *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.
9255    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9256    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9257    pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedListCall<'a, C>
9258    where
9259        T: AsRef<str>,
9260    {
9261        self._additional_params
9262            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9263        self
9264    }
9265
9266    /// Identifies the authorization scope for the method you are building.
9267    ///
9268    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9269    /// [`Scope::Readonly`].
9270    ///
9271    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9272    /// tokens for more than one scope.
9273    ///
9274    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9275    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9276    /// sufficient, a read-write scope will do as well.
9277    pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedListCall<'a, C>
9278    where
9279        St: AsRef<str>,
9280    {
9281        self._scopes.insert(String::from(scope.as_ref()));
9282        self
9283    }
9284    /// Identifies the authorization scope(s) for the method you are building.
9285    ///
9286    /// See [`Self::add_scope()`] for details.
9287    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedListCall<'a, C>
9288    where
9289        I: IntoIterator<Item = St>,
9290        St: AsRef<str>,
9291    {
9292        self._scopes
9293            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9294        self
9295    }
9296
9297    /// Removes all scopes, and no default scope will be used either.
9298    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9299    /// for details).
9300    pub fn clear_scopes(mut self) -> AccountReportSavedListCall<'a, C> {
9301        self._scopes.clear();
9302        self
9303    }
9304}
9305
9306/// Generates an ad hoc report.
9307///
9308/// A builder for the *reports.generate* method supported by a *account* resource.
9309/// It is not used directly, but through a [`AccountMethods`] instance.
9310///
9311/// # Example
9312///
9313/// Instantiate a resource method builder
9314///
9315/// ```test_harness,no_run
9316/// # extern crate hyper;
9317/// # extern crate hyper_rustls;
9318/// # extern crate google_adsense2 as adsense2;
9319/// # async fn dox() {
9320/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9321///
9322/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9324/// #     secret,
9325/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9326/// # ).build().await.unwrap();
9327///
9328/// # let client = hyper_util::client::legacy::Client::builder(
9329/// #     hyper_util::rt::TokioExecutor::new()
9330/// # )
9331/// # .build(
9332/// #     hyper_rustls::HttpsConnectorBuilder::new()
9333/// #         .with_native_roots()
9334/// #         .unwrap()
9335/// #         .https_or_http()
9336/// #         .enable_http1()
9337/// #         .build()
9338/// # );
9339/// # let mut hub = Adsense::new(client, auth);
9340/// // You can configure optional parameters by calling the respective setters at will, and
9341/// // execute the final call using `doit()`.
9342/// // Values shown here are possibly random and not representative !
9343/// let result = hub.accounts().reports_generate("account")
9344///              .start_date_year(-56)
9345///              .start_date_month(-7)
9346///              .start_date_day(-30)
9347///              .reporting_time_zone("diam")
9348///              .add_order_by("dolores")
9349///              .add_metrics("dolores")
9350///              .limit(-68)
9351///              .language_code("sed")
9352///              .add_filters("no")
9353///              .end_date_year(-85)
9354///              .end_date_month(-94)
9355///              .end_date_day(-80)
9356///              .add_dimensions("no")
9357///              .date_range("nonumy")
9358///              .currency_code("At")
9359///              .doit().await;
9360/// # }
9361/// ```
9362pub struct AccountReportGenerateCall<'a, C>
9363where
9364    C: 'a,
9365{
9366    hub: &'a Adsense<C>,
9367    _account: String,
9368    _start_date_year: Option<i32>,
9369    _start_date_month: Option<i32>,
9370    _start_date_day: Option<i32>,
9371    _reporting_time_zone: Option<String>,
9372    _order_by: Vec<String>,
9373    _metrics: Vec<String>,
9374    _limit: Option<i32>,
9375    _language_code: Option<String>,
9376    _filters: Vec<String>,
9377    _end_date_year: Option<i32>,
9378    _end_date_month: Option<i32>,
9379    _end_date_day: Option<i32>,
9380    _dimensions: Vec<String>,
9381    _date_range: Option<String>,
9382    _currency_code: Option<String>,
9383    _delegate: Option<&'a mut dyn common::Delegate>,
9384    _additional_params: HashMap<String, String>,
9385    _scopes: BTreeSet<String>,
9386}
9387
9388impl<'a, C> common::CallBuilder for AccountReportGenerateCall<'a, C> {}
9389
9390impl<'a, C> AccountReportGenerateCall<'a, C>
9391where
9392    C: common::Connector,
9393{
9394    /// Perform the operation you have build so far.
9395    pub async fn doit(mut self) -> common::Result<(common::Response, ReportResult)> {
9396        use std::borrow::Cow;
9397        use std::io::{Read, Seek};
9398
9399        use common::{url::Params, ToParts};
9400        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9401
9402        let mut dd = common::DefaultDelegate;
9403        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9404        dlg.begin(common::MethodInfo {
9405            id: "adsense.accounts.reports.generate",
9406            http_method: hyper::Method::GET,
9407        });
9408
9409        for &field in [
9410            "alt",
9411            "account",
9412            "startDate.year",
9413            "startDate.month",
9414            "startDate.day",
9415            "reportingTimeZone",
9416            "orderBy",
9417            "metrics",
9418            "limit",
9419            "languageCode",
9420            "filters",
9421            "endDate.year",
9422            "endDate.month",
9423            "endDate.day",
9424            "dimensions",
9425            "dateRange",
9426            "currencyCode",
9427        ]
9428        .iter()
9429        {
9430            if self._additional_params.contains_key(field) {
9431                dlg.finished(false);
9432                return Err(common::Error::FieldClash(field));
9433            }
9434        }
9435
9436        let mut params = Params::with_capacity(18 + self._additional_params.len());
9437        params.push("account", self._account);
9438        if let Some(value) = self._start_date_year.as_ref() {
9439            params.push("startDate.year", value.to_string());
9440        }
9441        if let Some(value) = self._start_date_month.as_ref() {
9442            params.push("startDate.month", value.to_string());
9443        }
9444        if let Some(value) = self._start_date_day.as_ref() {
9445            params.push("startDate.day", value.to_string());
9446        }
9447        if let Some(value) = self._reporting_time_zone.as_ref() {
9448            params.push("reportingTimeZone", value);
9449        }
9450        if !self._order_by.is_empty() {
9451            for f in self._order_by.iter() {
9452                params.push("orderBy", f);
9453            }
9454        }
9455        if !self._metrics.is_empty() {
9456            for f in self._metrics.iter() {
9457                params.push("metrics", f);
9458            }
9459        }
9460        if let Some(value) = self._limit.as_ref() {
9461            params.push("limit", value.to_string());
9462        }
9463        if let Some(value) = self._language_code.as_ref() {
9464            params.push("languageCode", value);
9465        }
9466        if !self._filters.is_empty() {
9467            for f in self._filters.iter() {
9468                params.push("filters", f);
9469            }
9470        }
9471        if let Some(value) = self._end_date_year.as_ref() {
9472            params.push("endDate.year", value.to_string());
9473        }
9474        if let Some(value) = self._end_date_month.as_ref() {
9475            params.push("endDate.month", value.to_string());
9476        }
9477        if let Some(value) = self._end_date_day.as_ref() {
9478            params.push("endDate.day", value.to_string());
9479        }
9480        if !self._dimensions.is_empty() {
9481            for f in self._dimensions.iter() {
9482                params.push("dimensions", f);
9483            }
9484        }
9485        if let Some(value) = self._date_range.as_ref() {
9486            params.push("dateRange", value);
9487        }
9488        if let Some(value) = self._currency_code.as_ref() {
9489            params.push("currencyCode", value);
9490        }
9491
9492        params.extend(self._additional_params.iter());
9493
9494        params.push("alt", "json");
9495        let mut url = self.hub._base_url.clone() + "v2/{+account}/reports:generate";
9496        if self._scopes.is_empty() {
9497            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9498        }
9499
9500        #[allow(clippy::single_element_loop)]
9501        for &(find_this, param_name) in [("{+account}", "account")].iter() {
9502            url = params.uri_replacement(url, param_name, find_this, true);
9503        }
9504        {
9505            let to_remove = ["account"];
9506            params.remove_params(&to_remove);
9507        }
9508
9509        let url = params.parse_with_url(&url);
9510
9511        loop {
9512            let token = match self
9513                .hub
9514                .auth
9515                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9516                .await
9517            {
9518                Ok(token) => token,
9519                Err(e) => match dlg.token(e) {
9520                    Ok(token) => token,
9521                    Err(e) => {
9522                        dlg.finished(false);
9523                        return Err(common::Error::MissingToken(e));
9524                    }
9525                },
9526            };
9527            let mut req_result = {
9528                let client = &self.hub.client;
9529                dlg.pre_request();
9530                let mut req_builder = hyper::Request::builder()
9531                    .method(hyper::Method::GET)
9532                    .uri(url.as_str())
9533                    .header(USER_AGENT, self.hub._user_agent.clone());
9534
9535                if let Some(token) = token.as_ref() {
9536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9537                }
9538
9539                let request = req_builder
9540                    .header(CONTENT_LENGTH, 0_u64)
9541                    .body(common::to_body::<String>(None));
9542
9543                client.request(request.unwrap()).await
9544            };
9545
9546            match req_result {
9547                Err(err) => {
9548                    if let common::Retry::After(d) = dlg.http_error(&err) {
9549                        sleep(d).await;
9550                        continue;
9551                    }
9552                    dlg.finished(false);
9553                    return Err(common::Error::HttpError(err));
9554                }
9555                Ok(res) => {
9556                    let (mut parts, body) = res.into_parts();
9557                    let mut body = common::Body::new(body);
9558                    if !parts.status.is_success() {
9559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9560                        let error = serde_json::from_str(&common::to_string(&bytes));
9561                        let response = common::to_response(parts, bytes.into());
9562
9563                        if let common::Retry::After(d) =
9564                            dlg.http_failure(&response, error.as_ref().ok())
9565                        {
9566                            sleep(d).await;
9567                            continue;
9568                        }
9569
9570                        dlg.finished(false);
9571
9572                        return Err(match error {
9573                            Ok(value) => common::Error::BadRequest(value),
9574                            _ => common::Error::Failure(response),
9575                        });
9576                    }
9577                    let response = {
9578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9579                        let encoded = common::to_string(&bytes);
9580                        match serde_json::from_str(&encoded) {
9581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9582                            Err(error) => {
9583                                dlg.response_json_decode_error(&encoded, &error);
9584                                return Err(common::Error::JsonDecodeError(
9585                                    encoded.to_string(),
9586                                    error,
9587                                ));
9588                            }
9589                        }
9590                    };
9591
9592                    dlg.finished(true);
9593                    return Ok(response);
9594                }
9595            }
9596        }
9597    }
9598
9599    /// Required. The account which owns the collection of reports. Format: accounts/{account}
9600    ///
9601    /// Sets the *account* path property to the given value.
9602    ///
9603    /// Even though the property as already been set when instantiating this call,
9604    /// we provide this method for API completeness.
9605    pub fn account(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9606        self._account = new_value.to_string();
9607        self
9608    }
9609    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9610    ///
9611    /// Sets the *start date.year* query property to the given value.
9612    pub fn start_date_year(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9613        self._start_date_year = Some(new_value);
9614        self
9615    }
9616    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9617    ///
9618    /// Sets the *start date.month* query property to the given value.
9619    pub fn start_date_month(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9620        self._start_date_month = Some(new_value);
9621        self
9622    }
9623    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9624    ///
9625    /// Sets the *start date.day* query property to the given value.
9626    pub fn start_date_day(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9627        self._start_date_day = Some(new_value);
9628        self
9629    }
9630    /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
9631    ///
9632    /// Sets the *reporting time zone* query property to the given value.
9633    pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9634        self._reporting_time_zone = Some(new_value.to_string());
9635        self
9636    }
9637    /// The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
9638    ///
9639    /// Append the given value to the *order by* query property.
9640    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9641    pub fn add_order_by(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9642        self._order_by.push(new_value.to_string());
9643        self
9644    }
9645    /// Required. Reporting metrics.
9646    ///
9647    /// Append the given value to the *metrics* query property.
9648    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9649    pub fn add_metrics(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9650        self._metrics.push(new_value.to_string());
9651        self
9652    }
9653    /// The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
9654    ///
9655    /// Sets the *limit* query property to the given value.
9656    pub fn limit(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9657        self._limit = Some(new_value);
9658        self
9659    }
9660    /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
9661    ///
9662    /// Sets the *language code* query property to the given value.
9663    pub fn language_code(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9664        self._language_code = Some(new_value.to_string());
9665        self
9666    }
9667    /// A list of [filters](https://developers.google.com/adsense/management/reporting/filtering) to apply to the report. All provided filters must match in order for the data to be included in the report.
9668    ///
9669    /// Append the given value to the *filters* query property.
9670    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9671    pub fn add_filters(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9672        self._filters.push(new_value.to_string());
9673        self
9674    }
9675    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9676    ///
9677    /// Sets the *end date.year* query property to the given value.
9678    pub fn end_date_year(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9679        self._end_date_year = Some(new_value);
9680        self
9681    }
9682    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9683    ///
9684    /// Sets the *end date.month* query property to the given value.
9685    pub fn end_date_month(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9686        self._end_date_month = Some(new_value);
9687        self
9688    }
9689    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9690    ///
9691    /// Sets the *end date.day* query property to the given value.
9692    pub fn end_date_day(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9693        self._end_date_day = Some(new_value);
9694        self
9695    }
9696    /// Dimensions to base the report on.
9697    ///
9698    /// Append the given value to the *dimensions* query property.
9699    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9700    pub fn add_dimensions(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9701        self._dimensions.push(new_value.to_string());
9702        self
9703    }
9704    /// Date range of the report, if unset the range will be considered CUSTOM.
9705    ///
9706    /// Sets the *date range* query property to the given value.
9707    pub fn date_range(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9708        self._date_range = Some(new_value.to_string());
9709        self
9710    }
9711    /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
9712    ///
9713    /// Sets the *currency code* query property to the given value.
9714    pub fn currency_code(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9715        self._currency_code = Some(new_value.to_string());
9716        self
9717    }
9718    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9719    /// while executing the actual API request.
9720    ///
9721    /// ````text
9722    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9723    /// ````
9724    ///
9725    /// Sets the *delegate* property to the given value.
9726    pub fn delegate(
9727        mut self,
9728        new_value: &'a mut dyn common::Delegate,
9729    ) -> AccountReportGenerateCall<'a, C> {
9730        self._delegate = Some(new_value);
9731        self
9732    }
9733
9734    /// Set any additional parameter of the query string used in the request.
9735    /// It should be used to set parameters which are not yet available through their own
9736    /// setters.
9737    ///
9738    /// Please note that this method must not be used to set any of the known parameters
9739    /// which have their own setter method. If done anyway, the request will fail.
9740    ///
9741    /// # Additional Parameters
9742    ///
9743    /// * *$.xgafv* (query-string) - V1 error format.
9744    /// * *access_token* (query-string) - OAuth access token.
9745    /// * *alt* (query-string) - Data format for response.
9746    /// * *callback* (query-string) - JSONP
9747    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9748    /// * *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.
9749    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9750    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9751    /// * *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.
9752    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9753    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9754    pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCall<'a, C>
9755    where
9756        T: AsRef<str>,
9757    {
9758        self._additional_params
9759            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9760        self
9761    }
9762
9763    /// Identifies the authorization scope for the method you are building.
9764    ///
9765    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9766    /// [`Scope::Readonly`].
9767    ///
9768    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9769    /// tokens for more than one scope.
9770    ///
9771    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9772    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9773    /// sufficient, a read-write scope will do as well.
9774    pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCall<'a, C>
9775    where
9776        St: AsRef<str>,
9777    {
9778        self._scopes.insert(String::from(scope.as_ref()));
9779        self
9780    }
9781    /// Identifies the authorization scope(s) for the method you are building.
9782    ///
9783    /// See [`Self::add_scope()`] for details.
9784    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCall<'a, C>
9785    where
9786        I: IntoIterator<Item = St>,
9787        St: AsRef<str>,
9788    {
9789        self._scopes
9790            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9791        self
9792    }
9793
9794    /// Removes all scopes, and no default scope will be used either.
9795    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9796    /// for details).
9797    pub fn clear_scopes(mut self) -> AccountReportGenerateCall<'a, C> {
9798        self._scopes.clear();
9799        self
9800    }
9801}
9802
9803/// Generates a csv formatted ad hoc report.
9804///
9805/// A builder for the *reports.generateCsv* method supported by a *account* resource.
9806/// It is not used directly, but through a [`AccountMethods`] instance.
9807///
9808/// # Example
9809///
9810/// Instantiate a resource method builder
9811///
9812/// ```test_harness,no_run
9813/// # extern crate hyper;
9814/// # extern crate hyper_rustls;
9815/// # extern crate google_adsense2 as adsense2;
9816/// # async fn dox() {
9817/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9818///
9819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9820/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9821/// #     secret,
9822/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9823/// # ).build().await.unwrap();
9824///
9825/// # let client = hyper_util::client::legacy::Client::builder(
9826/// #     hyper_util::rt::TokioExecutor::new()
9827/// # )
9828/// # .build(
9829/// #     hyper_rustls::HttpsConnectorBuilder::new()
9830/// #         .with_native_roots()
9831/// #         .unwrap()
9832/// #         .https_or_http()
9833/// #         .enable_http1()
9834/// #         .build()
9835/// # );
9836/// # let mut hub = Adsense::new(client, auth);
9837/// // You can configure optional parameters by calling the respective setters at will, and
9838/// // execute the final call using `doit()`.
9839/// // Values shown here are possibly random and not representative !
9840/// let result = hub.accounts().reports_generate_csv("account")
9841///              .start_date_year(-32)
9842///              .start_date_month(-69)
9843///              .start_date_day(-95)
9844///              .reporting_time_zone("erat")
9845///              .add_order_by("aliquyam")
9846///              .add_metrics("amet")
9847///              .limit(-57)
9848///              .language_code("et")
9849///              .add_filters("sea")
9850///              .end_date_year(-96)
9851///              .end_date_month(-46)
9852///              .end_date_day(-65)
9853///              .add_dimensions("est")
9854///              .date_range("aliquyam")
9855///              .currency_code("elitr")
9856///              .doit().await;
9857/// # }
9858/// ```
9859pub struct AccountReportGenerateCsvCall<'a, C>
9860where
9861    C: 'a,
9862{
9863    hub: &'a Adsense<C>,
9864    _account: String,
9865    _start_date_year: Option<i32>,
9866    _start_date_month: Option<i32>,
9867    _start_date_day: Option<i32>,
9868    _reporting_time_zone: Option<String>,
9869    _order_by: Vec<String>,
9870    _metrics: Vec<String>,
9871    _limit: Option<i32>,
9872    _language_code: Option<String>,
9873    _filters: Vec<String>,
9874    _end_date_year: Option<i32>,
9875    _end_date_month: Option<i32>,
9876    _end_date_day: Option<i32>,
9877    _dimensions: Vec<String>,
9878    _date_range: Option<String>,
9879    _currency_code: Option<String>,
9880    _delegate: Option<&'a mut dyn common::Delegate>,
9881    _additional_params: HashMap<String, String>,
9882    _scopes: BTreeSet<String>,
9883}
9884
9885impl<'a, C> common::CallBuilder for AccountReportGenerateCsvCall<'a, C> {}
9886
9887impl<'a, C> AccountReportGenerateCsvCall<'a, C>
9888where
9889    C: common::Connector,
9890{
9891    /// Perform the operation you have build so far.
9892    pub async fn doit(mut self) -> common::Result<(common::Response, HttpBody)> {
9893        use std::borrow::Cow;
9894        use std::io::{Read, Seek};
9895
9896        use common::{url::Params, ToParts};
9897        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9898
9899        let mut dd = common::DefaultDelegate;
9900        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9901        dlg.begin(common::MethodInfo {
9902            id: "adsense.accounts.reports.generateCsv",
9903            http_method: hyper::Method::GET,
9904        });
9905
9906        for &field in [
9907            "alt",
9908            "account",
9909            "startDate.year",
9910            "startDate.month",
9911            "startDate.day",
9912            "reportingTimeZone",
9913            "orderBy",
9914            "metrics",
9915            "limit",
9916            "languageCode",
9917            "filters",
9918            "endDate.year",
9919            "endDate.month",
9920            "endDate.day",
9921            "dimensions",
9922            "dateRange",
9923            "currencyCode",
9924        ]
9925        .iter()
9926        {
9927            if self._additional_params.contains_key(field) {
9928                dlg.finished(false);
9929                return Err(common::Error::FieldClash(field));
9930            }
9931        }
9932
9933        let mut params = Params::with_capacity(18 + self._additional_params.len());
9934        params.push("account", self._account);
9935        if let Some(value) = self._start_date_year.as_ref() {
9936            params.push("startDate.year", value.to_string());
9937        }
9938        if let Some(value) = self._start_date_month.as_ref() {
9939            params.push("startDate.month", value.to_string());
9940        }
9941        if let Some(value) = self._start_date_day.as_ref() {
9942            params.push("startDate.day", value.to_string());
9943        }
9944        if let Some(value) = self._reporting_time_zone.as_ref() {
9945            params.push("reportingTimeZone", value);
9946        }
9947        if !self._order_by.is_empty() {
9948            for f in self._order_by.iter() {
9949                params.push("orderBy", f);
9950            }
9951        }
9952        if !self._metrics.is_empty() {
9953            for f in self._metrics.iter() {
9954                params.push("metrics", f);
9955            }
9956        }
9957        if let Some(value) = self._limit.as_ref() {
9958            params.push("limit", value.to_string());
9959        }
9960        if let Some(value) = self._language_code.as_ref() {
9961            params.push("languageCode", value);
9962        }
9963        if !self._filters.is_empty() {
9964            for f in self._filters.iter() {
9965                params.push("filters", f);
9966            }
9967        }
9968        if let Some(value) = self._end_date_year.as_ref() {
9969            params.push("endDate.year", value.to_string());
9970        }
9971        if let Some(value) = self._end_date_month.as_ref() {
9972            params.push("endDate.month", value.to_string());
9973        }
9974        if let Some(value) = self._end_date_day.as_ref() {
9975            params.push("endDate.day", value.to_string());
9976        }
9977        if !self._dimensions.is_empty() {
9978            for f in self._dimensions.iter() {
9979                params.push("dimensions", f);
9980            }
9981        }
9982        if let Some(value) = self._date_range.as_ref() {
9983            params.push("dateRange", value);
9984        }
9985        if let Some(value) = self._currency_code.as_ref() {
9986            params.push("currencyCode", value);
9987        }
9988
9989        params.extend(self._additional_params.iter());
9990
9991        params.push("alt", "json");
9992        let mut url = self.hub._base_url.clone() + "v2/{+account}/reports:generateCsv";
9993        if self._scopes.is_empty() {
9994            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9995        }
9996
9997        #[allow(clippy::single_element_loop)]
9998        for &(find_this, param_name) in [("{+account}", "account")].iter() {
9999            url = params.uri_replacement(url, param_name, find_this, true);
10000        }
10001        {
10002            let to_remove = ["account"];
10003            params.remove_params(&to_remove);
10004        }
10005
10006        let url = params.parse_with_url(&url);
10007
10008        loop {
10009            let token = match self
10010                .hub
10011                .auth
10012                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10013                .await
10014            {
10015                Ok(token) => token,
10016                Err(e) => match dlg.token(e) {
10017                    Ok(token) => token,
10018                    Err(e) => {
10019                        dlg.finished(false);
10020                        return Err(common::Error::MissingToken(e));
10021                    }
10022                },
10023            };
10024            let mut req_result = {
10025                let client = &self.hub.client;
10026                dlg.pre_request();
10027                let mut req_builder = hyper::Request::builder()
10028                    .method(hyper::Method::GET)
10029                    .uri(url.as_str())
10030                    .header(USER_AGENT, self.hub._user_agent.clone());
10031
10032                if let Some(token) = token.as_ref() {
10033                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10034                }
10035
10036                let request = req_builder
10037                    .header(CONTENT_LENGTH, 0_u64)
10038                    .body(common::to_body::<String>(None));
10039
10040                client.request(request.unwrap()).await
10041            };
10042
10043            match req_result {
10044                Err(err) => {
10045                    if let common::Retry::After(d) = dlg.http_error(&err) {
10046                        sleep(d).await;
10047                        continue;
10048                    }
10049                    dlg.finished(false);
10050                    return Err(common::Error::HttpError(err));
10051                }
10052                Ok(res) => {
10053                    let (mut parts, body) = res.into_parts();
10054                    let mut body = common::Body::new(body);
10055                    if !parts.status.is_success() {
10056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10057                        let error = serde_json::from_str(&common::to_string(&bytes));
10058                        let response = common::to_response(parts, bytes.into());
10059
10060                        if let common::Retry::After(d) =
10061                            dlg.http_failure(&response, error.as_ref().ok())
10062                        {
10063                            sleep(d).await;
10064                            continue;
10065                        }
10066
10067                        dlg.finished(false);
10068
10069                        return Err(match error {
10070                            Ok(value) => common::Error::BadRequest(value),
10071                            _ => common::Error::Failure(response),
10072                        });
10073                    }
10074                    let response = {
10075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10076                        let encoded = common::to_string(&bytes);
10077                        match serde_json::from_str(&encoded) {
10078                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10079                            Err(error) => {
10080                                dlg.response_json_decode_error(&encoded, &error);
10081                                return Err(common::Error::JsonDecodeError(
10082                                    encoded.to_string(),
10083                                    error,
10084                                ));
10085                            }
10086                        }
10087                    };
10088
10089                    dlg.finished(true);
10090                    return Ok(response);
10091                }
10092            }
10093        }
10094    }
10095
10096    /// Required. The account which owns the collection of reports. Format: accounts/{account}
10097    ///
10098    /// Sets the *account* path property to the given value.
10099    ///
10100    /// Even though the property as already been set when instantiating this call,
10101    /// we provide this method for API completeness.
10102    pub fn account(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10103        self._account = new_value.to_string();
10104        self
10105    }
10106    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
10107    ///
10108    /// Sets the *start date.year* query property to the given value.
10109    pub fn start_date_year(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10110        self._start_date_year = Some(new_value);
10111        self
10112    }
10113    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
10114    ///
10115    /// Sets the *start date.month* query property to the given value.
10116    pub fn start_date_month(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10117        self._start_date_month = Some(new_value);
10118        self
10119    }
10120    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
10121    ///
10122    /// Sets the *start date.day* query property to the given value.
10123    pub fn start_date_day(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10124        self._start_date_day = Some(new_value);
10125        self
10126    }
10127    /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
10128    ///
10129    /// Sets the *reporting time zone* query property to the given value.
10130    pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10131        self._reporting_time_zone = Some(new_value.to_string());
10132        self
10133    }
10134    /// The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
10135    ///
10136    /// Append the given value to the *order by* query property.
10137    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10138    pub fn add_order_by(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10139        self._order_by.push(new_value.to_string());
10140        self
10141    }
10142    /// Required. Reporting metrics.
10143    ///
10144    /// Append the given value to the *metrics* query property.
10145    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10146    pub fn add_metrics(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10147        self._metrics.push(new_value.to_string());
10148        self
10149    }
10150    /// The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
10151    ///
10152    /// Sets the *limit* query property to the given value.
10153    pub fn limit(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10154        self._limit = Some(new_value);
10155        self
10156    }
10157    /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
10158    ///
10159    /// Sets the *language code* query property to the given value.
10160    pub fn language_code(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10161        self._language_code = Some(new_value.to_string());
10162        self
10163    }
10164    /// A list of [filters](https://developers.google.com/adsense/management/reporting/filtering) to apply to the report. All provided filters must match in order for the data to be included in the report.
10165    ///
10166    /// Append the given value to the *filters* query property.
10167    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10168    pub fn add_filters(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10169        self._filters.push(new_value.to_string());
10170        self
10171    }
10172    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
10173    ///
10174    /// Sets the *end date.year* query property to the given value.
10175    pub fn end_date_year(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10176        self._end_date_year = Some(new_value);
10177        self
10178    }
10179    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
10180    ///
10181    /// Sets the *end date.month* query property to the given value.
10182    pub fn end_date_month(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10183        self._end_date_month = Some(new_value);
10184        self
10185    }
10186    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
10187    ///
10188    /// Sets the *end date.day* query property to the given value.
10189    pub fn end_date_day(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10190        self._end_date_day = Some(new_value);
10191        self
10192    }
10193    /// Dimensions to base the report on.
10194    ///
10195    /// Append the given value to the *dimensions* query property.
10196    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10197    pub fn add_dimensions(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10198        self._dimensions.push(new_value.to_string());
10199        self
10200    }
10201    /// Date range of the report, if unset the range will be considered CUSTOM.
10202    ///
10203    /// Sets the *date range* query property to the given value.
10204    pub fn date_range(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10205        self._date_range = Some(new_value.to_string());
10206        self
10207    }
10208    /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
10209    ///
10210    /// Sets the *currency code* query property to the given value.
10211    pub fn currency_code(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10212        self._currency_code = Some(new_value.to_string());
10213        self
10214    }
10215    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10216    /// while executing the actual API request.
10217    ///
10218    /// ````text
10219    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10220    /// ````
10221    ///
10222    /// Sets the *delegate* property to the given value.
10223    pub fn delegate(
10224        mut self,
10225        new_value: &'a mut dyn common::Delegate,
10226    ) -> AccountReportGenerateCsvCall<'a, C> {
10227        self._delegate = Some(new_value);
10228        self
10229    }
10230
10231    /// Set any additional parameter of the query string used in the request.
10232    /// It should be used to set parameters which are not yet available through their own
10233    /// setters.
10234    ///
10235    /// Please note that this method must not be used to set any of the known parameters
10236    /// which have their own setter method. If done anyway, the request will fail.
10237    ///
10238    /// # Additional Parameters
10239    ///
10240    /// * *$.xgafv* (query-string) - V1 error format.
10241    /// * *access_token* (query-string) - OAuth access token.
10242    /// * *alt* (query-string) - Data format for response.
10243    /// * *callback* (query-string) - JSONP
10244    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10245    /// * *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.
10246    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10247    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10248    /// * *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.
10249    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10250    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10251    pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCsvCall<'a, C>
10252    where
10253        T: AsRef<str>,
10254    {
10255        self._additional_params
10256            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10257        self
10258    }
10259
10260    /// Identifies the authorization scope for the method you are building.
10261    ///
10262    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10263    /// [`Scope::Readonly`].
10264    ///
10265    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10266    /// tokens for more than one scope.
10267    ///
10268    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10269    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10270    /// sufficient, a read-write scope will do as well.
10271    pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCsvCall<'a, C>
10272    where
10273        St: AsRef<str>,
10274    {
10275        self._scopes.insert(String::from(scope.as_ref()));
10276        self
10277    }
10278    /// Identifies the authorization scope(s) for the method you are building.
10279    ///
10280    /// See [`Self::add_scope()`] for details.
10281    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCsvCall<'a, C>
10282    where
10283        I: IntoIterator<Item = St>,
10284        St: AsRef<str>,
10285    {
10286        self._scopes
10287            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10288        self
10289    }
10290
10291    /// Removes all scopes, and no default scope will be used either.
10292    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10293    /// for details).
10294    pub fn clear_scopes(mut self) -> AccountReportGenerateCsvCall<'a, C> {
10295        self._scopes.clear();
10296        self
10297    }
10298}
10299
10300/// Gets the saved report from the given resource name.
10301///
10302/// A builder for the *reports.getSaved* method supported by a *account* resource.
10303/// It is not used directly, but through a [`AccountMethods`] instance.
10304///
10305/// # Example
10306///
10307/// Instantiate a resource method builder
10308///
10309/// ```test_harness,no_run
10310/// # extern crate hyper;
10311/// # extern crate hyper_rustls;
10312/// # extern crate google_adsense2 as adsense2;
10313/// # async fn dox() {
10314/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10315///
10316/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10317/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10318/// #     secret,
10319/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10320/// # ).build().await.unwrap();
10321///
10322/// # let client = hyper_util::client::legacy::Client::builder(
10323/// #     hyper_util::rt::TokioExecutor::new()
10324/// # )
10325/// # .build(
10326/// #     hyper_rustls::HttpsConnectorBuilder::new()
10327/// #         .with_native_roots()
10328/// #         .unwrap()
10329/// #         .https_or_http()
10330/// #         .enable_http1()
10331/// #         .build()
10332/// # );
10333/// # let mut hub = Adsense::new(client, auth);
10334/// // You can configure optional parameters by calling the respective setters at will, and
10335/// // execute the final call using `doit()`.
10336/// // Values shown here are possibly random and not representative !
10337/// let result = hub.accounts().reports_get_saved("name")
10338///              .doit().await;
10339/// # }
10340/// ```
10341pub struct AccountReportGetSavedCall<'a, C>
10342where
10343    C: 'a,
10344{
10345    hub: &'a Adsense<C>,
10346    _name: String,
10347    _delegate: Option<&'a mut dyn common::Delegate>,
10348    _additional_params: HashMap<String, String>,
10349    _scopes: BTreeSet<String>,
10350}
10351
10352impl<'a, C> common::CallBuilder for AccountReportGetSavedCall<'a, C> {}
10353
10354impl<'a, C> AccountReportGetSavedCall<'a, C>
10355where
10356    C: common::Connector,
10357{
10358    /// Perform the operation you have build so far.
10359    pub async fn doit(mut self) -> common::Result<(common::Response, SavedReport)> {
10360        use std::borrow::Cow;
10361        use std::io::{Read, Seek};
10362
10363        use common::{url::Params, ToParts};
10364        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10365
10366        let mut dd = common::DefaultDelegate;
10367        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10368        dlg.begin(common::MethodInfo {
10369            id: "adsense.accounts.reports.getSaved",
10370            http_method: hyper::Method::GET,
10371        });
10372
10373        for &field in ["alt", "name"].iter() {
10374            if self._additional_params.contains_key(field) {
10375                dlg.finished(false);
10376                return Err(common::Error::FieldClash(field));
10377            }
10378        }
10379
10380        let mut params = Params::with_capacity(3 + self._additional_params.len());
10381        params.push("name", self._name);
10382
10383        params.extend(self._additional_params.iter());
10384
10385        params.push("alt", "json");
10386        let mut url = self.hub._base_url.clone() + "v2/{+name}/saved";
10387        if self._scopes.is_empty() {
10388            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10389        }
10390
10391        #[allow(clippy::single_element_loop)]
10392        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10393            url = params.uri_replacement(url, param_name, find_this, true);
10394        }
10395        {
10396            let to_remove = ["name"];
10397            params.remove_params(&to_remove);
10398        }
10399
10400        let url = params.parse_with_url(&url);
10401
10402        loop {
10403            let token = match self
10404                .hub
10405                .auth
10406                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10407                .await
10408            {
10409                Ok(token) => token,
10410                Err(e) => match dlg.token(e) {
10411                    Ok(token) => token,
10412                    Err(e) => {
10413                        dlg.finished(false);
10414                        return Err(common::Error::MissingToken(e));
10415                    }
10416                },
10417            };
10418            let mut req_result = {
10419                let client = &self.hub.client;
10420                dlg.pre_request();
10421                let mut req_builder = hyper::Request::builder()
10422                    .method(hyper::Method::GET)
10423                    .uri(url.as_str())
10424                    .header(USER_AGENT, self.hub._user_agent.clone());
10425
10426                if let Some(token) = token.as_ref() {
10427                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10428                }
10429
10430                let request = req_builder
10431                    .header(CONTENT_LENGTH, 0_u64)
10432                    .body(common::to_body::<String>(None));
10433
10434                client.request(request.unwrap()).await
10435            };
10436
10437            match req_result {
10438                Err(err) => {
10439                    if let common::Retry::After(d) = dlg.http_error(&err) {
10440                        sleep(d).await;
10441                        continue;
10442                    }
10443                    dlg.finished(false);
10444                    return Err(common::Error::HttpError(err));
10445                }
10446                Ok(res) => {
10447                    let (mut parts, body) = res.into_parts();
10448                    let mut body = common::Body::new(body);
10449                    if !parts.status.is_success() {
10450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10451                        let error = serde_json::from_str(&common::to_string(&bytes));
10452                        let response = common::to_response(parts, bytes.into());
10453
10454                        if let common::Retry::After(d) =
10455                            dlg.http_failure(&response, error.as_ref().ok())
10456                        {
10457                            sleep(d).await;
10458                            continue;
10459                        }
10460
10461                        dlg.finished(false);
10462
10463                        return Err(match error {
10464                            Ok(value) => common::Error::BadRequest(value),
10465                            _ => common::Error::Failure(response),
10466                        });
10467                    }
10468                    let response = {
10469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10470                        let encoded = common::to_string(&bytes);
10471                        match serde_json::from_str(&encoded) {
10472                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10473                            Err(error) => {
10474                                dlg.response_json_decode_error(&encoded, &error);
10475                                return Err(common::Error::JsonDecodeError(
10476                                    encoded.to_string(),
10477                                    error,
10478                                ));
10479                            }
10480                        }
10481                    };
10482
10483                    dlg.finished(true);
10484                    return Ok(response);
10485                }
10486            }
10487        }
10488    }
10489
10490    /// Required. The name of the saved report to retrieve. Format: accounts/{account}/reports/{report}
10491    ///
10492    /// Sets the *name* path property to the given value.
10493    ///
10494    /// Even though the property as already been set when instantiating this call,
10495    /// we provide this method for API completeness.
10496    pub fn name(mut self, new_value: &str) -> AccountReportGetSavedCall<'a, C> {
10497        self._name = new_value.to_string();
10498        self
10499    }
10500    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10501    /// while executing the actual API request.
10502    ///
10503    /// ````text
10504    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10505    /// ````
10506    ///
10507    /// Sets the *delegate* property to the given value.
10508    pub fn delegate(
10509        mut self,
10510        new_value: &'a mut dyn common::Delegate,
10511    ) -> AccountReportGetSavedCall<'a, C> {
10512        self._delegate = Some(new_value);
10513        self
10514    }
10515
10516    /// Set any additional parameter of the query string used in the request.
10517    /// It should be used to set parameters which are not yet available through their own
10518    /// setters.
10519    ///
10520    /// Please note that this method must not be used to set any of the known parameters
10521    /// which have their own setter method. If done anyway, the request will fail.
10522    ///
10523    /// # Additional Parameters
10524    ///
10525    /// * *$.xgafv* (query-string) - V1 error format.
10526    /// * *access_token* (query-string) - OAuth access token.
10527    /// * *alt* (query-string) - Data format for response.
10528    /// * *callback* (query-string) - JSONP
10529    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10530    /// * *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.
10531    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10532    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10533    /// * *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.
10534    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10535    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10536    pub fn param<T>(mut self, name: T, value: T) -> AccountReportGetSavedCall<'a, C>
10537    where
10538        T: AsRef<str>,
10539    {
10540        self._additional_params
10541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10542        self
10543    }
10544
10545    /// Identifies the authorization scope for the method you are building.
10546    ///
10547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10548    /// [`Scope::Readonly`].
10549    ///
10550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10551    /// tokens for more than one scope.
10552    ///
10553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10555    /// sufficient, a read-write scope will do as well.
10556    pub fn add_scope<St>(mut self, scope: St) -> AccountReportGetSavedCall<'a, C>
10557    where
10558        St: AsRef<str>,
10559    {
10560        self._scopes.insert(String::from(scope.as_ref()));
10561        self
10562    }
10563    /// Identifies the authorization scope(s) for the method you are building.
10564    ///
10565    /// See [`Self::add_scope()`] for details.
10566    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGetSavedCall<'a, C>
10567    where
10568        I: IntoIterator<Item = St>,
10569        St: AsRef<str>,
10570    {
10571        self._scopes
10572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10573        self
10574    }
10575
10576    /// Removes all scopes, and no default scope will be used either.
10577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10578    /// for details).
10579    pub fn clear_scopes(mut self) -> AccountReportGetSavedCall<'a, C> {
10580        self._scopes.clear();
10581        self
10582    }
10583}
10584
10585/// Gets information about the selected site.
10586///
10587/// A builder for the *sites.get* method supported by a *account* resource.
10588/// It is not used directly, but through a [`AccountMethods`] instance.
10589///
10590/// # Example
10591///
10592/// Instantiate a resource method builder
10593///
10594/// ```test_harness,no_run
10595/// # extern crate hyper;
10596/// # extern crate hyper_rustls;
10597/// # extern crate google_adsense2 as adsense2;
10598/// # async fn dox() {
10599/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10600///
10601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10602/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10603/// #     secret,
10604/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10605/// # ).build().await.unwrap();
10606///
10607/// # let client = hyper_util::client::legacy::Client::builder(
10608/// #     hyper_util::rt::TokioExecutor::new()
10609/// # )
10610/// # .build(
10611/// #     hyper_rustls::HttpsConnectorBuilder::new()
10612/// #         .with_native_roots()
10613/// #         .unwrap()
10614/// #         .https_or_http()
10615/// #         .enable_http1()
10616/// #         .build()
10617/// # );
10618/// # let mut hub = Adsense::new(client, auth);
10619/// // You can configure optional parameters by calling the respective setters at will, and
10620/// // execute the final call using `doit()`.
10621/// // Values shown here are possibly random and not representative !
10622/// let result = hub.accounts().sites_get("name")
10623///              .doit().await;
10624/// # }
10625/// ```
10626pub struct AccountSiteGetCall<'a, C>
10627where
10628    C: 'a,
10629{
10630    hub: &'a Adsense<C>,
10631    _name: String,
10632    _delegate: Option<&'a mut dyn common::Delegate>,
10633    _additional_params: HashMap<String, String>,
10634    _scopes: BTreeSet<String>,
10635}
10636
10637impl<'a, C> common::CallBuilder for AccountSiteGetCall<'a, C> {}
10638
10639impl<'a, C> AccountSiteGetCall<'a, C>
10640where
10641    C: common::Connector,
10642{
10643    /// Perform the operation you have build so far.
10644    pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
10645        use std::borrow::Cow;
10646        use std::io::{Read, Seek};
10647
10648        use common::{url::Params, ToParts};
10649        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10650
10651        let mut dd = common::DefaultDelegate;
10652        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10653        dlg.begin(common::MethodInfo {
10654            id: "adsense.accounts.sites.get",
10655            http_method: hyper::Method::GET,
10656        });
10657
10658        for &field in ["alt", "name"].iter() {
10659            if self._additional_params.contains_key(field) {
10660                dlg.finished(false);
10661                return Err(common::Error::FieldClash(field));
10662            }
10663        }
10664
10665        let mut params = Params::with_capacity(3 + self._additional_params.len());
10666        params.push("name", self._name);
10667
10668        params.extend(self._additional_params.iter());
10669
10670        params.push("alt", "json");
10671        let mut url = self.hub._base_url.clone() + "v2/{+name}";
10672        if self._scopes.is_empty() {
10673            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10674        }
10675
10676        #[allow(clippy::single_element_loop)]
10677        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10678            url = params.uri_replacement(url, param_name, find_this, true);
10679        }
10680        {
10681            let to_remove = ["name"];
10682            params.remove_params(&to_remove);
10683        }
10684
10685        let url = params.parse_with_url(&url);
10686
10687        loop {
10688            let token = match self
10689                .hub
10690                .auth
10691                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10692                .await
10693            {
10694                Ok(token) => token,
10695                Err(e) => match dlg.token(e) {
10696                    Ok(token) => token,
10697                    Err(e) => {
10698                        dlg.finished(false);
10699                        return Err(common::Error::MissingToken(e));
10700                    }
10701                },
10702            };
10703            let mut req_result = {
10704                let client = &self.hub.client;
10705                dlg.pre_request();
10706                let mut req_builder = hyper::Request::builder()
10707                    .method(hyper::Method::GET)
10708                    .uri(url.as_str())
10709                    .header(USER_AGENT, self.hub._user_agent.clone());
10710
10711                if let Some(token) = token.as_ref() {
10712                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10713                }
10714
10715                let request = req_builder
10716                    .header(CONTENT_LENGTH, 0_u64)
10717                    .body(common::to_body::<String>(None));
10718
10719                client.request(request.unwrap()).await
10720            };
10721
10722            match req_result {
10723                Err(err) => {
10724                    if let common::Retry::After(d) = dlg.http_error(&err) {
10725                        sleep(d).await;
10726                        continue;
10727                    }
10728                    dlg.finished(false);
10729                    return Err(common::Error::HttpError(err));
10730                }
10731                Ok(res) => {
10732                    let (mut parts, body) = res.into_parts();
10733                    let mut body = common::Body::new(body);
10734                    if !parts.status.is_success() {
10735                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10736                        let error = serde_json::from_str(&common::to_string(&bytes));
10737                        let response = common::to_response(parts, bytes.into());
10738
10739                        if let common::Retry::After(d) =
10740                            dlg.http_failure(&response, error.as_ref().ok())
10741                        {
10742                            sleep(d).await;
10743                            continue;
10744                        }
10745
10746                        dlg.finished(false);
10747
10748                        return Err(match error {
10749                            Ok(value) => common::Error::BadRequest(value),
10750                            _ => common::Error::Failure(response),
10751                        });
10752                    }
10753                    let response = {
10754                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10755                        let encoded = common::to_string(&bytes);
10756                        match serde_json::from_str(&encoded) {
10757                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10758                            Err(error) => {
10759                                dlg.response_json_decode_error(&encoded, &error);
10760                                return Err(common::Error::JsonDecodeError(
10761                                    encoded.to_string(),
10762                                    error,
10763                                ));
10764                            }
10765                        }
10766                    };
10767
10768                    dlg.finished(true);
10769                    return Ok(response);
10770                }
10771            }
10772        }
10773    }
10774
10775    /// Required. Name of the site. Format: accounts/{account}/sites/{site}
10776    ///
10777    /// Sets the *name* path property to the given value.
10778    ///
10779    /// Even though the property as already been set when instantiating this call,
10780    /// we provide this method for API completeness.
10781    pub fn name(mut self, new_value: &str) -> AccountSiteGetCall<'a, C> {
10782        self._name = new_value.to_string();
10783        self
10784    }
10785    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10786    /// while executing the actual API request.
10787    ///
10788    /// ````text
10789    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10790    /// ````
10791    ///
10792    /// Sets the *delegate* property to the given value.
10793    pub fn delegate(
10794        mut self,
10795        new_value: &'a mut dyn common::Delegate,
10796    ) -> AccountSiteGetCall<'a, C> {
10797        self._delegate = Some(new_value);
10798        self
10799    }
10800
10801    /// Set any additional parameter of the query string used in the request.
10802    /// It should be used to set parameters which are not yet available through their own
10803    /// setters.
10804    ///
10805    /// Please note that this method must not be used to set any of the known parameters
10806    /// which have their own setter method. If done anyway, the request will fail.
10807    ///
10808    /// # Additional Parameters
10809    ///
10810    /// * *$.xgafv* (query-string) - V1 error format.
10811    /// * *access_token* (query-string) - OAuth access token.
10812    /// * *alt* (query-string) - Data format for response.
10813    /// * *callback* (query-string) - JSONP
10814    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10815    /// * *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.
10816    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10817    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10818    /// * *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.
10819    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10820    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10821    pub fn param<T>(mut self, name: T, value: T) -> AccountSiteGetCall<'a, C>
10822    where
10823        T: AsRef<str>,
10824    {
10825        self._additional_params
10826            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10827        self
10828    }
10829
10830    /// Identifies the authorization scope for the method you are building.
10831    ///
10832    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10833    /// [`Scope::Readonly`].
10834    ///
10835    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10836    /// tokens for more than one scope.
10837    ///
10838    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10839    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10840    /// sufficient, a read-write scope will do as well.
10841    pub fn add_scope<St>(mut self, scope: St) -> AccountSiteGetCall<'a, C>
10842    where
10843        St: AsRef<str>,
10844    {
10845        self._scopes.insert(String::from(scope.as_ref()));
10846        self
10847    }
10848    /// Identifies the authorization scope(s) for the method you are building.
10849    ///
10850    /// See [`Self::add_scope()`] for details.
10851    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSiteGetCall<'a, C>
10852    where
10853        I: IntoIterator<Item = St>,
10854        St: AsRef<str>,
10855    {
10856        self._scopes
10857            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10858        self
10859    }
10860
10861    /// Removes all scopes, and no default scope will be used either.
10862    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10863    /// for details).
10864    pub fn clear_scopes(mut self) -> AccountSiteGetCall<'a, C> {
10865        self._scopes.clear();
10866        self
10867    }
10868}
10869
10870/// Lists all the sites available in an account.
10871///
10872/// A builder for the *sites.list* method supported by a *account* resource.
10873/// It is not used directly, but through a [`AccountMethods`] instance.
10874///
10875/// # Example
10876///
10877/// Instantiate a resource method builder
10878///
10879/// ```test_harness,no_run
10880/// # extern crate hyper;
10881/// # extern crate hyper_rustls;
10882/// # extern crate google_adsense2 as adsense2;
10883/// # async fn dox() {
10884/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10885///
10886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10887/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10888/// #     secret,
10889/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10890/// # ).build().await.unwrap();
10891///
10892/// # let client = hyper_util::client::legacy::Client::builder(
10893/// #     hyper_util::rt::TokioExecutor::new()
10894/// # )
10895/// # .build(
10896/// #     hyper_rustls::HttpsConnectorBuilder::new()
10897/// #         .with_native_roots()
10898/// #         .unwrap()
10899/// #         .https_or_http()
10900/// #         .enable_http1()
10901/// #         .build()
10902/// # );
10903/// # let mut hub = Adsense::new(client, auth);
10904/// // You can configure optional parameters by calling the respective setters at will, and
10905/// // execute the final call using `doit()`.
10906/// // Values shown here are possibly random and not representative !
10907/// let result = hub.accounts().sites_list("parent")
10908///              .page_token("sit")
10909///              .page_size(-93)
10910///              .doit().await;
10911/// # }
10912/// ```
10913pub struct AccountSiteListCall<'a, C>
10914where
10915    C: 'a,
10916{
10917    hub: &'a Adsense<C>,
10918    _parent: String,
10919    _page_token: Option<String>,
10920    _page_size: Option<i32>,
10921    _delegate: Option<&'a mut dyn common::Delegate>,
10922    _additional_params: HashMap<String, String>,
10923    _scopes: BTreeSet<String>,
10924}
10925
10926impl<'a, C> common::CallBuilder for AccountSiteListCall<'a, C> {}
10927
10928impl<'a, C> AccountSiteListCall<'a, C>
10929where
10930    C: common::Connector,
10931{
10932    /// Perform the operation you have build so far.
10933    pub async fn doit(mut self) -> common::Result<(common::Response, ListSitesResponse)> {
10934        use std::borrow::Cow;
10935        use std::io::{Read, Seek};
10936
10937        use common::{url::Params, ToParts};
10938        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10939
10940        let mut dd = common::DefaultDelegate;
10941        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10942        dlg.begin(common::MethodInfo {
10943            id: "adsense.accounts.sites.list",
10944            http_method: hyper::Method::GET,
10945        });
10946
10947        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10948            if self._additional_params.contains_key(field) {
10949                dlg.finished(false);
10950                return Err(common::Error::FieldClash(field));
10951            }
10952        }
10953
10954        let mut params = Params::with_capacity(5 + self._additional_params.len());
10955        params.push("parent", self._parent);
10956        if let Some(value) = self._page_token.as_ref() {
10957            params.push("pageToken", value);
10958        }
10959        if let Some(value) = self._page_size.as_ref() {
10960            params.push("pageSize", value.to_string());
10961        }
10962
10963        params.extend(self._additional_params.iter());
10964
10965        params.push("alt", "json");
10966        let mut url = self.hub._base_url.clone() + "v2/{+parent}/sites";
10967        if self._scopes.is_empty() {
10968            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10969        }
10970
10971        #[allow(clippy::single_element_loop)]
10972        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10973            url = params.uri_replacement(url, param_name, find_this, true);
10974        }
10975        {
10976            let to_remove = ["parent"];
10977            params.remove_params(&to_remove);
10978        }
10979
10980        let url = params.parse_with_url(&url);
10981
10982        loop {
10983            let token = match self
10984                .hub
10985                .auth
10986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10987                .await
10988            {
10989                Ok(token) => token,
10990                Err(e) => match dlg.token(e) {
10991                    Ok(token) => token,
10992                    Err(e) => {
10993                        dlg.finished(false);
10994                        return Err(common::Error::MissingToken(e));
10995                    }
10996                },
10997            };
10998            let mut req_result = {
10999                let client = &self.hub.client;
11000                dlg.pre_request();
11001                let mut req_builder = hyper::Request::builder()
11002                    .method(hyper::Method::GET)
11003                    .uri(url.as_str())
11004                    .header(USER_AGENT, self.hub._user_agent.clone());
11005
11006                if let Some(token) = token.as_ref() {
11007                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11008                }
11009
11010                let request = req_builder
11011                    .header(CONTENT_LENGTH, 0_u64)
11012                    .body(common::to_body::<String>(None));
11013
11014                client.request(request.unwrap()).await
11015            };
11016
11017            match req_result {
11018                Err(err) => {
11019                    if let common::Retry::After(d) = dlg.http_error(&err) {
11020                        sleep(d).await;
11021                        continue;
11022                    }
11023                    dlg.finished(false);
11024                    return Err(common::Error::HttpError(err));
11025                }
11026                Ok(res) => {
11027                    let (mut parts, body) = res.into_parts();
11028                    let mut body = common::Body::new(body);
11029                    if !parts.status.is_success() {
11030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11031                        let error = serde_json::from_str(&common::to_string(&bytes));
11032                        let response = common::to_response(parts, bytes.into());
11033
11034                        if let common::Retry::After(d) =
11035                            dlg.http_failure(&response, error.as_ref().ok())
11036                        {
11037                            sleep(d).await;
11038                            continue;
11039                        }
11040
11041                        dlg.finished(false);
11042
11043                        return Err(match error {
11044                            Ok(value) => common::Error::BadRequest(value),
11045                            _ => common::Error::Failure(response),
11046                        });
11047                    }
11048                    let response = {
11049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11050                        let encoded = common::to_string(&bytes);
11051                        match serde_json::from_str(&encoded) {
11052                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11053                            Err(error) => {
11054                                dlg.response_json_decode_error(&encoded, &error);
11055                                return Err(common::Error::JsonDecodeError(
11056                                    encoded.to_string(),
11057                                    error,
11058                                ));
11059                            }
11060                        }
11061                    };
11062
11063                    dlg.finished(true);
11064                    return Ok(response);
11065                }
11066            }
11067        }
11068    }
11069
11070    /// Required. The account which owns the collection of sites. Format: accounts/{account}
11071    ///
11072    /// Sets the *parent* path property to the given value.
11073    ///
11074    /// Even though the property as already been set when instantiating this call,
11075    /// we provide this method for API completeness.
11076    pub fn parent(mut self, new_value: &str) -> AccountSiteListCall<'a, C> {
11077        self._parent = new_value.to_string();
11078        self
11079    }
11080    /// A page token, received from a previous `ListSites` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSites` must match the call that provided the page token.
11081    ///
11082    /// Sets the *page token* query property to the given value.
11083    pub fn page_token(mut self, new_value: &str) -> AccountSiteListCall<'a, C> {
11084        self._page_token = Some(new_value.to_string());
11085        self
11086    }
11087    /// The maximum number of sites to include in the response, used for paging. If unspecified, at most 10000 sites will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
11088    ///
11089    /// Sets the *page size* query property to the given value.
11090    pub fn page_size(mut self, new_value: i32) -> AccountSiteListCall<'a, C> {
11091        self._page_size = Some(new_value);
11092        self
11093    }
11094    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11095    /// while executing the actual API request.
11096    ///
11097    /// ````text
11098    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11099    /// ````
11100    ///
11101    /// Sets the *delegate* property to the given value.
11102    pub fn delegate(
11103        mut self,
11104        new_value: &'a mut dyn common::Delegate,
11105    ) -> AccountSiteListCall<'a, C> {
11106        self._delegate = Some(new_value);
11107        self
11108    }
11109
11110    /// Set any additional parameter of the query string used in the request.
11111    /// It should be used to set parameters which are not yet available through their own
11112    /// setters.
11113    ///
11114    /// Please note that this method must not be used to set any of the known parameters
11115    /// which have their own setter method. If done anyway, the request will fail.
11116    ///
11117    /// # Additional Parameters
11118    ///
11119    /// * *$.xgafv* (query-string) - V1 error format.
11120    /// * *access_token* (query-string) - OAuth access token.
11121    /// * *alt* (query-string) - Data format for response.
11122    /// * *callback* (query-string) - JSONP
11123    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11124    /// * *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.
11125    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11126    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11127    /// * *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.
11128    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11129    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11130    pub fn param<T>(mut self, name: T, value: T) -> AccountSiteListCall<'a, C>
11131    where
11132        T: AsRef<str>,
11133    {
11134        self._additional_params
11135            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11136        self
11137    }
11138
11139    /// Identifies the authorization scope for the method you are building.
11140    ///
11141    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11142    /// [`Scope::Readonly`].
11143    ///
11144    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11145    /// tokens for more than one scope.
11146    ///
11147    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11148    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11149    /// sufficient, a read-write scope will do as well.
11150    pub fn add_scope<St>(mut self, scope: St) -> AccountSiteListCall<'a, C>
11151    where
11152        St: AsRef<str>,
11153    {
11154        self._scopes.insert(String::from(scope.as_ref()));
11155        self
11156    }
11157    /// Identifies the authorization scope(s) for the method you are building.
11158    ///
11159    /// See [`Self::add_scope()`] for details.
11160    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSiteListCall<'a, C>
11161    where
11162        I: IntoIterator<Item = St>,
11163        St: AsRef<str>,
11164    {
11165        self._scopes
11166            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11167        self
11168    }
11169
11170    /// Removes all scopes, and no default scope will be used either.
11171    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11172    /// for details).
11173    pub fn clear_scopes(mut self) -> AccountSiteListCall<'a, C> {
11174        self._scopes.clear();
11175        self
11176    }
11177}
11178
11179/// Gets information about the selected AdSense account.
11180///
11181/// A builder for the *get* method supported by a *account* resource.
11182/// It is not used directly, but through a [`AccountMethods`] instance.
11183///
11184/// # Example
11185///
11186/// Instantiate a resource method builder
11187///
11188/// ```test_harness,no_run
11189/// # extern crate hyper;
11190/// # extern crate hyper_rustls;
11191/// # extern crate google_adsense2 as adsense2;
11192/// # async fn dox() {
11193/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11194///
11195/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11196/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11197/// #     secret,
11198/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11199/// # ).build().await.unwrap();
11200///
11201/// # let client = hyper_util::client::legacy::Client::builder(
11202/// #     hyper_util::rt::TokioExecutor::new()
11203/// # )
11204/// # .build(
11205/// #     hyper_rustls::HttpsConnectorBuilder::new()
11206/// #         .with_native_roots()
11207/// #         .unwrap()
11208/// #         .https_or_http()
11209/// #         .enable_http1()
11210/// #         .build()
11211/// # );
11212/// # let mut hub = Adsense::new(client, auth);
11213/// // You can configure optional parameters by calling the respective setters at will, and
11214/// // execute the final call using `doit()`.
11215/// // Values shown here are possibly random and not representative !
11216/// let result = hub.accounts().get("name")
11217///              .doit().await;
11218/// # }
11219/// ```
11220pub struct AccountGetCall<'a, C>
11221where
11222    C: 'a,
11223{
11224    hub: &'a Adsense<C>,
11225    _name: String,
11226    _delegate: Option<&'a mut dyn common::Delegate>,
11227    _additional_params: HashMap<String, String>,
11228    _scopes: BTreeSet<String>,
11229}
11230
11231impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
11232
11233impl<'a, C> AccountGetCall<'a, C>
11234where
11235    C: common::Connector,
11236{
11237    /// Perform the operation you have build so far.
11238    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
11239        use std::borrow::Cow;
11240        use std::io::{Read, Seek};
11241
11242        use common::{url::Params, ToParts};
11243        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11244
11245        let mut dd = common::DefaultDelegate;
11246        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11247        dlg.begin(common::MethodInfo {
11248            id: "adsense.accounts.get",
11249            http_method: hyper::Method::GET,
11250        });
11251
11252        for &field in ["alt", "name"].iter() {
11253            if self._additional_params.contains_key(field) {
11254                dlg.finished(false);
11255                return Err(common::Error::FieldClash(field));
11256            }
11257        }
11258
11259        let mut params = Params::with_capacity(3 + self._additional_params.len());
11260        params.push("name", self._name);
11261
11262        params.extend(self._additional_params.iter());
11263
11264        params.push("alt", "json");
11265        let mut url = self.hub._base_url.clone() + "v2/{+name}";
11266        if self._scopes.is_empty() {
11267            self._scopes.insert(Scope::Readonly.as_ref().to_string());
11268        }
11269
11270        #[allow(clippy::single_element_loop)]
11271        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11272            url = params.uri_replacement(url, param_name, find_this, true);
11273        }
11274        {
11275            let to_remove = ["name"];
11276            params.remove_params(&to_remove);
11277        }
11278
11279        let url = params.parse_with_url(&url);
11280
11281        loop {
11282            let token = match self
11283                .hub
11284                .auth
11285                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11286                .await
11287            {
11288                Ok(token) => token,
11289                Err(e) => match dlg.token(e) {
11290                    Ok(token) => token,
11291                    Err(e) => {
11292                        dlg.finished(false);
11293                        return Err(common::Error::MissingToken(e));
11294                    }
11295                },
11296            };
11297            let mut req_result = {
11298                let client = &self.hub.client;
11299                dlg.pre_request();
11300                let mut req_builder = hyper::Request::builder()
11301                    .method(hyper::Method::GET)
11302                    .uri(url.as_str())
11303                    .header(USER_AGENT, self.hub._user_agent.clone());
11304
11305                if let Some(token) = token.as_ref() {
11306                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11307                }
11308
11309                let request = req_builder
11310                    .header(CONTENT_LENGTH, 0_u64)
11311                    .body(common::to_body::<String>(None));
11312
11313                client.request(request.unwrap()).await
11314            };
11315
11316            match req_result {
11317                Err(err) => {
11318                    if let common::Retry::After(d) = dlg.http_error(&err) {
11319                        sleep(d).await;
11320                        continue;
11321                    }
11322                    dlg.finished(false);
11323                    return Err(common::Error::HttpError(err));
11324                }
11325                Ok(res) => {
11326                    let (mut parts, body) = res.into_parts();
11327                    let mut body = common::Body::new(body);
11328                    if !parts.status.is_success() {
11329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11330                        let error = serde_json::from_str(&common::to_string(&bytes));
11331                        let response = common::to_response(parts, bytes.into());
11332
11333                        if let common::Retry::After(d) =
11334                            dlg.http_failure(&response, error.as_ref().ok())
11335                        {
11336                            sleep(d).await;
11337                            continue;
11338                        }
11339
11340                        dlg.finished(false);
11341
11342                        return Err(match error {
11343                            Ok(value) => common::Error::BadRequest(value),
11344                            _ => common::Error::Failure(response),
11345                        });
11346                    }
11347                    let response = {
11348                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11349                        let encoded = common::to_string(&bytes);
11350                        match serde_json::from_str(&encoded) {
11351                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11352                            Err(error) => {
11353                                dlg.response_json_decode_error(&encoded, &error);
11354                                return Err(common::Error::JsonDecodeError(
11355                                    encoded.to_string(),
11356                                    error,
11357                                ));
11358                            }
11359                        }
11360                    };
11361
11362                    dlg.finished(true);
11363                    return Ok(response);
11364                }
11365            }
11366        }
11367    }
11368
11369    /// Required. Account to get information about. Format: accounts/{account}
11370    ///
11371    /// Sets the *name* path property to the given value.
11372    ///
11373    /// Even though the property as already been set when instantiating this call,
11374    /// we provide this method for API completeness.
11375    pub fn name(mut self, new_value: &str) -> AccountGetCall<'a, C> {
11376        self._name = new_value.to_string();
11377        self
11378    }
11379    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11380    /// while executing the actual API request.
11381    ///
11382    /// ````text
11383    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11384    /// ````
11385    ///
11386    /// Sets the *delegate* property to the given value.
11387    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
11388        self._delegate = Some(new_value);
11389        self
11390    }
11391
11392    /// Set any additional parameter of the query string used in the request.
11393    /// It should be used to set parameters which are not yet available through their own
11394    /// setters.
11395    ///
11396    /// Please note that this method must not be used to set any of the known parameters
11397    /// which have their own setter method. If done anyway, the request will fail.
11398    ///
11399    /// # Additional Parameters
11400    ///
11401    /// * *$.xgafv* (query-string) - V1 error format.
11402    /// * *access_token* (query-string) - OAuth access token.
11403    /// * *alt* (query-string) - Data format for response.
11404    /// * *callback* (query-string) - JSONP
11405    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11406    /// * *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.
11407    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11408    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11409    /// * *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.
11410    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11411    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11412    pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
11413    where
11414        T: AsRef<str>,
11415    {
11416        self._additional_params
11417            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11418        self
11419    }
11420
11421    /// Identifies the authorization scope for the method you are building.
11422    ///
11423    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11424    /// [`Scope::Readonly`].
11425    ///
11426    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11427    /// tokens for more than one scope.
11428    ///
11429    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11430    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11431    /// sufficient, a read-write scope will do as well.
11432    pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
11433    where
11434        St: AsRef<str>,
11435    {
11436        self._scopes.insert(String::from(scope.as_ref()));
11437        self
11438    }
11439    /// Identifies the authorization scope(s) for the method you are building.
11440    ///
11441    /// See [`Self::add_scope()`] for details.
11442    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
11443    where
11444        I: IntoIterator<Item = St>,
11445        St: AsRef<str>,
11446    {
11447        self._scopes
11448            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11449        self
11450    }
11451
11452    /// Removes all scopes, and no default scope will be used either.
11453    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11454    /// for details).
11455    pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
11456        self._scopes.clear();
11457        self
11458    }
11459}
11460
11461/// Gets the ad blocking recovery tag of an account.
11462///
11463/// A builder for the *getAdBlockingRecoveryTag* method supported by a *account* resource.
11464/// It is not used directly, but through a [`AccountMethods`] instance.
11465///
11466/// # Example
11467///
11468/// Instantiate a resource method builder
11469///
11470/// ```test_harness,no_run
11471/// # extern crate hyper;
11472/// # extern crate hyper_rustls;
11473/// # extern crate google_adsense2 as adsense2;
11474/// # async fn dox() {
11475/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11476///
11477/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11478/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11479/// #     secret,
11480/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11481/// # ).build().await.unwrap();
11482///
11483/// # let client = hyper_util::client::legacy::Client::builder(
11484/// #     hyper_util::rt::TokioExecutor::new()
11485/// # )
11486/// # .build(
11487/// #     hyper_rustls::HttpsConnectorBuilder::new()
11488/// #         .with_native_roots()
11489/// #         .unwrap()
11490/// #         .https_or_http()
11491/// #         .enable_http1()
11492/// #         .build()
11493/// # );
11494/// # let mut hub = Adsense::new(client, auth);
11495/// // You can configure optional parameters by calling the respective setters at will, and
11496/// // execute the final call using `doit()`.
11497/// // Values shown here are possibly random and not representative !
11498/// let result = hub.accounts().get_ad_blocking_recovery_tag("name")
11499///              .doit().await;
11500/// # }
11501/// ```
11502pub struct AccountGetAdBlockingRecoveryTagCall<'a, C>
11503where
11504    C: 'a,
11505{
11506    hub: &'a Adsense<C>,
11507    _name: String,
11508    _delegate: Option<&'a mut dyn common::Delegate>,
11509    _additional_params: HashMap<String, String>,
11510    _scopes: BTreeSet<String>,
11511}
11512
11513impl<'a, C> common::CallBuilder for AccountGetAdBlockingRecoveryTagCall<'a, C> {}
11514
11515impl<'a, C> AccountGetAdBlockingRecoveryTagCall<'a, C>
11516where
11517    C: common::Connector,
11518{
11519    /// Perform the operation you have build so far.
11520    pub async fn doit(mut self) -> common::Result<(common::Response, AdBlockingRecoveryTag)> {
11521        use std::borrow::Cow;
11522        use std::io::{Read, Seek};
11523
11524        use common::{url::Params, ToParts};
11525        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11526
11527        let mut dd = common::DefaultDelegate;
11528        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11529        dlg.begin(common::MethodInfo {
11530            id: "adsense.accounts.getAdBlockingRecoveryTag",
11531            http_method: hyper::Method::GET,
11532        });
11533
11534        for &field in ["alt", "name"].iter() {
11535            if self._additional_params.contains_key(field) {
11536                dlg.finished(false);
11537                return Err(common::Error::FieldClash(field));
11538            }
11539        }
11540
11541        let mut params = Params::with_capacity(3 + self._additional_params.len());
11542        params.push("name", self._name);
11543
11544        params.extend(self._additional_params.iter());
11545
11546        params.push("alt", "json");
11547        let mut url = self.hub._base_url.clone() + "v2/{+name}/adBlockingRecoveryTag";
11548        if self._scopes.is_empty() {
11549            self._scopes.insert(Scope::Readonly.as_ref().to_string());
11550        }
11551
11552        #[allow(clippy::single_element_loop)]
11553        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11554            url = params.uri_replacement(url, param_name, find_this, true);
11555        }
11556        {
11557            let to_remove = ["name"];
11558            params.remove_params(&to_remove);
11559        }
11560
11561        let url = params.parse_with_url(&url);
11562
11563        loop {
11564            let token = match self
11565                .hub
11566                .auth
11567                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11568                .await
11569            {
11570                Ok(token) => token,
11571                Err(e) => match dlg.token(e) {
11572                    Ok(token) => token,
11573                    Err(e) => {
11574                        dlg.finished(false);
11575                        return Err(common::Error::MissingToken(e));
11576                    }
11577                },
11578            };
11579            let mut req_result = {
11580                let client = &self.hub.client;
11581                dlg.pre_request();
11582                let mut req_builder = hyper::Request::builder()
11583                    .method(hyper::Method::GET)
11584                    .uri(url.as_str())
11585                    .header(USER_AGENT, self.hub._user_agent.clone());
11586
11587                if let Some(token) = token.as_ref() {
11588                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11589                }
11590
11591                let request = req_builder
11592                    .header(CONTENT_LENGTH, 0_u64)
11593                    .body(common::to_body::<String>(None));
11594
11595                client.request(request.unwrap()).await
11596            };
11597
11598            match req_result {
11599                Err(err) => {
11600                    if let common::Retry::After(d) = dlg.http_error(&err) {
11601                        sleep(d).await;
11602                        continue;
11603                    }
11604                    dlg.finished(false);
11605                    return Err(common::Error::HttpError(err));
11606                }
11607                Ok(res) => {
11608                    let (mut parts, body) = res.into_parts();
11609                    let mut body = common::Body::new(body);
11610                    if !parts.status.is_success() {
11611                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11612                        let error = serde_json::from_str(&common::to_string(&bytes));
11613                        let response = common::to_response(parts, bytes.into());
11614
11615                        if let common::Retry::After(d) =
11616                            dlg.http_failure(&response, error.as_ref().ok())
11617                        {
11618                            sleep(d).await;
11619                            continue;
11620                        }
11621
11622                        dlg.finished(false);
11623
11624                        return Err(match error {
11625                            Ok(value) => common::Error::BadRequest(value),
11626                            _ => common::Error::Failure(response),
11627                        });
11628                    }
11629                    let response = {
11630                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11631                        let encoded = common::to_string(&bytes);
11632                        match serde_json::from_str(&encoded) {
11633                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11634                            Err(error) => {
11635                                dlg.response_json_decode_error(&encoded, &error);
11636                                return Err(common::Error::JsonDecodeError(
11637                                    encoded.to_string(),
11638                                    error,
11639                                ));
11640                            }
11641                        }
11642                    };
11643
11644                    dlg.finished(true);
11645                    return Ok(response);
11646                }
11647            }
11648        }
11649    }
11650
11651    /// Required. The name of the account to get the tag for. Format: accounts/{account}
11652    ///
11653    /// Sets the *name* path property to the given value.
11654    ///
11655    /// Even though the property as already been set when instantiating this call,
11656    /// we provide this method for API completeness.
11657    pub fn name(mut self, new_value: &str) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
11658        self._name = new_value.to_string();
11659        self
11660    }
11661    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11662    /// while executing the actual API request.
11663    ///
11664    /// ````text
11665    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11666    /// ````
11667    ///
11668    /// Sets the *delegate* property to the given value.
11669    pub fn delegate(
11670        mut self,
11671        new_value: &'a mut dyn common::Delegate,
11672    ) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
11673        self._delegate = Some(new_value);
11674        self
11675    }
11676
11677    /// Set any additional parameter of the query string used in the request.
11678    /// It should be used to set parameters which are not yet available through their own
11679    /// setters.
11680    ///
11681    /// Please note that this method must not be used to set any of the known parameters
11682    /// which have their own setter method. If done anyway, the request will fail.
11683    ///
11684    /// # Additional Parameters
11685    ///
11686    /// * *$.xgafv* (query-string) - V1 error format.
11687    /// * *access_token* (query-string) - OAuth access token.
11688    /// * *alt* (query-string) - Data format for response.
11689    /// * *callback* (query-string) - JSONP
11690    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11691    /// * *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.
11692    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11693    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11694    /// * *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.
11695    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11696    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11697    pub fn param<T>(mut self, name: T, value: T) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
11698    where
11699        T: AsRef<str>,
11700    {
11701        self._additional_params
11702            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11703        self
11704    }
11705
11706    /// Identifies the authorization scope for the method you are building.
11707    ///
11708    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11709    /// [`Scope::Readonly`].
11710    ///
11711    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11712    /// tokens for more than one scope.
11713    ///
11714    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11715    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11716    /// sufficient, a read-write scope will do as well.
11717    pub fn add_scope<St>(mut self, scope: St) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
11718    where
11719        St: AsRef<str>,
11720    {
11721        self._scopes.insert(String::from(scope.as_ref()));
11722        self
11723    }
11724    /// Identifies the authorization scope(s) for the method you are building.
11725    ///
11726    /// See [`Self::add_scope()`] for details.
11727    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
11728    where
11729        I: IntoIterator<Item = St>,
11730        St: AsRef<str>,
11731    {
11732        self._scopes
11733            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11734        self
11735    }
11736
11737    /// Removes all scopes, and no default scope will be used either.
11738    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11739    /// for details).
11740    pub fn clear_scopes(mut self) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
11741        self._scopes.clear();
11742        self
11743    }
11744}
11745
11746/// Lists all accounts available to this user.
11747///
11748/// A builder for the *list* method supported by a *account* resource.
11749/// It is not used directly, but through a [`AccountMethods`] instance.
11750///
11751/// # Example
11752///
11753/// Instantiate a resource method builder
11754///
11755/// ```test_harness,no_run
11756/// # extern crate hyper;
11757/// # extern crate hyper_rustls;
11758/// # extern crate google_adsense2 as adsense2;
11759/// # async fn dox() {
11760/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11761///
11762/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11763/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11764/// #     secret,
11765/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11766/// # ).build().await.unwrap();
11767///
11768/// # let client = hyper_util::client::legacy::Client::builder(
11769/// #     hyper_util::rt::TokioExecutor::new()
11770/// # )
11771/// # .build(
11772/// #     hyper_rustls::HttpsConnectorBuilder::new()
11773/// #         .with_native_roots()
11774/// #         .unwrap()
11775/// #         .https_or_http()
11776/// #         .enable_http1()
11777/// #         .build()
11778/// # );
11779/// # let mut hub = Adsense::new(client, auth);
11780/// // You can configure optional parameters by calling the respective setters at will, and
11781/// // execute the final call using `doit()`.
11782/// // Values shown here are possibly random and not representative !
11783/// let result = hub.accounts().list()
11784///              .page_token("ea")
11785///              .page_size(-15)
11786///              .doit().await;
11787/// # }
11788/// ```
11789pub struct AccountListCall<'a, C>
11790where
11791    C: 'a,
11792{
11793    hub: &'a Adsense<C>,
11794    _page_token: Option<String>,
11795    _page_size: Option<i32>,
11796    _delegate: Option<&'a mut dyn common::Delegate>,
11797    _additional_params: HashMap<String, String>,
11798    _scopes: BTreeSet<String>,
11799}
11800
11801impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
11802
11803impl<'a, C> AccountListCall<'a, C>
11804where
11805    C: common::Connector,
11806{
11807    /// Perform the operation you have build so far.
11808    pub async fn doit(mut self) -> common::Result<(common::Response, ListAccountsResponse)> {
11809        use std::borrow::Cow;
11810        use std::io::{Read, Seek};
11811
11812        use common::{url::Params, ToParts};
11813        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11814
11815        let mut dd = common::DefaultDelegate;
11816        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11817        dlg.begin(common::MethodInfo {
11818            id: "adsense.accounts.list",
11819            http_method: hyper::Method::GET,
11820        });
11821
11822        for &field in ["alt", "pageToken", "pageSize"].iter() {
11823            if self._additional_params.contains_key(field) {
11824                dlg.finished(false);
11825                return Err(common::Error::FieldClash(field));
11826            }
11827        }
11828
11829        let mut params = Params::with_capacity(4 + self._additional_params.len());
11830        if let Some(value) = self._page_token.as_ref() {
11831            params.push("pageToken", value);
11832        }
11833        if let Some(value) = self._page_size.as_ref() {
11834            params.push("pageSize", value.to_string());
11835        }
11836
11837        params.extend(self._additional_params.iter());
11838
11839        params.push("alt", "json");
11840        let mut url = self.hub._base_url.clone() + "v2/accounts";
11841        if self._scopes.is_empty() {
11842            self._scopes.insert(Scope::Readonly.as_ref().to_string());
11843        }
11844
11845        let url = params.parse_with_url(&url);
11846
11847        loop {
11848            let token = match self
11849                .hub
11850                .auth
11851                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11852                .await
11853            {
11854                Ok(token) => token,
11855                Err(e) => match dlg.token(e) {
11856                    Ok(token) => token,
11857                    Err(e) => {
11858                        dlg.finished(false);
11859                        return Err(common::Error::MissingToken(e));
11860                    }
11861                },
11862            };
11863            let mut req_result = {
11864                let client = &self.hub.client;
11865                dlg.pre_request();
11866                let mut req_builder = hyper::Request::builder()
11867                    .method(hyper::Method::GET)
11868                    .uri(url.as_str())
11869                    .header(USER_AGENT, self.hub._user_agent.clone());
11870
11871                if let Some(token) = token.as_ref() {
11872                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11873                }
11874
11875                let request = req_builder
11876                    .header(CONTENT_LENGTH, 0_u64)
11877                    .body(common::to_body::<String>(None));
11878
11879                client.request(request.unwrap()).await
11880            };
11881
11882            match req_result {
11883                Err(err) => {
11884                    if let common::Retry::After(d) = dlg.http_error(&err) {
11885                        sleep(d).await;
11886                        continue;
11887                    }
11888                    dlg.finished(false);
11889                    return Err(common::Error::HttpError(err));
11890                }
11891                Ok(res) => {
11892                    let (mut parts, body) = res.into_parts();
11893                    let mut body = common::Body::new(body);
11894                    if !parts.status.is_success() {
11895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11896                        let error = serde_json::from_str(&common::to_string(&bytes));
11897                        let response = common::to_response(parts, bytes.into());
11898
11899                        if let common::Retry::After(d) =
11900                            dlg.http_failure(&response, error.as_ref().ok())
11901                        {
11902                            sleep(d).await;
11903                            continue;
11904                        }
11905
11906                        dlg.finished(false);
11907
11908                        return Err(match error {
11909                            Ok(value) => common::Error::BadRequest(value),
11910                            _ => common::Error::Failure(response),
11911                        });
11912                    }
11913                    let response = {
11914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11915                        let encoded = common::to_string(&bytes);
11916                        match serde_json::from_str(&encoded) {
11917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11918                            Err(error) => {
11919                                dlg.response_json_decode_error(&encoded, &error);
11920                                return Err(common::Error::JsonDecodeError(
11921                                    encoded.to_string(),
11922                                    error,
11923                                ));
11924                            }
11925                        }
11926                    };
11927
11928                    dlg.finished(true);
11929                    return Ok(response);
11930                }
11931            }
11932        }
11933    }
11934
11935    /// A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
11936    ///
11937    /// Sets the *page token* query property to the given value.
11938    pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C> {
11939        self._page_token = Some(new_value.to_string());
11940        self
11941    }
11942    /// The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
11943    ///
11944    /// Sets the *page size* query property to the given value.
11945    pub fn page_size(mut self, new_value: i32) -> AccountListCall<'a, C> {
11946        self._page_size = Some(new_value);
11947        self
11948    }
11949    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11950    /// while executing the actual API request.
11951    ///
11952    /// ````text
11953    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11954    /// ````
11955    ///
11956    /// Sets the *delegate* property to the given value.
11957    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
11958        self._delegate = Some(new_value);
11959        self
11960    }
11961
11962    /// Set any additional parameter of the query string used in the request.
11963    /// It should be used to set parameters which are not yet available through their own
11964    /// setters.
11965    ///
11966    /// Please note that this method must not be used to set any of the known parameters
11967    /// which have their own setter method. If done anyway, the request will fail.
11968    ///
11969    /// # Additional Parameters
11970    ///
11971    /// * *$.xgafv* (query-string) - V1 error format.
11972    /// * *access_token* (query-string) - OAuth access token.
11973    /// * *alt* (query-string) - Data format for response.
11974    /// * *callback* (query-string) - JSONP
11975    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11976    /// * *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.
11977    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11978    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11979    /// * *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.
11980    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11981    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11982    pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
11983    where
11984        T: AsRef<str>,
11985    {
11986        self._additional_params
11987            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11988        self
11989    }
11990
11991    /// Identifies the authorization scope for the method you are building.
11992    ///
11993    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11994    /// [`Scope::Readonly`].
11995    ///
11996    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11997    /// tokens for more than one scope.
11998    ///
11999    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12000    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12001    /// sufficient, a read-write scope will do as well.
12002    pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
12003    where
12004        St: AsRef<str>,
12005    {
12006        self._scopes.insert(String::from(scope.as_ref()));
12007        self
12008    }
12009    /// Identifies the authorization scope(s) for the method you are building.
12010    ///
12011    /// See [`Self::add_scope()`] for details.
12012    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
12013    where
12014        I: IntoIterator<Item = St>,
12015        St: AsRef<str>,
12016    {
12017        self._scopes
12018            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12019        self
12020    }
12021
12022    /// Removes all scopes, and no default scope will be used either.
12023    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12024    /// for details).
12025    pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
12026        self._scopes.clear();
12027        self
12028    }
12029}
12030
12031/// Lists all accounts directly managed by the given AdSense account.
12032///
12033/// A builder for the *listChildAccounts* method supported by a *account* resource.
12034/// It is not used directly, but through a [`AccountMethods`] instance.
12035///
12036/// # Example
12037///
12038/// Instantiate a resource method builder
12039///
12040/// ```test_harness,no_run
12041/// # extern crate hyper;
12042/// # extern crate hyper_rustls;
12043/// # extern crate google_adsense2 as adsense2;
12044/// # async fn dox() {
12045/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12046///
12047/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12048/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12049/// #     secret,
12050/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12051/// # ).build().await.unwrap();
12052///
12053/// # let client = hyper_util::client::legacy::Client::builder(
12054/// #     hyper_util::rt::TokioExecutor::new()
12055/// # )
12056/// # .build(
12057/// #     hyper_rustls::HttpsConnectorBuilder::new()
12058/// #         .with_native_roots()
12059/// #         .unwrap()
12060/// #         .https_or_http()
12061/// #         .enable_http1()
12062/// #         .build()
12063/// # );
12064/// # let mut hub = Adsense::new(client, auth);
12065/// // You can configure optional parameters by calling the respective setters at will, and
12066/// // execute the final call using `doit()`.
12067/// // Values shown here are possibly random and not representative !
12068/// let result = hub.accounts().list_child_accounts("parent")
12069///              .page_token("eos")
12070///              .page_size(-68)
12071///              .doit().await;
12072/// # }
12073/// ```
12074pub struct AccountListChildAccountCall<'a, C>
12075where
12076    C: 'a,
12077{
12078    hub: &'a Adsense<C>,
12079    _parent: String,
12080    _page_token: Option<String>,
12081    _page_size: Option<i32>,
12082    _delegate: Option<&'a mut dyn common::Delegate>,
12083    _additional_params: HashMap<String, String>,
12084    _scopes: BTreeSet<String>,
12085}
12086
12087impl<'a, C> common::CallBuilder for AccountListChildAccountCall<'a, C> {}
12088
12089impl<'a, C> AccountListChildAccountCall<'a, C>
12090where
12091    C: common::Connector,
12092{
12093    /// Perform the operation you have build so far.
12094    pub async fn doit(mut self) -> common::Result<(common::Response, ListChildAccountsResponse)> {
12095        use std::borrow::Cow;
12096        use std::io::{Read, Seek};
12097
12098        use common::{url::Params, ToParts};
12099        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12100
12101        let mut dd = common::DefaultDelegate;
12102        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12103        dlg.begin(common::MethodInfo {
12104            id: "adsense.accounts.listChildAccounts",
12105            http_method: hyper::Method::GET,
12106        });
12107
12108        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12109            if self._additional_params.contains_key(field) {
12110                dlg.finished(false);
12111                return Err(common::Error::FieldClash(field));
12112            }
12113        }
12114
12115        let mut params = Params::with_capacity(5 + self._additional_params.len());
12116        params.push("parent", self._parent);
12117        if let Some(value) = self._page_token.as_ref() {
12118            params.push("pageToken", value);
12119        }
12120        if let Some(value) = self._page_size.as_ref() {
12121            params.push("pageSize", value.to_string());
12122        }
12123
12124        params.extend(self._additional_params.iter());
12125
12126        params.push("alt", "json");
12127        let mut url = self.hub._base_url.clone() + "v2/{+parent}:listChildAccounts";
12128        if self._scopes.is_empty() {
12129            self._scopes.insert(Scope::Readonly.as_ref().to_string());
12130        }
12131
12132        #[allow(clippy::single_element_loop)]
12133        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12134            url = params.uri_replacement(url, param_name, find_this, true);
12135        }
12136        {
12137            let to_remove = ["parent"];
12138            params.remove_params(&to_remove);
12139        }
12140
12141        let url = params.parse_with_url(&url);
12142
12143        loop {
12144            let token = match self
12145                .hub
12146                .auth
12147                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12148                .await
12149            {
12150                Ok(token) => token,
12151                Err(e) => match dlg.token(e) {
12152                    Ok(token) => token,
12153                    Err(e) => {
12154                        dlg.finished(false);
12155                        return Err(common::Error::MissingToken(e));
12156                    }
12157                },
12158            };
12159            let mut req_result = {
12160                let client = &self.hub.client;
12161                dlg.pre_request();
12162                let mut req_builder = hyper::Request::builder()
12163                    .method(hyper::Method::GET)
12164                    .uri(url.as_str())
12165                    .header(USER_AGENT, self.hub._user_agent.clone());
12166
12167                if let Some(token) = token.as_ref() {
12168                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12169                }
12170
12171                let request = req_builder
12172                    .header(CONTENT_LENGTH, 0_u64)
12173                    .body(common::to_body::<String>(None));
12174
12175                client.request(request.unwrap()).await
12176            };
12177
12178            match req_result {
12179                Err(err) => {
12180                    if let common::Retry::After(d) = dlg.http_error(&err) {
12181                        sleep(d).await;
12182                        continue;
12183                    }
12184                    dlg.finished(false);
12185                    return Err(common::Error::HttpError(err));
12186                }
12187                Ok(res) => {
12188                    let (mut parts, body) = res.into_parts();
12189                    let mut body = common::Body::new(body);
12190                    if !parts.status.is_success() {
12191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12192                        let error = serde_json::from_str(&common::to_string(&bytes));
12193                        let response = common::to_response(parts, bytes.into());
12194
12195                        if let common::Retry::After(d) =
12196                            dlg.http_failure(&response, error.as_ref().ok())
12197                        {
12198                            sleep(d).await;
12199                            continue;
12200                        }
12201
12202                        dlg.finished(false);
12203
12204                        return Err(match error {
12205                            Ok(value) => common::Error::BadRequest(value),
12206                            _ => common::Error::Failure(response),
12207                        });
12208                    }
12209                    let response = {
12210                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12211                        let encoded = common::to_string(&bytes);
12212                        match serde_json::from_str(&encoded) {
12213                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12214                            Err(error) => {
12215                                dlg.response_json_decode_error(&encoded, &error);
12216                                return Err(common::Error::JsonDecodeError(
12217                                    encoded.to_string(),
12218                                    error,
12219                                ));
12220                            }
12221                        }
12222                    };
12223
12224                    dlg.finished(true);
12225                    return Ok(response);
12226                }
12227            }
12228        }
12229    }
12230
12231    /// Required. The parent account, which owns the child accounts. Format: accounts/{account}
12232    ///
12233    /// Sets the *parent* path property to the given value.
12234    ///
12235    /// Even though the property as already been set when instantiating this call,
12236    /// we provide this method for API completeness.
12237    pub fn parent(mut self, new_value: &str) -> AccountListChildAccountCall<'a, C> {
12238        self._parent = new_value.to_string();
12239        self
12240    }
12241    /// A page token, received from a previous `ListChildAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListChildAccounts` must match the call that provided the page token.
12242    ///
12243    /// Sets the *page token* query property to the given value.
12244    pub fn page_token(mut self, new_value: &str) -> AccountListChildAccountCall<'a, C> {
12245        self._page_token = Some(new_value.to_string());
12246        self
12247    }
12248    /// The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
12249    ///
12250    /// Sets the *page size* query property to the given value.
12251    pub fn page_size(mut self, new_value: i32) -> AccountListChildAccountCall<'a, C> {
12252        self._page_size = Some(new_value);
12253        self
12254    }
12255    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12256    /// while executing the actual API request.
12257    ///
12258    /// ````text
12259    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12260    /// ````
12261    ///
12262    /// Sets the *delegate* property to the given value.
12263    pub fn delegate(
12264        mut self,
12265        new_value: &'a mut dyn common::Delegate,
12266    ) -> AccountListChildAccountCall<'a, C> {
12267        self._delegate = Some(new_value);
12268        self
12269    }
12270
12271    /// Set any additional parameter of the query string used in the request.
12272    /// It should be used to set parameters which are not yet available through their own
12273    /// setters.
12274    ///
12275    /// Please note that this method must not be used to set any of the known parameters
12276    /// which have their own setter method. If done anyway, the request will fail.
12277    ///
12278    /// # Additional Parameters
12279    ///
12280    /// * *$.xgafv* (query-string) - V1 error format.
12281    /// * *access_token* (query-string) - OAuth access token.
12282    /// * *alt* (query-string) - Data format for response.
12283    /// * *callback* (query-string) - JSONP
12284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12285    /// * *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.
12286    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12287    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12288    /// * *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.
12289    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12290    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12291    pub fn param<T>(mut self, name: T, value: T) -> AccountListChildAccountCall<'a, C>
12292    where
12293        T: AsRef<str>,
12294    {
12295        self._additional_params
12296            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12297        self
12298    }
12299
12300    /// Identifies the authorization scope for the method you are building.
12301    ///
12302    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12303    /// [`Scope::Readonly`].
12304    ///
12305    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12306    /// tokens for more than one scope.
12307    ///
12308    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12309    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12310    /// sufficient, a read-write scope will do as well.
12311    pub fn add_scope<St>(mut self, scope: St) -> AccountListChildAccountCall<'a, C>
12312    where
12313        St: AsRef<str>,
12314    {
12315        self._scopes.insert(String::from(scope.as_ref()));
12316        self
12317    }
12318    /// Identifies the authorization scope(s) for the method you are building.
12319    ///
12320    /// See [`Self::add_scope()`] for details.
12321    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListChildAccountCall<'a, C>
12322    where
12323        I: IntoIterator<Item = St>,
12324        St: AsRef<str>,
12325    {
12326        self._scopes
12327            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12328        self
12329    }
12330
12331    /// Removes all scopes, and no default scope will be used either.
12332    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12333    /// for details).
12334    pub fn clear_scopes(mut self) -> AccountListChildAccountCall<'a, C> {
12335        self._scopes.clear();
12336        self
12337    }
12338}