google_adexchangeseller2/
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 Ad Exchange data
17    AdexchangeSeller,
18
19    /// View your Ad Exchange data
20    AdexchangeSellerReadonly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::AdexchangeSeller => "https://www.googleapis.com/auth/adexchange.seller",
27            Scope::AdexchangeSellerReadonly => {
28                "https://www.googleapis.com/auth/adexchange.seller.readonly"
29            }
30        }
31    }
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Scope {
36    fn default() -> Scope {
37        Scope::AdexchangeSellerReadonly
38    }
39}
40
41// ########
42// HUB ###
43// ######
44
45/// Central instance to access all AdExchangeSeller related resource activities
46///
47/// # Examples
48///
49/// Instantiate a new hub
50///
51/// ```test_harness,no_run
52/// extern crate hyper;
53/// extern crate hyper_rustls;
54/// extern crate google_adexchangeseller2 as adexchangeseller2;
55/// use adexchangeseller2::{Result, Error};
56/// # async fn dox() {
57/// use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58///
59/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
60/// // `client_secret`, among other things.
61/// let secret: yup_oauth2::ApplicationSecret = Default::default();
62/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
63/// // unless you replace  `None` with the desired Flow.
64/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
65/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
66/// // retrieve them from storage.
67/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
68///     .with_native_roots()
69///     .unwrap()
70///     .https_only()
71///     .enable_http2()
72///     .build();
73///
74/// let executor = hyper_util::rt::TokioExecutor::new();
75/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
76///     secret,
77///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
78///     yup_oauth2::client::CustomHyperClientBuilder::from(
79///         hyper_util::client::legacy::Client::builder(executor).build(connector),
80///     ),
81/// ).build().await.unwrap();
82///
83/// let client = hyper_util::client::legacy::Client::builder(
84///     hyper_util::rt::TokioExecutor::new()
85/// )
86/// .build(
87///     hyper_rustls::HttpsConnectorBuilder::new()
88///         .with_native_roots()
89///         .unwrap()
90///         .https_or_http()
91///         .enable_http2()
92///         .build()
93/// );
94/// let mut hub = AdExchangeSeller::new(client, auth);
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
99///              .start_index(51)
100///              .add_sort("sed")
101///              .add_metric("ut")
102///              .max_results(89)
103///              .locale("rebum.")
104///              .add_filter("est")
105///              .add_dimension("ipsum")
106///              .doit().await;
107///
108/// match result {
109///     Err(e) => match e {
110///         // The Error enum provides details about what exactly happened.
111///         // You can also just use its `Debug`, `Display` or `Error` traits
112///          Error::HttpError(_)
113///         |Error::Io(_)
114///         |Error::MissingAPIKey
115///         |Error::MissingToken(_)
116///         |Error::Cancelled
117///         |Error::UploadSizeLimitExceeded(_, _)
118///         |Error::Failure(_)
119///         |Error::BadRequest(_)
120///         |Error::FieldClash(_)
121///         |Error::JsonDecodeError(_, _) => println!("{}", e),
122///     },
123///     Ok(res) => println!("Success: {:?}", res),
124/// }
125/// # }
126/// ```
127#[derive(Clone)]
128pub struct AdExchangeSeller<C> {
129    pub client: common::Client<C>,
130    pub auth: Box<dyn common::GetToken>,
131    _user_agent: String,
132    _base_url: String,
133    _root_url: String,
134}
135
136impl<C> common::Hub for AdExchangeSeller<C> {}
137
138impl<'a, C> AdExchangeSeller<C> {
139    pub fn new<A: 'static + common::GetToken>(
140        client: common::Client<C>,
141        auth: A,
142    ) -> AdExchangeSeller<C> {
143        AdExchangeSeller {
144            client,
145            auth: Box::new(auth),
146            _user_agent: "google-api-rust-client/7.0.0".to_string(),
147            _base_url: "https://www.googleapis.com/adexchangeseller/v2.0/".to_string(),
148            _root_url: "https://www.googleapis.com/".to_string(),
149        }
150    }
151
152    pub fn accounts(&'a self) -> AccountMethods<'a, C> {
153        AccountMethods { hub: self }
154    }
155
156    /// Set the user-agent header field to use in all requests to the server.
157    /// It defaults to `google-api-rust-client/7.0.0`.
158    ///
159    /// Returns the previously set user-agent.
160    pub fn user_agent(&mut self, agent_name: String) -> String {
161        std::mem::replace(&mut self._user_agent, agent_name)
162    }
163
164    /// Set the base url to use in all requests to the server.
165    /// It defaults to `https://www.googleapis.com/adexchangeseller/v2.0/`.
166    ///
167    /// Returns the previously set base url.
168    pub fn base_url(&mut self, new_base_url: String) -> String {
169        std::mem::replace(&mut self._base_url, new_base_url)
170    }
171
172    /// Set the root url to use in all requests to the server.
173    /// It defaults to `https://www.googleapis.com/`.
174    ///
175    /// Returns the previously set root url.
176    pub fn root_url(&mut self, new_root_url: String) -> String {
177        std::mem::replace(&mut self._root_url, new_root_url)
178    }
179}
180
181// ############
182// SCHEMAS ###
183// ##########
184/// There is no detailed description.
185///
186/// # Activities
187///
188/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
189/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
190///
191/// * [adclients list accounts](AccountAdclientListCall) (none)
192/// * [alerts list accounts](AccountAlertListCall) (none)
193/// * [customchannels get accounts](AccountCustomchannelGetCall) (none)
194/// * [customchannels list accounts](AccountCustomchannelListCall) (none)
195/// * [metadata dimensions list accounts](AccountMetadataDimensionListCall) (none)
196/// * [metadata metrics list accounts](AccountMetadataMetricListCall) (none)
197/// * [preferreddeals get accounts](AccountPreferreddealGetCall) (none)
198/// * [preferreddeals list accounts](AccountPreferreddealListCall) (none)
199/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (none)
200/// * [reports saved list accounts](AccountReportSavedListCall) (none)
201/// * [reports generate accounts](AccountReportGenerateCall) (none)
202/// * [urlchannels list accounts](AccountUrlchannelListCall) (none)
203/// * [get accounts](AccountGetCall) (response)
204/// * [list accounts](AccountListCall) (none)
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct Account {
209    /// Unique identifier of this account.
210    pub id: Option<String>,
211    /// Kind of resource this is, in this case adexchangeseller#account.
212    pub kind: Option<String>,
213    /// Name of this account.
214    pub name: Option<String>,
215}
216
217impl common::Resource for Account {}
218impl common::ResponseResult for Account {}
219
220/// There is no detailed description.
221///
222/// # Activities
223///
224/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
225/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
226///
227/// * [list accounts](AccountListCall) (response)
228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
229#[serde_with::serde_as]
230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
231pub struct Accounts {
232    /// ETag of this response for caching purposes.
233    pub etag: Option<String>,
234    /// The accounts returned in this list response.
235    pub items: Option<Vec<Account>>,
236    /// Kind of list this is, in this case adexchangeseller#accounts.
237    pub kind: Option<String>,
238    /// Continuation token used to page through accounts. To retrieve the next page of results, set the next request's "pageToken" value to this.
239    #[serde(rename = "nextPageToken")]
240    pub next_page_token: Option<String>,
241}
242
243impl common::ResponseResult for Accounts {}
244
245/// There is no detailed description.
246///
247/// This type is not used in any activity, and only used as *part* of another schema.
248///
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct AdClient {
253    /// Whether this ad client is opted in to ARC.
254    #[serde(rename = "arcOptIn")]
255    pub arc_opt_in: Option<bool>,
256    /// Unique identifier of this ad client.
257    pub id: Option<String>,
258    /// Kind of resource this is, in this case adexchangeseller#adClient.
259    pub kind: Option<String>,
260    /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension.
261    #[serde(rename = "productCode")]
262    pub product_code: Option<String>,
263    /// Whether this ad client supports being reported on.
264    #[serde(rename = "supportsReporting")]
265    pub supports_reporting: Option<bool>,
266}
267
268impl common::Part for AdClient {}
269
270/// There is no detailed description.
271///
272/// # Activities
273///
274/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
275/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
276///
277/// * [adclients list accounts](AccountAdclientListCall) (response)
278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
279#[serde_with::serde_as]
280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
281pub struct AdClients {
282    /// ETag of this response for caching purposes.
283    pub etag: Option<String>,
284    /// The ad clients returned in this list response.
285    pub items: Option<Vec<AdClient>>,
286    /// Kind of list this is, in this case adexchangeseller#adClients.
287    pub kind: Option<String>,
288    /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this.
289    #[serde(rename = "nextPageToken")]
290    pub next_page_token: Option<String>,
291}
292
293impl common::ResponseResult for AdClients {}
294
295/// There is no detailed description.
296///
297/// This type is not used in any activity, and only used as *part* of another schema.
298///
299#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
300#[serde_with::serde_as]
301#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
302pub struct Alert {
303    /// Unique identifier of this alert. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
304    pub id: Option<String>,
305    /// Kind of resource this is, in this case adexchangeseller#alert.
306    pub kind: Option<String>,
307    /// The localized alert message.
308    pub message: Option<String>,
309    /// Severity of this alert. Possible values: INFO, WARNING, SEVERE.
310    pub severity: Option<String>,
311    /// Type of this alert. Possible values: SELF_HOLD, MIGRATED_TO_BILLING3, ADDRESS_PIN_VERIFICATION, PHONE_PIN_VERIFICATION, CORPORATE_ENTITY, GRAYLISTED_PUBLISHER, API_HOLD.
312    #[serde(rename = "type")]
313    pub type_: Option<String>,
314}
315
316impl common::Part for Alert {}
317
318/// There is no detailed description.
319///
320/// # Activities
321///
322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
324///
325/// * [alerts list accounts](AccountAlertListCall) (response)
326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
327#[serde_with::serde_as]
328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
329pub struct Alerts {
330    /// The alerts returned in this list response.
331    pub items: Option<Vec<Alert>>,
332    /// Kind of list this is, in this case adexchangeseller#alerts.
333    pub kind: Option<String>,
334}
335
336impl common::ResponseResult for Alerts {}
337
338/// There is no detailed description.
339///
340/// # Activities
341///
342/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
343/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
344///
345/// * [customchannels get accounts](AccountCustomchannelGetCall) (response)
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct CustomChannel {
350    /// Code of this custom channel, not necessarily unique across ad clients.
351    pub code: Option<String>,
352    /// Unique identifier of this custom channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
353    pub id: Option<String>,
354    /// Kind of resource this is, in this case adexchangeseller#customChannel.
355    pub kind: Option<String>,
356    /// Name of this custom channel.
357    pub name: Option<String>,
358    /// The targeting information of this custom channel, if activated.
359    #[serde(rename = "targetingInfo")]
360    pub targeting_info: Option<CustomChannelTargetingInfo>,
361}
362
363impl common::ResponseResult for CustomChannel {}
364
365/// There is no detailed description.
366///
367/// # Activities
368///
369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
371///
372/// * [customchannels list accounts](AccountCustomchannelListCall) (response)
373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
374#[serde_with::serde_as]
375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
376pub struct CustomChannels {
377    /// ETag of this response for caching purposes.
378    pub etag: Option<String>,
379    /// The custom channels returned in this list response.
380    pub items: Option<Vec<CustomChannel>>,
381    /// Kind of list this is, in this case adexchangeseller#customChannels.
382    pub kind: Option<String>,
383    /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
384    #[serde(rename = "nextPageToken")]
385    pub next_page_token: Option<String>,
386}
387
388impl common::ResponseResult for CustomChannels {}
389
390/// There is no detailed description.
391///
392/// # Activities
393///
394/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
395/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
396///
397/// * [metadata dimensions list accounts](AccountMetadataDimensionListCall) (response)
398/// * [metadata metrics list accounts](AccountMetadataMetricListCall) (response)
399#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
400#[serde_with::serde_as]
401#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
402pub struct Metadata {
403    /// no description provided
404    pub items: Option<Vec<ReportingMetadataEntry>>,
405    /// Kind of list this is, in this case adexchangeseller#metadata.
406    pub kind: Option<String>,
407}
408
409impl common::ResponseResult for Metadata {}
410
411/// There is no detailed description.
412///
413/// # Activities
414///
415/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
416/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
417///
418/// * [preferreddeals get accounts](AccountPreferreddealGetCall) (response)
419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
420#[serde_with::serde_as]
421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
422pub struct PreferredDeal {
423    /// The name of the advertiser this deal is for.
424    #[serde(rename = "advertiserName")]
425    pub advertiser_name: Option<String>,
426    /// The name of the buyer network this deal is for.
427    #[serde(rename = "buyerNetworkName")]
428    pub buyer_network_name: Option<String>,
429    /// The currency code that applies to the fixed_cpm value. If not set then assumed to be USD.
430    #[serde(rename = "currencyCode")]
431    pub currency_code: Option<String>,
432    /// Time when this deal stops being active in seconds since the epoch (GMT). If not set then this deal is valid until manually disabled by the publisher.
433    #[serde(rename = "endTime")]
434    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
435    pub end_time: Option<u64>,
436    /// The fixed price for this preferred deal. In cpm micros of currency according to currencyCode. If set, then this preferred deal is eligible for the fixed price tier of buying (highest priority, pay exactly the configured fixed price).
437    #[serde(rename = "fixedCpm")]
438    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
439    pub fixed_cpm: Option<i64>,
440    /// Unique identifier of this preferred deal.
441    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
442    pub id: Option<i64>,
443    /// Kind of resource this is, in this case adexchangeseller#preferredDeal.
444    pub kind: Option<String>,
445    /// Time when this deal becomes active in seconds since the epoch (GMT). If not set then this deal is active immediately upon creation.
446    #[serde(rename = "startTime")]
447    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
448    pub start_time: Option<u64>,
449}
450
451impl common::ResponseResult for PreferredDeal {}
452
453/// There is no detailed description.
454///
455/// # Activities
456///
457/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
458/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
459///
460/// * [preferreddeals list accounts](AccountPreferreddealListCall) (response)
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct PreferredDeals {
465    /// The preferred deals returned in this list response.
466    pub items: Option<Vec<PreferredDeal>>,
467    /// Kind of list this is, in this case adexchangeseller#preferredDeals.
468    pub kind: Option<String>,
469}
470
471impl common::ResponseResult for PreferredDeals {}
472
473/// There is no detailed description.
474///
475/// # Activities
476///
477/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
478/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
479///
480/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (response)
481/// * [reports generate accounts](AccountReportGenerateCall) (response)
482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
483#[serde_with::serde_as]
484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
485pub struct Report {
486    /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
487    pub averages: Option<Vec<String>>,
488    /// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request.
489    pub headers: Option<Vec<ReportHeaders>>,
490    /// Kind this is, in this case adexchangeseller#report.
491    pub kind: Option<String>,
492    /// 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. The dimension cells contain strings, and the metric cells contain numbers.
493    pub rows: Option<Vec<Vec<String>>>,
494    /// The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit.
495    #[serde(rename = "totalMatchedRows")]
496    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
497    pub total_matched_rows: Option<i64>,
498    /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
499    pub totals: Option<Vec<String>>,
500    /// Any warnings associated with generation of the report.
501    pub warnings: Option<Vec<String>>,
502}
503
504impl common::ResponseResult for Report {}
505
506/// There is no detailed description.
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct ReportingMetadataEntry {
514    /// For metrics this is a list of dimension IDs which the metric is compatible with, for dimensions it is a list of compatibility groups the dimension belongs to.
515    #[serde(rename = "compatibleDimensions")]
516    pub compatible_dimensions: Option<Vec<String>>,
517    /// The names of the metrics the dimension or metric this reporting metadata entry describes is compatible with.
518    #[serde(rename = "compatibleMetrics")]
519    pub compatible_metrics: Option<Vec<String>>,
520    /// Unique identifier of this reporting metadata entry, corresponding to the name of the appropriate dimension or metric.
521    pub id: Option<String>,
522    /// Kind of resource this is, in this case adexchangeseller#reportingMetadataEntry.
523    pub kind: Option<String>,
524    /// The names of the dimensions which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted.
525    #[serde(rename = "requiredDimensions")]
526    pub required_dimensions: Option<Vec<String>>,
527    /// The names of the metrics which the dimension or metric this reporting metadata entry describes requires to also be present in order for the report to be valid. Omitting these will not cause an error or warning, but may result in data which cannot be correctly interpreted.
528    #[serde(rename = "requiredMetrics")]
529    pub required_metrics: Option<Vec<String>>,
530    /// The codes of the projects supported by the dimension or metric this reporting metadata entry describes.
531    #[serde(rename = "supportedProducts")]
532    pub supported_products: Option<Vec<String>>,
533}
534
535impl common::Part for ReportingMetadataEntry {}
536
537/// There is no detailed description.
538///
539/// This type is not used in any activity, and only used as *part* of another schema.
540///
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct SavedReport {
545    /// Unique identifier of this saved report.
546    pub id: Option<String>,
547    /// Kind of resource this is, in this case adexchangeseller#savedReport.
548    pub kind: Option<String>,
549    /// This saved report's name.
550    pub name: Option<String>,
551}
552
553impl common::Part for SavedReport {}
554
555/// There is no detailed description.
556///
557/// # Activities
558///
559/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
560/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
561///
562/// * [reports saved list accounts](AccountReportSavedListCall) (response)
563#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
564#[serde_with::serde_as]
565#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
566pub struct SavedReports {
567    /// ETag of this response for caching purposes.
568    pub etag: Option<String>,
569    /// The saved reports returned in this list response.
570    pub items: Option<Vec<SavedReport>>,
571    /// Kind of list this is, in this case adexchangeseller#savedReports.
572    pub kind: Option<String>,
573    /// Continuation token used to page through saved reports. To retrieve the next page of results, set the next request's "pageToken" value to this.
574    #[serde(rename = "nextPageToken")]
575    pub next_page_token: Option<String>,
576}
577
578impl common::ResponseResult for SavedReports {}
579
580/// There is no detailed description.
581///
582/// This type is not used in any activity, and only used as *part* of another schema.
583///
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct UrlChannel {
588    /// Unique identifier of this URL channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
589    pub id: Option<String>,
590    /// Kind of resource this is, in this case adexchangeseller#urlChannel.
591    pub kind: Option<String>,
592    /// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home
593    #[serde(rename = "urlPattern")]
594    pub url_pattern: Option<String>,
595}
596
597impl common::Part for UrlChannel {}
598
599/// There is no detailed description.
600///
601/// # Activities
602///
603/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
604/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
605///
606/// * [urlchannels list accounts](AccountUrlchannelListCall) (response)
607#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
608#[serde_with::serde_as]
609#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
610pub struct UrlChannels {
611    /// ETag of this response for caching purposes.
612    pub etag: Option<String>,
613    /// The URL channels returned in this list response.
614    pub items: Option<Vec<UrlChannel>>,
615    /// Kind of list this is, in this case adexchangeseller#urlChannels.
616    pub kind: Option<String>,
617    /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
618    #[serde(rename = "nextPageToken")]
619    pub next_page_token: Option<String>,
620}
621
622impl common::ResponseResult for UrlChannels {}
623
624/// The targeting information of this custom channel, if activated.
625///
626/// This type is not used in any activity, and only used as *part* of another schema.
627///
628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
629#[serde_with::serde_as]
630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
631pub struct CustomChannelTargetingInfo {
632    /// The name used to describe this channel externally.
633    #[serde(rename = "adsAppearOn")]
634    pub ads_appear_on: Option<String>,
635    /// The external description of the channel.
636    pub description: Option<String>,
637    /// The locations in which ads appear. (Only valid for content and mobile content ads). Acceptable values for content ads are: TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT, MULTIPLE_LOCATIONS. Acceptable values for mobile content ads are: TOP, MIDDLE, BOTTOM, MULTIPLE_LOCATIONS.
638    pub location: Option<String>,
639    /// The language of the sites ads will be displayed on.
640    #[serde(rename = "siteLanguage")]
641    pub site_language: Option<String>,
642}
643
644impl common::NestedType for CustomChannelTargetingInfo {}
645impl common::Part for CustomChannelTargetingInfo {}
646
647/// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request.
648///
649/// This type is not used in any activity, and only used as *part* of another schema.
650///
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct ReportHeaders {
655    /// The currency of this column. Only present if the header type is METRIC_CURRENCY.
656    pub currency: Option<String>,
657    /// The name of the header.
658    pub name: Option<String>,
659    /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY.
660    #[serde(rename = "type")]
661    pub type_: Option<String>,
662}
663
664impl common::NestedType for ReportHeaders {}
665impl common::Part for ReportHeaders {}
666
667// ###################
668// MethodBuilders ###
669// #################
670
671/// A builder providing access to all methods supported on *account* resources.
672/// It is not used directly, but through the [`AdExchangeSeller`] hub.
673///
674/// # Example
675///
676/// Instantiate a resource builder
677///
678/// ```test_harness,no_run
679/// extern crate hyper;
680/// extern crate hyper_rustls;
681/// extern crate google_adexchangeseller2 as adexchangeseller2;
682///
683/// # async fn dox() {
684/// use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
685///
686/// let secret: yup_oauth2::ApplicationSecret = Default::default();
687/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
688///     .with_native_roots()
689///     .unwrap()
690///     .https_only()
691///     .enable_http2()
692///     .build();
693///
694/// let executor = hyper_util::rt::TokioExecutor::new();
695/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
696///     secret,
697///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
698///     yup_oauth2::client::CustomHyperClientBuilder::from(
699///         hyper_util::client::legacy::Client::builder(executor).build(connector),
700///     ),
701/// ).build().await.unwrap();
702///
703/// let client = hyper_util::client::legacy::Client::builder(
704///     hyper_util::rt::TokioExecutor::new()
705/// )
706/// .build(
707///     hyper_rustls::HttpsConnectorBuilder::new()
708///         .with_native_roots()
709///         .unwrap()
710///         .https_or_http()
711///         .enable_http2()
712///         .build()
713/// );
714/// let mut hub = AdExchangeSeller::new(client, auth);
715/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
716/// // like `adclients_list(...)`, `alerts_list(...)`, `customchannels_get(...)`, `customchannels_list(...)`, `get(...)`, `list(...)`, `metadata_dimensions_list(...)`, `metadata_metrics_list(...)`, `preferreddeals_get(...)`, `preferreddeals_list(...)`, `reports_generate(...)`, `reports_saved_generate(...)`, `reports_saved_list(...)` and `urlchannels_list(...)`
717/// // to build up your call.
718/// let rb = hub.accounts();
719/// # }
720/// ```
721pub struct AccountMethods<'a, C>
722where
723    C: 'a,
724{
725    hub: &'a AdExchangeSeller<C>,
726}
727
728impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
729
730impl<'a, C> AccountMethods<'a, C> {
731    /// Create a builder to help you perform the following task:
732    ///
733    /// List all ad clients in this Ad Exchange account.
734    ///
735    /// # Arguments
736    ///
737    /// * `accountId` - Account to which the ad client belongs.
738    pub fn adclients_list(&self, account_id: &str) -> AccountAdclientListCall<'a, C> {
739        AccountAdclientListCall {
740            hub: self.hub,
741            _account_id: account_id.to_string(),
742            _page_token: Default::default(),
743            _max_results: Default::default(),
744            _delegate: Default::default(),
745            _additional_params: Default::default(),
746            _scopes: Default::default(),
747        }
748    }
749
750    /// Create a builder to help you perform the following task:
751    ///
752    /// List the alerts for this Ad Exchange account.
753    ///
754    /// # Arguments
755    ///
756    /// * `accountId` - Account owning the alerts.
757    pub fn alerts_list(&self, account_id: &str) -> AccountAlertListCall<'a, C> {
758        AccountAlertListCall {
759            hub: self.hub,
760            _account_id: account_id.to_string(),
761            _locale: Default::default(),
762            _delegate: Default::default(),
763            _additional_params: Default::default(),
764            _scopes: Default::default(),
765        }
766    }
767
768    /// Create a builder to help you perform the following task:
769    ///
770    /// Get the specified custom channel from the specified ad client.
771    ///
772    /// # Arguments
773    ///
774    /// * `accountId` - Account to which the ad client belongs.
775    /// * `adClientId` - Ad client which contains the custom channel.
776    /// * `customChannelId` - Custom channel to retrieve.
777    pub fn customchannels_get(
778        &self,
779        account_id: &str,
780        ad_client_id: &str,
781        custom_channel_id: &str,
782    ) -> AccountCustomchannelGetCall<'a, C> {
783        AccountCustomchannelGetCall {
784            hub: self.hub,
785            _account_id: account_id.to_string(),
786            _ad_client_id: ad_client_id.to_string(),
787            _custom_channel_id: custom_channel_id.to_string(),
788            _delegate: Default::default(),
789            _additional_params: Default::default(),
790            _scopes: Default::default(),
791        }
792    }
793
794    /// Create a builder to help you perform the following task:
795    ///
796    /// List all custom channels in the specified ad client for this Ad Exchange account.
797    ///
798    /// # Arguments
799    ///
800    /// * `accountId` - Account to which the ad client belongs.
801    /// * `adClientId` - Ad client for which to list custom channels.
802    pub fn customchannels_list(
803        &self,
804        account_id: &str,
805        ad_client_id: &str,
806    ) -> AccountCustomchannelListCall<'a, C> {
807        AccountCustomchannelListCall {
808            hub: self.hub,
809            _account_id: account_id.to_string(),
810            _ad_client_id: ad_client_id.to_string(),
811            _page_token: Default::default(),
812            _max_results: Default::default(),
813            _delegate: Default::default(),
814            _additional_params: Default::default(),
815            _scopes: Default::default(),
816        }
817    }
818
819    /// Create a builder to help you perform the following task:
820    ///
821    /// List the metadata for the dimensions available to this AdExchange account.
822    ///
823    /// # Arguments
824    ///
825    /// * `accountId` - Account with visibility to the dimensions.
826    pub fn metadata_dimensions_list(
827        &self,
828        account_id: &str,
829    ) -> AccountMetadataDimensionListCall<'a, C> {
830        AccountMetadataDimensionListCall {
831            hub: self.hub,
832            _account_id: account_id.to_string(),
833            _delegate: Default::default(),
834            _additional_params: Default::default(),
835            _scopes: Default::default(),
836        }
837    }
838
839    /// Create a builder to help you perform the following task:
840    ///
841    /// List the metadata for the metrics available to this AdExchange account.
842    ///
843    /// # Arguments
844    ///
845    /// * `accountId` - Account with visibility to the metrics.
846    pub fn metadata_metrics_list(&self, account_id: &str) -> AccountMetadataMetricListCall<'a, C> {
847        AccountMetadataMetricListCall {
848            hub: self.hub,
849            _account_id: account_id.to_string(),
850            _delegate: Default::default(),
851            _additional_params: Default::default(),
852            _scopes: Default::default(),
853        }
854    }
855
856    /// Create a builder to help you perform the following task:
857    ///
858    /// Get information about the selected Ad Exchange Preferred Deal.
859    ///
860    /// # Arguments
861    ///
862    /// * `accountId` - Account owning the deal.
863    /// * `dealId` - Preferred deal to get information about.
864    pub fn preferreddeals_get(
865        &self,
866        account_id: &str,
867        deal_id: &str,
868    ) -> AccountPreferreddealGetCall<'a, C> {
869        AccountPreferreddealGetCall {
870            hub: self.hub,
871            _account_id: account_id.to_string(),
872            _deal_id: deal_id.to_string(),
873            _delegate: Default::default(),
874            _additional_params: Default::default(),
875            _scopes: Default::default(),
876        }
877    }
878
879    /// Create a builder to help you perform the following task:
880    ///
881    /// List the preferred deals for this Ad Exchange account.
882    ///
883    /// # Arguments
884    ///
885    /// * `accountId` - Account owning the deals.
886    pub fn preferreddeals_list(&self, account_id: &str) -> AccountPreferreddealListCall<'a, C> {
887        AccountPreferreddealListCall {
888            hub: self.hub,
889            _account_id: account_id.to_string(),
890            _delegate: Default::default(),
891            _additional_params: Default::default(),
892            _scopes: Default::default(),
893        }
894    }
895
896    /// Create a builder to help you perform the following task:
897    ///
898    /// Generate an Ad Exchange report based on the saved report ID sent in the query parameters.
899    ///
900    /// # Arguments
901    ///
902    /// * `accountId` - Account owning the saved report.
903    /// * `savedReportId` - The saved report to retrieve.
904    pub fn reports_saved_generate(
905        &self,
906        account_id: &str,
907        saved_report_id: &str,
908    ) -> AccountReportSavedGenerateCall<'a, C> {
909        AccountReportSavedGenerateCall {
910            hub: self.hub,
911            _account_id: account_id.to_string(),
912            _saved_report_id: saved_report_id.to_string(),
913            _start_index: Default::default(),
914            _max_results: Default::default(),
915            _locale: Default::default(),
916            _delegate: Default::default(),
917            _additional_params: Default::default(),
918            _scopes: Default::default(),
919        }
920    }
921
922    /// Create a builder to help you perform the following task:
923    ///
924    /// List all saved reports in this Ad Exchange account.
925    ///
926    /// # Arguments
927    ///
928    /// * `accountId` - Account owning the saved reports.
929    pub fn reports_saved_list(&self, account_id: &str) -> AccountReportSavedListCall<'a, C> {
930        AccountReportSavedListCall {
931            hub: self.hub,
932            _account_id: account_id.to_string(),
933            _page_token: Default::default(),
934            _max_results: Default::default(),
935            _delegate: Default::default(),
936            _additional_params: Default::default(),
937            _scopes: Default::default(),
938        }
939    }
940
941    /// Create a builder to help you perform the following task:
942    ///
943    /// Generate an Ad Exchange report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
944    ///
945    /// # Arguments
946    ///
947    /// * `accountId` - Account which owns the generated report.
948    /// * `startDate` - Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
949    /// * `endDate` - End of the date range to report on in "YYYY-MM-DD" format, inclusive.
950    pub fn reports_generate(
951        &self,
952        account_id: &str,
953        start_date: &str,
954        end_date: &str,
955    ) -> AccountReportGenerateCall<'a, C> {
956        AccountReportGenerateCall {
957            hub: self.hub,
958            _account_id: account_id.to_string(),
959            _start_date: start_date.to_string(),
960            _end_date: end_date.to_string(),
961            _start_index: Default::default(),
962            _sort: Default::default(),
963            _metric: Default::default(),
964            _max_results: Default::default(),
965            _locale: Default::default(),
966            _filter: Default::default(),
967            _dimension: Default::default(),
968            _delegate: Default::default(),
969            _additional_params: Default::default(),
970            _scopes: Default::default(),
971        }
972    }
973
974    /// Create a builder to help you perform the following task:
975    ///
976    /// List all URL channels in the specified ad client for this Ad Exchange account.
977    ///
978    /// # Arguments
979    ///
980    /// * `accountId` - Account to which the ad client belongs.
981    /// * `adClientId` - Ad client for which to list URL channels.
982    pub fn urlchannels_list(
983        &self,
984        account_id: &str,
985        ad_client_id: &str,
986    ) -> AccountUrlchannelListCall<'a, C> {
987        AccountUrlchannelListCall {
988            hub: self.hub,
989            _account_id: account_id.to_string(),
990            _ad_client_id: ad_client_id.to_string(),
991            _page_token: Default::default(),
992            _max_results: Default::default(),
993            _delegate: Default::default(),
994            _additional_params: Default::default(),
995            _scopes: Default::default(),
996        }
997    }
998
999    /// Create a builder to help you perform the following task:
1000    ///
1001    /// Get information about the selected Ad Exchange account.
1002    ///
1003    /// # Arguments
1004    ///
1005    /// * `accountId` - Account to get information about. Tip: 'myaccount' is a valid ID.
1006    pub fn get(&self, account_id: &str) -> AccountGetCall<'a, C> {
1007        AccountGetCall {
1008            hub: self.hub,
1009            _account_id: account_id.to_string(),
1010            _delegate: Default::default(),
1011            _additional_params: Default::default(),
1012            _scopes: Default::default(),
1013        }
1014    }
1015
1016    /// Create a builder to help you perform the following task:
1017    ///
1018    /// List all accounts available to this Ad Exchange account.
1019    pub fn list(&self) -> AccountListCall<'a, C> {
1020        AccountListCall {
1021            hub: self.hub,
1022            _page_token: Default::default(),
1023            _max_results: Default::default(),
1024            _delegate: Default::default(),
1025            _additional_params: Default::default(),
1026            _scopes: Default::default(),
1027        }
1028    }
1029}
1030
1031// ###################
1032// CallBuilders   ###
1033// #################
1034
1035/// List all ad clients in this Ad Exchange account.
1036///
1037/// A builder for the *adclients.list* method supported by a *account* resource.
1038/// It is not used directly, but through a [`AccountMethods`] instance.
1039///
1040/// # Example
1041///
1042/// Instantiate a resource method builder
1043///
1044/// ```test_harness,no_run
1045/// # extern crate hyper;
1046/// # extern crate hyper_rustls;
1047/// # extern crate google_adexchangeseller2 as adexchangeseller2;
1048/// # async fn dox() {
1049/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1050///
1051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1052/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1053/// #     .with_native_roots()
1054/// #     .unwrap()
1055/// #     .https_only()
1056/// #     .enable_http2()
1057/// #     .build();
1058///
1059/// # let executor = hyper_util::rt::TokioExecutor::new();
1060/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1061/// #     secret,
1062/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1063/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1064/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1065/// #     ),
1066/// # ).build().await.unwrap();
1067///
1068/// # let client = hyper_util::client::legacy::Client::builder(
1069/// #     hyper_util::rt::TokioExecutor::new()
1070/// # )
1071/// # .build(
1072/// #     hyper_rustls::HttpsConnectorBuilder::new()
1073/// #         .with_native_roots()
1074/// #         .unwrap()
1075/// #         .https_or_http()
1076/// #         .enable_http2()
1077/// #         .build()
1078/// # );
1079/// # let mut hub = AdExchangeSeller::new(client, auth);
1080/// // You can configure optional parameters by calling the respective setters at will, and
1081/// // execute the final call using `doit()`.
1082/// // Values shown here are possibly random and not representative !
1083/// let result = hub.accounts().adclients_list("accountId")
1084///              .page_token("est")
1085///              .max_results(39)
1086///              .doit().await;
1087/// # }
1088/// ```
1089pub struct AccountAdclientListCall<'a, C>
1090where
1091    C: 'a,
1092{
1093    hub: &'a AdExchangeSeller<C>,
1094    _account_id: String,
1095    _page_token: Option<String>,
1096    _max_results: Option<u32>,
1097    _delegate: Option<&'a mut dyn common::Delegate>,
1098    _additional_params: HashMap<String, String>,
1099    _scopes: BTreeSet<String>,
1100}
1101
1102impl<'a, C> common::CallBuilder for AccountAdclientListCall<'a, C> {}
1103
1104impl<'a, C> AccountAdclientListCall<'a, C>
1105where
1106    C: common::Connector,
1107{
1108    /// Perform the operation you have build so far.
1109    pub async fn doit(mut self) -> common::Result<(common::Response, AdClients)> {
1110        use std::borrow::Cow;
1111        use std::io::{Read, Seek};
1112
1113        use common::{url::Params, ToParts};
1114        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1115
1116        let mut dd = common::DefaultDelegate;
1117        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1118        dlg.begin(common::MethodInfo {
1119            id: "adexchangeseller.accounts.adclients.list",
1120            http_method: hyper::Method::GET,
1121        });
1122
1123        for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
1124            if self._additional_params.contains_key(field) {
1125                dlg.finished(false);
1126                return Err(common::Error::FieldClash(field));
1127            }
1128        }
1129
1130        let mut params = Params::with_capacity(5 + self._additional_params.len());
1131        params.push("accountId", self._account_id);
1132        if let Some(value) = self._page_token.as_ref() {
1133            params.push("pageToken", value);
1134        }
1135        if let Some(value) = self._max_results.as_ref() {
1136            params.push("maxResults", value.to_string());
1137        }
1138
1139        params.extend(self._additional_params.iter());
1140
1141        params.push("alt", "json");
1142        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/adclients";
1143        if self._scopes.is_empty() {
1144            self._scopes
1145                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
1146        }
1147
1148        #[allow(clippy::single_element_loop)]
1149        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
1150            url = params.uri_replacement(url, param_name, find_this, false);
1151        }
1152        {
1153            let to_remove = ["accountId"];
1154            params.remove_params(&to_remove);
1155        }
1156
1157        let url = params.parse_with_url(&url);
1158
1159        loop {
1160            let token = match self
1161                .hub
1162                .auth
1163                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1164                .await
1165            {
1166                Ok(token) => token,
1167                Err(e) => match dlg.token(e) {
1168                    Ok(token) => token,
1169                    Err(e) => {
1170                        dlg.finished(false);
1171                        return Err(common::Error::MissingToken(e));
1172                    }
1173                },
1174            };
1175            let mut req_result = {
1176                let client = &self.hub.client;
1177                dlg.pre_request();
1178                let mut req_builder = hyper::Request::builder()
1179                    .method(hyper::Method::GET)
1180                    .uri(url.as_str())
1181                    .header(USER_AGENT, self.hub._user_agent.clone());
1182
1183                if let Some(token) = token.as_ref() {
1184                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1185                }
1186
1187                let request = req_builder
1188                    .header(CONTENT_LENGTH, 0_u64)
1189                    .body(common::to_body::<String>(None));
1190
1191                client.request(request.unwrap()).await
1192            };
1193
1194            match req_result {
1195                Err(err) => {
1196                    if let common::Retry::After(d) = dlg.http_error(&err) {
1197                        sleep(d).await;
1198                        continue;
1199                    }
1200                    dlg.finished(false);
1201                    return Err(common::Error::HttpError(err));
1202                }
1203                Ok(res) => {
1204                    let (mut parts, body) = res.into_parts();
1205                    let mut body = common::Body::new(body);
1206                    if !parts.status.is_success() {
1207                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1208                        let error = serde_json::from_str(&common::to_string(&bytes));
1209                        let response = common::to_response(parts, bytes.into());
1210
1211                        if let common::Retry::After(d) =
1212                            dlg.http_failure(&response, error.as_ref().ok())
1213                        {
1214                            sleep(d).await;
1215                            continue;
1216                        }
1217
1218                        dlg.finished(false);
1219
1220                        return Err(match error {
1221                            Ok(value) => common::Error::BadRequest(value),
1222                            _ => common::Error::Failure(response),
1223                        });
1224                    }
1225                    let response = {
1226                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1227                        let encoded = common::to_string(&bytes);
1228                        match serde_json::from_str(&encoded) {
1229                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1230                            Err(error) => {
1231                                dlg.response_json_decode_error(&encoded, &error);
1232                                return Err(common::Error::JsonDecodeError(
1233                                    encoded.to_string(),
1234                                    error,
1235                                ));
1236                            }
1237                        }
1238                    };
1239
1240                    dlg.finished(true);
1241                    return Ok(response);
1242                }
1243            }
1244        }
1245    }
1246
1247    /// Account to which the ad client belongs.
1248    ///
1249    /// Sets the *account id* path property to the given value.
1250    ///
1251    /// Even though the property as already been set when instantiating this call,
1252    /// we provide this method for API completeness.
1253    pub fn account_id(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
1254        self._account_id = new_value.to_string();
1255        self
1256    }
1257    /// A continuation token, used to page through ad clients. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
1258    ///
1259    /// Sets the *page token* query property to the given value.
1260    pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
1261        self._page_token = Some(new_value.to_string());
1262        self
1263    }
1264    /// The maximum number of ad clients to include in the response, used for paging.
1265    ///
1266    /// Sets the *max results* query property to the given value.
1267    pub fn max_results(mut self, new_value: u32) -> AccountAdclientListCall<'a, C> {
1268        self._max_results = Some(new_value);
1269        self
1270    }
1271    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1272    /// while executing the actual API request.
1273    ///
1274    /// ````text
1275    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1276    /// ````
1277    ///
1278    /// Sets the *delegate* property to the given value.
1279    pub fn delegate(
1280        mut self,
1281        new_value: &'a mut dyn common::Delegate,
1282    ) -> AccountAdclientListCall<'a, C> {
1283        self._delegate = Some(new_value);
1284        self
1285    }
1286
1287    /// Set any additional parameter of the query string used in the request.
1288    /// It should be used to set parameters which are not yet available through their own
1289    /// setters.
1290    ///
1291    /// Please note that this method must not be used to set any of the known parameters
1292    /// which have their own setter method. If done anyway, the request will fail.
1293    ///
1294    /// # Additional Parameters
1295    ///
1296    /// * *alt* (query-string) - Data format for the response.
1297    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1298    /// * *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.
1299    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1300    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1301    /// * *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. Overrides userIp if both are provided.
1302    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1303    pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientListCall<'a, C>
1304    where
1305        T: AsRef<str>,
1306    {
1307        self._additional_params
1308            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1309        self
1310    }
1311
1312    /// Identifies the authorization scope for the method you are building.
1313    ///
1314    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1315    /// [`Scope::AdexchangeSellerReadonly`].
1316    ///
1317    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1318    /// tokens for more than one scope.
1319    ///
1320    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1321    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1322    /// sufficient, a read-write scope will do as well.
1323    pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientListCall<'a, C>
1324    where
1325        St: AsRef<str>,
1326    {
1327        self._scopes.insert(String::from(scope.as_ref()));
1328        self
1329    }
1330    /// Identifies the authorization scope(s) for the method you are building.
1331    ///
1332    /// See [`Self::add_scope()`] for details.
1333    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientListCall<'a, C>
1334    where
1335        I: IntoIterator<Item = St>,
1336        St: AsRef<str>,
1337    {
1338        self._scopes
1339            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1340        self
1341    }
1342
1343    /// Removes all scopes, and no default scope will be used either.
1344    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1345    /// for details).
1346    pub fn clear_scopes(mut self) -> AccountAdclientListCall<'a, C> {
1347        self._scopes.clear();
1348        self
1349    }
1350}
1351
1352/// List the alerts for this Ad Exchange account.
1353///
1354/// A builder for the *alerts.list* method supported by a *account* resource.
1355/// It is not used directly, but through a [`AccountMethods`] instance.
1356///
1357/// # Example
1358///
1359/// Instantiate a resource method builder
1360///
1361/// ```test_harness,no_run
1362/// # extern crate hyper;
1363/// # extern crate hyper_rustls;
1364/// # extern crate google_adexchangeseller2 as adexchangeseller2;
1365/// # async fn dox() {
1366/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1367///
1368/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1369/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1370/// #     .with_native_roots()
1371/// #     .unwrap()
1372/// #     .https_only()
1373/// #     .enable_http2()
1374/// #     .build();
1375///
1376/// # let executor = hyper_util::rt::TokioExecutor::new();
1377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1378/// #     secret,
1379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1380/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1381/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1382/// #     ),
1383/// # ).build().await.unwrap();
1384///
1385/// # let client = hyper_util::client::legacy::Client::builder(
1386/// #     hyper_util::rt::TokioExecutor::new()
1387/// # )
1388/// # .build(
1389/// #     hyper_rustls::HttpsConnectorBuilder::new()
1390/// #         .with_native_roots()
1391/// #         .unwrap()
1392/// #         .https_or_http()
1393/// #         .enable_http2()
1394/// #         .build()
1395/// # );
1396/// # let mut hub = AdExchangeSeller::new(client, auth);
1397/// // You can configure optional parameters by calling the respective setters at will, and
1398/// // execute the final call using `doit()`.
1399/// // Values shown here are possibly random and not representative !
1400/// let result = hub.accounts().alerts_list("accountId")
1401///              .locale("dolor")
1402///              .doit().await;
1403/// # }
1404/// ```
1405pub struct AccountAlertListCall<'a, C>
1406where
1407    C: 'a,
1408{
1409    hub: &'a AdExchangeSeller<C>,
1410    _account_id: String,
1411    _locale: Option<String>,
1412    _delegate: Option<&'a mut dyn common::Delegate>,
1413    _additional_params: HashMap<String, String>,
1414    _scopes: BTreeSet<String>,
1415}
1416
1417impl<'a, C> common::CallBuilder for AccountAlertListCall<'a, C> {}
1418
1419impl<'a, C> AccountAlertListCall<'a, C>
1420where
1421    C: common::Connector,
1422{
1423    /// Perform the operation you have build so far.
1424    pub async fn doit(mut self) -> common::Result<(common::Response, Alerts)> {
1425        use std::borrow::Cow;
1426        use std::io::{Read, Seek};
1427
1428        use common::{url::Params, ToParts};
1429        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1430
1431        let mut dd = common::DefaultDelegate;
1432        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1433        dlg.begin(common::MethodInfo {
1434            id: "adexchangeseller.accounts.alerts.list",
1435            http_method: hyper::Method::GET,
1436        });
1437
1438        for &field in ["alt", "accountId", "locale"].iter() {
1439            if self._additional_params.contains_key(field) {
1440                dlg.finished(false);
1441                return Err(common::Error::FieldClash(field));
1442            }
1443        }
1444
1445        let mut params = Params::with_capacity(4 + self._additional_params.len());
1446        params.push("accountId", self._account_id);
1447        if let Some(value) = self._locale.as_ref() {
1448            params.push("locale", value);
1449        }
1450
1451        params.extend(self._additional_params.iter());
1452
1453        params.push("alt", "json");
1454        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/alerts";
1455        if self._scopes.is_empty() {
1456            self._scopes
1457                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
1458        }
1459
1460        #[allow(clippy::single_element_loop)]
1461        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
1462            url = params.uri_replacement(url, param_name, find_this, false);
1463        }
1464        {
1465            let to_remove = ["accountId"];
1466            params.remove_params(&to_remove);
1467        }
1468
1469        let url = params.parse_with_url(&url);
1470
1471        loop {
1472            let token = match self
1473                .hub
1474                .auth
1475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1476                .await
1477            {
1478                Ok(token) => token,
1479                Err(e) => match dlg.token(e) {
1480                    Ok(token) => token,
1481                    Err(e) => {
1482                        dlg.finished(false);
1483                        return Err(common::Error::MissingToken(e));
1484                    }
1485                },
1486            };
1487            let mut req_result = {
1488                let client = &self.hub.client;
1489                dlg.pre_request();
1490                let mut req_builder = hyper::Request::builder()
1491                    .method(hyper::Method::GET)
1492                    .uri(url.as_str())
1493                    .header(USER_AGENT, self.hub._user_agent.clone());
1494
1495                if let Some(token) = token.as_ref() {
1496                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1497                }
1498
1499                let request = req_builder
1500                    .header(CONTENT_LENGTH, 0_u64)
1501                    .body(common::to_body::<String>(None));
1502
1503                client.request(request.unwrap()).await
1504            };
1505
1506            match req_result {
1507                Err(err) => {
1508                    if let common::Retry::After(d) = dlg.http_error(&err) {
1509                        sleep(d).await;
1510                        continue;
1511                    }
1512                    dlg.finished(false);
1513                    return Err(common::Error::HttpError(err));
1514                }
1515                Ok(res) => {
1516                    let (mut parts, body) = res.into_parts();
1517                    let mut body = common::Body::new(body);
1518                    if !parts.status.is_success() {
1519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1520                        let error = serde_json::from_str(&common::to_string(&bytes));
1521                        let response = common::to_response(parts, bytes.into());
1522
1523                        if let common::Retry::After(d) =
1524                            dlg.http_failure(&response, error.as_ref().ok())
1525                        {
1526                            sleep(d).await;
1527                            continue;
1528                        }
1529
1530                        dlg.finished(false);
1531
1532                        return Err(match error {
1533                            Ok(value) => common::Error::BadRequest(value),
1534                            _ => common::Error::Failure(response),
1535                        });
1536                    }
1537                    let response = {
1538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1539                        let encoded = common::to_string(&bytes);
1540                        match serde_json::from_str(&encoded) {
1541                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1542                            Err(error) => {
1543                                dlg.response_json_decode_error(&encoded, &error);
1544                                return Err(common::Error::JsonDecodeError(
1545                                    encoded.to_string(),
1546                                    error,
1547                                ));
1548                            }
1549                        }
1550                    };
1551
1552                    dlg.finished(true);
1553                    return Ok(response);
1554                }
1555            }
1556        }
1557    }
1558
1559    /// Account owning the alerts.
1560    ///
1561    /// Sets the *account id* path property to the given value.
1562    ///
1563    /// Even though the property as already been set when instantiating this call,
1564    /// we provide this method for API completeness.
1565    pub fn account_id(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
1566        self._account_id = new_value.to_string();
1567        self
1568    }
1569    /// The locale to use for translating alert messages. The account locale will be used if this is not supplied. The AdSense default (English) will be used if the supplied locale is invalid or unsupported.
1570    ///
1571    /// Sets the *locale* query property to the given value.
1572    pub fn locale(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
1573        self._locale = Some(new_value.to_string());
1574        self
1575    }
1576    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1577    /// while executing the actual API request.
1578    ///
1579    /// ````text
1580    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1581    /// ````
1582    ///
1583    /// Sets the *delegate* property to the given value.
1584    pub fn delegate(
1585        mut self,
1586        new_value: &'a mut dyn common::Delegate,
1587    ) -> AccountAlertListCall<'a, C> {
1588        self._delegate = Some(new_value);
1589        self
1590    }
1591
1592    /// Set any additional parameter of the query string used in the request.
1593    /// It should be used to set parameters which are not yet available through their own
1594    /// setters.
1595    ///
1596    /// Please note that this method must not be used to set any of the known parameters
1597    /// which have their own setter method. If done anyway, the request will fail.
1598    ///
1599    /// # Additional Parameters
1600    ///
1601    /// * *alt* (query-string) - Data format for the response.
1602    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1603    /// * *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.
1604    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1605    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1606    /// * *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. Overrides userIp if both are provided.
1607    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1608    pub fn param<T>(mut self, name: T, value: T) -> AccountAlertListCall<'a, C>
1609    where
1610        T: AsRef<str>,
1611    {
1612        self._additional_params
1613            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1614        self
1615    }
1616
1617    /// Identifies the authorization scope for the method you are building.
1618    ///
1619    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1620    /// [`Scope::AdexchangeSellerReadonly`].
1621    ///
1622    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1623    /// tokens for more than one scope.
1624    ///
1625    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1626    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1627    /// sufficient, a read-write scope will do as well.
1628    pub fn add_scope<St>(mut self, scope: St) -> AccountAlertListCall<'a, C>
1629    where
1630        St: AsRef<str>,
1631    {
1632        self._scopes.insert(String::from(scope.as_ref()));
1633        self
1634    }
1635    /// Identifies the authorization scope(s) for the method you are building.
1636    ///
1637    /// See [`Self::add_scope()`] for details.
1638    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAlertListCall<'a, C>
1639    where
1640        I: IntoIterator<Item = St>,
1641        St: AsRef<str>,
1642    {
1643        self._scopes
1644            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1645        self
1646    }
1647
1648    /// Removes all scopes, and no default scope will be used either.
1649    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1650    /// for details).
1651    pub fn clear_scopes(mut self) -> AccountAlertListCall<'a, C> {
1652        self._scopes.clear();
1653        self
1654    }
1655}
1656
1657/// Get the specified custom channel from the specified ad client.
1658///
1659/// A builder for the *customchannels.get* method supported by a *account* resource.
1660/// It is not used directly, but through a [`AccountMethods`] instance.
1661///
1662/// # Example
1663///
1664/// Instantiate a resource method builder
1665///
1666/// ```test_harness,no_run
1667/// # extern crate hyper;
1668/// # extern crate hyper_rustls;
1669/// # extern crate google_adexchangeseller2 as adexchangeseller2;
1670/// # async fn dox() {
1671/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1672///
1673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1674/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1675/// #     .with_native_roots()
1676/// #     .unwrap()
1677/// #     .https_only()
1678/// #     .enable_http2()
1679/// #     .build();
1680///
1681/// # let executor = hyper_util::rt::TokioExecutor::new();
1682/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1683/// #     secret,
1684/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1685/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1686/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1687/// #     ),
1688/// # ).build().await.unwrap();
1689///
1690/// # let client = hyper_util::client::legacy::Client::builder(
1691/// #     hyper_util::rt::TokioExecutor::new()
1692/// # )
1693/// # .build(
1694/// #     hyper_rustls::HttpsConnectorBuilder::new()
1695/// #         .with_native_roots()
1696/// #         .unwrap()
1697/// #         .https_or_http()
1698/// #         .enable_http2()
1699/// #         .build()
1700/// # );
1701/// # let mut hub = AdExchangeSeller::new(client, auth);
1702/// // You can configure optional parameters by calling the respective setters at will, and
1703/// // execute the final call using `doit()`.
1704/// // Values shown here are possibly random and not representative !
1705/// let result = hub.accounts().customchannels_get("accountId", "adClientId", "customChannelId")
1706///              .doit().await;
1707/// # }
1708/// ```
1709pub struct AccountCustomchannelGetCall<'a, C>
1710where
1711    C: 'a,
1712{
1713    hub: &'a AdExchangeSeller<C>,
1714    _account_id: String,
1715    _ad_client_id: String,
1716    _custom_channel_id: String,
1717    _delegate: Option<&'a mut dyn common::Delegate>,
1718    _additional_params: HashMap<String, String>,
1719    _scopes: BTreeSet<String>,
1720}
1721
1722impl<'a, C> common::CallBuilder for AccountCustomchannelGetCall<'a, C> {}
1723
1724impl<'a, C> AccountCustomchannelGetCall<'a, C>
1725where
1726    C: common::Connector,
1727{
1728    /// Perform the operation you have build so far.
1729    pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
1730        use std::borrow::Cow;
1731        use std::io::{Read, Seek};
1732
1733        use common::{url::Params, ToParts};
1734        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1735
1736        let mut dd = common::DefaultDelegate;
1737        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1738        dlg.begin(common::MethodInfo {
1739            id: "adexchangeseller.accounts.customchannels.get",
1740            http_method: hyper::Method::GET,
1741        });
1742
1743        for &field in ["alt", "accountId", "adClientId", "customChannelId"].iter() {
1744            if self._additional_params.contains_key(field) {
1745                dlg.finished(false);
1746                return Err(common::Error::FieldClash(field));
1747            }
1748        }
1749
1750        let mut params = Params::with_capacity(5 + self._additional_params.len());
1751        params.push("accountId", self._account_id);
1752        params.push("adClientId", self._ad_client_id);
1753        params.push("customChannelId", self._custom_channel_id);
1754
1755        params.extend(self._additional_params.iter());
1756
1757        params.push("alt", "json");
1758        let mut url = self.hub._base_url.clone()
1759            + "accounts/{accountId}/adclients/{adClientId}/customchannels/{customChannelId}";
1760        if self._scopes.is_empty() {
1761            self._scopes
1762                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
1763        }
1764
1765        #[allow(clippy::single_element_loop)]
1766        for &(find_this, param_name) in [
1767            ("{accountId}", "accountId"),
1768            ("{adClientId}", "adClientId"),
1769            ("{customChannelId}", "customChannelId"),
1770        ]
1771        .iter()
1772        {
1773            url = params.uri_replacement(url, param_name, find_this, false);
1774        }
1775        {
1776            let to_remove = ["customChannelId", "adClientId", "accountId"];
1777            params.remove_params(&to_remove);
1778        }
1779
1780        let url = params.parse_with_url(&url);
1781
1782        loop {
1783            let token = match self
1784                .hub
1785                .auth
1786                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1787                .await
1788            {
1789                Ok(token) => token,
1790                Err(e) => match dlg.token(e) {
1791                    Ok(token) => token,
1792                    Err(e) => {
1793                        dlg.finished(false);
1794                        return Err(common::Error::MissingToken(e));
1795                    }
1796                },
1797            };
1798            let mut req_result = {
1799                let client = &self.hub.client;
1800                dlg.pre_request();
1801                let mut req_builder = hyper::Request::builder()
1802                    .method(hyper::Method::GET)
1803                    .uri(url.as_str())
1804                    .header(USER_AGENT, self.hub._user_agent.clone());
1805
1806                if let Some(token) = token.as_ref() {
1807                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1808                }
1809
1810                let request = req_builder
1811                    .header(CONTENT_LENGTH, 0_u64)
1812                    .body(common::to_body::<String>(None));
1813
1814                client.request(request.unwrap()).await
1815            };
1816
1817            match req_result {
1818                Err(err) => {
1819                    if let common::Retry::After(d) = dlg.http_error(&err) {
1820                        sleep(d).await;
1821                        continue;
1822                    }
1823                    dlg.finished(false);
1824                    return Err(common::Error::HttpError(err));
1825                }
1826                Ok(res) => {
1827                    let (mut parts, body) = res.into_parts();
1828                    let mut body = common::Body::new(body);
1829                    if !parts.status.is_success() {
1830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1831                        let error = serde_json::from_str(&common::to_string(&bytes));
1832                        let response = common::to_response(parts, bytes.into());
1833
1834                        if let common::Retry::After(d) =
1835                            dlg.http_failure(&response, error.as_ref().ok())
1836                        {
1837                            sleep(d).await;
1838                            continue;
1839                        }
1840
1841                        dlg.finished(false);
1842
1843                        return Err(match error {
1844                            Ok(value) => common::Error::BadRequest(value),
1845                            _ => common::Error::Failure(response),
1846                        });
1847                    }
1848                    let response = {
1849                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1850                        let encoded = common::to_string(&bytes);
1851                        match serde_json::from_str(&encoded) {
1852                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1853                            Err(error) => {
1854                                dlg.response_json_decode_error(&encoded, &error);
1855                                return Err(common::Error::JsonDecodeError(
1856                                    encoded.to_string(),
1857                                    error,
1858                                ));
1859                            }
1860                        }
1861                    };
1862
1863                    dlg.finished(true);
1864                    return Ok(response);
1865                }
1866            }
1867        }
1868    }
1869
1870    /// Account to which the ad client belongs.
1871    ///
1872    /// Sets the *account id* path property to the given value.
1873    ///
1874    /// Even though the property as already been set when instantiating this call,
1875    /// we provide this method for API completeness.
1876    pub fn account_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
1877        self._account_id = new_value.to_string();
1878        self
1879    }
1880    /// Ad client which contains the custom channel.
1881    ///
1882    /// Sets the *ad client id* path property to the given value.
1883    ///
1884    /// Even though the property as already been set when instantiating this call,
1885    /// we provide this method for API completeness.
1886    pub fn ad_client_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
1887        self._ad_client_id = new_value.to_string();
1888        self
1889    }
1890    /// Custom channel to retrieve.
1891    ///
1892    /// Sets the *custom channel id* path property to the given value.
1893    ///
1894    /// Even though the property as already been set when instantiating this call,
1895    /// we provide this method for API completeness.
1896    pub fn custom_channel_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
1897        self._custom_channel_id = new_value.to_string();
1898        self
1899    }
1900    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1901    /// while executing the actual API request.
1902    ///
1903    /// ````text
1904    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1905    /// ````
1906    ///
1907    /// Sets the *delegate* property to the given value.
1908    pub fn delegate(
1909        mut self,
1910        new_value: &'a mut dyn common::Delegate,
1911    ) -> AccountCustomchannelGetCall<'a, C> {
1912        self._delegate = Some(new_value);
1913        self
1914    }
1915
1916    /// Set any additional parameter of the query string used in the request.
1917    /// It should be used to set parameters which are not yet available through their own
1918    /// setters.
1919    ///
1920    /// Please note that this method must not be used to set any of the known parameters
1921    /// which have their own setter method. If done anyway, the request will fail.
1922    ///
1923    /// # Additional Parameters
1924    ///
1925    /// * *alt* (query-string) - Data format for the response.
1926    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1927    /// * *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.
1928    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1929    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1930    /// * *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. Overrides userIp if both are provided.
1931    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1932    pub fn param<T>(mut self, name: T, value: T) -> AccountCustomchannelGetCall<'a, C>
1933    where
1934        T: AsRef<str>,
1935    {
1936        self._additional_params
1937            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1938        self
1939    }
1940
1941    /// Identifies the authorization scope for the method you are building.
1942    ///
1943    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1944    /// [`Scope::AdexchangeSellerReadonly`].
1945    ///
1946    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1947    /// tokens for more than one scope.
1948    ///
1949    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1950    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1951    /// sufficient, a read-write scope will do as well.
1952    pub fn add_scope<St>(mut self, scope: St) -> AccountCustomchannelGetCall<'a, C>
1953    where
1954        St: AsRef<str>,
1955    {
1956        self._scopes.insert(String::from(scope.as_ref()));
1957        self
1958    }
1959    /// Identifies the authorization scope(s) for the method you are building.
1960    ///
1961    /// See [`Self::add_scope()`] for details.
1962    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountCustomchannelGetCall<'a, C>
1963    where
1964        I: IntoIterator<Item = St>,
1965        St: AsRef<str>,
1966    {
1967        self._scopes
1968            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1969        self
1970    }
1971
1972    /// Removes all scopes, and no default scope will be used either.
1973    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1974    /// for details).
1975    pub fn clear_scopes(mut self) -> AccountCustomchannelGetCall<'a, C> {
1976        self._scopes.clear();
1977        self
1978    }
1979}
1980
1981/// List all custom channels in the specified ad client for this Ad Exchange account.
1982///
1983/// A builder for the *customchannels.list* method supported by a *account* resource.
1984/// It is not used directly, but through a [`AccountMethods`] instance.
1985///
1986/// # Example
1987///
1988/// Instantiate a resource method builder
1989///
1990/// ```test_harness,no_run
1991/// # extern crate hyper;
1992/// # extern crate hyper_rustls;
1993/// # extern crate google_adexchangeseller2 as adexchangeseller2;
1994/// # async fn dox() {
1995/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1996///
1997/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1998/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1999/// #     .with_native_roots()
2000/// #     .unwrap()
2001/// #     .https_only()
2002/// #     .enable_http2()
2003/// #     .build();
2004///
2005/// # let executor = hyper_util::rt::TokioExecutor::new();
2006/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2007/// #     secret,
2008/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2009/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2010/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2011/// #     ),
2012/// # ).build().await.unwrap();
2013///
2014/// # let client = hyper_util::client::legacy::Client::builder(
2015/// #     hyper_util::rt::TokioExecutor::new()
2016/// # )
2017/// # .build(
2018/// #     hyper_rustls::HttpsConnectorBuilder::new()
2019/// #         .with_native_roots()
2020/// #         .unwrap()
2021/// #         .https_or_http()
2022/// #         .enable_http2()
2023/// #         .build()
2024/// # );
2025/// # let mut hub = AdExchangeSeller::new(client, auth);
2026/// // You can configure optional parameters by calling the respective setters at will, and
2027/// // execute the final call using `doit()`.
2028/// // Values shown here are possibly random and not representative !
2029/// let result = hub.accounts().customchannels_list("accountId", "adClientId")
2030///              .page_token("sed")
2031///              .max_results(40)
2032///              .doit().await;
2033/// # }
2034/// ```
2035pub struct AccountCustomchannelListCall<'a, C>
2036where
2037    C: 'a,
2038{
2039    hub: &'a AdExchangeSeller<C>,
2040    _account_id: String,
2041    _ad_client_id: String,
2042    _page_token: Option<String>,
2043    _max_results: Option<u32>,
2044    _delegate: Option<&'a mut dyn common::Delegate>,
2045    _additional_params: HashMap<String, String>,
2046    _scopes: BTreeSet<String>,
2047}
2048
2049impl<'a, C> common::CallBuilder for AccountCustomchannelListCall<'a, C> {}
2050
2051impl<'a, C> AccountCustomchannelListCall<'a, C>
2052where
2053    C: common::Connector,
2054{
2055    /// Perform the operation you have build so far.
2056    pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
2057        use std::borrow::Cow;
2058        use std::io::{Read, Seek};
2059
2060        use common::{url::Params, ToParts};
2061        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2062
2063        let mut dd = common::DefaultDelegate;
2064        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2065        dlg.begin(common::MethodInfo {
2066            id: "adexchangeseller.accounts.customchannels.list",
2067            http_method: hyper::Method::GET,
2068        });
2069
2070        for &field in ["alt", "accountId", "adClientId", "pageToken", "maxResults"].iter() {
2071            if self._additional_params.contains_key(field) {
2072                dlg.finished(false);
2073                return Err(common::Error::FieldClash(field));
2074            }
2075        }
2076
2077        let mut params = Params::with_capacity(6 + self._additional_params.len());
2078        params.push("accountId", self._account_id);
2079        params.push("adClientId", self._ad_client_id);
2080        if let Some(value) = self._page_token.as_ref() {
2081            params.push("pageToken", value);
2082        }
2083        if let Some(value) = self._max_results.as_ref() {
2084            params.push("maxResults", value.to_string());
2085        }
2086
2087        params.extend(self._additional_params.iter());
2088
2089        params.push("alt", "json");
2090        let mut url = self.hub._base_url.clone()
2091            + "accounts/{accountId}/adclients/{adClientId}/customchannels";
2092        if self._scopes.is_empty() {
2093            self._scopes
2094                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
2095        }
2096
2097        #[allow(clippy::single_element_loop)]
2098        for &(find_this, param_name) in
2099            [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
2100        {
2101            url = params.uri_replacement(url, param_name, find_this, false);
2102        }
2103        {
2104            let to_remove = ["adClientId", "accountId"];
2105            params.remove_params(&to_remove);
2106        }
2107
2108        let url = params.parse_with_url(&url);
2109
2110        loop {
2111            let token = match self
2112                .hub
2113                .auth
2114                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2115                .await
2116            {
2117                Ok(token) => token,
2118                Err(e) => match dlg.token(e) {
2119                    Ok(token) => token,
2120                    Err(e) => {
2121                        dlg.finished(false);
2122                        return Err(common::Error::MissingToken(e));
2123                    }
2124                },
2125            };
2126            let mut req_result = {
2127                let client = &self.hub.client;
2128                dlg.pre_request();
2129                let mut req_builder = hyper::Request::builder()
2130                    .method(hyper::Method::GET)
2131                    .uri(url.as_str())
2132                    .header(USER_AGENT, self.hub._user_agent.clone());
2133
2134                if let Some(token) = token.as_ref() {
2135                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2136                }
2137
2138                let request = req_builder
2139                    .header(CONTENT_LENGTH, 0_u64)
2140                    .body(common::to_body::<String>(None));
2141
2142                client.request(request.unwrap()).await
2143            };
2144
2145            match req_result {
2146                Err(err) => {
2147                    if let common::Retry::After(d) = dlg.http_error(&err) {
2148                        sleep(d).await;
2149                        continue;
2150                    }
2151                    dlg.finished(false);
2152                    return Err(common::Error::HttpError(err));
2153                }
2154                Ok(res) => {
2155                    let (mut parts, body) = res.into_parts();
2156                    let mut body = common::Body::new(body);
2157                    if !parts.status.is_success() {
2158                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2159                        let error = serde_json::from_str(&common::to_string(&bytes));
2160                        let response = common::to_response(parts, bytes.into());
2161
2162                        if let common::Retry::After(d) =
2163                            dlg.http_failure(&response, error.as_ref().ok())
2164                        {
2165                            sleep(d).await;
2166                            continue;
2167                        }
2168
2169                        dlg.finished(false);
2170
2171                        return Err(match error {
2172                            Ok(value) => common::Error::BadRequest(value),
2173                            _ => common::Error::Failure(response),
2174                        });
2175                    }
2176                    let response = {
2177                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2178                        let encoded = common::to_string(&bytes);
2179                        match serde_json::from_str(&encoded) {
2180                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2181                            Err(error) => {
2182                                dlg.response_json_decode_error(&encoded, &error);
2183                                return Err(common::Error::JsonDecodeError(
2184                                    encoded.to_string(),
2185                                    error,
2186                                ));
2187                            }
2188                        }
2189                    };
2190
2191                    dlg.finished(true);
2192                    return Ok(response);
2193                }
2194            }
2195        }
2196    }
2197
2198    /// Account to which the ad client belongs.
2199    ///
2200    /// Sets the *account id* path property to the given value.
2201    ///
2202    /// Even though the property as already been set when instantiating this call,
2203    /// we provide this method for API completeness.
2204    pub fn account_id(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
2205        self._account_id = new_value.to_string();
2206        self
2207    }
2208    /// Ad client for which to list custom channels.
2209    ///
2210    /// Sets the *ad client id* path property to the given value.
2211    ///
2212    /// Even though the property as already been set when instantiating this call,
2213    /// we provide this method for API completeness.
2214    pub fn ad_client_id(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
2215        self._ad_client_id = new_value.to_string();
2216        self
2217    }
2218    /// A continuation token, used to page through custom channels. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
2219    ///
2220    /// Sets the *page token* query property to the given value.
2221    pub fn page_token(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
2222        self._page_token = Some(new_value.to_string());
2223        self
2224    }
2225    /// The maximum number of custom channels to include in the response, used for paging.
2226    ///
2227    /// Sets the *max results* query property to the given value.
2228    pub fn max_results(mut self, new_value: u32) -> AccountCustomchannelListCall<'a, C> {
2229        self._max_results = Some(new_value);
2230        self
2231    }
2232    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2233    /// while executing the actual API request.
2234    ///
2235    /// ````text
2236    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2237    /// ````
2238    ///
2239    /// Sets the *delegate* property to the given value.
2240    pub fn delegate(
2241        mut self,
2242        new_value: &'a mut dyn common::Delegate,
2243    ) -> AccountCustomchannelListCall<'a, C> {
2244        self._delegate = Some(new_value);
2245        self
2246    }
2247
2248    /// Set any additional parameter of the query string used in the request.
2249    /// It should be used to set parameters which are not yet available through their own
2250    /// setters.
2251    ///
2252    /// Please note that this method must not be used to set any of the known parameters
2253    /// which have their own setter method. If done anyway, the request will fail.
2254    ///
2255    /// # Additional Parameters
2256    ///
2257    /// * *alt* (query-string) - Data format for the response.
2258    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2259    /// * *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.
2260    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2261    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2262    /// * *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. Overrides userIp if both are provided.
2263    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2264    pub fn param<T>(mut self, name: T, value: T) -> AccountCustomchannelListCall<'a, C>
2265    where
2266        T: AsRef<str>,
2267    {
2268        self._additional_params
2269            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2270        self
2271    }
2272
2273    /// Identifies the authorization scope for the method you are building.
2274    ///
2275    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2276    /// [`Scope::AdexchangeSellerReadonly`].
2277    ///
2278    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2279    /// tokens for more than one scope.
2280    ///
2281    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2282    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2283    /// sufficient, a read-write scope will do as well.
2284    pub fn add_scope<St>(mut self, scope: St) -> AccountCustomchannelListCall<'a, C>
2285    where
2286        St: AsRef<str>,
2287    {
2288        self._scopes.insert(String::from(scope.as_ref()));
2289        self
2290    }
2291    /// Identifies the authorization scope(s) for the method you are building.
2292    ///
2293    /// See [`Self::add_scope()`] for details.
2294    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountCustomchannelListCall<'a, C>
2295    where
2296        I: IntoIterator<Item = St>,
2297        St: AsRef<str>,
2298    {
2299        self._scopes
2300            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2301        self
2302    }
2303
2304    /// Removes all scopes, and no default scope will be used either.
2305    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2306    /// for details).
2307    pub fn clear_scopes(mut self) -> AccountCustomchannelListCall<'a, C> {
2308        self._scopes.clear();
2309        self
2310    }
2311}
2312
2313/// List the metadata for the dimensions available to this AdExchange account.
2314///
2315/// A builder for the *metadata.dimensions.list* method supported by a *account* resource.
2316/// It is not used directly, but through a [`AccountMethods`] instance.
2317///
2318/// # Example
2319///
2320/// Instantiate a resource method builder
2321///
2322/// ```test_harness,no_run
2323/// # extern crate hyper;
2324/// # extern crate hyper_rustls;
2325/// # extern crate google_adexchangeseller2 as adexchangeseller2;
2326/// # async fn dox() {
2327/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2328///
2329/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2330/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2331/// #     .with_native_roots()
2332/// #     .unwrap()
2333/// #     .https_only()
2334/// #     .enable_http2()
2335/// #     .build();
2336///
2337/// # let executor = hyper_util::rt::TokioExecutor::new();
2338/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2339/// #     secret,
2340/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2341/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2342/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2343/// #     ),
2344/// # ).build().await.unwrap();
2345///
2346/// # let client = hyper_util::client::legacy::Client::builder(
2347/// #     hyper_util::rt::TokioExecutor::new()
2348/// # )
2349/// # .build(
2350/// #     hyper_rustls::HttpsConnectorBuilder::new()
2351/// #         .with_native_roots()
2352/// #         .unwrap()
2353/// #         .https_or_http()
2354/// #         .enable_http2()
2355/// #         .build()
2356/// # );
2357/// # let mut hub = AdExchangeSeller::new(client, auth);
2358/// // You can configure optional parameters by calling the respective setters at will, and
2359/// // execute the final call using `doit()`.
2360/// // Values shown here are possibly random and not representative !
2361/// let result = hub.accounts().metadata_dimensions_list("accountId")
2362///              .doit().await;
2363/// # }
2364/// ```
2365pub struct AccountMetadataDimensionListCall<'a, C>
2366where
2367    C: 'a,
2368{
2369    hub: &'a AdExchangeSeller<C>,
2370    _account_id: String,
2371    _delegate: Option<&'a mut dyn common::Delegate>,
2372    _additional_params: HashMap<String, String>,
2373    _scopes: BTreeSet<String>,
2374}
2375
2376impl<'a, C> common::CallBuilder for AccountMetadataDimensionListCall<'a, C> {}
2377
2378impl<'a, C> AccountMetadataDimensionListCall<'a, C>
2379where
2380    C: common::Connector,
2381{
2382    /// Perform the operation you have build so far.
2383    pub async fn doit(mut self) -> common::Result<(common::Response, Metadata)> {
2384        use std::borrow::Cow;
2385        use std::io::{Read, Seek};
2386
2387        use common::{url::Params, ToParts};
2388        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2389
2390        let mut dd = common::DefaultDelegate;
2391        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2392        dlg.begin(common::MethodInfo {
2393            id: "adexchangeseller.accounts.metadata.dimensions.list",
2394            http_method: hyper::Method::GET,
2395        });
2396
2397        for &field in ["alt", "accountId"].iter() {
2398            if self._additional_params.contains_key(field) {
2399                dlg.finished(false);
2400                return Err(common::Error::FieldClash(field));
2401            }
2402        }
2403
2404        let mut params = Params::with_capacity(3 + self._additional_params.len());
2405        params.push("accountId", self._account_id);
2406
2407        params.extend(self._additional_params.iter());
2408
2409        params.push("alt", "json");
2410        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/metadata/dimensions";
2411        if self._scopes.is_empty() {
2412            self._scopes
2413                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
2414        }
2415
2416        #[allow(clippy::single_element_loop)]
2417        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
2418            url = params.uri_replacement(url, param_name, find_this, false);
2419        }
2420        {
2421            let to_remove = ["accountId"];
2422            params.remove_params(&to_remove);
2423        }
2424
2425        let url = params.parse_with_url(&url);
2426
2427        loop {
2428            let token = match self
2429                .hub
2430                .auth
2431                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2432                .await
2433            {
2434                Ok(token) => token,
2435                Err(e) => match dlg.token(e) {
2436                    Ok(token) => token,
2437                    Err(e) => {
2438                        dlg.finished(false);
2439                        return Err(common::Error::MissingToken(e));
2440                    }
2441                },
2442            };
2443            let mut req_result = {
2444                let client = &self.hub.client;
2445                dlg.pre_request();
2446                let mut req_builder = hyper::Request::builder()
2447                    .method(hyper::Method::GET)
2448                    .uri(url.as_str())
2449                    .header(USER_AGENT, self.hub._user_agent.clone());
2450
2451                if let Some(token) = token.as_ref() {
2452                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2453                }
2454
2455                let request = req_builder
2456                    .header(CONTENT_LENGTH, 0_u64)
2457                    .body(common::to_body::<String>(None));
2458
2459                client.request(request.unwrap()).await
2460            };
2461
2462            match req_result {
2463                Err(err) => {
2464                    if let common::Retry::After(d) = dlg.http_error(&err) {
2465                        sleep(d).await;
2466                        continue;
2467                    }
2468                    dlg.finished(false);
2469                    return Err(common::Error::HttpError(err));
2470                }
2471                Ok(res) => {
2472                    let (mut parts, body) = res.into_parts();
2473                    let mut body = common::Body::new(body);
2474                    if !parts.status.is_success() {
2475                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2476                        let error = serde_json::from_str(&common::to_string(&bytes));
2477                        let response = common::to_response(parts, bytes.into());
2478
2479                        if let common::Retry::After(d) =
2480                            dlg.http_failure(&response, error.as_ref().ok())
2481                        {
2482                            sleep(d).await;
2483                            continue;
2484                        }
2485
2486                        dlg.finished(false);
2487
2488                        return Err(match error {
2489                            Ok(value) => common::Error::BadRequest(value),
2490                            _ => common::Error::Failure(response),
2491                        });
2492                    }
2493                    let response = {
2494                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2495                        let encoded = common::to_string(&bytes);
2496                        match serde_json::from_str(&encoded) {
2497                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2498                            Err(error) => {
2499                                dlg.response_json_decode_error(&encoded, &error);
2500                                return Err(common::Error::JsonDecodeError(
2501                                    encoded.to_string(),
2502                                    error,
2503                                ));
2504                            }
2505                        }
2506                    };
2507
2508                    dlg.finished(true);
2509                    return Ok(response);
2510                }
2511            }
2512        }
2513    }
2514
2515    /// Account with visibility to the dimensions.
2516    ///
2517    /// Sets the *account id* path property to the given value.
2518    ///
2519    /// Even though the property as already been set when instantiating this call,
2520    /// we provide this method for API completeness.
2521    pub fn account_id(mut self, new_value: &str) -> AccountMetadataDimensionListCall<'a, C> {
2522        self._account_id = new_value.to_string();
2523        self
2524    }
2525    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2526    /// while executing the actual API request.
2527    ///
2528    /// ````text
2529    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2530    /// ````
2531    ///
2532    /// Sets the *delegate* property to the given value.
2533    pub fn delegate(
2534        mut self,
2535        new_value: &'a mut dyn common::Delegate,
2536    ) -> AccountMetadataDimensionListCall<'a, C> {
2537        self._delegate = Some(new_value);
2538        self
2539    }
2540
2541    /// Set any additional parameter of the query string used in the request.
2542    /// It should be used to set parameters which are not yet available through their own
2543    /// setters.
2544    ///
2545    /// Please note that this method must not be used to set any of the known parameters
2546    /// which have their own setter method. If done anyway, the request will fail.
2547    ///
2548    /// # Additional Parameters
2549    ///
2550    /// * *alt* (query-string) - Data format for the response.
2551    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2552    /// * *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.
2553    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2554    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2555    /// * *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. Overrides userIp if both are provided.
2556    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2557    pub fn param<T>(mut self, name: T, value: T) -> AccountMetadataDimensionListCall<'a, C>
2558    where
2559        T: AsRef<str>,
2560    {
2561        self._additional_params
2562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2563        self
2564    }
2565
2566    /// Identifies the authorization scope for the method you are building.
2567    ///
2568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2569    /// [`Scope::AdexchangeSellerReadonly`].
2570    ///
2571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2572    /// tokens for more than one scope.
2573    ///
2574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2576    /// sufficient, a read-write scope will do as well.
2577    pub fn add_scope<St>(mut self, scope: St) -> AccountMetadataDimensionListCall<'a, C>
2578    where
2579        St: AsRef<str>,
2580    {
2581        self._scopes.insert(String::from(scope.as_ref()));
2582        self
2583    }
2584    /// Identifies the authorization scope(s) for the method you are building.
2585    ///
2586    /// See [`Self::add_scope()`] for details.
2587    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountMetadataDimensionListCall<'a, C>
2588    where
2589        I: IntoIterator<Item = St>,
2590        St: AsRef<str>,
2591    {
2592        self._scopes
2593            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2594        self
2595    }
2596
2597    /// Removes all scopes, and no default scope will be used either.
2598    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2599    /// for details).
2600    pub fn clear_scopes(mut self) -> AccountMetadataDimensionListCall<'a, C> {
2601        self._scopes.clear();
2602        self
2603    }
2604}
2605
2606/// List the metadata for the metrics available to this AdExchange account.
2607///
2608/// A builder for the *metadata.metrics.list* method supported by a *account* resource.
2609/// It is not used directly, but through a [`AccountMethods`] instance.
2610///
2611/// # Example
2612///
2613/// Instantiate a resource method builder
2614///
2615/// ```test_harness,no_run
2616/// # extern crate hyper;
2617/// # extern crate hyper_rustls;
2618/// # extern crate google_adexchangeseller2 as adexchangeseller2;
2619/// # async fn dox() {
2620/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2621///
2622/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2623/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2624/// #     .with_native_roots()
2625/// #     .unwrap()
2626/// #     .https_only()
2627/// #     .enable_http2()
2628/// #     .build();
2629///
2630/// # let executor = hyper_util::rt::TokioExecutor::new();
2631/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2632/// #     secret,
2633/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2634/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2635/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2636/// #     ),
2637/// # ).build().await.unwrap();
2638///
2639/// # let client = hyper_util::client::legacy::Client::builder(
2640/// #     hyper_util::rt::TokioExecutor::new()
2641/// # )
2642/// # .build(
2643/// #     hyper_rustls::HttpsConnectorBuilder::new()
2644/// #         .with_native_roots()
2645/// #         .unwrap()
2646/// #         .https_or_http()
2647/// #         .enable_http2()
2648/// #         .build()
2649/// # );
2650/// # let mut hub = AdExchangeSeller::new(client, auth);
2651/// // You can configure optional parameters by calling the respective setters at will, and
2652/// // execute the final call using `doit()`.
2653/// // Values shown here are possibly random and not representative !
2654/// let result = hub.accounts().metadata_metrics_list("accountId")
2655///              .doit().await;
2656/// # }
2657/// ```
2658pub struct AccountMetadataMetricListCall<'a, C>
2659where
2660    C: 'a,
2661{
2662    hub: &'a AdExchangeSeller<C>,
2663    _account_id: String,
2664    _delegate: Option<&'a mut dyn common::Delegate>,
2665    _additional_params: HashMap<String, String>,
2666    _scopes: BTreeSet<String>,
2667}
2668
2669impl<'a, C> common::CallBuilder for AccountMetadataMetricListCall<'a, C> {}
2670
2671impl<'a, C> AccountMetadataMetricListCall<'a, C>
2672where
2673    C: common::Connector,
2674{
2675    /// Perform the operation you have build so far.
2676    pub async fn doit(mut self) -> common::Result<(common::Response, Metadata)> {
2677        use std::borrow::Cow;
2678        use std::io::{Read, Seek};
2679
2680        use common::{url::Params, ToParts};
2681        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2682
2683        let mut dd = common::DefaultDelegate;
2684        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2685        dlg.begin(common::MethodInfo {
2686            id: "adexchangeseller.accounts.metadata.metrics.list",
2687            http_method: hyper::Method::GET,
2688        });
2689
2690        for &field in ["alt", "accountId"].iter() {
2691            if self._additional_params.contains_key(field) {
2692                dlg.finished(false);
2693                return Err(common::Error::FieldClash(field));
2694            }
2695        }
2696
2697        let mut params = Params::with_capacity(3 + self._additional_params.len());
2698        params.push("accountId", self._account_id);
2699
2700        params.extend(self._additional_params.iter());
2701
2702        params.push("alt", "json");
2703        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/metadata/metrics";
2704        if self._scopes.is_empty() {
2705            self._scopes
2706                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
2707        }
2708
2709        #[allow(clippy::single_element_loop)]
2710        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
2711            url = params.uri_replacement(url, param_name, find_this, false);
2712        }
2713        {
2714            let to_remove = ["accountId"];
2715            params.remove_params(&to_remove);
2716        }
2717
2718        let url = params.parse_with_url(&url);
2719
2720        loop {
2721            let token = match self
2722                .hub
2723                .auth
2724                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2725                .await
2726            {
2727                Ok(token) => token,
2728                Err(e) => match dlg.token(e) {
2729                    Ok(token) => token,
2730                    Err(e) => {
2731                        dlg.finished(false);
2732                        return Err(common::Error::MissingToken(e));
2733                    }
2734                },
2735            };
2736            let mut req_result = {
2737                let client = &self.hub.client;
2738                dlg.pre_request();
2739                let mut req_builder = hyper::Request::builder()
2740                    .method(hyper::Method::GET)
2741                    .uri(url.as_str())
2742                    .header(USER_AGENT, self.hub._user_agent.clone());
2743
2744                if let Some(token) = token.as_ref() {
2745                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2746                }
2747
2748                let request = req_builder
2749                    .header(CONTENT_LENGTH, 0_u64)
2750                    .body(common::to_body::<String>(None));
2751
2752                client.request(request.unwrap()).await
2753            };
2754
2755            match req_result {
2756                Err(err) => {
2757                    if let common::Retry::After(d) = dlg.http_error(&err) {
2758                        sleep(d).await;
2759                        continue;
2760                    }
2761                    dlg.finished(false);
2762                    return Err(common::Error::HttpError(err));
2763                }
2764                Ok(res) => {
2765                    let (mut parts, body) = res.into_parts();
2766                    let mut body = common::Body::new(body);
2767                    if !parts.status.is_success() {
2768                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2769                        let error = serde_json::from_str(&common::to_string(&bytes));
2770                        let response = common::to_response(parts, bytes.into());
2771
2772                        if let common::Retry::After(d) =
2773                            dlg.http_failure(&response, error.as_ref().ok())
2774                        {
2775                            sleep(d).await;
2776                            continue;
2777                        }
2778
2779                        dlg.finished(false);
2780
2781                        return Err(match error {
2782                            Ok(value) => common::Error::BadRequest(value),
2783                            _ => common::Error::Failure(response),
2784                        });
2785                    }
2786                    let response = {
2787                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2788                        let encoded = common::to_string(&bytes);
2789                        match serde_json::from_str(&encoded) {
2790                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2791                            Err(error) => {
2792                                dlg.response_json_decode_error(&encoded, &error);
2793                                return Err(common::Error::JsonDecodeError(
2794                                    encoded.to_string(),
2795                                    error,
2796                                ));
2797                            }
2798                        }
2799                    };
2800
2801                    dlg.finished(true);
2802                    return Ok(response);
2803                }
2804            }
2805        }
2806    }
2807
2808    /// Account with visibility to the metrics.
2809    ///
2810    /// Sets the *account id* path property to the given value.
2811    ///
2812    /// Even though the property as already been set when instantiating this call,
2813    /// we provide this method for API completeness.
2814    pub fn account_id(mut self, new_value: &str) -> AccountMetadataMetricListCall<'a, C> {
2815        self._account_id = new_value.to_string();
2816        self
2817    }
2818    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2819    /// while executing the actual API request.
2820    ///
2821    /// ````text
2822    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2823    /// ````
2824    ///
2825    /// Sets the *delegate* property to the given value.
2826    pub fn delegate(
2827        mut self,
2828        new_value: &'a mut dyn common::Delegate,
2829    ) -> AccountMetadataMetricListCall<'a, C> {
2830        self._delegate = Some(new_value);
2831        self
2832    }
2833
2834    /// Set any additional parameter of the query string used in the request.
2835    /// It should be used to set parameters which are not yet available through their own
2836    /// setters.
2837    ///
2838    /// Please note that this method must not be used to set any of the known parameters
2839    /// which have their own setter method. If done anyway, the request will fail.
2840    ///
2841    /// # Additional Parameters
2842    ///
2843    /// * *alt* (query-string) - Data format for the response.
2844    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2845    /// * *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.
2846    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2847    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2848    /// * *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. Overrides userIp if both are provided.
2849    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2850    pub fn param<T>(mut self, name: T, value: T) -> AccountMetadataMetricListCall<'a, C>
2851    where
2852        T: AsRef<str>,
2853    {
2854        self._additional_params
2855            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2856        self
2857    }
2858
2859    /// Identifies the authorization scope for the method you are building.
2860    ///
2861    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2862    /// [`Scope::AdexchangeSellerReadonly`].
2863    ///
2864    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2865    /// tokens for more than one scope.
2866    ///
2867    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2868    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2869    /// sufficient, a read-write scope will do as well.
2870    pub fn add_scope<St>(mut self, scope: St) -> AccountMetadataMetricListCall<'a, C>
2871    where
2872        St: AsRef<str>,
2873    {
2874        self._scopes.insert(String::from(scope.as_ref()));
2875        self
2876    }
2877    /// Identifies the authorization scope(s) for the method you are building.
2878    ///
2879    /// See [`Self::add_scope()`] for details.
2880    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountMetadataMetricListCall<'a, C>
2881    where
2882        I: IntoIterator<Item = St>,
2883        St: AsRef<str>,
2884    {
2885        self._scopes
2886            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2887        self
2888    }
2889
2890    /// Removes all scopes, and no default scope will be used either.
2891    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2892    /// for details).
2893    pub fn clear_scopes(mut self) -> AccountMetadataMetricListCall<'a, C> {
2894        self._scopes.clear();
2895        self
2896    }
2897}
2898
2899/// Get information about the selected Ad Exchange Preferred Deal.
2900///
2901/// A builder for the *preferreddeals.get* method supported by a *account* resource.
2902/// It is not used directly, but through a [`AccountMethods`] instance.
2903///
2904/// # Example
2905///
2906/// Instantiate a resource method builder
2907///
2908/// ```test_harness,no_run
2909/// # extern crate hyper;
2910/// # extern crate hyper_rustls;
2911/// # extern crate google_adexchangeseller2 as adexchangeseller2;
2912/// # async fn dox() {
2913/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2914///
2915/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2916/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2917/// #     .with_native_roots()
2918/// #     .unwrap()
2919/// #     .https_only()
2920/// #     .enable_http2()
2921/// #     .build();
2922///
2923/// # let executor = hyper_util::rt::TokioExecutor::new();
2924/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2925/// #     secret,
2926/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2927/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2928/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2929/// #     ),
2930/// # ).build().await.unwrap();
2931///
2932/// # let client = hyper_util::client::legacy::Client::builder(
2933/// #     hyper_util::rt::TokioExecutor::new()
2934/// # )
2935/// # .build(
2936/// #     hyper_rustls::HttpsConnectorBuilder::new()
2937/// #         .with_native_roots()
2938/// #         .unwrap()
2939/// #         .https_or_http()
2940/// #         .enable_http2()
2941/// #         .build()
2942/// # );
2943/// # let mut hub = AdExchangeSeller::new(client, auth);
2944/// // You can configure optional parameters by calling the respective setters at will, and
2945/// // execute the final call using `doit()`.
2946/// // Values shown here are possibly random and not representative !
2947/// let result = hub.accounts().preferreddeals_get("accountId", "dealId")
2948///              .doit().await;
2949/// # }
2950/// ```
2951pub struct AccountPreferreddealGetCall<'a, C>
2952where
2953    C: 'a,
2954{
2955    hub: &'a AdExchangeSeller<C>,
2956    _account_id: String,
2957    _deal_id: String,
2958    _delegate: Option<&'a mut dyn common::Delegate>,
2959    _additional_params: HashMap<String, String>,
2960    _scopes: BTreeSet<String>,
2961}
2962
2963impl<'a, C> common::CallBuilder for AccountPreferreddealGetCall<'a, C> {}
2964
2965impl<'a, C> AccountPreferreddealGetCall<'a, C>
2966where
2967    C: common::Connector,
2968{
2969    /// Perform the operation you have build so far.
2970    pub async fn doit(mut self) -> common::Result<(common::Response, PreferredDeal)> {
2971        use std::borrow::Cow;
2972        use std::io::{Read, Seek};
2973
2974        use common::{url::Params, ToParts};
2975        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2976
2977        let mut dd = common::DefaultDelegate;
2978        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2979        dlg.begin(common::MethodInfo {
2980            id: "adexchangeseller.accounts.preferreddeals.get",
2981            http_method: hyper::Method::GET,
2982        });
2983
2984        for &field in ["alt", "accountId", "dealId"].iter() {
2985            if self._additional_params.contains_key(field) {
2986                dlg.finished(false);
2987                return Err(common::Error::FieldClash(field));
2988            }
2989        }
2990
2991        let mut params = Params::with_capacity(4 + self._additional_params.len());
2992        params.push("accountId", self._account_id);
2993        params.push("dealId", self._deal_id);
2994
2995        params.extend(self._additional_params.iter());
2996
2997        params.push("alt", "json");
2998        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/preferreddeals/{dealId}";
2999        if self._scopes.is_empty() {
3000            self._scopes
3001                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
3002        }
3003
3004        #[allow(clippy::single_element_loop)]
3005        for &(find_this, param_name) in
3006            [("{accountId}", "accountId"), ("{dealId}", "dealId")].iter()
3007        {
3008            url = params.uri_replacement(url, param_name, find_this, false);
3009        }
3010        {
3011            let to_remove = ["dealId", "accountId"];
3012            params.remove_params(&to_remove);
3013        }
3014
3015        let url = params.parse_with_url(&url);
3016
3017        loop {
3018            let token = match self
3019                .hub
3020                .auth
3021                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3022                .await
3023            {
3024                Ok(token) => token,
3025                Err(e) => match dlg.token(e) {
3026                    Ok(token) => token,
3027                    Err(e) => {
3028                        dlg.finished(false);
3029                        return Err(common::Error::MissingToken(e));
3030                    }
3031                },
3032            };
3033            let mut req_result = {
3034                let client = &self.hub.client;
3035                dlg.pre_request();
3036                let mut req_builder = hyper::Request::builder()
3037                    .method(hyper::Method::GET)
3038                    .uri(url.as_str())
3039                    .header(USER_AGENT, self.hub._user_agent.clone());
3040
3041                if let Some(token) = token.as_ref() {
3042                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3043                }
3044
3045                let request = req_builder
3046                    .header(CONTENT_LENGTH, 0_u64)
3047                    .body(common::to_body::<String>(None));
3048
3049                client.request(request.unwrap()).await
3050            };
3051
3052            match req_result {
3053                Err(err) => {
3054                    if let common::Retry::After(d) = dlg.http_error(&err) {
3055                        sleep(d).await;
3056                        continue;
3057                    }
3058                    dlg.finished(false);
3059                    return Err(common::Error::HttpError(err));
3060                }
3061                Ok(res) => {
3062                    let (mut parts, body) = res.into_parts();
3063                    let mut body = common::Body::new(body);
3064                    if !parts.status.is_success() {
3065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3066                        let error = serde_json::from_str(&common::to_string(&bytes));
3067                        let response = common::to_response(parts, bytes.into());
3068
3069                        if let common::Retry::After(d) =
3070                            dlg.http_failure(&response, error.as_ref().ok())
3071                        {
3072                            sleep(d).await;
3073                            continue;
3074                        }
3075
3076                        dlg.finished(false);
3077
3078                        return Err(match error {
3079                            Ok(value) => common::Error::BadRequest(value),
3080                            _ => common::Error::Failure(response),
3081                        });
3082                    }
3083                    let response = {
3084                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3085                        let encoded = common::to_string(&bytes);
3086                        match serde_json::from_str(&encoded) {
3087                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3088                            Err(error) => {
3089                                dlg.response_json_decode_error(&encoded, &error);
3090                                return Err(common::Error::JsonDecodeError(
3091                                    encoded.to_string(),
3092                                    error,
3093                                ));
3094                            }
3095                        }
3096                    };
3097
3098                    dlg.finished(true);
3099                    return Ok(response);
3100                }
3101            }
3102        }
3103    }
3104
3105    /// Account owning the deal.
3106    ///
3107    /// Sets the *account id* path property to the given value.
3108    ///
3109    /// Even though the property as already been set when instantiating this call,
3110    /// we provide this method for API completeness.
3111    pub fn account_id(mut self, new_value: &str) -> AccountPreferreddealGetCall<'a, C> {
3112        self._account_id = new_value.to_string();
3113        self
3114    }
3115    /// Preferred deal to get information about.
3116    ///
3117    /// Sets the *deal id* path property to the given value.
3118    ///
3119    /// Even though the property as already been set when instantiating this call,
3120    /// we provide this method for API completeness.
3121    pub fn deal_id(mut self, new_value: &str) -> AccountPreferreddealGetCall<'a, C> {
3122        self._deal_id = new_value.to_string();
3123        self
3124    }
3125    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3126    /// while executing the actual API request.
3127    ///
3128    /// ````text
3129    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3130    /// ````
3131    ///
3132    /// Sets the *delegate* property to the given value.
3133    pub fn delegate(
3134        mut self,
3135        new_value: &'a mut dyn common::Delegate,
3136    ) -> AccountPreferreddealGetCall<'a, C> {
3137        self._delegate = Some(new_value);
3138        self
3139    }
3140
3141    /// Set any additional parameter of the query string used in the request.
3142    /// It should be used to set parameters which are not yet available through their own
3143    /// setters.
3144    ///
3145    /// Please note that this method must not be used to set any of the known parameters
3146    /// which have their own setter method. If done anyway, the request will fail.
3147    ///
3148    /// # Additional Parameters
3149    ///
3150    /// * *alt* (query-string) - Data format for the response.
3151    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3152    /// * *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.
3153    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3154    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3155    /// * *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. Overrides userIp if both are provided.
3156    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3157    pub fn param<T>(mut self, name: T, value: T) -> AccountPreferreddealGetCall<'a, C>
3158    where
3159        T: AsRef<str>,
3160    {
3161        self._additional_params
3162            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3163        self
3164    }
3165
3166    /// Identifies the authorization scope for the method you are building.
3167    ///
3168    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3169    /// [`Scope::AdexchangeSellerReadonly`].
3170    ///
3171    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3172    /// tokens for more than one scope.
3173    ///
3174    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3175    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3176    /// sufficient, a read-write scope will do as well.
3177    pub fn add_scope<St>(mut self, scope: St) -> AccountPreferreddealGetCall<'a, C>
3178    where
3179        St: AsRef<str>,
3180    {
3181        self._scopes.insert(String::from(scope.as_ref()));
3182        self
3183    }
3184    /// Identifies the authorization scope(s) for the method you are building.
3185    ///
3186    /// See [`Self::add_scope()`] for details.
3187    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPreferreddealGetCall<'a, C>
3188    where
3189        I: IntoIterator<Item = St>,
3190        St: AsRef<str>,
3191    {
3192        self._scopes
3193            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3194        self
3195    }
3196
3197    /// Removes all scopes, and no default scope will be used either.
3198    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3199    /// for details).
3200    pub fn clear_scopes(mut self) -> AccountPreferreddealGetCall<'a, C> {
3201        self._scopes.clear();
3202        self
3203    }
3204}
3205
3206/// List the preferred deals for this Ad Exchange account.
3207///
3208/// A builder for the *preferreddeals.list* method supported by a *account* resource.
3209/// It is not used directly, but through a [`AccountMethods`] instance.
3210///
3211/// # Example
3212///
3213/// Instantiate a resource method builder
3214///
3215/// ```test_harness,no_run
3216/// # extern crate hyper;
3217/// # extern crate hyper_rustls;
3218/// # extern crate google_adexchangeseller2 as adexchangeseller2;
3219/// # async fn dox() {
3220/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3221///
3222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3223/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3224/// #     .with_native_roots()
3225/// #     .unwrap()
3226/// #     .https_only()
3227/// #     .enable_http2()
3228/// #     .build();
3229///
3230/// # let executor = hyper_util::rt::TokioExecutor::new();
3231/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3232/// #     secret,
3233/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3234/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3235/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3236/// #     ),
3237/// # ).build().await.unwrap();
3238///
3239/// # let client = hyper_util::client::legacy::Client::builder(
3240/// #     hyper_util::rt::TokioExecutor::new()
3241/// # )
3242/// # .build(
3243/// #     hyper_rustls::HttpsConnectorBuilder::new()
3244/// #         .with_native_roots()
3245/// #         .unwrap()
3246/// #         .https_or_http()
3247/// #         .enable_http2()
3248/// #         .build()
3249/// # );
3250/// # let mut hub = AdExchangeSeller::new(client, auth);
3251/// // You can configure optional parameters by calling the respective setters at will, and
3252/// // execute the final call using `doit()`.
3253/// // Values shown here are possibly random and not representative !
3254/// let result = hub.accounts().preferreddeals_list("accountId")
3255///              .doit().await;
3256/// # }
3257/// ```
3258pub struct AccountPreferreddealListCall<'a, C>
3259where
3260    C: 'a,
3261{
3262    hub: &'a AdExchangeSeller<C>,
3263    _account_id: String,
3264    _delegate: Option<&'a mut dyn common::Delegate>,
3265    _additional_params: HashMap<String, String>,
3266    _scopes: BTreeSet<String>,
3267}
3268
3269impl<'a, C> common::CallBuilder for AccountPreferreddealListCall<'a, C> {}
3270
3271impl<'a, C> AccountPreferreddealListCall<'a, C>
3272where
3273    C: common::Connector,
3274{
3275    /// Perform the operation you have build so far.
3276    pub async fn doit(mut self) -> common::Result<(common::Response, PreferredDeals)> {
3277        use std::borrow::Cow;
3278        use std::io::{Read, Seek};
3279
3280        use common::{url::Params, ToParts};
3281        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3282
3283        let mut dd = common::DefaultDelegate;
3284        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3285        dlg.begin(common::MethodInfo {
3286            id: "adexchangeseller.accounts.preferreddeals.list",
3287            http_method: hyper::Method::GET,
3288        });
3289
3290        for &field in ["alt", "accountId"].iter() {
3291            if self._additional_params.contains_key(field) {
3292                dlg.finished(false);
3293                return Err(common::Error::FieldClash(field));
3294            }
3295        }
3296
3297        let mut params = Params::with_capacity(3 + self._additional_params.len());
3298        params.push("accountId", self._account_id);
3299
3300        params.extend(self._additional_params.iter());
3301
3302        params.push("alt", "json");
3303        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/preferreddeals";
3304        if self._scopes.is_empty() {
3305            self._scopes
3306                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
3307        }
3308
3309        #[allow(clippy::single_element_loop)]
3310        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
3311            url = params.uri_replacement(url, param_name, find_this, false);
3312        }
3313        {
3314            let to_remove = ["accountId"];
3315            params.remove_params(&to_remove);
3316        }
3317
3318        let url = params.parse_with_url(&url);
3319
3320        loop {
3321            let token = match self
3322                .hub
3323                .auth
3324                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3325                .await
3326            {
3327                Ok(token) => token,
3328                Err(e) => match dlg.token(e) {
3329                    Ok(token) => token,
3330                    Err(e) => {
3331                        dlg.finished(false);
3332                        return Err(common::Error::MissingToken(e));
3333                    }
3334                },
3335            };
3336            let mut req_result = {
3337                let client = &self.hub.client;
3338                dlg.pre_request();
3339                let mut req_builder = hyper::Request::builder()
3340                    .method(hyper::Method::GET)
3341                    .uri(url.as_str())
3342                    .header(USER_AGENT, self.hub._user_agent.clone());
3343
3344                if let Some(token) = token.as_ref() {
3345                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3346                }
3347
3348                let request = req_builder
3349                    .header(CONTENT_LENGTH, 0_u64)
3350                    .body(common::to_body::<String>(None));
3351
3352                client.request(request.unwrap()).await
3353            };
3354
3355            match req_result {
3356                Err(err) => {
3357                    if let common::Retry::After(d) = dlg.http_error(&err) {
3358                        sleep(d).await;
3359                        continue;
3360                    }
3361                    dlg.finished(false);
3362                    return Err(common::Error::HttpError(err));
3363                }
3364                Ok(res) => {
3365                    let (mut parts, body) = res.into_parts();
3366                    let mut body = common::Body::new(body);
3367                    if !parts.status.is_success() {
3368                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3369                        let error = serde_json::from_str(&common::to_string(&bytes));
3370                        let response = common::to_response(parts, bytes.into());
3371
3372                        if let common::Retry::After(d) =
3373                            dlg.http_failure(&response, error.as_ref().ok())
3374                        {
3375                            sleep(d).await;
3376                            continue;
3377                        }
3378
3379                        dlg.finished(false);
3380
3381                        return Err(match error {
3382                            Ok(value) => common::Error::BadRequest(value),
3383                            _ => common::Error::Failure(response),
3384                        });
3385                    }
3386                    let response = {
3387                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3388                        let encoded = common::to_string(&bytes);
3389                        match serde_json::from_str(&encoded) {
3390                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3391                            Err(error) => {
3392                                dlg.response_json_decode_error(&encoded, &error);
3393                                return Err(common::Error::JsonDecodeError(
3394                                    encoded.to_string(),
3395                                    error,
3396                                ));
3397                            }
3398                        }
3399                    };
3400
3401                    dlg.finished(true);
3402                    return Ok(response);
3403                }
3404            }
3405        }
3406    }
3407
3408    /// Account owning the deals.
3409    ///
3410    /// Sets the *account id* path property to the given value.
3411    ///
3412    /// Even though the property as already been set when instantiating this call,
3413    /// we provide this method for API completeness.
3414    pub fn account_id(mut self, new_value: &str) -> AccountPreferreddealListCall<'a, C> {
3415        self._account_id = new_value.to_string();
3416        self
3417    }
3418    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3419    /// while executing the actual API request.
3420    ///
3421    /// ````text
3422    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3423    /// ````
3424    ///
3425    /// Sets the *delegate* property to the given value.
3426    pub fn delegate(
3427        mut self,
3428        new_value: &'a mut dyn common::Delegate,
3429    ) -> AccountPreferreddealListCall<'a, C> {
3430        self._delegate = Some(new_value);
3431        self
3432    }
3433
3434    /// Set any additional parameter of the query string used in the request.
3435    /// It should be used to set parameters which are not yet available through their own
3436    /// setters.
3437    ///
3438    /// Please note that this method must not be used to set any of the known parameters
3439    /// which have their own setter method. If done anyway, the request will fail.
3440    ///
3441    /// # Additional Parameters
3442    ///
3443    /// * *alt* (query-string) - Data format for the response.
3444    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3445    /// * *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.
3446    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3447    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3448    /// * *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. Overrides userIp if both are provided.
3449    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3450    pub fn param<T>(mut self, name: T, value: T) -> AccountPreferreddealListCall<'a, C>
3451    where
3452        T: AsRef<str>,
3453    {
3454        self._additional_params
3455            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3456        self
3457    }
3458
3459    /// Identifies the authorization scope for the method you are building.
3460    ///
3461    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3462    /// [`Scope::AdexchangeSellerReadonly`].
3463    ///
3464    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3465    /// tokens for more than one scope.
3466    ///
3467    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3468    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3469    /// sufficient, a read-write scope will do as well.
3470    pub fn add_scope<St>(mut self, scope: St) -> AccountPreferreddealListCall<'a, C>
3471    where
3472        St: AsRef<str>,
3473    {
3474        self._scopes.insert(String::from(scope.as_ref()));
3475        self
3476    }
3477    /// Identifies the authorization scope(s) for the method you are building.
3478    ///
3479    /// See [`Self::add_scope()`] for details.
3480    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPreferreddealListCall<'a, C>
3481    where
3482        I: IntoIterator<Item = St>,
3483        St: AsRef<str>,
3484    {
3485        self._scopes
3486            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3487        self
3488    }
3489
3490    /// Removes all scopes, and no default scope will be used either.
3491    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3492    /// for details).
3493    pub fn clear_scopes(mut self) -> AccountPreferreddealListCall<'a, C> {
3494        self._scopes.clear();
3495        self
3496    }
3497}
3498
3499/// Generate an Ad Exchange report based on the saved report ID sent in the query parameters.
3500///
3501/// A builder for the *reports.saved.generate* method supported by a *account* resource.
3502/// It is not used directly, but through a [`AccountMethods`] instance.
3503///
3504/// # Example
3505///
3506/// Instantiate a resource method builder
3507///
3508/// ```test_harness,no_run
3509/// # extern crate hyper;
3510/// # extern crate hyper_rustls;
3511/// # extern crate google_adexchangeseller2 as adexchangeseller2;
3512/// # async fn dox() {
3513/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3514///
3515/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3516/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3517/// #     .with_native_roots()
3518/// #     .unwrap()
3519/// #     .https_only()
3520/// #     .enable_http2()
3521/// #     .build();
3522///
3523/// # let executor = hyper_util::rt::TokioExecutor::new();
3524/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3525/// #     secret,
3526/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3527/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3528/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3529/// #     ),
3530/// # ).build().await.unwrap();
3531///
3532/// # let client = hyper_util::client::legacy::Client::builder(
3533/// #     hyper_util::rt::TokioExecutor::new()
3534/// # )
3535/// # .build(
3536/// #     hyper_rustls::HttpsConnectorBuilder::new()
3537/// #         .with_native_roots()
3538/// #         .unwrap()
3539/// #         .https_or_http()
3540/// #         .enable_http2()
3541/// #         .build()
3542/// # );
3543/// # let mut hub = AdExchangeSeller::new(client, auth);
3544/// // You can configure optional parameters by calling the respective setters at will, and
3545/// // execute the final call using `doit()`.
3546/// // Values shown here are possibly random and not representative !
3547/// let result = hub.accounts().reports_saved_generate("accountId", "savedReportId")
3548///              .start_index(-31)
3549///              .max_results(-93)
3550///              .locale("duo")
3551///              .doit().await;
3552/// # }
3553/// ```
3554pub struct AccountReportSavedGenerateCall<'a, C>
3555where
3556    C: 'a,
3557{
3558    hub: &'a AdExchangeSeller<C>,
3559    _account_id: String,
3560    _saved_report_id: String,
3561    _start_index: Option<i32>,
3562    _max_results: Option<i32>,
3563    _locale: Option<String>,
3564    _delegate: Option<&'a mut dyn common::Delegate>,
3565    _additional_params: HashMap<String, String>,
3566    _scopes: BTreeSet<String>,
3567}
3568
3569impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCall<'a, C> {}
3570
3571impl<'a, C> AccountReportSavedGenerateCall<'a, C>
3572where
3573    C: common::Connector,
3574{
3575    /// Perform the operation you have build so far.
3576    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
3577        use std::borrow::Cow;
3578        use std::io::{Read, Seek};
3579
3580        use common::{url::Params, ToParts};
3581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3582
3583        let mut dd = common::DefaultDelegate;
3584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3585        dlg.begin(common::MethodInfo {
3586            id: "adexchangeseller.accounts.reports.saved.generate",
3587            http_method: hyper::Method::GET,
3588        });
3589
3590        for &field in [
3591            "alt",
3592            "accountId",
3593            "savedReportId",
3594            "startIndex",
3595            "maxResults",
3596            "locale",
3597        ]
3598        .iter()
3599        {
3600            if self._additional_params.contains_key(field) {
3601                dlg.finished(false);
3602                return Err(common::Error::FieldClash(field));
3603            }
3604        }
3605
3606        let mut params = Params::with_capacity(7 + self._additional_params.len());
3607        params.push("accountId", self._account_id);
3608        params.push("savedReportId", self._saved_report_id);
3609        if let Some(value) = self._start_index.as_ref() {
3610            params.push("startIndex", value.to_string());
3611        }
3612        if let Some(value) = self._max_results.as_ref() {
3613            params.push("maxResults", value.to_string());
3614        }
3615        if let Some(value) = self._locale.as_ref() {
3616            params.push("locale", value);
3617        }
3618
3619        params.extend(self._additional_params.iter());
3620
3621        params.push("alt", "json");
3622        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports/{savedReportId}";
3623        if self._scopes.is_empty() {
3624            self._scopes
3625                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
3626        }
3627
3628        #[allow(clippy::single_element_loop)]
3629        for &(find_this, param_name) in [
3630            ("{accountId}", "accountId"),
3631            ("{savedReportId}", "savedReportId"),
3632        ]
3633        .iter()
3634        {
3635            url = params.uri_replacement(url, param_name, find_this, false);
3636        }
3637        {
3638            let to_remove = ["savedReportId", "accountId"];
3639            params.remove_params(&to_remove);
3640        }
3641
3642        let url = params.parse_with_url(&url);
3643
3644        loop {
3645            let token = match self
3646                .hub
3647                .auth
3648                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3649                .await
3650            {
3651                Ok(token) => token,
3652                Err(e) => match dlg.token(e) {
3653                    Ok(token) => token,
3654                    Err(e) => {
3655                        dlg.finished(false);
3656                        return Err(common::Error::MissingToken(e));
3657                    }
3658                },
3659            };
3660            let mut req_result = {
3661                let client = &self.hub.client;
3662                dlg.pre_request();
3663                let mut req_builder = hyper::Request::builder()
3664                    .method(hyper::Method::GET)
3665                    .uri(url.as_str())
3666                    .header(USER_AGENT, self.hub._user_agent.clone());
3667
3668                if let Some(token) = token.as_ref() {
3669                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3670                }
3671
3672                let request = req_builder
3673                    .header(CONTENT_LENGTH, 0_u64)
3674                    .body(common::to_body::<String>(None));
3675
3676                client.request(request.unwrap()).await
3677            };
3678
3679            match req_result {
3680                Err(err) => {
3681                    if let common::Retry::After(d) = dlg.http_error(&err) {
3682                        sleep(d).await;
3683                        continue;
3684                    }
3685                    dlg.finished(false);
3686                    return Err(common::Error::HttpError(err));
3687                }
3688                Ok(res) => {
3689                    let (mut parts, body) = res.into_parts();
3690                    let mut body = common::Body::new(body);
3691                    if !parts.status.is_success() {
3692                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3693                        let error = serde_json::from_str(&common::to_string(&bytes));
3694                        let response = common::to_response(parts, bytes.into());
3695
3696                        if let common::Retry::After(d) =
3697                            dlg.http_failure(&response, error.as_ref().ok())
3698                        {
3699                            sleep(d).await;
3700                            continue;
3701                        }
3702
3703                        dlg.finished(false);
3704
3705                        return Err(match error {
3706                            Ok(value) => common::Error::BadRequest(value),
3707                            _ => common::Error::Failure(response),
3708                        });
3709                    }
3710                    let response = {
3711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3712                        let encoded = common::to_string(&bytes);
3713                        match serde_json::from_str(&encoded) {
3714                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3715                            Err(error) => {
3716                                dlg.response_json_decode_error(&encoded, &error);
3717                                return Err(common::Error::JsonDecodeError(
3718                                    encoded.to_string(),
3719                                    error,
3720                                ));
3721                            }
3722                        }
3723                    };
3724
3725                    dlg.finished(true);
3726                    return Ok(response);
3727                }
3728            }
3729        }
3730    }
3731
3732    /// Account owning the saved report.
3733    ///
3734    /// Sets the *account id* path property to the given value.
3735    ///
3736    /// Even though the property as already been set when instantiating this call,
3737    /// we provide this method for API completeness.
3738    pub fn account_id(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
3739        self._account_id = new_value.to_string();
3740        self
3741    }
3742    /// The saved report to retrieve.
3743    ///
3744    /// Sets the *saved report id* path property to the given value.
3745    ///
3746    /// Even though the property as already been set when instantiating this call,
3747    /// we provide this method for API completeness.
3748    pub fn saved_report_id(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
3749        self._saved_report_id = new_value.to_string();
3750        self
3751    }
3752    /// Index of the first row of report data to return.
3753    ///
3754    /// Sets the *start index* query property to the given value.
3755    pub fn start_index(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
3756        self._start_index = Some(new_value);
3757        self
3758    }
3759    /// The maximum number of rows of report data to return.
3760    ///
3761    /// Sets the *max results* query property to the given value.
3762    pub fn max_results(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
3763        self._max_results = Some(new_value);
3764        self
3765    }
3766    /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
3767    ///
3768    /// Sets the *locale* query property to the given value.
3769    pub fn locale(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
3770        self._locale = Some(new_value.to_string());
3771        self
3772    }
3773    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3774    /// while executing the actual API request.
3775    ///
3776    /// ````text
3777    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3778    /// ````
3779    ///
3780    /// Sets the *delegate* property to the given value.
3781    pub fn delegate(
3782        mut self,
3783        new_value: &'a mut dyn common::Delegate,
3784    ) -> AccountReportSavedGenerateCall<'a, C> {
3785        self._delegate = Some(new_value);
3786        self
3787    }
3788
3789    /// Set any additional parameter of the query string used in the request.
3790    /// It should be used to set parameters which are not yet available through their own
3791    /// setters.
3792    ///
3793    /// Please note that this method must not be used to set any of the known parameters
3794    /// which have their own setter method. If done anyway, the request will fail.
3795    ///
3796    /// # Additional Parameters
3797    ///
3798    /// * *alt* (query-string) - Data format for the response.
3799    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3800    /// * *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.
3801    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3802    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3803    /// * *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. Overrides userIp if both are provided.
3804    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3805    pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCall<'a, C>
3806    where
3807        T: AsRef<str>,
3808    {
3809        self._additional_params
3810            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3811        self
3812    }
3813
3814    /// Identifies the authorization scope for the method you are building.
3815    ///
3816    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3817    /// [`Scope::AdexchangeSellerReadonly`].
3818    ///
3819    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3820    /// tokens for more than one scope.
3821    ///
3822    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3823    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3824    /// sufficient, a read-write scope will do as well.
3825    pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCall<'a, C>
3826    where
3827        St: AsRef<str>,
3828    {
3829        self._scopes.insert(String::from(scope.as_ref()));
3830        self
3831    }
3832    /// Identifies the authorization scope(s) for the method you are building.
3833    ///
3834    /// See [`Self::add_scope()`] for details.
3835    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCall<'a, C>
3836    where
3837        I: IntoIterator<Item = St>,
3838        St: AsRef<str>,
3839    {
3840        self._scopes
3841            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3842        self
3843    }
3844
3845    /// Removes all scopes, and no default scope will be used either.
3846    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3847    /// for details).
3848    pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCall<'a, C> {
3849        self._scopes.clear();
3850        self
3851    }
3852}
3853
3854/// List all saved reports in this Ad Exchange account.
3855///
3856/// A builder for the *reports.saved.list* method supported by a *account* resource.
3857/// It is not used directly, but through a [`AccountMethods`] instance.
3858///
3859/// # Example
3860///
3861/// Instantiate a resource method builder
3862///
3863/// ```test_harness,no_run
3864/// # extern crate hyper;
3865/// # extern crate hyper_rustls;
3866/// # extern crate google_adexchangeseller2 as adexchangeseller2;
3867/// # async fn dox() {
3868/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3869///
3870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3871/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3872/// #     .with_native_roots()
3873/// #     .unwrap()
3874/// #     .https_only()
3875/// #     .enable_http2()
3876/// #     .build();
3877///
3878/// # let executor = hyper_util::rt::TokioExecutor::new();
3879/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3880/// #     secret,
3881/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3882/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3883/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3884/// #     ),
3885/// # ).build().await.unwrap();
3886///
3887/// # let client = hyper_util::client::legacy::Client::builder(
3888/// #     hyper_util::rt::TokioExecutor::new()
3889/// # )
3890/// # .build(
3891/// #     hyper_rustls::HttpsConnectorBuilder::new()
3892/// #         .with_native_roots()
3893/// #         .unwrap()
3894/// #         .https_or_http()
3895/// #         .enable_http2()
3896/// #         .build()
3897/// # );
3898/// # let mut hub = AdExchangeSeller::new(client, auth);
3899/// // You can configure optional parameters by calling the respective setters at will, and
3900/// // execute the final call using `doit()`.
3901/// // Values shown here are possibly random and not representative !
3902/// let result = hub.accounts().reports_saved_list("accountId")
3903///              .page_token("et")
3904///              .max_results(-28)
3905///              .doit().await;
3906/// # }
3907/// ```
3908pub struct AccountReportSavedListCall<'a, C>
3909where
3910    C: 'a,
3911{
3912    hub: &'a AdExchangeSeller<C>,
3913    _account_id: String,
3914    _page_token: Option<String>,
3915    _max_results: Option<i32>,
3916    _delegate: Option<&'a mut dyn common::Delegate>,
3917    _additional_params: HashMap<String, String>,
3918    _scopes: BTreeSet<String>,
3919}
3920
3921impl<'a, C> common::CallBuilder for AccountReportSavedListCall<'a, C> {}
3922
3923impl<'a, C> AccountReportSavedListCall<'a, C>
3924where
3925    C: common::Connector,
3926{
3927    /// Perform the operation you have build so far.
3928    pub async fn doit(mut self) -> common::Result<(common::Response, SavedReports)> {
3929        use std::borrow::Cow;
3930        use std::io::{Read, Seek};
3931
3932        use common::{url::Params, ToParts};
3933        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3934
3935        let mut dd = common::DefaultDelegate;
3936        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3937        dlg.begin(common::MethodInfo {
3938            id: "adexchangeseller.accounts.reports.saved.list",
3939            http_method: hyper::Method::GET,
3940        });
3941
3942        for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
3943            if self._additional_params.contains_key(field) {
3944                dlg.finished(false);
3945                return Err(common::Error::FieldClash(field));
3946            }
3947        }
3948
3949        let mut params = Params::with_capacity(5 + self._additional_params.len());
3950        params.push("accountId", self._account_id);
3951        if let Some(value) = self._page_token.as_ref() {
3952            params.push("pageToken", value);
3953        }
3954        if let Some(value) = self._max_results.as_ref() {
3955            params.push("maxResults", value.to_string());
3956        }
3957
3958        params.extend(self._additional_params.iter());
3959
3960        params.push("alt", "json");
3961        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports/saved";
3962        if self._scopes.is_empty() {
3963            self._scopes
3964                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
3965        }
3966
3967        #[allow(clippy::single_element_loop)]
3968        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
3969            url = params.uri_replacement(url, param_name, find_this, false);
3970        }
3971        {
3972            let to_remove = ["accountId"];
3973            params.remove_params(&to_remove);
3974        }
3975
3976        let url = params.parse_with_url(&url);
3977
3978        loop {
3979            let token = match self
3980                .hub
3981                .auth
3982                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3983                .await
3984            {
3985                Ok(token) => token,
3986                Err(e) => match dlg.token(e) {
3987                    Ok(token) => token,
3988                    Err(e) => {
3989                        dlg.finished(false);
3990                        return Err(common::Error::MissingToken(e));
3991                    }
3992                },
3993            };
3994            let mut req_result = {
3995                let client = &self.hub.client;
3996                dlg.pre_request();
3997                let mut req_builder = hyper::Request::builder()
3998                    .method(hyper::Method::GET)
3999                    .uri(url.as_str())
4000                    .header(USER_AGENT, self.hub._user_agent.clone());
4001
4002                if let Some(token) = token.as_ref() {
4003                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4004                }
4005
4006                let request = req_builder
4007                    .header(CONTENT_LENGTH, 0_u64)
4008                    .body(common::to_body::<String>(None));
4009
4010                client.request(request.unwrap()).await
4011            };
4012
4013            match req_result {
4014                Err(err) => {
4015                    if let common::Retry::After(d) = dlg.http_error(&err) {
4016                        sleep(d).await;
4017                        continue;
4018                    }
4019                    dlg.finished(false);
4020                    return Err(common::Error::HttpError(err));
4021                }
4022                Ok(res) => {
4023                    let (mut parts, body) = res.into_parts();
4024                    let mut body = common::Body::new(body);
4025                    if !parts.status.is_success() {
4026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4027                        let error = serde_json::from_str(&common::to_string(&bytes));
4028                        let response = common::to_response(parts, bytes.into());
4029
4030                        if let common::Retry::After(d) =
4031                            dlg.http_failure(&response, error.as_ref().ok())
4032                        {
4033                            sleep(d).await;
4034                            continue;
4035                        }
4036
4037                        dlg.finished(false);
4038
4039                        return Err(match error {
4040                            Ok(value) => common::Error::BadRequest(value),
4041                            _ => common::Error::Failure(response),
4042                        });
4043                    }
4044                    let response = {
4045                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4046                        let encoded = common::to_string(&bytes);
4047                        match serde_json::from_str(&encoded) {
4048                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4049                            Err(error) => {
4050                                dlg.response_json_decode_error(&encoded, &error);
4051                                return Err(common::Error::JsonDecodeError(
4052                                    encoded.to_string(),
4053                                    error,
4054                                ));
4055                            }
4056                        }
4057                    };
4058
4059                    dlg.finished(true);
4060                    return Ok(response);
4061                }
4062            }
4063        }
4064    }
4065
4066    /// Account owning the saved reports.
4067    ///
4068    /// Sets the *account id* path property to the given value.
4069    ///
4070    /// Even though the property as already been set when instantiating this call,
4071    /// we provide this method for API completeness.
4072    pub fn account_id(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
4073        self._account_id = new_value.to_string();
4074        self
4075    }
4076    /// A continuation token, used to page through saved reports. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
4077    ///
4078    /// Sets the *page token* query property to the given value.
4079    pub fn page_token(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
4080        self._page_token = Some(new_value.to_string());
4081        self
4082    }
4083    /// The maximum number of saved reports to include in the response, used for paging.
4084    ///
4085    /// Sets the *max results* query property to the given value.
4086    pub fn max_results(mut self, new_value: i32) -> AccountReportSavedListCall<'a, C> {
4087        self._max_results = Some(new_value);
4088        self
4089    }
4090    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4091    /// while executing the actual API request.
4092    ///
4093    /// ````text
4094    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4095    /// ````
4096    ///
4097    /// Sets the *delegate* property to the given value.
4098    pub fn delegate(
4099        mut self,
4100        new_value: &'a mut dyn common::Delegate,
4101    ) -> AccountReportSavedListCall<'a, C> {
4102        self._delegate = Some(new_value);
4103        self
4104    }
4105
4106    /// Set any additional parameter of the query string used in the request.
4107    /// It should be used to set parameters which are not yet available through their own
4108    /// setters.
4109    ///
4110    /// Please note that this method must not be used to set any of the known parameters
4111    /// which have their own setter method. If done anyway, the request will fail.
4112    ///
4113    /// # Additional Parameters
4114    ///
4115    /// * *alt* (query-string) - Data format for the response.
4116    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4117    /// * *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.
4118    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4119    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4120    /// * *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. Overrides userIp if both are provided.
4121    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4122    pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedListCall<'a, C>
4123    where
4124        T: AsRef<str>,
4125    {
4126        self._additional_params
4127            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4128        self
4129    }
4130
4131    /// Identifies the authorization scope for the method you are building.
4132    ///
4133    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4134    /// [`Scope::AdexchangeSellerReadonly`].
4135    ///
4136    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4137    /// tokens for more than one scope.
4138    ///
4139    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4140    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4141    /// sufficient, a read-write scope will do as well.
4142    pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedListCall<'a, C>
4143    where
4144        St: AsRef<str>,
4145    {
4146        self._scopes.insert(String::from(scope.as_ref()));
4147        self
4148    }
4149    /// Identifies the authorization scope(s) for the method you are building.
4150    ///
4151    /// See [`Self::add_scope()`] for details.
4152    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedListCall<'a, C>
4153    where
4154        I: IntoIterator<Item = St>,
4155        St: AsRef<str>,
4156    {
4157        self._scopes
4158            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4159        self
4160    }
4161
4162    /// Removes all scopes, and no default scope will be used either.
4163    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4164    /// for details).
4165    pub fn clear_scopes(mut self) -> AccountReportSavedListCall<'a, C> {
4166        self._scopes.clear();
4167        self
4168    }
4169}
4170
4171/// Generate an Ad Exchange report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
4172///
4173/// This method supports **media download**. To enable it, adjust the builder like this:
4174/// `.param("alt", "media")`.
4175/// Please note that due to missing multi-part support on the server side, you will only receive the media,
4176/// but not the `Report` structure that you would usually get. The latter will be a default value.
4177///
4178/// A builder for the *reports.generate* method supported by a *account* resource.
4179/// It is not used directly, but through a [`AccountMethods`] instance.
4180///
4181/// # Example
4182///
4183/// Instantiate a resource method builder
4184///
4185/// ```test_harness,no_run
4186/// # extern crate hyper;
4187/// # extern crate hyper_rustls;
4188/// # extern crate google_adexchangeseller2 as adexchangeseller2;
4189/// # async fn dox() {
4190/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4191///
4192/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4193/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4194/// #     .with_native_roots()
4195/// #     .unwrap()
4196/// #     .https_only()
4197/// #     .enable_http2()
4198/// #     .build();
4199///
4200/// # let executor = hyper_util::rt::TokioExecutor::new();
4201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4202/// #     secret,
4203/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4204/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4205/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4206/// #     ),
4207/// # ).build().await.unwrap();
4208///
4209/// # let client = hyper_util::client::legacy::Client::builder(
4210/// #     hyper_util::rt::TokioExecutor::new()
4211/// # )
4212/// # .build(
4213/// #     hyper_rustls::HttpsConnectorBuilder::new()
4214/// #         .with_native_roots()
4215/// #         .unwrap()
4216/// #         .https_or_http()
4217/// #         .enable_http2()
4218/// #         .build()
4219/// # );
4220/// # let mut hub = AdExchangeSeller::new(client, auth);
4221/// // You can configure optional parameters by calling the respective setters at will, and
4222/// // execute the final call using `doit()`.
4223/// // Values shown here are possibly random and not representative !
4224/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
4225///              .start_index(52)
4226///              .add_sort("et")
4227///              .add_metric("et")
4228///              .max_results(6)
4229///              .locale("Stet")
4230///              .add_filter("dolor")
4231///              .add_dimension("duo")
4232///              .doit().await;
4233/// # }
4234/// ```
4235pub struct AccountReportGenerateCall<'a, C>
4236where
4237    C: 'a,
4238{
4239    hub: &'a AdExchangeSeller<C>,
4240    _account_id: String,
4241    _start_date: String,
4242    _end_date: String,
4243    _start_index: Option<u32>,
4244    _sort: Vec<String>,
4245    _metric: Vec<String>,
4246    _max_results: Option<u32>,
4247    _locale: Option<String>,
4248    _filter: Vec<String>,
4249    _dimension: Vec<String>,
4250    _delegate: Option<&'a mut dyn common::Delegate>,
4251    _additional_params: HashMap<String, String>,
4252    _scopes: BTreeSet<String>,
4253}
4254
4255impl<'a, C> common::CallBuilder for AccountReportGenerateCall<'a, C> {}
4256
4257impl<'a, C> AccountReportGenerateCall<'a, C>
4258where
4259    C: common::Connector,
4260{
4261    /// Perform the operation you have build so far.
4262    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
4263        use std::borrow::Cow;
4264        use std::io::{Read, Seek};
4265
4266        use common::{url::Params, ToParts};
4267        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4268
4269        let mut dd = common::DefaultDelegate;
4270        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4271        dlg.begin(common::MethodInfo {
4272            id: "adexchangeseller.accounts.reports.generate",
4273            http_method: hyper::Method::GET,
4274        });
4275
4276        for &field in [
4277            "accountId",
4278            "startDate",
4279            "endDate",
4280            "startIndex",
4281            "sort",
4282            "metric",
4283            "maxResults",
4284            "locale",
4285            "filter",
4286            "dimension",
4287        ]
4288        .iter()
4289        {
4290            if self._additional_params.contains_key(field) {
4291                dlg.finished(false);
4292                return Err(common::Error::FieldClash(field));
4293            }
4294        }
4295
4296        let mut params = Params::with_capacity(11 + self._additional_params.len());
4297        params.push("accountId", self._account_id);
4298        params.push("startDate", self._start_date);
4299        params.push("endDate", self._end_date);
4300        if let Some(value) = self._start_index.as_ref() {
4301            params.push("startIndex", value.to_string());
4302        }
4303        if !self._sort.is_empty() {
4304            for f in self._sort.iter() {
4305                params.push("sort", f);
4306            }
4307        }
4308        if !self._metric.is_empty() {
4309            for f in self._metric.iter() {
4310                params.push("metric", f);
4311            }
4312        }
4313        if let Some(value) = self._max_results.as_ref() {
4314            params.push("maxResults", value.to_string());
4315        }
4316        if let Some(value) = self._locale.as_ref() {
4317            params.push("locale", value);
4318        }
4319        if !self._filter.is_empty() {
4320            for f in self._filter.iter() {
4321                params.push("filter", f);
4322            }
4323        }
4324        if !self._dimension.is_empty() {
4325            for f in self._dimension.iter() {
4326                params.push("dimension", f);
4327            }
4328        }
4329
4330        params.extend(self._additional_params.iter());
4331
4332        let (alt_field_missing, enable_resource_parsing) = {
4333            if let Some(value) = params.get("alt") {
4334                (false, value == "json")
4335            } else {
4336                (true, true)
4337            }
4338        };
4339        if alt_field_missing {
4340            params.push("alt", "json");
4341        }
4342        let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports";
4343        if self._scopes.is_empty() {
4344            self._scopes
4345                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
4346        }
4347
4348        #[allow(clippy::single_element_loop)]
4349        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
4350            url = params.uri_replacement(url, param_name, find_this, false);
4351        }
4352        {
4353            let to_remove = ["accountId"];
4354            params.remove_params(&to_remove);
4355        }
4356
4357        let url = params.parse_with_url(&url);
4358
4359        loop {
4360            let token = match self
4361                .hub
4362                .auth
4363                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4364                .await
4365            {
4366                Ok(token) => token,
4367                Err(e) => match dlg.token(e) {
4368                    Ok(token) => token,
4369                    Err(e) => {
4370                        dlg.finished(false);
4371                        return Err(common::Error::MissingToken(e));
4372                    }
4373                },
4374            };
4375            let mut req_result = {
4376                let client = &self.hub.client;
4377                dlg.pre_request();
4378                let mut req_builder = hyper::Request::builder()
4379                    .method(hyper::Method::GET)
4380                    .uri(url.as_str())
4381                    .header(USER_AGENT, self.hub._user_agent.clone());
4382
4383                if let Some(token) = token.as_ref() {
4384                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4385                }
4386
4387                let request = req_builder
4388                    .header(CONTENT_LENGTH, 0_u64)
4389                    .body(common::to_body::<String>(None));
4390
4391                client.request(request.unwrap()).await
4392            };
4393
4394            match req_result {
4395                Err(err) => {
4396                    if let common::Retry::After(d) = dlg.http_error(&err) {
4397                        sleep(d).await;
4398                        continue;
4399                    }
4400                    dlg.finished(false);
4401                    return Err(common::Error::HttpError(err));
4402                }
4403                Ok(res) => {
4404                    let (mut parts, body) = res.into_parts();
4405                    let mut body = common::Body::new(body);
4406                    if !parts.status.is_success() {
4407                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4408                        let error = serde_json::from_str(&common::to_string(&bytes));
4409                        let response = common::to_response(parts, bytes.into());
4410
4411                        if let common::Retry::After(d) =
4412                            dlg.http_failure(&response, error.as_ref().ok())
4413                        {
4414                            sleep(d).await;
4415                            continue;
4416                        }
4417
4418                        dlg.finished(false);
4419
4420                        return Err(match error {
4421                            Ok(value) => common::Error::BadRequest(value),
4422                            _ => common::Error::Failure(response),
4423                        });
4424                    }
4425                    let response = if enable_resource_parsing {
4426                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4427                        let encoded = common::to_string(&bytes);
4428                        match serde_json::from_str(&encoded) {
4429                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4430                            Err(error) => {
4431                                dlg.response_json_decode_error(&encoded, &error);
4432                                return Err(common::Error::JsonDecodeError(
4433                                    encoded.to_string(),
4434                                    error,
4435                                ));
4436                            }
4437                        }
4438                    } else {
4439                        (
4440                            common::Response::from_parts(parts, body),
4441                            Default::default(),
4442                        )
4443                    };
4444
4445                    dlg.finished(true);
4446                    return Ok(response);
4447                }
4448            }
4449        }
4450    }
4451
4452    /// Account which owns the generated report.
4453    ///
4454    /// Sets the *account id* path property to the given value.
4455    ///
4456    /// Even though the property as already been set when instantiating this call,
4457    /// we provide this method for API completeness.
4458    pub fn account_id(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4459        self._account_id = new_value.to_string();
4460        self
4461    }
4462    /// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
4463    ///
4464    /// Sets the *start date* query property to the given value.
4465    ///
4466    /// Even though the property as already been set when instantiating this call,
4467    /// we provide this method for API completeness.
4468    pub fn start_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4469        self._start_date = new_value.to_string();
4470        self
4471    }
4472    /// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
4473    ///
4474    /// Sets the *end date* query property to the given value.
4475    ///
4476    /// Even though the property as already been set when instantiating this call,
4477    /// we provide this method for API completeness.
4478    pub fn end_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4479        self._end_date = new_value.to_string();
4480        self
4481    }
4482    /// Index of the first row of report data to return.
4483    ///
4484    /// Sets the *start index* query property to the given value.
4485    pub fn start_index(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C> {
4486        self._start_index = Some(new_value);
4487        self
4488    }
4489    /// The name of a dimension or metric to sort the resulting report on, optionally prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
4490    ///
4491    /// Append the given value to the *sort* query property.
4492    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4493    pub fn add_sort(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4494        self._sort.push(new_value.to_string());
4495        self
4496    }
4497    /// Numeric columns to include in the report.
4498    ///
4499    /// Append the given value to the *metric* query property.
4500    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4501    pub fn add_metric(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4502        self._metric.push(new_value.to_string());
4503        self
4504    }
4505    /// The maximum number of rows of report data to return.
4506    ///
4507    /// Sets the *max results* query property to the given value.
4508    pub fn max_results(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C> {
4509        self._max_results = Some(new_value);
4510        self
4511    }
4512    /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
4513    ///
4514    /// Sets the *locale* query property to the given value.
4515    pub fn locale(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4516        self._locale = Some(new_value.to_string());
4517        self
4518    }
4519    /// Filters to be run on the report.
4520    ///
4521    /// Append the given value to the *filter* query property.
4522    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4523    pub fn add_filter(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4524        self._filter.push(new_value.to_string());
4525        self
4526    }
4527    /// Dimensions to base the report on.
4528    ///
4529    /// Append the given value to the *dimension* query property.
4530    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4531    pub fn add_dimension(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4532        self._dimension.push(new_value.to_string());
4533        self
4534    }
4535    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4536    /// while executing the actual API request.
4537    ///
4538    /// ````text
4539    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4540    /// ````
4541    ///
4542    /// Sets the *delegate* property to the given value.
4543    pub fn delegate(
4544        mut self,
4545        new_value: &'a mut dyn common::Delegate,
4546    ) -> AccountReportGenerateCall<'a, C> {
4547        self._delegate = Some(new_value);
4548        self
4549    }
4550
4551    /// Set any additional parameter of the query string used in the request.
4552    /// It should be used to set parameters which are not yet available through their own
4553    /// setters.
4554    ///
4555    /// Please note that this method must not be used to set any of the known parameters
4556    /// which have their own setter method. If done anyway, the request will fail.
4557    ///
4558    /// # Additional Parameters
4559    ///
4560    /// * *alt* (query-string) - Data format for the response.
4561    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4562    /// * *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.
4563    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4564    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4565    /// * *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. Overrides userIp if both are provided.
4566    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4567    pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCall<'a, C>
4568    where
4569        T: AsRef<str>,
4570    {
4571        self._additional_params
4572            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4573        self
4574    }
4575
4576    /// Identifies the authorization scope for the method you are building.
4577    ///
4578    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4579    /// [`Scope::AdexchangeSellerReadonly`].
4580    ///
4581    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4582    /// tokens for more than one scope.
4583    ///
4584    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4585    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4586    /// sufficient, a read-write scope will do as well.
4587    pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCall<'a, C>
4588    where
4589        St: AsRef<str>,
4590    {
4591        self._scopes.insert(String::from(scope.as_ref()));
4592        self
4593    }
4594    /// Identifies the authorization scope(s) for the method you are building.
4595    ///
4596    /// See [`Self::add_scope()`] for details.
4597    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCall<'a, C>
4598    where
4599        I: IntoIterator<Item = St>,
4600        St: AsRef<str>,
4601    {
4602        self._scopes
4603            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4604        self
4605    }
4606
4607    /// Removes all scopes, and no default scope will be used either.
4608    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4609    /// for details).
4610    pub fn clear_scopes(mut self) -> AccountReportGenerateCall<'a, C> {
4611        self._scopes.clear();
4612        self
4613    }
4614}
4615
4616/// List all URL channels in the specified ad client for this Ad Exchange account.
4617///
4618/// A builder for the *urlchannels.list* method supported by a *account* resource.
4619/// It is not used directly, but through a [`AccountMethods`] instance.
4620///
4621/// # Example
4622///
4623/// Instantiate a resource method builder
4624///
4625/// ```test_harness,no_run
4626/// # extern crate hyper;
4627/// # extern crate hyper_rustls;
4628/// # extern crate google_adexchangeseller2 as adexchangeseller2;
4629/// # async fn dox() {
4630/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4631///
4632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4633/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4634/// #     .with_native_roots()
4635/// #     .unwrap()
4636/// #     .https_only()
4637/// #     .enable_http2()
4638/// #     .build();
4639///
4640/// # let executor = hyper_util::rt::TokioExecutor::new();
4641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4642/// #     secret,
4643/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4644/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4645/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4646/// #     ),
4647/// # ).build().await.unwrap();
4648///
4649/// # let client = hyper_util::client::legacy::Client::builder(
4650/// #     hyper_util::rt::TokioExecutor::new()
4651/// # )
4652/// # .build(
4653/// #     hyper_rustls::HttpsConnectorBuilder::new()
4654/// #         .with_native_roots()
4655/// #         .unwrap()
4656/// #         .https_or_http()
4657/// #         .enable_http2()
4658/// #         .build()
4659/// # );
4660/// # let mut hub = AdExchangeSeller::new(client, auth);
4661/// // You can configure optional parameters by calling the respective setters at will, and
4662/// // execute the final call using `doit()`.
4663/// // Values shown here are possibly random and not representative !
4664/// let result = hub.accounts().urlchannels_list("accountId", "adClientId")
4665///              .page_token("invidunt")
4666///              .max_results(36)
4667///              .doit().await;
4668/// # }
4669/// ```
4670pub struct AccountUrlchannelListCall<'a, C>
4671where
4672    C: 'a,
4673{
4674    hub: &'a AdExchangeSeller<C>,
4675    _account_id: String,
4676    _ad_client_id: String,
4677    _page_token: Option<String>,
4678    _max_results: Option<u32>,
4679    _delegate: Option<&'a mut dyn common::Delegate>,
4680    _additional_params: HashMap<String, String>,
4681    _scopes: BTreeSet<String>,
4682}
4683
4684impl<'a, C> common::CallBuilder for AccountUrlchannelListCall<'a, C> {}
4685
4686impl<'a, C> AccountUrlchannelListCall<'a, C>
4687where
4688    C: common::Connector,
4689{
4690    /// Perform the operation you have build so far.
4691    pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannels)> {
4692        use std::borrow::Cow;
4693        use std::io::{Read, Seek};
4694
4695        use common::{url::Params, ToParts};
4696        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4697
4698        let mut dd = common::DefaultDelegate;
4699        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4700        dlg.begin(common::MethodInfo {
4701            id: "adexchangeseller.accounts.urlchannels.list",
4702            http_method: hyper::Method::GET,
4703        });
4704
4705        for &field in ["alt", "accountId", "adClientId", "pageToken", "maxResults"].iter() {
4706            if self._additional_params.contains_key(field) {
4707                dlg.finished(false);
4708                return Err(common::Error::FieldClash(field));
4709            }
4710        }
4711
4712        let mut params = Params::with_capacity(6 + self._additional_params.len());
4713        params.push("accountId", self._account_id);
4714        params.push("adClientId", self._ad_client_id);
4715        if let Some(value) = self._page_token.as_ref() {
4716            params.push("pageToken", value);
4717        }
4718        if let Some(value) = self._max_results.as_ref() {
4719            params.push("maxResults", value.to_string());
4720        }
4721
4722        params.extend(self._additional_params.iter());
4723
4724        params.push("alt", "json");
4725        let mut url =
4726            self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/urlchannels";
4727        if self._scopes.is_empty() {
4728            self._scopes
4729                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
4730        }
4731
4732        #[allow(clippy::single_element_loop)]
4733        for &(find_this, param_name) in
4734            [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
4735        {
4736            url = params.uri_replacement(url, param_name, find_this, false);
4737        }
4738        {
4739            let to_remove = ["adClientId", "accountId"];
4740            params.remove_params(&to_remove);
4741        }
4742
4743        let url = params.parse_with_url(&url);
4744
4745        loop {
4746            let token = match self
4747                .hub
4748                .auth
4749                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4750                .await
4751            {
4752                Ok(token) => token,
4753                Err(e) => match dlg.token(e) {
4754                    Ok(token) => token,
4755                    Err(e) => {
4756                        dlg.finished(false);
4757                        return Err(common::Error::MissingToken(e));
4758                    }
4759                },
4760            };
4761            let mut req_result = {
4762                let client = &self.hub.client;
4763                dlg.pre_request();
4764                let mut req_builder = hyper::Request::builder()
4765                    .method(hyper::Method::GET)
4766                    .uri(url.as_str())
4767                    .header(USER_AGENT, self.hub._user_agent.clone());
4768
4769                if let Some(token) = token.as_ref() {
4770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4771                }
4772
4773                let request = req_builder
4774                    .header(CONTENT_LENGTH, 0_u64)
4775                    .body(common::to_body::<String>(None));
4776
4777                client.request(request.unwrap()).await
4778            };
4779
4780            match req_result {
4781                Err(err) => {
4782                    if let common::Retry::After(d) = dlg.http_error(&err) {
4783                        sleep(d).await;
4784                        continue;
4785                    }
4786                    dlg.finished(false);
4787                    return Err(common::Error::HttpError(err));
4788                }
4789                Ok(res) => {
4790                    let (mut parts, body) = res.into_parts();
4791                    let mut body = common::Body::new(body);
4792                    if !parts.status.is_success() {
4793                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4794                        let error = serde_json::from_str(&common::to_string(&bytes));
4795                        let response = common::to_response(parts, bytes.into());
4796
4797                        if let common::Retry::After(d) =
4798                            dlg.http_failure(&response, error.as_ref().ok())
4799                        {
4800                            sleep(d).await;
4801                            continue;
4802                        }
4803
4804                        dlg.finished(false);
4805
4806                        return Err(match error {
4807                            Ok(value) => common::Error::BadRequest(value),
4808                            _ => common::Error::Failure(response),
4809                        });
4810                    }
4811                    let response = {
4812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4813                        let encoded = common::to_string(&bytes);
4814                        match serde_json::from_str(&encoded) {
4815                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4816                            Err(error) => {
4817                                dlg.response_json_decode_error(&encoded, &error);
4818                                return Err(common::Error::JsonDecodeError(
4819                                    encoded.to_string(),
4820                                    error,
4821                                ));
4822                            }
4823                        }
4824                    };
4825
4826                    dlg.finished(true);
4827                    return Ok(response);
4828                }
4829            }
4830        }
4831    }
4832
4833    /// Account to which the ad client belongs.
4834    ///
4835    /// Sets the *account id* path property to the given value.
4836    ///
4837    /// Even though the property as already been set when instantiating this call,
4838    /// we provide this method for API completeness.
4839    pub fn account_id(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
4840        self._account_id = new_value.to_string();
4841        self
4842    }
4843    /// Ad client for which to list URL channels.
4844    ///
4845    /// Sets the *ad client id* path property to the given value.
4846    ///
4847    /// Even though the property as already been set when instantiating this call,
4848    /// we provide this method for API completeness.
4849    pub fn ad_client_id(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
4850        self._ad_client_id = new_value.to_string();
4851        self
4852    }
4853    /// A continuation token, used to page through URL channels. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
4854    ///
4855    /// Sets the *page token* query property to the given value.
4856    pub fn page_token(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
4857        self._page_token = Some(new_value.to_string());
4858        self
4859    }
4860    /// The maximum number of URL channels to include in the response, used for paging.
4861    ///
4862    /// Sets the *max results* query property to the given value.
4863    pub fn max_results(mut self, new_value: u32) -> AccountUrlchannelListCall<'a, C> {
4864        self._max_results = Some(new_value);
4865        self
4866    }
4867    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4868    /// while executing the actual API request.
4869    ///
4870    /// ````text
4871    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4872    /// ````
4873    ///
4874    /// Sets the *delegate* property to the given value.
4875    pub fn delegate(
4876        mut self,
4877        new_value: &'a mut dyn common::Delegate,
4878    ) -> AccountUrlchannelListCall<'a, C> {
4879        self._delegate = Some(new_value);
4880        self
4881    }
4882
4883    /// Set any additional parameter of the query string used in the request.
4884    /// It should be used to set parameters which are not yet available through their own
4885    /// setters.
4886    ///
4887    /// Please note that this method must not be used to set any of the known parameters
4888    /// which have their own setter method. If done anyway, the request will fail.
4889    ///
4890    /// # Additional Parameters
4891    ///
4892    /// * *alt* (query-string) - Data format for the response.
4893    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4894    /// * *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.
4895    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4896    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4897    /// * *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. Overrides userIp if both are provided.
4898    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4899    pub fn param<T>(mut self, name: T, value: T) -> AccountUrlchannelListCall<'a, C>
4900    where
4901        T: AsRef<str>,
4902    {
4903        self._additional_params
4904            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4905        self
4906    }
4907
4908    /// Identifies the authorization scope for the method you are building.
4909    ///
4910    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4911    /// [`Scope::AdexchangeSellerReadonly`].
4912    ///
4913    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4914    /// tokens for more than one scope.
4915    ///
4916    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4917    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4918    /// sufficient, a read-write scope will do as well.
4919    pub fn add_scope<St>(mut self, scope: St) -> AccountUrlchannelListCall<'a, C>
4920    where
4921        St: AsRef<str>,
4922    {
4923        self._scopes.insert(String::from(scope.as_ref()));
4924        self
4925    }
4926    /// Identifies the authorization scope(s) for the method you are building.
4927    ///
4928    /// See [`Self::add_scope()`] for details.
4929    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUrlchannelListCall<'a, C>
4930    where
4931        I: IntoIterator<Item = St>,
4932        St: AsRef<str>,
4933    {
4934        self._scopes
4935            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4936        self
4937    }
4938
4939    /// Removes all scopes, and no default scope will be used either.
4940    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4941    /// for details).
4942    pub fn clear_scopes(mut self) -> AccountUrlchannelListCall<'a, C> {
4943        self._scopes.clear();
4944        self
4945    }
4946}
4947
4948/// Get information about the selected Ad Exchange account.
4949///
4950/// A builder for the *get* method supported by a *account* resource.
4951/// It is not used directly, but through a [`AccountMethods`] instance.
4952///
4953/// # Example
4954///
4955/// Instantiate a resource method builder
4956///
4957/// ```test_harness,no_run
4958/// # extern crate hyper;
4959/// # extern crate hyper_rustls;
4960/// # extern crate google_adexchangeseller2 as adexchangeseller2;
4961/// # async fn dox() {
4962/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4963///
4964/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4965/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4966/// #     .with_native_roots()
4967/// #     .unwrap()
4968/// #     .https_only()
4969/// #     .enable_http2()
4970/// #     .build();
4971///
4972/// # let executor = hyper_util::rt::TokioExecutor::new();
4973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4974/// #     secret,
4975/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4976/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4977/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4978/// #     ),
4979/// # ).build().await.unwrap();
4980///
4981/// # let client = hyper_util::client::legacy::Client::builder(
4982/// #     hyper_util::rt::TokioExecutor::new()
4983/// # )
4984/// # .build(
4985/// #     hyper_rustls::HttpsConnectorBuilder::new()
4986/// #         .with_native_roots()
4987/// #         .unwrap()
4988/// #         .https_or_http()
4989/// #         .enable_http2()
4990/// #         .build()
4991/// # );
4992/// # let mut hub = AdExchangeSeller::new(client, auth);
4993/// // You can configure optional parameters by calling the respective setters at will, and
4994/// // execute the final call using `doit()`.
4995/// // Values shown here are possibly random and not representative !
4996/// let result = hub.accounts().get("accountId")
4997///              .doit().await;
4998/// # }
4999/// ```
5000pub struct AccountGetCall<'a, C>
5001where
5002    C: 'a,
5003{
5004    hub: &'a AdExchangeSeller<C>,
5005    _account_id: String,
5006    _delegate: Option<&'a mut dyn common::Delegate>,
5007    _additional_params: HashMap<String, String>,
5008    _scopes: BTreeSet<String>,
5009}
5010
5011impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
5012
5013impl<'a, C> AccountGetCall<'a, C>
5014where
5015    C: common::Connector,
5016{
5017    /// Perform the operation you have build so far.
5018    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
5019        use std::borrow::Cow;
5020        use std::io::{Read, Seek};
5021
5022        use common::{url::Params, ToParts};
5023        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5024
5025        let mut dd = common::DefaultDelegate;
5026        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5027        dlg.begin(common::MethodInfo {
5028            id: "adexchangeseller.accounts.get",
5029            http_method: hyper::Method::GET,
5030        });
5031
5032        for &field in ["alt", "accountId"].iter() {
5033            if self._additional_params.contains_key(field) {
5034                dlg.finished(false);
5035                return Err(common::Error::FieldClash(field));
5036            }
5037        }
5038
5039        let mut params = Params::with_capacity(3 + self._additional_params.len());
5040        params.push("accountId", self._account_id);
5041
5042        params.extend(self._additional_params.iter());
5043
5044        params.push("alt", "json");
5045        let mut url = self.hub._base_url.clone() + "accounts/{accountId}";
5046        if self._scopes.is_empty() {
5047            self._scopes
5048                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
5049        }
5050
5051        #[allow(clippy::single_element_loop)]
5052        for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
5053            url = params.uri_replacement(url, param_name, find_this, false);
5054        }
5055        {
5056            let to_remove = ["accountId"];
5057            params.remove_params(&to_remove);
5058        }
5059
5060        let url = params.parse_with_url(&url);
5061
5062        loop {
5063            let token = match self
5064                .hub
5065                .auth
5066                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5067                .await
5068            {
5069                Ok(token) => token,
5070                Err(e) => match dlg.token(e) {
5071                    Ok(token) => token,
5072                    Err(e) => {
5073                        dlg.finished(false);
5074                        return Err(common::Error::MissingToken(e));
5075                    }
5076                },
5077            };
5078            let mut req_result = {
5079                let client = &self.hub.client;
5080                dlg.pre_request();
5081                let mut req_builder = hyper::Request::builder()
5082                    .method(hyper::Method::GET)
5083                    .uri(url.as_str())
5084                    .header(USER_AGENT, self.hub._user_agent.clone());
5085
5086                if let Some(token) = token.as_ref() {
5087                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5088                }
5089
5090                let request = req_builder
5091                    .header(CONTENT_LENGTH, 0_u64)
5092                    .body(common::to_body::<String>(None));
5093
5094                client.request(request.unwrap()).await
5095            };
5096
5097            match req_result {
5098                Err(err) => {
5099                    if let common::Retry::After(d) = dlg.http_error(&err) {
5100                        sleep(d).await;
5101                        continue;
5102                    }
5103                    dlg.finished(false);
5104                    return Err(common::Error::HttpError(err));
5105                }
5106                Ok(res) => {
5107                    let (mut parts, body) = res.into_parts();
5108                    let mut body = common::Body::new(body);
5109                    if !parts.status.is_success() {
5110                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5111                        let error = serde_json::from_str(&common::to_string(&bytes));
5112                        let response = common::to_response(parts, bytes.into());
5113
5114                        if let common::Retry::After(d) =
5115                            dlg.http_failure(&response, error.as_ref().ok())
5116                        {
5117                            sleep(d).await;
5118                            continue;
5119                        }
5120
5121                        dlg.finished(false);
5122
5123                        return Err(match error {
5124                            Ok(value) => common::Error::BadRequest(value),
5125                            _ => common::Error::Failure(response),
5126                        });
5127                    }
5128                    let response = {
5129                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5130                        let encoded = common::to_string(&bytes);
5131                        match serde_json::from_str(&encoded) {
5132                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5133                            Err(error) => {
5134                                dlg.response_json_decode_error(&encoded, &error);
5135                                return Err(common::Error::JsonDecodeError(
5136                                    encoded.to_string(),
5137                                    error,
5138                                ));
5139                            }
5140                        }
5141                    };
5142
5143                    dlg.finished(true);
5144                    return Ok(response);
5145                }
5146            }
5147        }
5148    }
5149
5150    /// Account to get information about. Tip: 'myaccount' is a valid ID.
5151    ///
5152    /// Sets the *account id* path property to the given value.
5153    ///
5154    /// Even though the property as already been set when instantiating this call,
5155    /// we provide this method for API completeness.
5156    pub fn account_id(mut self, new_value: &str) -> AccountGetCall<'a, C> {
5157        self._account_id = new_value.to_string();
5158        self
5159    }
5160    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5161    /// while executing the actual API request.
5162    ///
5163    /// ````text
5164    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5165    /// ````
5166    ///
5167    /// Sets the *delegate* property to the given value.
5168    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
5169        self._delegate = Some(new_value);
5170        self
5171    }
5172
5173    /// Set any additional parameter of the query string used in the request.
5174    /// It should be used to set parameters which are not yet available through their own
5175    /// setters.
5176    ///
5177    /// Please note that this method must not be used to set any of the known parameters
5178    /// which have their own setter method. If done anyway, the request will fail.
5179    ///
5180    /// # Additional Parameters
5181    ///
5182    /// * *alt* (query-string) - Data format for the response.
5183    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5184    /// * *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.
5185    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5186    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5187    /// * *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. Overrides userIp if both are provided.
5188    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
5189    pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
5190    where
5191        T: AsRef<str>,
5192    {
5193        self._additional_params
5194            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5195        self
5196    }
5197
5198    /// Identifies the authorization scope for the method you are building.
5199    ///
5200    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5201    /// [`Scope::AdexchangeSellerReadonly`].
5202    ///
5203    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5204    /// tokens for more than one scope.
5205    ///
5206    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5207    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5208    /// sufficient, a read-write scope will do as well.
5209    pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
5210    where
5211        St: AsRef<str>,
5212    {
5213        self._scopes.insert(String::from(scope.as_ref()));
5214        self
5215    }
5216    /// Identifies the authorization scope(s) for the method you are building.
5217    ///
5218    /// See [`Self::add_scope()`] for details.
5219    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
5220    where
5221        I: IntoIterator<Item = St>,
5222        St: AsRef<str>,
5223    {
5224        self._scopes
5225            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5226        self
5227    }
5228
5229    /// Removes all scopes, and no default scope will be used either.
5230    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5231    /// for details).
5232    pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
5233        self._scopes.clear();
5234        self
5235    }
5236}
5237
5238/// List all accounts available to this Ad Exchange account.
5239///
5240/// A builder for the *list* method supported by a *account* resource.
5241/// It is not used directly, but through a [`AccountMethods`] instance.
5242///
5243/// # Example
5244///
5245/// Instantiate a resource method builder
5246///
5247/// ```test_harness,no_run
5248/// # extern crate hyper;
5249/// # extern crate hyper_rustls;
5250/// # extern crate google_adexchangeseller2 as adexchangeseller2;
5251/// # async fn dox() {
5252/// # use adexchangeseller2::{AdExchangeSeller, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5253///
5254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5256/// #     .with_native_roots()
5257/// #     .unwrap()
5258/// #     .https_only()
5259/// #     .enable_http2()
5260/// #     .build();
5261///
5262/// # let executor = hyper_util::rt::TokioExecutor::new();
5263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5264/// #     secret,
5265/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5266/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5267/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5268/// #     ),
5269/// # ).build().await.unwrap();
5270///
5271/// # let client = hyper_util::client::legacy::Client::builder(
5272/// #     hyper_util::rt::TokioExecutor::new()
5273/// # )
5274/// # .build(
5275/// #     hyper_rustls::HttpsConnectorBuilder::new()
5276/// #         .with_native_roots()
5277/// #         .unwrap()
5278/// #         .https_or_http()
5279/// #         .enable_http2()
5280/// #         .build()
5281/// # );
5282/// # let mut hub = AdExchangeSeller::new(client, auth);
5283/// // You can configure optional parameters by calling the respective setters at will, and
5284/// // execute the final call using `doit()`.
5285/// // Values shown here are possibly random and not representative !
5286/// let result = hub.accounts().list()
5287///              .page_token("elitr")
5288///              .max_results(-6)
5289///              .doit().await;
5290/// # }
5291/// ```
5292pub struct AccountListCall<'a, C>
5293where
5294    C: 'a,
5295{
5296    hub: &'a AdExchangeSeller<C>,
5297    _page_token: Option<String>,
5298    _max_results: Option<i32>,
5299    _delegate: Option<&'a mut dyn common::Delegate>,
5300    _additional_params: HashMap<String, String>,
5301    _scopes: BTreeSet<String>,
5302}
5303
5304impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
5305
5306impl<'a, C> AccountListCall<'a, C>
5307where
5308    C: common::Connector,
5309{
5310    /// Perform the operation you have build so far.
5311    pub async fn doit(mut self) -> common::Result<(common::Response, Accounts)> {
5312        use std::borrow::Cow;
5313        use std::io::{Read, Seek};
5314
5315        use common::{url::Params, ToParts};
5316        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5317
5318        let mut dd = common::DefaultDelegate;
5319        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5320        dlg.begin(common::MethodInfo {
5321            id: "adexchangeseller.accounts.list",
5322            http_method: hyper::Method::GET,
5323        });
5324
5325        for &field in ["alt", "pageToken", "maxResults"].iter() {
5326            if self._additional_params.contains_key(field) {
5327                dlg.finished(false);
5328                return Err(common::Error::FieldClash(field));
5329            }
5330        }
5331
5332        let mut params = Params::with_capacity(4 + self._additional_params.len());
5333        if let Some(value) = self._page_token.as_ref() {
5334            params.push("pageToken", value);
5335        }
5336        if let Some(value) = self._max_results.as_ref() {
5337            params.push("maxResults", value.to_string());
5338        }
5339
5340        params.extend(self._additional_params.iter());
5341
5342        params.push("alt", "json");
5343        let mut url = self.hub._base_url.clone() + "accounts";
5344        if self._scopes.is_empty() {
5345            self._scopes
5346                .insert(Scope::AdexchangeSellerReadonly.as_ref().to_string());
5347        }
5348
5349        let url = params.parse_with_url(&url);
5350
5351        loop {
5352            let token = match self
5353                .hub
5354                .auth
5355                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5356                .await
5357            {
5358                Ok(token) => token,
5359                Err(e) => match dlg.token(e) {
5360                    Ok(token) => token,
5361                    Err(e) => {
5362                        dlg.finished(false);
5363                        return Err(common::Error::MissingToken(e));
5364                    }
5365                },
5366            };
5367            let mut req_result = {
5368                let client = &self.hub.client;
5369                dlg.pre_request();
5370                let mut req_builder = hyper::Request::builder()
5371                    .method(hyper::Method::GET)
5372                    .uri(url.as_str())
5373                    .header(USER_AGENT, self.hub._user_agent.clone());
5374
5375                if let Some(token) = token.as_ref() {
5376                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5377                }
5378
5379                let request = req_builder
5380                    .header(CONTENT_LENGTH, 0_u64)
5381                    .body(common::to_body::<String>(None));
5382
5383                client.request(request.unwrap()).await
5384            };
5385
5386            match req_result {
5387                Err(err) => {
5388                    if let common::Retry::After(d) = dlg.http_error(&err) {
5389                        sleep(d).await;
5390                        continue;
5391                    }
5392                    dlg.finished(false);
5393                    return Err(common::Error::HttpError(err));
5394                }
5395                Ok(res) => {
5396                    let (mut parts, body) = res.into_parts();
5397                    let mut body = common::Body::new(body);
5398                    if !parts.status.is_success() {
5399                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5400                        let error = serde_json::from_str(&common::to_string(&bytes));
5401                        let response = common::to_response(parts, bytes.into());
5402
5403                        if let common::Retry::After(d) =
5404                            dlg.http_failure(&response, error.as_ref().ok())
5405                        {
5406                            sleep(d).await;
5407                            continue;
5408                        }
5409
5410                        dlg.finished(false);
5411
5412                        return Err(match error {
5413                            Ok(value) => common::Error::BadRequest(value),
5414                            _ => common::Error::Failure(response),
5415                        });
5416                    }
5417                    let response = {
5418                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5419                        let encoded = common::to_string(&bytes);
5420                        match serde_json::from_str(&encoded) {
5421                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5422                            Err(error) => {
5423                                dlg.response_json_decode_error(&encoded, &error);
5424                                return Err(common::Error::JsonDecodeError(
5425                                    encoded.to_string(),
5426                                    error,
5427                                ));
5428                            }
5429                        }
5430                    };
5431
5432                    dlg.finished(true);
5433                    return Ok(response);
5434                }
5435            }
5436        }
5437    }
5438
5439    /// A continuation token, used to page through accounts. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
5440    ///
5441    /// Sets the *page token* query property to the given value.
5442    pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C> {
5443        self._page_token = Some(new_value.to_string());
5444        self
5445    }
5446    /// The maximum number of accounts to include in the response, used for paging.
5447    ///
5448    /// Sets the *max results* query property to the given value.
5449    pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C> {
5450        self._max_results = Some(new_value);
5451        self
5452    }
5453    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5454    /// while executing the actual API request.
5455    ///
5456    /// ````text
5457    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5458    /// ````
5459    ///
5460    /// Sets the *delegate* property to the given value.
5461    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
5462        self._delegate = Some(new_value);
5463        self
5464    }
5465
5466    /// Set any additional parameter of the query string used in the request.
5467    /// It should be used to set parameters which are not yet available through their own
5468    /// setters.
5469    ///
5470    /// Please note that this method must not be used to set any of the known parameters
5471    /// which have their own setter method. If done anyway, the request will fail.
5472    ///
5473    /// # Additional Parameters
5474    ///
5475    /// * *alt* (query-string) - Data format for the response.
5476    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5477    /// * *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.
5478    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5479    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5480    /// * *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. Overrides userIp if both are provided.
5481    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
5482    pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
5483    where
5484        T: AsRef<str>,
5485    {
5486        self._additional_params
5487            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5488        self
5489    }
5490
5491    /// Identifies the authorization scope for the method you are building.
5492    ///
5493    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5494    /// [`Scope::AdexchangeSellerReadonly`].
5495    ///
5496    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5497    /// tokens for more than one scope.
5498    ///
5499    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5500    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5501    /// sufficient, a read-write scope will do as well.
5502    pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
5503    where
5504        St: AsRef<str>,
5505    {
5506        self._scopes.insert(String::from(scope.as_ref()));
5507        self
5508    }
5509    /// Identifies the authorization scope(s) for the method you are building.
5510    ///
5511    /// See [`Self::add_scope()`] for details.
5512    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
5513    where
5514        I: IntoIterator<Item = St>,
5515        St: AsRef<str>,
5516    {
5517        self._scopes
5518            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5519        self
5520    }
5521
5522    /// Removes all scopes, and no default scope will be used either.
5523    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5524    /// for details).
5525    pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
5526        self._scopes.clear();
5527        self
5528    }
5529}