google_adsense1d4/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// View and manage your AdSense data
17 Full,
18
19 /// View your AdSense data
20 Readonly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/adsense",
27 Scope::Readonly => "https://www.googleapis.com/auth/adsense.readonly",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Readonly
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all AdSense related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_adsense1d4 as adsense1d4;
53/// use adsense1d4::{Result, Error};
54/// # async fn dox() {
55/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = AdSense::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
97/// .use_timezone_reporting(true)
98/// .start_index(-50)
99/// .add_sort("ipsum")
100/// .add_metric("est")
101/// .max_results(-62)
102/// .locale("ea")
103/// .add_filter("dolor")
104/// .add_dimension("Lorem")
105/// .currency("eos")
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 AdSense<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 AdSense<C> {}
137
138impl<'a, C> AdSense<C> {
139 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> AdSense<C> {
140 AdSense {
141 client,
142 auth: Box::new(auth),
143 _user_agent: "google-api-rust-client/7.0.0".to_string(),
144 _base_url: "https://www.googleapis.com/adsense/v1.4/".to_string(),
145 _root_url: "https://www.googleapis.com/".to_string(),
146 }
147 }
148
149 pub fn accounts(&'a self) -> AccountMethods<'a, C> {
150 AccountMethods { hub: self }
151 }
152 pub fn adclients(&'a self) -> AdclientMethods<'a, C> {
153 AdclientMethods { hub: self }
154 }
155 pub fn adunits(&'a self) -> AdunitMethods<'a, C> {
156 AdunitMethods { hub: self }
157 }
158 pub fn alerts(&'a self) -> AlertMethods<'a, C> {
159 AlertMethods { hub: self }
160 }
161 pub fn customchannels(&'a self) -> CustomchannelMethods<'a, C> {
162 CustomchannelMethods { hub: self }
163 }
164 pub fn metadata(&'a self) -> MetadataMethods<'a, C> {
165 MetadataMethods { hub: self }
166 }
167 pub fn payments(&'a self) -> PaymentMethods<'a, C> {
168 PaymentMethods { hub: self }
169 }
170 pub fn reports(&'a self) -> ReportMethods<'a, C> {
171 ReportMethods { hub: self }
172 }
173 pub fn savedadstyles(&'a self) -> SavedadstyleMethods<'a, C> {
174 SavedadstyleMethods { hub: self }
175 }
176 pub fn urlchannels(&'a self) -> UrlchannelMethods<'a, C> {
177 UrlchannelMethods { hub: self }
178 }
179
180 /// Set the user-agent header field to use in all requests to the server.
181 /// It defaults to `google-api-rust-client/7.0.0`.
182 ///
183 /// Returns the previously set user-agent.
184 pub fn user_agent(&mut self, agent_name: String) -> String {
185 std::mem::replace(&mut self._user_agent, agent_name)
186 }
187
188 /// Set the base url to use in all requests to the server.
189 /// It defaults to `https://www.googleapis.com/adsense/v1.4/`.
190 ///
191 /// Returns the previously set base url.
192 pub fn base_url(&mut self, new_base_url: String) -> String {
193 std::mem::replace(&mut self._base_url, new_base_url)
194 }
195
196 /// Set the root url to use in all requests to the server.
197 /// It defaults to `https://www.googleapis.com/`.
198 ///
199 /// Returns the previously set root url.
200 pub fn root_url(&mut self, new_root_url: String) -> String {
201 std::mem::replace(&mut self._root_url, new_root_url)
202 }
203}
204
205// ############
206// SCHEMAS ###
207// ##########
208/// There is no detailed description.
209///
210/// # Activities
211///
212/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
213/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
214///
215/// * [adclients get ad code accounts](AccountAdclientGetAdCodeCall) (none)
216/// * [adclients list accounts](AccountAdclientListCall) (none)
217/// * [adunits customchannels list accounts](AccountAdunitCustomchannelListCall) (none)
218/// * [adunits get accounts](AccountAdunitGetCall) (none)
219/// * [adunits get ad code accounts](AccountAdunitGetAdCodeCall) (none)
220/// * [adunits list accounts](AccountAdunitListCall) (none)
221/// * [alerts delete accounts](AccountAlertDeleteCall) (none)
222/// * [alerts list accounts](AccountAlertListCall) (none)
223/// * [customchannels adunits list accounts](AccountCustomchannelAdunitListCall) (none)
224/// * [customchannels get accounts](AccountCustomchannelGetCall) (none)
225/// * [customchannels list accounts](AccountCustomchannelListCall) (none)
226/// * [payments list accounts](AccountPaymentListCall) (none)
227/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (none)
228/// * [reports saved list accounts](AccountReportSavedListCall) (none)
229/// * [reports generate accounts](AccountReportGenerateCall) (none)
230/// * [savedadstyles get accounts](AccountSavedadstyleGetCall) (none)
231/// * [savedadstyles list accounts](AccountSavedadstyleListCall) (none)
232/// * [urlchannels list accounts](AccountUrlchannelListCall) (none)
233/// * [get accounts](AccountGetCall) (response)
234/// * [list accounts](AccountListCall) (none)
235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
236#[serde_with::serde_as]
237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
238pub struct Account {
239 /// no description provided
240 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
241 pub creation_time: Option<i64>,
242 /// Unique identifier of this account.
243 pub id: Option<String>,
244 /// Kind of resource this is, in this case adsense#account.
245 pub kind: Option<String>,
246 /// Name of this account.
247 pub name: Option<String>,
248 /// Whether this account is premium.
249 pub premium: Option<bool>,
250 /// Sub accounts of the this account.
251 #[serde(rename = "subAccounts")]
252 pub sub_accounts: Option<Vec<Account>>,
253 /// AdSense timezone of this account.
254 pub timezone: Option<String>,
255}
256
257impl common::Resource for Account {}
258impl common::ResponseResult for Account {}
259
260/// There is no detailed description.
261///
262/// # Activities
263///
264/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
265/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
266///
267/// * [list accounts](AccountListCall) (response)
268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
269#[serde_with::serde_as]
270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
271pub struct Accounts {
272 /// ETag of this response for caching purposes.
273 pub etag: Option<String>,
274 /// The accounts returned in this list response.
275 pub items: Option<Vec<Account>>,
276 /// Kind of list this is, in this case adsense#accounts.
277 pub kind: Option<String>,
278 /// Continuation token used to page through accounts. To retrieve the next page of results, set the next request's "pageToken" value to this.
279 #[serde(rename = "nextPageToken")]
280 pub next_page_token: Option<String>,
281}
282
283impl common::ResponseResult for Accounts {}
284
285/// There is no detailed description.
286///
287/// This type is not used in any activity, and only used as *part* of another schema.
288///
289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
290#[serde_with::serde_as]
291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
292pub struct AdClient {
293 /// Whether this ad client is opted in to ARC.
294 #[serde(rename = "arcOptIn")]
295 pub arc_opt_in: Option<bool>,
296 /// Unique identifier of this ad client.
297 pub id: Option<String>,
298 /// Kind of resource this is, in this case adsense#adClient.
299 pub kind: Option<String>,
300 /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension.
301 #[serde(rename = "productCode")]
302 pub product_code: Option<String>,
303 /// Whether this ad client supports being reported on.
304 #[serde(rename = "supportsReporting")]
305 pub supports_reporting: Option<bool>,
306}
307
308impl common::Part for AdClient {}
309
310/// There is no detailed description.
311///
312/// # Activities
313///
314/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
315/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
316///
317/// * [adclients list accounts](AccountAdclientListCall) (response)
318/// * [list adclients](AdclientListCall) (response)
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct AdClients {
323 /// ETag of this response for caching purposes.
324 pub etag: Option<String>,
325 /// The ad clients returned in this list response.
326 pub items: Option<Vec<AdClient>>,
327 /// Kind of list this is, in this case adsense#adClients.
328 pub kind: Option<String>,
329 /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this.
330 #[serde(rename = "nextPageToken")]
331 pub next_page_token: Option<String>,
332}
333
334impl common::ResponseResult for AdClients {}
335
336/// There is no detailed description.
337///
338/// # Activities
339///
340/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
341/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
342///
343/// * [adclients get ad code accounts](AccountAdclientGetAdCodeCall) (response)
344/// * [adunits get ad code accounts](AccountAdunitGetAdCodeCall) (response)
345/// * [get ad code adunits](AdunitGetAdCodeCall) (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 AdCode {
350 /// The Auto ad code snippet. The ad code snippet.
351 #[serde(rename = "adCode")]
352 pub ad_code: Option<String>,
353 /// The AMP Auto ad code snippet that goes in the body of an AMP page.
354 #[serde(rename = "ampBody")]
355 pub amp_body: Option<String>,
356 /// The AMP Auto ad code snippet that goes in the head of an AMP page.
357 #[serde(rename = "ampHead")]
358 pub amp_head: Option<String>,
359 /// Kind this is, in this case adsense#adCode.
360 pub kind: Option<String>,
361}
362
363impl common::ResponseResult for AdCode {}
364
365/// There is no detailed description.
366///
367/// This type is not used in any activity, and only used as *part* of another schema.
368///
369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
370#[serde_with::serde_as]
371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
372pub struct AdStyle {
373 /// The colors which are included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
374 pub colors: Option<AdStyleColors>,
375 /// The style of the corners in the ad (deprecated: never populated, ignored).
376 pub corners: Option<String>,
377 /// The font which is included in the style.
378 pub font: Option<AdStyleFont>,
379 /// Kind this is, in this case adsense#adStyle.
380 pub kind: Option<String>,
381}
382
383impl common::Part for AdStyle {}
384
385/// There is no detailed description.
386///
387/// # Activities
388///
389/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
390/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
391///
392/// * [adunits get accounts](AccountAdunitGetCall) (response)
393/// * [get adunits](AdunitGetCall) (response)
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct AdUnit {
398 /// Identity code of this ad unit, not necessarily unique across ad clients.
399 pub code: Option<String>,
400 /// Settings specific to content ads (AFC) and highend mobile content ads (AFMC - deprecated).
401 #[serde(rename = "contentAdsSettings")]
402 pub content_ads_settings: Option<AdUnitContentAdsSettings>,
403 /// Custom style information specific to this ad unit.
404 #[serde(rename = "customStyle")]
405 pub custom_style: Option<AdStyle>,
406 /// Settings specific to feed ads (AFF) - deprecated.
407 #[serde(rename = "feedAdsSettings")]
408 pub feed_ads_settings: Option<AdUnitFeedAdsSettings>,
409 /// Unique identifier of this ad unit. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
410 pub id: Option<String>,
411 /// Kind of resource this is, in this case adsense#adUnit.
412 pub kind: Option<String>,
413 /// Settings specific to WAP mobile content ads (AFMC) - deprecated.
414 #[serde(rename = "mobileContentAdsSettings")]
415 pub mobile_content_ads_settings: Option<AdUnitMobileContentAdsSettings>,
416 /// Name of this ad unit.
417 pub name: Option<String>,
418 /// ID of the saved ad style which holds this ad unit's style information.
419 #[serde(rename = "savedStyleId")]
420 pub saved_style_id: Option<String>,
421 /// Status of this ad unit. Possible values are:
422 /// NEW: Indicates that the ad unit was created within the last seven days and does not yet have any activity associated with it.
423 ///
424 /// ACTIVE: Indicates that there has been activity on this ad unit in the last seven days.
425 ///
426 /// INACTIVE: Indicates that there has been no activity on this ad unit in the last seven days.
427 pub status: Option<String>,
428}
429
430impl common::Resource for AdUnit {}
431impl common::ResponseResult for AdUnit {}
432
433/// There is no detailed description.
434///
435/// # Activities
436///
437/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
438/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
439///
440/// * [adunits list accounts](AccountAdunitListCall) (response)
441/// * [customchannels adunits list accounts](AccountCustomchannelAdunitListCall) (response)
442/// * [list adunits](AdunitListCall) (response)
443/// * [adunits list customchannels](CustomchannelAdunitListCall) (response)
444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
445#[serde_with::serde_as]
446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
447pub struct AdUnits {
448 /// ETag of this response for caching purposes.
449 pub etag: Option<String>,
450 /// The ad units returned in this list response.
451 pub items: Option<Vec<AdUnit>>,
452 /// Kind of list this is, in this case adsense#adUnits.
453 pub kind: Option<String>,
454 /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this.
455 #[serde(rename = "nextPageToken")]
456 pub next_page_token: Option<String>,
457}
458
459impl common::ResponseResult for AdUnits {}
460
461/// There is no detailed description.
462///
463/// # Activities
464///
465/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
466/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
467///
468/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (response)
469/// * [reports generate accounts](AccountReportGenerateCall) (response)
470/// * [saved generate reports](ReportSavedGenerateCall) (response)
471/// * [generate reports](ReportGenerateCall) (response)
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct AdsenseReportsGenerateResponse {
476 /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
477 pub averages: Option<Vec<String>>,
478 /// The requested end date in yyyy-mm-dd format.
479 #[serde(rename = "endDate")]
480 pub end_date: Option<String>,
481 /// 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.
482 pub headers: Option<Vec<AdsenseReportsGenerateResponseHeaders>>,
483 /// Kind this is, in this case adsense#report.
484 pub kind: Option<String>,
485 /// 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.
486 pub rows: Option<Vec<Vec<String>>>,
487 /// The requested start date in yyyy-mm-dd format.
488 #[serde(rename = "startDate")]
489 pub start_date: Option<String>,
490 /// 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.
491 #[serde(rename = "totalMatchedRows")]
492 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
493 pub total_matched_rows: Option<i64>,
494 /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
495 pub totals: Option<Vec<String>>,
496 /// Any warnings associated with generation of the report.
497 pub warnings: Option<Vec<String>>,
498}
499
500impl common::ResponseResult for AdsenseReportsGenerateResponse {}
501
502/// There is no detailed description.
503///
504/// # Activities
505///
506/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
507/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
508///
509/// * [delete alerts](AlertDeleteCall) (none)
510/// * [list alerts](AlertListCall) (none)
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct Alert {
515 /// 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.
516 pub id: Option<String>,
517 /// Whether this alert can be dismissed.
518 #[serde(rename = "isDismissible")]
519 pub is_dismissible: Option<bool>,
520 /// Kind of resource this is, in this case adsense#alert.
521 pub kind: Option<String>,
522 /// The localized alert message.
523 pub message: Option<String>,
524 /// Severity of this alert. Possible values: INFO, WARNING, SEVERE.
525 pub severity: Option<String>,
526 /// Type of this alert. Possible values: SELF_HOLD, MIGRATED_TO_BILLING3, ADDRESS_PIN_VERIFICATION, PHONE_PIN_VERIFICATION, CORPORATE_ENTITY, GRAYLISTED_PUBLISHER, API_HOLD.
527 #[serde(rename = "type")]
528 pub type_: Option<String>,
529}
530
531impl common::Resource for Alert {}
532
533/// There is no detailed description.
534///
535/// # Activities
536///
537/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
538/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
539///
540/// * [alerts list accounts](AccountAlertListCall) (response)
541/// * [list alerts](AlertListCall) (response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct Alerts {
546 /// The alerts returned in this list response.
547 pub items: Option<Vec<Alert>>,
548 /// Kind of list this is, in this case adsense#alerts.
549 pub kind: Option<String>,
550}
551
552impl common::ResponseResult for Alerts {}
553
554/// There is no detailed description.
555///
556/// # Activities
557///
558/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
559/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
560///
561/// * [customchannels get accounts](AccountCustomchannelGetCall) (response)
562/// * [get customchannels](CustomchannelGetCall) (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 CustomChannel {
567 /// Code of this custom channel, not necessarily unique across ad clients.
568 pub code: Option<String>,
569 /// 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.
570 pub id: Option<String>,
571 /// Kind of resource this is, in this case adsense#customChannel.
572 pub kind: Option<String>,
573 /// Name of this custom channel.
574 pub name: Option<String>,
575 /// The targeting information of this custom channel, if activated.
576 #[serde(rename = "targetingInfo")]
577 pub targeting_info: Option<CustomChannelTargetingInfo>,
578}
579
580impl common::Resource for CustomChannel {}
581impl common::ResponseResult for CustomChannel {}
582
583/// There is no detailed description.
584///
585/// # Activities
586///
587/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
588/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
589///
590/// * [adunits customchannels list accounts](AccountAdunitCustomchannelListCall) (response)
591/// * [customchannels list accounts](AccountCustomchannelListCall) (response)
592/// * [customchannels list adunits](AdunitCustomchannelListCall) (response)
593/// * [list customchannels](CustomchannelListCall) (response)
594#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
595#[serde_with::serde_as]
596#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
597pub struct CustomChannels {
598 /// ETag of this response for caching purposes.
599 pub etag: Option<String>,
600 /// The custom channels returned in this list response.
601 pub items: Option<Vec<CustomChannel>>,
602 /// Kind of list this is, in this case adsense#customChannels.
603 pub kind: Option<String>,
604 /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
605 #[serde(rename = "nextPageToken")]
606 pub next_page_token: Option<String>,
607}
608
609impl common::ResponseResult for CustomChannels {}
610
611/// There is no detailed description.
612///
613/// # Activities
614///
615/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
616/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
617///
618/// * [dimensions list metadata](MetadataDimensionListCall) (response)
619/// * [metrics list metadata](MetadataMetricListCall) (response)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct Metadata {
624 /// no description provided
625 pub items: Option<Vec<ReportingMetadataEntry>>,
626 /// Kind of list this is, in this case adsense#metadata.
627 pub kind: Option<String>,
628}
629
630impl common::ResponseResult for Metadata {}
631
632/// There is no detailed description.
633///
634/// # Activities
635///
636/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
637/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
638///
639/// * [list payments](PaymentListCall) (none)
640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
641#[serde_with::serde_as]
642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
643pub struct Payment {
644 /// Unique identifier of this Payment.
645 pub id: Option<String>,
646 /// Kind of resource this is, in this case adsense#payment.
647 pub kind: Option<String>,
648 /// The amount to be paid.
649 #[serde(rename = "paymentAmount")]
650 pub payment_amount: Option<String>,
651 /// The currency code for the amount to be paid.
652 #[serde(rename = "paymentAmountCurrencyCode")]
653 pub payment_amount_currency_code: Option<String>,
654 /// The date this payment was/will be credited to the user, or none if the payment threshold has not been met.
655 #[serde(rename = "paymentDate")]
656 pub payment_date: Option<String>,
657}
658
659impl common::Resource for Payment {}
660
661/// There is no detailed description.
662///
663/// # Activities
664///
665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
667///
668/// * [payments list accounts](AccountPaymentListCall) (response)
669/// * [list payments](PaymentListCall) (response)
670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
671#[serde_with::serde_as]
672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
673pub struct Payments {
674 /// The list of Payments for the account. One or both of a) the account's most recent payment; and b) the account's upcoming payment.
675 pub items: Option<Vec<Payment>>,
676 /// Kind of list this is, in this case adsense#payments.
677 pub kind: Option<String>,
678}
679
680impl common::ResponseResult for Payments {}
681
682/// There is no detailed description.
683///
684/// This type is not used in any activity, and only used as *part* of another schema.
685///
686#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
687#[serde_with::serde_as]
688#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
689pub struct ReportingMetadataEntry {
690 /// 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.
691 #[serde(rename = "compatibleDimensions")]
692 pub compatible_dimensions: Option<Vec<String>>,
693 /// The names of the metrics the dimension or metric this reporting metadata entry describes is compatible with.
694 #[serde(rename = "compatibleMetrics")]
695 pub compatible_metrics: Option<Vec<String>>,
696 /// Unique identifier of this reporting metadata entry, corresponding to the name of the appropriate dimension or metric.
697 pub id: Option<String>,
698 /// Kind of resource this is, in this case adsense#reportingMetadataEntry.
699 pub kind: Option<String>,
700 /// 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.
701 #[serde(rename = "requiredDimensions")]
702 pub required_dimensions: Option<Vec<String>>,
703 /// 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.
704 #[serde(rename = "requiredMetrics")]
705 pub required_metrics: Option<Vec<String>>,
706 /// The codes of the projects supported by the dimension or metric this reporting metadata entry describes.
707 #[serde(rename = "supportedProducts")]
708 pub supported_products: Option<Vec<String>>,
709}
710
711impl common::Part for ReportingMetadataEntry {}
712
713/// There is no detailed description.
714///
715/// # Activities
716///
717/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
718/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
719///
720/// * [savedadstyles get accounts](AccountSavedadstyleGetCall) (response)
721/// * [get savedadstyles](SavedadstyleGetCall) (response)
722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
723#[serde_with::serde_as]
724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
725pub struct SavedAdStyle {
726 /// The AdStyle itself.
727 #[serde(rename = "adStyle")]
728 pub ad_style: Option<AdStyle>,
729 /// Unique identifier of this saved ad style. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
730 pub id: Option<String>,
731 /// Kind of resource this is, in this case adsense#savedAdStyle.
732 pub kind: Option<String>,
733 /// The user selected name of this SavedAdStyle.
734 pub name: Option<String>,
735}
736
737impl common::Resource for SavedAdStyle {}
738impl common::ResponseResult for SavedAdStyle {}
739
740/// There is no detailed description.
741///
742/// # Activities
743///
744/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
745/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
746///
747/// * [savedadstyles list accounts](AccountSavedadstyleListCall) (response)
748/// * [list savedadstyles](SavedadstyleListCall) (response)
749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
750#[serde_with::serde_as]
751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
752pub struct SavedAdStyles {
753 /// ETag of this response for caching purposes.
754 pub etag: Option<String>,
755 /// The saved ad styles returned in this list response.
756 pub items: Option<Vec<SavedAdStyle>>,
757 /// Kind of list this is, in this case adsense#savedAdStyles.
758 pub kind: Option<String>,
759 /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this.
760 #[serde(rename = "nextPageToken")]
761 pub next_page_token: Option<String>,
762}
763
764impl common::ResponseResult for SavedAdStyles {}
765
766/// There is no detailed description.
767///
768/// This type is not used in any activity, and only used as *part* of another schema.
769///
770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
771#[serde_with::serde_as]
772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
773pub struct SavedReport {
774 /// Unique identifier of this saved report.
775 pub id: Option<String>,
776 /// Kind of resource this is, in this case adsense#savedReport.
777 pub kind: Option<String>,
778 /// This saved report's name.
779 pub name: Option<String>,
780}
781
782impl common::Part for SavedReport {}
783
784/// There is no detailed description.
785///
786/// # Activities
787///
788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
790///
791/// * [reports saved list accounts](AccountReportSavedListCall) (response)
792/// * [saved list reports](ReportSavedListCall) (response)
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct SavedReports {
797 /// ETag of this response for caching purposes.
798 pub etag: Option<String>,
799 /// The saved reports returned in this list response.
800 pub items: Option<Vec<SavedReport>>,
801 /// Kind of list this is, in this case adsense#savedReports.
802 pub kind: Option<String>,
803 /// Continuation token used to page through saved reports. To retrieve the next page of results, set the next request's "pageToken" value to this.
804 #[serde(rename = "nextPageToken")]
805 pub next_page_token: Option<String>,
806}
807
808impl common::ResponseResult for SavedReports {}
809
810/// There is no detailed description.
811///
812/// This type is not used in any activity, and only used as *part* of another schema.
813///
814#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
815#[serde_with::serde_as]
816#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
817pub struct UrlChannel {
818 /// 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.
819 pub id: Option<String>,
820 /// Kind of resource this is, in this case adsense#urlChannel.
821 pub kind: Option<String>,
822 /// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home
823 #[serde(rename = "urlPattern")]
824 pub url_pattern: Option<String>,
825}
826
827impl common::Part for UrlChannel {}
828
829/// There is no detailed description.
830///
831/// # Activities
832///
833/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
834/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
835///
836/// * [urlchannels list accounts](AccountUrlchannelListCall) (response)
837/// * [list urlchannels](UrlchannelListCall) (response)
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct UrlChannels {
842 /// ETag of this response for caching purposes.
843 pub etag: Option<String>,
844 /// The URL channels returned in this list response.
845 pub items: Option<Vec<UrlChannel>>,
846 /// Kind of list this is, in this case adsense#urlChannels.
847 pub kind: Option<String>,
848 /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
849 #[serde(rename = "nextPageToken")]
850 pub next_page_token: Option<String>,
851}
852
853impl common::ResponseResult for UrlChannels {}
854
855/// The colors which are included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
856///
857/// This type is not used in any activity, and only used as *part* of another schema.
858///
859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
860#[serde_with::serde_as]
861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
862pub struct AdStyleColors {
863 /// The color of the ad background.
864 pub background: Option<String>,
865 /// The color of the ad border.
866 pub border: Option<String>,
867 /// The color of the ad text.
868 pub text: Option<String>,
869 /// The color of the ad title.
870 pub title: Option<String>,
871 /// The color of the ad url.
872 pub url: Option<String>,
873}
874
875impl common::NestedType for AdStyleColors {}
876impl common::Part for AdStyleColors {}
877
878/// The font which is included in the style.
879///
880/// This type is not used in any activity, and only used as *part* of another schema.
881///
882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
883#[serde_with::serde_as]
884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
885pub struct AdStyleFont {
886 /// The family of the font.
887 pub family: Option<String>,
888 /// The size of the font.
889 pub size: Option<String>,
890}
891
892impl common::NestedType for AdStyleFont {}
893impl common::Part for AdStyleFont {}
894
895/// Settings specific to content ads (AFC) and highend mobile content ads (AFMC - deprecated).
896///
897/// This type is not used in any activity, and only used as *part* of another schema.
898///
899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
900#[serde_with::serde_as]
901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
902pub struct AdUnitContentAdsSettings {
903 /// The backup option to be used in instances where no ad is available.
904 #[serde(rename = "backupOption")]
905 pub backup_option: Option<AdUnitContentAdsSettingsBackupOption>,
906 /// Size of this ad unit.
907 pub size: Option<String>,
908 /// Type of this ad unit.
909 #[serde(rename = "type")]
910 pub type_: Option<String>,
911}
912
913impl common::NestedType for AdUnitContentAdsSettings {}
914impl common::Part for AdUnitContentAdsSettings {}
915
916/// The backup option to be used in instances where no ad is available.
917///
918/// This type is not used in any activity, and only used as *part* of another schema.
919///
920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
921#[serde_with::serde_as]
922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
923pub struct AdUnitContentAdsSettingsBackupOption {
924 /// Color to use when type is set to COLOR.
925 pub color: Option<String>,
926 /// Type of the backup option. Possible values are BLANK, COLOR and URL.
927 #[serde(rename = "type")]
928 pub type_: Option<String>,
929 /// URL to use when type is set to URL.
930 pub url: Option<String>,
931}
932
933impl common::NestedType for AdUnitContentAdsSettingsBackupOption {}
934impl common::Part for AdUnitContentAdsSettingsBackupOption {}
935
936/// Settings specific to feed ads (AFF) - deprecated.
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct AdUnitFeedAdsSettings {
944 /// The position of the ads relative to the feed entries.
945 #[serde(rename = "adPosition")]
946 pub ad_position: Option<String>,
947 /// The frequency at which ads should appear in the feed (i.e. every N entries).
948 pub frequency: Option<i32>,
949 /// The minimum length an entry should be in order to have attached ads.
950 #[serde(rename = "minimumWordCount")]
951 pub minimum_word_count: Option<i32>,
952 /// The type of ads which should appear.
953 #[serde(rename = "type")]
954 pub type_: Option<String>,
955}
956
957impl common::NestedType for AdUnitFeedAdsSettings {}
958impl common::Part for AdUnitFeedAdsSettings {}
959
960/// Settings specific to WAP mobile content ads (AFMC) - deprecated.
961///
962/// This type is not used in any activity, and only used as *part* of another schema.
963///
964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
965#[serde_with::serde_as]
966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
967pub struct AdUnitMobileContentAdsSettings {
968 /// The markup language to use for this ad unit.
969 #[serde(rename = "markupLanguage")]
970 pub markup_language: Option<String>,
971 /// The scripting language to use for this ad unit.
972 #[serde(rename = "scriptingLanguage")]
973 pub scripting_language: Option<String>,
974 /// Size of this ad unit.
975 pub size: Option<String>,
976 /// Type of this ad unit.
977 #[serde(rename = "type")]
978 pub type_: Option<String>,
979}
980
981impl common::NestedType for AdUnitMobileContentAdsSettings {}
982impl common::Part for AdUnitMobileContentAdsSettings {}
983
984/// 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.
985///
986/// This type is not used in any activity, and only used as *part* of another schema.
987///
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct AdsenseReportsGenerateResponseHeaders {
992 /// The currency of this column. Only present if the header type is METRIC_CURRENCY.
993 pub currency: Option<String>,
994 /// The name of the header.
995 pub name: Option<String>,
996 /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY.
997 #[serde(rename = "type")]
998 pub type_: Option<String>,
999}
1000
1001impl common::NestedType for AdsenseReportsGenerateResponseHeaders {}
1002impl common::Part for AdsenseReportsGenerateResponseHeaders {}
1003
1004/// The targeting information of this custom channel, if activated.
1005///
1006/// This type is not used in any activity, and only used as *part* of another schema.
1007///
1008#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1009#[serde_with::serde_as]
1010#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1011pub struct CustomChannelTargetingInfo {
1012 /// The name used to describe this channel externally.
1013 #[serde(rename = "adsAppearOn")]
1014 pub ads_appear_on: Option<String>,
1015 /// The external description of the channel.
1016 pub description: Option<String>,
1017 /// The locations in which ads appear. (Only valid for content and mobile content ads (deprecated)). 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 (deprecated) are: TOP, MIDDLE, BOTTOM, MULTIPLE_LOCATIONS.
1018 pub location: Option<String>,
1019 /// The language of the sites ads will be displayed on.
1020 #[serde(rename = "siteLanguage")]
1021 pub site_language: Option<String>,
1022}
1023
1024impl common::NestedType for CustomChannelTargetingInfo {}
1025impl common::Part for CustomChannelTargetingInfo {}
1026
1027// ###################
1028// MethodBuilders ###
1029// #################
1030
1031/// A builder providing access to all methods supported on *account* resources.
1032/// It is not used directly, but through the [`AdSense`] hub.
1033///
1034/// # Example
1035///
1036/// Instantiate a resource builder
1037///
1038/// ```test_harness,no_run
1039/// extern crate hyper;
1040/// extern crate hyper_rustls;
1041/// extern crate google_adsense1d4 as adsense1d4;
1042///
1043/// # async fn dox() {
1044/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1045///
1046/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1047/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1048/// .with_native_roots()
1049/// .unwrap()
1050/// .https_only()
1051/// .enable_http2()
1052/// .build();
1053///
1054/// let executor = hyper_util::rt::TokioExecutor::new();
1055/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1056/// secret,
1057/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1058/// yup_oauth2::client::CustomHyperClientBuilder::from(
1059/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1060/// ),
1061/// ).build().await.unwrap();
1062///
1063/// let client = hyper_util::client::legacy::Client::builder(
1064/// hyper_util::rt::TokioExecutor::new()
1065/// )
1066/// .build(
1067/// hyper_rustls::HttpsConnectorBuilder::new()
1068/// .with_native_roots()
1069/// .unwrap()
1070/// .https_or_http()
1071/// .enable_http2()
1072/// .build()
1073/// );
1074/// let mut hub = AdSense::new(client, auth);
1075/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1076/// // like `adclients_get_ad_code(...)`, `adclients_list(...)`, `adunits_customchannels_list(...)`, `adunits_get(...)`, `adunits_get_ad_code(...)`, `adunits_list(...)`, `alerts_delete(...)`, `alerts_list(...)`, `customchannels_adunits_list(...)`, `customchannels_get(...)`, `customchannels_list(...)`, `get(...)`, `list(...)`, `payments_list(...)`, `reports_generate(...)`, `reports_saved_generate(...)`, `reports_saved_list(...)`, `savedadstyles_get(...)`, `savedadstyles_list(...)` and `urlchannels_list(...)`
1077/// // to build up your call.
1078/// let rb = hub.accounts();
1079/// # }
1080/// ```
1081pub struct AccountMethods<'a, C>
1082where
1083 C: 'a,
1084{
1085 hub: &'a AdSense<C>,
1086}
1087
1088impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
1089
1090impl<'a, C> AccountMethods<'a, C> {
1091 /// Create a builder to help you perform the following task:
1092 ///
1093 /// Get Auto ad code for a given ad client.
1094 ///
1095 /// # Arguments
1096 ///
1097 /// * `accountId` - Account which contains the ad client.
1098 /// * `adClientId` - Ad client to get the code for.
1099 pub fn adclients_get_ad_code(
1100 &self,
1101 account_id: &str,
1102 ad_client_id: &str,
1103 ) -> AccountAdclientGetAdCodeCall<'a, C> {
1104 AccountAdclientGetAdCodeCall {
1105 hub: self.hub,
1106 _account_id: account_id.to_string(),
1107 _ad_client_id: ad_client_id.to_string(),
1108 _tag_partner: Default::default(),
1109 _delegate: Default::default(),
1110 _additional_params: Default::default(),
1111 _scopes: Default::default(),
1112 }
1113 }
1114
1115 /// Create a builder to help you perform the following task:
1116 ///
1117 /// List all ad clients in the specified account.
1118 ///
1119 /// # Arguments
1120 ///
1121 /// * `accountId` - Account for which to list ad clients.
1122 pub fn adclients_list(&self, account_id: &str) -> AccountAdclientListCall<'a, C> {
1123 AccountAdclientListCall {
1124 hub: self.hub,
1125 _account_id: account_id.to_string(),
1126 _page_token: Default::default(),
1127 _max_results: Default::default(),
1128 _delegate: Default::default(),
1129 _additional_params: Default::default(),
1130 _scopes: Default::default(),
1131 }
1132 }
1133
1134 /// Create a builder to help you perform the following task:
1135 ///
1136 /// List all custom channels which the specified ad unit belongs to.
1137 ///
1138 /// # Arguments
1139 ///
1140 /// * `accountId` - Account to which the ad client belongs.
1141 /// * `adClientId` - Ad client which contains the ad unit.
1142 /// * `adUnitId` - Ad unit for which to list custom channels.
1143 pub fn adunits_customchannels_list(
1144 &self,
1145 account_id: &str,
1146 ad_client_id: &str,
1147 ad_unit_id: &str,
1148 ) -> AccountAdunitCustomchannelListCall<'a, C> {
1149 AccountAdunitCustomchannelListCall {
1150 hub: self.hub,
1151 _account_id: account_id.to_string(),
1152 _ad_client_id: ad_client_id.to_string(),
1153 _ad_unit_id: ad_unit_id.to_string(),
1154 _page_token: Default::default(),
1155 _max_results: Default::default(),
1156 _delegate: Default::default(),
1157 _additional_params: Default::default(),
1158 _scopes: Default::default(),
1159 }
1160 }
1161
1162 /// Create a builder to help you perform the following task:
1163 ///
1164 /// Gets the specified ad unit in the specified ad client for the specified account.
1165 ///
1166 /// # Arguments
1167 ///
1168 /// * `accountId` - Account to which the ad client belongs.
1169 /// * `adClientId` - Ad client for which to get the ad unit.
1170 /// * `adUnitId` - Ad unit to retrieve.
1171 pub fn adunits_get(
1172 &self,
1173 account_id: &str,
1174 ad_client_id: &str,
1175 ad_unit_id: &str,
1176 ) -> AccountAdunitGetCall<'a, C> {
1177 AccountAdunitGetCall {
1178 hub: self.hub,
1179 _account_id: account_id.to_string(),
1180 _ad_client_id: ad_client_id.to_string(),
1181 _ad_unit_id: ad_unit_id.to_string(),
1182 _delegate: Default::default(),
1183 _additional_params: Default::default(),
1184 _scopes: Default::default(),
1185 }
1186 }
1187
1188 /// Create a builder to help you perform the following task:
1189 ///
1190 /// Get ad code for the specified ad unit.
1191 ///
1192 /// # Arguments
1193 ///
1194 /// * `accountId` - Account which contains the ad client.
1195 /// * `adClientId` - Ad client with contains the ad unit.
1196 /// * `adUnitId` - Ad unit to get the code for.
1197 pub fn adunits_get_ad_code(
1198 &self,
1199 account_id: &str,
1200 ad_client_id: &str,
1201 ad_unit_id: &str,
1202 ) -> AccountAdunitGetAdCodeCall<'a, C> {
1203 AccountAdunitGetAdCodeCall {
1204 hub: self.hub,
1205 _account_id: account_id.to_string(),
1206 _ad_client_id: ad_client_id.to_string(),
1207 _ad_unit_id: ad_unit_id.to_string(),
1208 _delegate: Default::default(),
1209 _additional_params: Default::default(),
1210 _scopes: Default::default(),
1211 }
1212 }
1213
1214 /// Create a builder to help you perform the following task:
1215 ///
1216 /// List all ad units in the specified ad client for the specified account.
1217 ///
1218 /// # Arguments
1219 ///
1220 /// * `accountId` - Account to which the ad client belongs.
1221 /// * `adClientId` - Ad client for which to list ad units.
1222 pub fn adunits_list(
1223 &self,
1224 account_id: &str,
1225 ad_client_id: &str,
1226 ) -> AccountAdunitListCall<'a, C> {
1227 AccountAdunitListCall {
1228 hub: self.hub,
1229 _account_id: account_id.to_string(),
1230 _ad_client_id: ad_client_id.to_string(),
1231 _page_token: Default::default(),
1232 _max_results: Default::default(),
1233 _include_inactive: Default::default(),
1234 _delegate: Default::default(),
1235 _additional_params: Default::default(),
1236 _scopes: Default::default(),
1237 }
1238 }
1239
1240 /// Create a builder to help you perform the following task:
1241 ///
1242 /// Dismiss (delete) the specified alert from the specified publisher AdSense account.
1243 ///
1244 /// # Arguments
1245 ///
1246 /// * `accountId` - Account which contains the ad unit.
1247 /// * `alertId` - Alert to delete.
1248 pub fn alerts_delete(&self, account_id: &str, alert_id: &str) -> AccountAlertDeleteCall<'a, C> {
1249 AccountAlertDeleteCall {
1250 hub: self.hub,
1251 _account_id: account_id.to_string(),
1252 _alert_id: alert_id.to_string(),
1253 _delegate: Default::default(),
1254 _additional_params: Default::default(),
1255 _scopes: Default::default(),
1256 }
1257 }
1258
1259 /// Create a builder to help you perform the following task:
1260 ///
1261 /// List the alerts for the specified AdSense account.
1262 ///
1263 /// # Arguments
1264 ///
1265 /// * `accountId` - Account for which to retrieve the alerts.
1266 pub fn alerts_list(&self, account_id: &str) -> AccountAlertListCall<'a, C> {
1267 AccountAlertListCall {
1268 hub: self.hub,
1269 _account_id: account_id.to_string(),
1270 _locale: Default::default(),
1271 _delegate: Default::default(),
1272 _additional_params: Default::default(),
1273 _scopes: Default::default(),
1274 }
1275 }
1276
1277 /// Create a builder to help you perform the following task:
1278 ///
1279 /// List all ad units in the specified custom channel.
1280 ///
1281 /// # Arguments
1282 ///
1283 /// * `accountId` - Account to which the ad client belongs.
1284 /// * `adClientId` - Ad client which contains the custom channel.
1285 /// * `customChannelId` - Custom channel for which to list ad units.
1286 pub fn customchannels_adunits_list(
1287 &self,
1288 account_id: &str,
1289 ad_client_id: &str,
1290 custom_channel_id: &str,
1291 ) -> AccountCustomchannelAdunitListCall<'a, C> {
1292 AccountCustomchannelAdunitListCall {
1293 hub: self.hub,
1294 _account_id: account_id.to_string(),
1295 _ad_client_id: ad_client_id.to_string(),
1296 _custom_channel_id: custom_channel_id.to_string(),
1297 _page_token: Default::default(),
1298 _max_results: Default::default(),
1299 _include_inactive: Default::default(),
1300 _delegate: Default::default(),
1301 _additional_params: Default::default(),
1302 _scopes: Default::default(),
1303 }
1304 }
1305
1306 /// Create a builder to help you perform the following task:
1307 ///
1308 /// Get the specified custom channel from the specified ad client for the specified account.
1309 ///
1310 /// # Arguments
1311 ///
1312 /// * `accountId` - Account to which the ad client belongs.
1313 /// * `adClientId` - Ad client which contains the custom channel.
1314 /// * `customChannelId` - Custom channel to retrieve.
1315 pub fn customchannels_get(
1316 &self,
1317 account_id: &str,
1318 ad_client_id: &str,
1319 custom_channel_id: &str,
1320 ) -> AccountCustomchannelGetCall<'a, C> {
1321 AccountCustomchannelGetCall {
1322 hub: self.hub,
1323 _account_id: account_id.to_string(),
1324 _ad_client_id: ad_client_id.to_string(),
1325 _custom_channel_id: custom_channel_id.to_string(),
1326 _delegate: Default::default(),
1327 _additional_params: Default::default(),
1328 _scopes: Default::default(),
1329 }
1330 }
1331
1332 /// Create a builder to help you perform the following task:
1333 ///
1334 /// List all custom channels in the specified ad client for the specified account.
1335 ///
1336 /// # Arguments
1337 ///
1338 /// * `accountId` - Account to which the ad client belongs.
1339 /// * `adClientId` - Ad client for which to list custom channels.
1340 pub fn customchannels_list(
1341 &self,
1342 account_id: &str,
1343 ad_client_id: &str,
1344 ) -> AccountCustomchannelListCall<'a, C> {
1345 AccountCustomchannelListCall {
1346 hub: self.hub,
1347 _account_id: account_id.to_string(),
1348 _ad_client_id: ad_client_id.to_string(),
1349 _page_token: Default::default(),
1350 _max_results: Default::default(),
1351 _delegate: Default::default(),
1352 _additional_params: Default::default(),
1353 _scopes: Default::default(),
1354 }
1355 }
1356
1357 /// Create a builder to help you perform the following task:
1358 ///
1359 /// List the payments for the specified AdSense account.
1360 ///
1361 /// # Arguments
1362 ///
1363 /// * `accountId` - Account for which to retrieve the payments.
1364 pub fn payments_list(&self, account_id: &str) -> AccountPaymentListCall<'a, C> {
1365 AccountPaymentListCall {
1366 hub: self.hub,
1367 _account_id: account_id.to_string(),
1368 _delegate: Default::default(),
1369 _additional_params: Default::default(),
1370 _scopes: Default::default(),
1371 }
1372 }
1373
1374 /// Create a builder to help you perform the following task:
1375 ///
1376 /// Generate an AdSense report based on the saved report ID sent in the query parameters.
1377 ///
1378 /// # Arguments
1379 ///
1380 /// * `accountId` - Account to which the saved reports belong.
1381 /// * `savedReportId` - The saved report to retrieve.
1382 pub fn reports_saved_generate(
1383 &self,
1384 account_id: &str,
1385 saved_report_id: &str,
1386 ) -> AccountReportSavedGenerateCall<'a, C> {
1387 AccountReportSavedGenerateCall {
1388 hub: self.hub,
1389 _account_id: account_id.to_string(),
1390 _saved_report_id: saved_report_id.to_string(),
1391 _start_index: Default::default(),
1392 _max_results: Default::default(),
1393 _locale: Default::default(),
1394 _delegate: Default::default(),
1395 _additional_params: Default::default(),
1396 _scopes: Default::default(),
1397 }
1398 }
1399
1400 /// Create a builder to help you perform the following task:
1401 ///
1402 /// List all saved reports in the specified AdSense account.
1403 ///
1404 /// # Arguments
1405 ///
1406 /// * `accountId` - Account to which the saved reports belong.
1407 pub fn reports_saved_list(&self, account_id: &str) -> AccountReportSavedListCall<'a, C> {
1408 AccountReportSavedListCall {
1409 hub: self.hub,
1410 _account_id: account_id.to_string(),
1411 _page_token: Default::default(),
1412 _max_results: Default::default(),
1413 _delegate: Default::default(),
1414 _additional_params: Default::default(),
1415 _scopes: Default::default(),
1416 }
1417 }
1418
1419 /// Create a builder to help you perform the following task:
1420 ///
1421 /// Generate an AdSense 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.
1422 ///
1423 /// # Arguments
1424 ///
1425 /// * `accountId` - Account upon which to report.
1426 /// * `startDate` - Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
1427 /// * `endDate` - End of the date range to report on in "YYYY-MM-DD" format, inclusive.
1428 pub fn reports_generate(
1429 &self,
1430 account_id: &str,
1431 start_date: &str,
1432 end_date: &str,
1433 ) -> AccountReportGenerateCall<'a, C> {
1434 AccountReportGenerateCall {
1435 hub: self.hub,
1436 _account_id: account_id.to_string(),
1437 _start_date: start_date.to_string(),
1438 _end_date: end_date.to_string(),
1439 _use_timezone_reporting: Default::default(),
1440 _start_index: Default::default(),
1441 _sort: Default::default(),
1442 _metric: Default::default(),
1443 _max_results: Default::default(),
1444 _locale: Default::default(),
1445 _filter: Default::default(),
1446 _dimension: Default::default(),
1447 _currency: Default::default(),
1448 _delegate: Default::default(),
1449 _additional_params: Default::default(),
1450 _scopes: Default::default(),
1451 }
1452 }
1453
1454 /// Create a builder to help you perform the following task:
1455 ///
1456 /// List a specific saved ad style for the specified account.
1457 ///
1458 /// # Arguments
1459 ///
1460 /// * `accountId` - Account for which to get the saved ad style.
1461 /// * `savedAdStyleId` - Saved ad style to retrieve.
1462 pub fn savedadstyles_get(
1463 &self,
1464 account_id: &str,
1465 saved_ad_style_id: &str,
1466 ) -> AccountSavedadstyleGetCall<'a, C> {
1467 AccountSavedadstyleGetCall {
1468 hub: self.hub,
1469 _account_id: account_id.to_string(),
1470 _saved_ad_style_id: saved_ad_style_id.to_string(),
1471 _delegate: Default::default(),
1472 _additional_params: Default::default(),
1473 _scopes: Default::default(),
1474 }
1475 }
1476
1477 /// Create a builder to help you perform the following task:
1478 ///
1479 /// List all saved ad styles in the specified account.
1480 ///
1481 /// # Arguments
1482 ///
1483 /// * `accountId` - Account for which to list saved ad styles.
1484 pub fn savedadstyles_list(&self, account_id: &str) -> AccountSavedadstyleListCall<'a, C> {
1485 AccountSavedadstyleListCall {
1486 hub: self.hub,
1487 _account_id: account_id.to_string(),
1488 _page_token: Default::default(),
1489 _max_results: Default::default(),
1490 _delegate: Default::default(),
1491 _additional_params: Default::default(),
1492 _scopes: Default::default(),
1493 }
1494 }
1495
1496 /// Create a builder to help you perform the following task:
1497 ///
1498 /// List all URL channels in the specified ad client for the specified account.
1499 ///
1500 /// # Arguments
1501 ///
1502 /// * `accountId` - Account to which the ad client belongs.
1503 /// * `adClientId` - Ad client for which to list URL channels.
1504 pub fn urlchannels_list(
1505 &self,
1506 account_id: &str,
1507 ad_client_id: &str,
1508 ) -> AccountUrlchannelListCall<'a, C> {
1509 AccountUrlchannelListCall {
1510 hub: self.hub,
1511 _account_id: account_id.to_string(),
1512 _ad_client_id: ad_client_id.to_string(),
1513 _page_token: Default::default(),
1514 _max_results: Default::default(),
1515 _delegate: Default::default(),
1516 _additional_params: Default::default(),
1517 _scopes: Default::default(),
1518 }
1519 }
1520
1521 /// Create a builder to help you perform the following task:
1522 ///
1523 /// Get information about the selected AdSense account.
1524 ///
1525 /// # Arguments
1526 ///
1527 /// * `accountId` - Account to get information about.
1528 pub fn get(&self, account_id: &str) -> AccountGetCall<'a, C> {
1529 AccountGetCall {
1530 hub: self.hub,
1531 _account_id: account_id.to_string(),
1532 _tree: Default::default(),
1533 _delegate: Default::default(),
1534 _additional_params: Default::default(),
1535 _scopes: Default::default(),
1536 }
1537 }
1538
1539 /// Create a builder to help you perform the following task:
1540 ///
1541 /// List all accounts available to this AdSense account.
1542 pub fn list(&self) -> AccountListCall<'a, C> {
1543 AccountListCall {
1544 hub: self.hub,
1545 _page_token: Default::default(),
1546 _max_results: Default::default(),
1547 _delegate: Default::default(),
1548 _additional_params: Default::default(),
1549 _scopes: Default::default(),
1550 }
1551 }
1552}
1553
1554/// A builder providing access to all methods supported on *adclient* resources.
1555/// It is not used directly, but through the [`AdSense`] hub.
1556///
1557/// # Example
1558///
1559/// Instantiate a resource builder
1560///
1561/// ```test_harness,no_run
1562/// extern crate hyper;
1563/// extern crate hyper_rustls;
1564/// extern crate google_adsense1d4 as adsense1d4;
1565///
1566/// # async fn dox() {
1567/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1568///
1569/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1570/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1571/// .with_native_roots()
1572/// .unwrap()
1573/// .https_only()
1574/// .enable_http2()
1575/// .build();
1576///
1577/// let executor = hyper_util::rt::TokioExecutor::new();
1578/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1579/// secret,
1580/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1581/// yup_oauth2::client::CustomHyperClientBuilder::from(
1582/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1583/// ),
1584/// ).build().await.unwrap();
1585///
1586/// let client = hyper_util::client::legacy::Client::builder(
1587/// hyper_util::rt::TokioExecutor::new()
1588/// )
1589/// .build(
1590/// hyper_rustls::HttpsConnectorBuilder::new()
1591/// .with_native_roots()
1592/// .unwrap()
1593/// .https_or_http()
1594/// .enable_http2()
1595/// .build()
1596/// );
1597/// let mut hub = AdSense::new(client, auth);
1598/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1599/// // like `list(...)`
1600/// // to build up your call.
1601/// let rb = hub.adclients();
1602/// # }
1603/// ```
1604pub struct AdclientMethods<'a, C>
1605where
1606 C: 'a,
1607{
1608 hub: &'a AdSense<C>,
1609}
1610
1611impl<'a, C> common::MethodsBuilder for AdclientMethods<'a, C> {}
1612
1613impl<'a, C> AdclientMethods<'a, C> {
1614 /// Create a builder to help you perform the following task:
1615 ///
1616 /// List all ad clients in this AdSense account.
1617 pub fn list(&self) -> AdclientListCall<'a, C> {
1618 AdclientListCall {
1619 hub: self.hub,
1620 _page_token: Default::default(),
1621 _max_results: Default::default(),
1622 _delegate: Default::default(),
1623 _additional_params: Default::default(),
1624 _scopes: Default::default(),
1625 }
1626 }
1627}
1628
1629/// A builder providing access to all methods supported on *adunit* resources.
1630/// It is not used directly, but through the [`AdSense`] hub.
1631///
1632/// # Example
1633///
1634/// Instantiate a resource builder
1635///
1636/// ```test_harness,no_run
1637/// extern crate hyper;
1638/// extern crate hyper_rustls;
1639/// extern crate google_adsense1d4 as adsense1d4;
1640///
1641/// # async fn dox() {
1642/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1643///
1644/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1645/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1646/// .with_native_roots()
1647/// .unwrap()
1648/// .https_only()
1649/// .enable_http2()
1650/// .build();
1651///
1652/// let executor = hyper_util::rt::TokioExecutor::new();
1653/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1654/// secret,
1655/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1656/// yup_oauth2::client::CustomHyperClientBuilder::from(
1657/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1658/// ),
1659/// ).build().await.unwrap();
1660///
1661/// let client = hyper_util::client::legacy::Client::builder(
1662/// hyper_util::rt::TokioExecutor::new()
1663/// )
1664/// .build(
1665/// hyper_rustls::HttpsConnectorBuilder::new()
1666/// .with_native_roots()
1667/// .unwrap()
1668/// .https_or_http()
1669/// .enable_http2()
1670/// .build()
1671/// );
1672/// let mut hub = AdSense::new(client, auth);
1673/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1674/// // like `customchannels_list(...)`, `get(...)`, `get_ad_code(...)` and `list(...)`
1675/// // to build up your call.
1676/// let rb = hub.adunits();
1677/// # }
1678/// ```
1679pub struct AdunitMethods<'a, C>
1680where
1681 C: 'a,
1682{
1683 hub: &'a AdSense<C>,
1684}
1685
1686impl<'a, C> common::MethodsBuilder for AdunitMethods<'a, C> {}
1687
1688impl<'a, C> AdunitMethods<'a, C> {
1689 /// Create a builder to help you perform the following task:
1690 ///
1691 /// List all custom channels which the specified ad unit belongs to.
1692 ///
1693 /// # Arguments
1694 ///
1695 /// * `adClientId` - Ad client which contains the ad unit.
1696 /// * `adUnitId` - Ad unit for which to list custom channels.
1697 pub fn customchannels_list(
1698 &self,
1699 ad_client_id: &str,
1700 ad_unit_id: &str,
1701 ) -> AdunitCustomchannelListCall<'a, C> {
1702 AdunitCustomchannelListCall {
1703 hub: self.hub,
1704 _ad_client_id: ad_client_id.to_string(),
1705 _ad_unit_id: ad_unit_id.to_string(),
1706 _page_token: Default::default(),
1707 _max_results: Default::default(),
1708 _delegate: Default::default(),
1709 _additional_params: Default::default(),
1710 _scopes: Default::default(),
1711 }
1712 }
1713
1714 /// Create a builder to help you perform the following task:
1715 ///
1716 /// Gets the specified ad unit in the specified ad client.
1717 ///
1718 /// # Arguments
1719 ///
1720 /// * `adClientId` - Ad client for which to get the ad unit.
1721 /// * `adUnitId` - Ad unit to retrieve.
1722 pub fn get(&self, ad_client_id: &str, ad_unit_id: &str) -> AdunitGetCall<'a, C> {
1723 AdunitGetCall {
1724 hub: self.hub,
1725 _ad_client_id: ad_client_id.to_string(),
1726 _ad_unit_id: ad_unit_id.to_string(),
1727 _delegate: Default::default(),
1728 _additional_params: Default::default(),
1729 _scopes: Default::default(),
1730 }
1731 }
1732
1733 /// Create a builder to help you perform the following task:
1734 ///
1735 /// Get ad code for the specified ad unit.
1736 ///
1737 /// # Arguments
1738 ///
1739 /// * `adClientId` - Ad client with contains the ad unit.
1740 /// * `adUnitId` - Ad unit to get the code for.
1741 pub fn get_ad_code(&self, ad_client_id: &str, ad_unit_id: &str) -> AdunitGetAdCodeCall<'a, C> {
1742 AdunitGetAdCodeCall {
1743 hub: self.hub,
1744 _ad_client_id: ad_client_id.to_string(),
1745 _ad_unit_id: ad_unit_id.to_string(),
1746 _delegate: Default::default(),
1747 _additional_params: Default::default(),
1748 _scopes: Default::default(),
1749 }
1750 }
1751
1752 /// Create a builder to help you perform the following task:
1753 ///
1754 /// List all ad units in the specified ad client for this AdSense account.
1755 ///
1756 /// # Arguments
1757 ///
1758 /// * `adClientId` - Ad client for which to list ad units.
1759 pub fn list(&self, ad_client_id: &str) -> AdunitListCall<'a, C> {
1760 AdunitListCall {
1761 hub: self.hub,
1762 _ad_client_id: ad_client_id.to_string(),
1763 _page_token: Default::default(),
1764 _max_results: Default::default(),
1765 _include_inactive: Default::default(),
1766 _delegate: Default::default(),
1767 _additional_params: Default::default(),
1768 _scopes: Default::default(),
1769 }
1770 }
1771}
1772
1773/// A builder providing access to all methods supported on *alert* resources.
1774/// It is not used directly, but through the [`AdSense`] hub.
1775///
1776/// # Example
1777///
1778/// Instantiate a resource builder
1779///
1780/// ```test_harness,no_run
1781/// extern crate hyper;
1782/// extern crate hyper_rustls;
1783/// extern crate google_adsense1d4 as adsense1d4;
1784///
1785/// # async fn dox() {
1786/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1787///
1788/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1789/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1790/// .with_native_roots()
1791/// .unwrap()
1792/// .https_only()
1793/// .enable_http2()
1794/// .build();
1795///
1796/// let executor = hyper_util::rt::TokioExecutor::new();
1797/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1798/// secret,
1799/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1800/// yup_oauth2::client::CustomHyperClientBuilder::from(
1801/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1802/// ),
1803/// ).build().await.unwrap();
1804///
1805/// let client = hyper_util::client::legacy::Client::builder(
1806/// hyper_util::rt::TokioExecutor::new()
1807/// )
1808/// .build(
1809/// hyper_rustls::HttpsConnectorBuilder::new()
1810/// .with_native_roots()
1811/// .unwrap()
1812/// .https_or_http()
1813/// .enable_http2()
1814/// .build()
1815/// );
1816/// let mut hub = AdSense::new(client, auth);
1817/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1818/// // like `delete(...)` and `list(...)`
1819/// // to build up your call.
1820/// let rb = hub.alerts();
1821/// # }
1822/// ```
1823pub struct AlertMethods<'a, C>
1824where
1825 C: 'a,
1826{
1827 hub: &'a AdSense<C>,
1828}
1829
1830impl<'a, C> common::MethodsBuilder for AlertMethods<'a, C> {}
1831
1832impl<'a, C> AlertMethods<'a, C> {
1833 /// Create a builder to help you perform the following task:
1834 ///
1835 /// Dismiss (delete) the specified alert from the publisher's AdSense account.
1836 ///
1837 /// # Arguments
1838 ///
1839 /// * `alertId` - Alert to delete.
1840 pub fn delete(&self, alert_id: &str) -> AlertDeleteCall<'a, C> {
1841 AlertDeleteCall {
1842 hub: self.hub,
1843 _alert_id: alert_id.to_string(),
1844 _delegate: Default::default(),
1845 _additional_params: Default::default(),
1846 _scopes: Default::default(),
1847 }
1848 }
1849
1850 /// Create a builder to help you perform the following task:
1851 ///
1852 /// List the alerts for this AdSense account.
1853 pub fn list(&self) -> AlertListCall<'a, C> {
1854 AlertListCall {
1855 hub: self.hub,
1856 _locale: Default::default(),
1857 _delegate: Default::default(),
1858 _additional_params: Default::default(),
1859 _scopes: Default::default(),
1860 }
1861 }
1862}
1863
1864/// A builder providing access to all methods supported on *customchannel* resources.
1865/// It is not used directly, but through the [`AdSense`] hub.
1866///
1867/// # Example
1868///
1869/// Instantiate a resource builder
1870///
1871/// ```test_harness,no_run
1872/// extern crate hyper;
1873/// extern crate hyper_rustls;
1874/// extern crate google_adsense1d4 as adsense1d4;
1875///
1876/// # async fn dox() {
1877/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1878///
1879/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1880/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1881/// .with_native_roots()
1882/// .unwrap()
1883/// .https_only()
1884/// .enable_http2()
1885/// .build();
1886///
1887/// let executor = hyper_util::rt::TokioExecutor::new();
1888/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1889/// secret,
1890/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1891/// yup_oauth2::client::CustomHyperClientBuilder::from(
1892/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1893/// ),
1894/// ).build().await.unwrap();
1895///
1896/// let client = hyper_util::client::legacy::Client::builder(
1897/// hyper_util::rt::TokioExecutor::new()
1898/// )
1899/// .build(
1900/// hyper_rustls::HttpsConnectorBuilder::new()
1901/// .with_native_roots()
1902/// .unwrap()
1903/// .https_or_http()
1904/// .enable_http2()
1905/// .build()
1906/// );
1907/// let mut hub = AdSense::new(client, auth);
1908/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1909/// // like `adunits_list(...)`, `get(...)` and `list(...)`
1910/// // to build up your call.
1911/// let rb = hub.customchannels();
1912/// # }
1913/// ```
1914pub struct CustomchannelMethods<'a, C>
1915where
1916 C: 'a,
1917{
1918 hub: &'a AdSense<C>,
1919}
1920
1921impl<'a, C> common::MethodsBuilder for CustomchannelMethods<'a, C> {}
1922
1923impl<'a, C> CustomchannelMethods<'a, C> {
1924 /// Create a builder to help you perform the following task:
1925 ///
1926 /// List all ad units in the specified custom channel.
1927 ///
1928 /// # Arguments
1929 ///
1930 /// * `adClientId` - Ad client which contains the custom channel.
1931 /// * `customChannelId` - Custom channel for which to list ad units.
1932 pub fn adunits_list(
1933 &self,
1934 ad_client_id: &str,
1935 custom_channel_id: &str,
1936 ) -> CustomchannelAdunitListCall<'a, C> {
1937 CustomchannelAdunitListCall {
1938 hub: self.hub,
1939 _ad_client_id: ad_client_id.to_string(),
1940 _custom_channel_id: custom_channel_id.to_string(),
1941 _page_token: Default::default(),
1942 _max_results: Default::default(),
1943 _include_inactive: Default::default(),
1944 _delegate: Default::default(),
1945 _additional_params: Default::default(),
1946 _scopes: Default::default(),
1947 }
1948 }
1949
1950 /// Create a builder to help you perform the following task:
1951 ///
1952 /// Get the specified custom channel from the specified ad client.
1953 ///
1954 /// # Arguments
1955 ///
1956 /// * `adClientId` - Ad client which contains the custom channel.
1957 /// * `customChannelId` - Custom channel to retrieve.
1958 pub fn get(&self, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelGetCall<'a, C> {
1959 CustomchannelGetCall {
1960 hub: self.hub,
1961 _ad_client_id: ad_client_id.to_string(),
1962 _custom_channel_id: custom_channel_id.to_string(),
1963 _delegate: Default::default(),
1964 _additional_params: Default::default(),
1965 _scopes: Default::default(),
1966 }
1967 }
1968
1969 /// Create a builder to help you perform the following task:
1970 ///
1971 /// List all custom channels in the specified ad client for this AdSense account.
1972 ///
1973 /// # Arguments
1974 ///
1975 /// * `adClientId` - Ad client for which to list custom channels.
1976 pub fn list(&self, ad_client_id: &str) -> CustomchannelListCall<'a, C> {
1977 CustomchannelListCall {
1978 hub: self.hub,
1979 _ad_client_id: ad_client_id.to_string(),
1980 _page_token: Default::default(),
1981 _max_results: Default::default(),
1982 _delegate: Default::default(),
1983 _additional_params: Default::default(),
1984 _scopes: Default::default(),
1985 }
1986 }
1987}
1988
1989/// A builder providing access to all methods supported on *metadata* resources.
1990/// It is not used directly, but through the [`AdSense`] hub.
1991///
1992/// # Example
1993///
1994/// Instantiate a resource builder
1995///
1996/// ```test_harness,no_run
1997/// extern crate hyper;
1998/// extern crate hyper_rustls;
1999/// extern crate google_adsense1d4 as adsense1d4;
2000///
2001/// # async fn dox() {
2002/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2003///
2004/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2005/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2006/// .with_native_roots()
2007/// .unwrap()
2008/// .https_only()
2009/// .enable_http2()
2010/// .build();
2011///
2012/// let executor = hyper_util::rt::TokioExecutor::new();
2013/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2014/// secret,
2015/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2016/// yup_oauth2::client::CustomHyperClientBuilder::from(
2017/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2018/// ),
2019/// ).build().await.unwrap();
2020///
2021/// let client = hyper_util::client::legacy::Client::builder(
2022/// hyper_util::rt::TokioExecutor::new()
2023/// )
2024/// .build(
2025/// hyper_rustls::HttpsConnectorBuilder::new()
2026/// .with_native_roots()
2027/// .unwrap()
2028/// .https_or_http()
2029/// .enable_http2()
2030/// .build()
2031/// );
2032/// let mut hub = AdSense::new(client, auth);
2033/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2034/// // like `dimensions_list(...)` and `metrics_list(...)`
2035/// // to build up your call.
2036/// let rb = hub.metadata();
2037/// # }
2038/// ```
2039pub struct MetadataMethods<'a, C>
2040where
2041 C: 'a,
2042{
2043 hub: &'a AdSense<C>,
2044}
2045
2046impl<'a, C> common::MethodsBuilder for MetadataMethods<'a, C> {}
2047
2048impl<'a, C> MetadataMethods<'a, C> {
2049 /// Create a builder to help you perform the following task:
2050 ///
2051 /// List the metadata for the dimensions available to this AdSense account.
2052 pub fn dimensions_list(&self) -> MetadataDimensionListCall<'a, C> {
2053 MetadataDimensionListCall {
2054 hub: self.hub,
2055 _delegate: Default::default(),
2056 _additional_params: Default::default(),
2057 _scopes: Default::default(),
2058 }
2059 }
2060
2061 /// Create a builder to help you perform the following task:
2062 ///
2063 /// List the metadata for the metrics available to this AdSense account.
2064 pub fn metrics_list(&self) -> MetadataMetricListCall<'a, C> {
2065 MetadataMetricListCall {
2066 hub: self.hub,
2067 _delegate: Default::default(),
2068 _additional_params: Default::default(),
2069 _scopes: Default::default(),
2070 }
2071 }
2072}
2073
2074/// A builder providing access to all methods supported on *payment* resources.
2075/// It is not used directly, but through the [`AdSense`] hub.
2076///
2077/// # Example
2078///
2079/// Instantiate a resource builder
2080///
2081/// ```test_harness,no_run
2082/// extern crate hyper;
2083/// extern crate hyper_rustls;
2084/// extern crate google_adsense1d4 as adsense1d4;
2085///
2086/// # async fn dox() {
2087/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2088///
2089/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2090/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2091/// .with_native_roots()
2092/// .unwrap()
2093/// .https_only()
2094/// .enable_http2()
2095/// .build();
2096///
2097/// let executor = hyper_util::rt::TokioExecutor::new();
2098/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2099/// secret,
2100/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2101/// yup_oauth2::client::CustomHyperClientBuilder::from(
2102/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2103/// ),
2104/// ).build().await.unwrap();
2105///
2106/// let client = hyper_util::client::legacy::Client::builder(
2107/// hyper_util::rt::TokioExecutor::new()
2108/// )
2109/// .build(
2110/// hyper_rustls::HttpsConnectorBuilder::new()
2111/// .with_native_roots()
2112/// .unwrap()
2113/// .https_or_http()
2114/// .enable_http2()
2115/// .build()
2116/// );
2117/// let mut hub = AdSense::new(client, auth);
2118/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2119/// // like `list(...)`
2120/// // to build up your call.
2121/// let rb = hub.payments();
2122/// # }
2123/// ```
2124pub struct PaymentMethods<'a, C>
2125where
2126 C: 'a,
2127{
2128 hub: &'a AdSense<C>,
2129}
2130
2131impl<'a, C> common::MethodsBuilder for PaymentMethods<'a, C> {}
2132
2133impl<'a, C> PaymentMethods<'a, C> {
2134 /// Create a builder to help you perform the following task:
2135 ///
2136 /// List the payments for this AdSense account.
2137 pub fn list(&self) -> PaymentListCall<'a, C> {
2138 PaymentListCall {
2139 hub: self.hub,
2140 _delegate: Default::default(),
2141 _additional_params: Default::default(),
2142 _scopes: Default::default(),
2143 }
2144 }
2145}
2146
2147/// A builder providing access to all methods supported on *report* resources.
2148/// It is not used directly, but through the [`AdSense`] hub.
2149///
2150/// # Example
2151///
2152/// Instantiate a resource builder
2153///
2154/// ```test_harness,no_run
2155/// extern crate hyper;
2156/// extern crate hyper_rustls;
2157/// extern crate google_adsense1d4 as adsense1d4;
2158///
2159/// # async fn dox() {
2160/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2161///
2162/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2163/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2164/// .with_native_roots()
2165/// .unwrap()
2166/// .https_only()
2167/// .enable_http2()
2168/// .build();
2169///
2170/// let executor = hyper_util::rt::TokioExecutor::new();
2171/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2172/// secret,
2173/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2174/// yup_oauth2::client::CustomHyperClientBuilder::from(
2175/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2176/// ),
2177/// ).build().await.unwrap();
2178///
2179/// let client = hyper_util::client::legacy::Client::builder(
2180/// hyper_util::rt::TokioExecutor::new()
2181/// )
2182/// .build(
2183/// hyper_rustls::HttpsConnectorBuilder::new()
2184/// .with_native_roots()
2185/// .unwrap()
2186/// .https_or_http()
2187/// .enable_http2()
2188/// .build()
2189/// );
2190/// let mut hub = AdSense::new(client, auth);
2191/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2192/// // like `generate(...)`, `saved_generate(...)` and `saved_list(...)`
2193/// // to build up your call.
2194/// let rb = hub.reports();
2195/// # }
2196/// ```
2197pub struct ReportMethods<'a, C>
2198where
2199 C: 'a,
2200{
2201 hub: &'a AdSense<C>,
2202}
2203
2204impl<'a, C> common::MethodsBuilder for ReportMethods<'a, C> {}
2205
2206impl<'a, C> ReportMethods<'a, C> {
2207 /// Create a builder to help you perform the following task:
2208 ///
2209 /// Generate an AdSense report based on the saved report ID sent in the query parameters.
2210 ///
2211 /// # Arguments
2212 ///
2213 /// * `savedReportId` - The saved report to retrieve.
2214 pub fn saved_generate(&self, saved_report_id: &str) -> ReportSavedGenerateCall<'a, C> {
2215 ReportSavedGenerateCall {
2216 hub: self.hub,
2217 _saved_report_id: saved_report_id.to_string(),
2218 _start_index: Default::default(),
2219 _max_results: Default::default(),
2220 _locale: Default::default(),
2221 _delegate: Default::default(),
2222 _additional_params: Default::default(),
2223 _scopes: Default::default(),
2224 }
2225 }
2226
2227 /// Create a builder to help you perform the following task:
2228 ///
2229 /// List all saved reports in this AdSense account.
2230 pub fn saved_list(&self) -> ReportSavedListCall<'a, C> {
2231 ReportSavedListCall {
2232 hub: self.hub,
2233 _page_token: Default::default(),
2234 _max_results: Default::default(),
2235 _delegate: Default::default(),
2236 _additional_params: Default::default(),
2237 _scopes: Default::default(),
2238 }
2239 }
2240
2241 /// Create a builder to help you perform the following task:
2242 ///
2243 /// Generate an AdSense 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.
2244 ///
2245 /// # Arguments
2246 ///
2247 /// * `startDate` - Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
2248 /// * `endDate` - End of the date range to report on in "YYYY-MM-DD" format, inclusive.
2249 pub fn generate(&self, start_date: &str, end_date: &str) -> ReportGenerateCall<'a, C> {
2250 ReportGenerateCall {
2251 hub: self.hub,
2252 _start_date: start_date.to_string(),
2253 _end_date: end_date.to_string(),
2254 _use_timezone_reporting: Default::default(),
2255 _start_index: Default::default(),
2256 _sort: Default::default(),
2257 _metric: Default::default(),
2258 _max_results: Default::default(),
2259 _locale: Default::default(),
2260 _filter: Default::default(),
2261 _dimension: Default::default(),
2262 _currency: Default::default(),
2263 _account_id: Default::default(),
2264 _delegate: Default::default(),
2265 _additional_params: Default::default(),
2266 _scopes: Default::default(),
2267 }
2268 }
2269}
2270
2271/// A builder providing access to all methods supported on *savedadstyle* resources.
2272/// It is not used directly, but through the [`AdSense`] hub.
2273///
2274/// # Example
2275///
2276/// Instantiate a resource builder
2277///
2278/// ```test_harness,no_run
2279/// extern crate hyper;
2280/// extern crate hyper_rustls;
2281/// extern crate google_adsense1d4 as adsense1d4;
2282///
2283/// # async fn dox() {
2284/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2285///
2286/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2287/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2288/// .with_native_roots()
2289/// .unwrap()
2290/// .https_only()
2291/// .enable_http2()
2292/// .build();
2293///
2294/// let executor = hyper_util::rt::TokioExecutor::new();
2295/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2296/// secret,
2297/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2298/// yup_oauth2::client::CustomHyperClientBuilder::from(
2299/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2300/// ),
2301/// ).build().await.unwrap();
2302///
2303/// let client = hyper_util::client::legacy::Client::builder(
2304/// hyper_util::rt::TokioExecutor::new()
2305/// )
2306/// .build(
2307/// hyper_rustls::HttpsConnectorBuilder::new()
2308/// .with_native_roots()
2309/// .unwrap()
2310/// .https_or_http()
2311/// .enable_http2()
2312/// .build()
2313/// );
2314/// let mut hub = AdSense::new(client, auth);
2315/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2316/// // like `get(...)` and `list(...)`
2317/// // to build up your call.
2318/// let rb = hub.savedadstyles();
2319/// # }
2320/// ```
2321pub struct SavedadstyleMethods<'a, C>
2322where
2323 C: 'a,
2324{
2325 hub: &'a AdSense<C>,
2326}
2327
2328impl<'a, C> common::MethodsBuilder for SavedadstyleMethods<'a, C> {}
2329
2330impl<'a, C> SavedadstyleMethods<'a, C> {
2331 /// Create a builder to help you perform the following task:
2332 ///
2333 /// Get a specific saved ad style from the user's account.
2334 ///
2335 /// # Arguments
2336 ///
2337 /// * `savedAdStyleId` - Saved ad style to retrieve.
2338 pub fn get(&self, saved_ad_style_id: &str) -> SavedadstyleGetCall<'a, C> {
2339 SavedadstyleGetCall {
2340 hub: self.hub,
2341 _saved_ad_style_id: saved_ad_style_id.to_string(),
2342 _delegate: Default::default(),
2343 _additional_params: Default::default(),
2344 _scopes: Default::default(),
2345 }
2346 }
2347
2348 /// Create a builder to help you perform the following task:
2349 ///
2350 /// List all saved ad styles in the user's account.
2351 pub fn list(&self) -> SavedadstyleListCall<'a, C> {
2352 SavedadstyleListCall {
2353 hub: self.hub,
2354 _page_token: Default::default(),
2355 _max_results: Default::default(),
2356 _delegate: Default::default(),
2357 _additional_params: Default::default(),
2358 _scopes: Default::default(),
2359 }
2360 }
2361}
2362
2363/// A builder providing access to all methods supported on *urlchannel* resources.
2364/// It is not used directly, but through the [`AdSense`] hub.
2365///
2366/// # Example
2367///
2368/// Instantiate a resource builder
2369///
2370/// ```test_harness,no_run
2371/// extern crate hyper;
2372/// extern crate hyper_rustls;
2373/// extern crate google_adsense1d4 as adsense1d4;
2374///
2375/// # async fn dox() {
2376/// use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2377///
2378/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2379/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2380/// .with_native_roots()
2381/// .unwrap()
2382/// .https_only()
2383/// .enable_http2()
2384/// .build();
2385///
2386/// let executor = hyper_util::rt::TokioExecutor::new();
2387/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2388/// secret,
2389/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2390/// yup_oauth2::client::CustomHyperClientBuilder::from(
2391/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2392/// ),
2393/// ).build().await.unwrap();
2394///
2395/// let client = hyper_util::client::legacy::Client::builder(
2396/// hyper_util::rt::TokioExecutor::new()
2397/// )
2398/// .build(
2399/// hyper_rustls::HttpsConnectorBuilder::new()
2400/// .with_native_roots()
2401/// .unwrap()
2402/// .https_or_http()
2403/// .enable_http2()
2404/// .build()
2405/// );
2406/// let mut hub = AdSense::new(client, auth);
2407/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2408/// // like `list(...)`
2409/// // to build up your call.
2410/// let rb = hub.urlchannels();
2411/// # }
2412/// ```
2413pub struct UrlchannelMethods<'a, C>
2414where
2415 C: 'a,
2416{
2417 hub: &'a AdSense<C>,
2418}
2419
2420impl<'a, C> common::MethodsBuilder for UrlchannelMethods<'a, C> {}
2421
2422impl<'a, C> UrlchannelMethods<'a, C> {
2423 /// Create a builder to help you perform the following task:
2424 ///
2425 /// List all URL channels in the specified ad client for this AdSense account.
2426 ///
2427 /// # Arguments
2428 ///
2429 /// * `adClientId` - Ad client for which to list URL channels.
2430 pub fn list(&self, ad_client_id: &str) -> UrlchannelListCall<'a, C> {
2431 UrlchannelListCall {
2432 hub: self.hub,
2433 _ad_client_id: ad_client_id.to_string(),
2434 _page_token: Default::default(),
2435 _max_results: Default::default(),
2436 _delegate: Default::default(),
2437 _additional_params: Default::default(),
2438 _scopes: Default::default(),
2439 }
2440 }
2441}
2442
2443// ###################
2444// CallBuilders ###
2445// #################
2446
2447/// Get Auto ad code for a given ad client.
2448///
2449/// A builder for the *adclients.getAdCode* method supported by a *account* resource.
2450/// It is not used directly, but through a [`AccountMethods`] instance.
2451///
2452/// # Example
2453///
2454/// Instantiate a resource method builder
2455///
2456/// ```test_harness,no_run
2457/// # extern crate hyper;
2458/// # extern crate hyper_rustls;
2459/// # extern crate google_adsense1d4 as adsense1d4;
2460/// # async fn dox() {
2461/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2462///
2463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2465/// # .with_native_roots()
2466/// # .unwrap()
2467/// # .https_only()
2468/// # .enable_http2()
2469/// # .build();
2470///
2471/// # let executor = hyper_util::rt::TokioExecutor::new();
2472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2473/// # secret,
2474/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2475/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2476/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2477/// # ),
2478/// # ).build().await.unwrap();
2479///
2480/// # let client = hyper_util::client::legacy::Client::builder(
2481/// # hyper_util::rt::TokioExecutor::new()
2482/// # )
2483/// # .build(
2484/// # hyper_rustls::HttpsConnectorBuilder::new()
2485/// # .with_native_roots()
2486/// # .unwrap()
2487/// # .https_or_http()
2488/// # .enable_http2()
2489/// # .build()
2490/// # );
2491/// # let mut hub = AdSense::new(client, auth);
2492/// // You can configure optional parameters by calling the respective setters at will, and
2493/// // execute the final call using `doit()`.
2494/// // Values shown here are possibly random and not representative !
2495/// let result = hub.accounts().adclients_get_ad_code("accountId", "adClientId")
2496/// .tag_partner("duo")
2497/// .doit().await;
2498/// # }
2499/// ```
2500pub struct AccountAdclientGetAdCodeCall<'a, C>
2501where
2502 C: 'a,
2503{
2504 hub: &'a AdSense<C>,
2505 _account_id: String,
2506 _ad_client_id: String,
2507 _tag_partner: Option<String>,
2508 _delegate: Option<&'a mut dyn common::Delegate>,
2509 _additional_params: HashMap<String, String>,
2510 _scopes: BTreeSet<String>,
2511}
2512
2513impl<'a, C> common::CallBuilder for AccountAdclientGetAdCodeCall<'a, C> {}
2514
2515impl<'a, C> AccountAdclientGetAdCodeCall<'a, C>
2516where
2517 C: common::Connector,
2518{
2519 /// Perform the operation you have build so far.
2520 pub async fn doit(mut self) -> common::Result<(common::Response, AdCode)> {
2521 use std::borrow::Cow;
2522 use std::io::{Read, Seek};
2523
2524 use common::{url::Params, ToParts};
2525 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2526
2527 let mut dd = common::DefaultDelegate;
2528 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2529 dlg.begin(common::MethodInfo {
2530 id: "adsense.accounts.adclients.getAdCode",
2531 http_method: hyper::Method::GET,
2532 });
2533
2534 for &field in ["alt", "accountId", "adClientId", "tagPartner"].iter() {
2535 if self._additional_params.contains_key(field) {
2536 dlg.finished(false);
2537 return Err(common::Error::FieldClash(field));
2538 }
2539 }
2540
2541 let mut params = Params::with_capacity(5 + self._additional_params.len());
2542 params.push("accountId", self._account_id);
2543 params.push("adClientId", self._ad_client_id);
2544 if let Some(value) = self._tag_partner.as_ref() {
2545 params.push("tagPartner", value);
2546 }
2547
2548 params.extend(self._additional_params.iter());
2549
2550 params.push("alt", "json");
2551 let mut url =
2552 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adcode";
2553 if self._scopes.is_empty() {
2554 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2555 }
2556
2557 #[allow(clippy::single_element_loop)]
2558 for &(find_this, param_name) in
2559 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
2560 {
2561 url = params.uri_replacement(url, param_name, find_this, false);
2562 }
2563 {
2564 let to_remove = ["adClientId", "accountId"];
2565 params.remove_params(&to_remove);
2566 }
2567
2568 let url = params.parse_with_url(&url);
2569
2570 loop {
2571 let token = match self
2572 .hub
2573 .auth
2574 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2575 .await
2576 {
2577 Ok(token) => token,
2578 Err(e) => match dlg.token(e) {
2579 Ok(token) => token,
2580 Err(e) => {
2581 dlg.finished(false);
2582 return Err(common::Error::MissingToken(e));
2583 }
2584 },
2585 };
2586 let mut req_result = {
2587 let client = &self.hub.client;
2588 dlg.pre_request();
2589 let mut req_builder = hyper::Request::builder()
2590 .method(hyper::Method::GET)
2591 .uri(url.as_str())
2592 .header(USER_AGENT, self.hub._user_agent.clone());
2593
2594 if let Some(token) = token.as_ref() {
2595 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2596 }
2597
2598 let request = req_builder
2599 .header(CONTENT_LENGTH, 0_u64)
2600 .body(common::to_body::<String>(None));
2601
2602 client.request(request.unwrap()).await
2603 };
2604
2605 match req_result {
2606 Err(err) => {
2607 if let common::Retry::After(d) = dlg.http_error(&err) {
2608 sleep(d).await;
2609 continue;
2610 }
2611 dlg.finished(false);
2612 return Err(common::Error::HttpError(err));
2613 }
2614 Ok(res) => {
2615 let (mut parts, body) = res.into_parts();
2616 let mut body = common::Body::new(body);
2617 if !parts.status.is_success() {
2618 let bytes = common::to_bytes(body).await.unwrap_or_default();
2619 let error = serde_json::from_str(&common::to_string(&bytes));
2620 let response = common::to_response(parts, bytes.into());
2621
2622 if let common::Retry::After(d) =
2623 dlg.http_failure(&response, error.as_ref().ok())
2624 {
2625 sleep(d).await;
2626 continue;
2627 }
2628
2629 dlg.finished(false);
2630
2631 return Err(match error {
2632 Ok(value) => common::Error::BadRequest(value),
2633 _ => common::Error::Failure(response),
2634 });
2635 }
2636 let response = {
2637 let bytes = common::to_bytes(body).await.unwrap_or_default();
2638 let encoded = common::to_string(&bytes);
2639 match serde_json::from_str(&encoded) {
2640 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2641 Err(error) => {
2642 dlg.response_json_decode_error(&encoded, &error);
2643 return Err(common::Error::JsonDecodeError(
2644 encoded.to_string(),
2645 error,
2646 ));
2647 }
2648 }
2649 };
2650
2651 dlg.finished(true);
2652 return Ok(response);
2653 }
2654 }
2655 }
2656 }
2657
2658 /// Account which contains the ad client.
2659 ///
2660 /// Sets the *account id* path property to the given value.
2661 ///
2662 /// Even though the property as already been set when instantiating this call,
2663 /// we provide this method for API completeness.
2664 pub fn account_id(mut self, new_value: &str) -> AccountAdclientGetAdCodeCall<'a, C> {
2665 self._account_id = new_value.to_string();
2666 self
2667 }
2668 /// Ad client to get the code for.
2669 ///
2670 /// Sets the *ad client id* path property to the given value.
2671 ///
2672 /// Even though the property as already been set when instantiating this call,
2673 /// we provide this method for API completeness.
2674 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdclientGetAdCodeCall<'a, C> {
2675 self._ad_client_id = new_value.to_string();
2676 self
2677 }
2678 /// Tag partner to include in the ad code snippet.
2679 ///
2680 /// Sets the *tag partner* query property to the given value.
2681 pub fn tag_partner(mut self, new_value: &str) -> AccountAdclientGetAdCodeCall<'a, C> {
2682 self._tag_partner = Some(new_value.to_string());
2683 self
2684 }
2685 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2686 /// while executing the actual API request.
2687 ///
2688 /// ````text
2689 /// It should be used to handle progress information, and to implement a certain level of resilience.
2690 /// ````
2691 ///
2692 /// Sets the *delegate* property to the given value.
2693 pub fn delegate(
2694 mut self,
2695 new_value: &'a mut dyn common::Delegate,
2696 ) -> AccountAdclientGetAdCodeCall<'a, C> {
2697 self._delegate = Some(new_value);
2698 self
2699 }
2700
2701 /// Set any additional parameter of the query string used in the request.
2702 /// It should be used to set parameters which are not yet available through their own
2703 /// setters.
2704 ///
2705 /// Please note that this method must not be used to set any of the known parameters
2706 /// which have their own setter method. If done anyway, the request will fail.
2707 ///
2708 /// # Additional Parameters
2709 ///
2710 /// * *alt* (query-string) - Data format for the response.
2711 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2712 /// * *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.
2713 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2714 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2715 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2716 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2717 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetAdCodeCall<'a, C>
2718 where
2719 T: AsRef<str>,
2720 {
2721 self._additional_params
2722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2723 self
2724 }
2725
2726 /// Identifies the authorization scope for the method you are building.
2727 ///
2728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2729 /// [`Scope::Readonly`].
2730 ///
2731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2732 /// tokens for more than one scope.
2733 ///
2734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2736 /// sufficient, a read-write scope will do as well.
2737 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetAdCodeCall<'a, C>
2738 where
2739 St: AsRef<str>,
2740 {
2741 self._scopes.insert(String::from(scope.as_ref()));
2742 self
2743 }
2744 /// Identifies the authorization scope(s) for the method you are building.
2745 ///
2746 /// See [`Self::add_scope()`] for details.
2747 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetAdCodeCall<'a, C>
2748 where
2749 I: IntoIterator<Item = St>,
2750 St: AsRef<str>,
2751 {
2752 self._scopes
2753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2754 self
2755 }
2756
2757 /// Removes all scopes, and no default scope will be used either.
2758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2759 /// for details).
2760 pub fn clear_scopes(mut self) -> AccountAdclientGetAdCodeCall<'a, C> {
2761 self._scopes.clear();
2762 self
2763 }
2764}
2765
2766/// List all ad clients in the specified account.
2767///
2768/// A builder for the *adclients.list* method supported by a *account* resource.
2769/// It is not used directly, but through a [`AccountMethods`] instance.
2770///
2771/// # Example
2772///
2773/// Instantiate a resource method builder
2774///
2775/// ```test_harness,no_run
2776/// # extern crate hyper;
2777/// # extern crate hyper_rustls;
2778/// # extern crate google_adsense1d4 as adsense1d4;
2779/// # async fn dox() {
2780/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2781///
2782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2783/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2784/// # .with_native_roots()
2785/// # .unwrap()
2786/// # .https_only()
2787/// # .enable_http2()
2788/// # .build();
2789///
2790/// # let executor = hyper_util::rt::TokioExecutor::new();
2791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2792/// # secret,
2793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2794/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2795/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2796/// # ),
2797/// # ).build().await.unwrap();
2798///
2799/// # let client = hyper_util::client::legacy::Client::builder(
2800/// # hyper_util::rt::TokioExecutor::new()
2801/// # )
2802/// # .build(
2803/// # hyper_rustls::HttpsConnectorBuilder::new()
2804/// # .with_native_roots()
2805/// # .unwrap()
2806/// # .https_or_http()
2807/// # .enable_http2()
2808/// # .build()
2809/// # );
2810/// # let mut hub = AdSense::new(client, auth);
2811/// // You can configure optional parameters by calling the respective setters at will, and
2812/// // execute the final call using `doit()`.
2813/// // Values shown here are possibly random and not representative !
2814/// let result = hub.accounts().adclients_list("accountId")
2815/// .page_token("no")
2816/// .max_results(-15)
2817/// .doit().await;
2818/// # }
2819/// ```
2820pub struct AccountAdclientListCall<'a, C>
2821where
2822 C: 'a,
2823{
2824 hub: &'a AdSense<C>,
2825 _account_id: String,
2826 _page_token: Option<String>,
2827 _max_results: Option<i32>,
2828 _delegate: Option<&'a mut dyn common::Delegate>,
2829 _additional_params: HashMap<String, String>,
2830 _scopes: BTreeSet<String>,
2831}
2832
2833impl<'a, C> common::CallBuilder for AccountAdclientListCall<'a, C> {}
2834
2835impl<'a, C> AccountAdclientListCall<'a, C>
2836where
2837 C: common::Connector,
2838{
2839 /// Perform the operation you have build so far.
2840 pub async fn doit(mut self) -> common::Result<(common::Response, AdClients)> {
2841 use std::borrow::Cow;
2842 use std::io::{Read, Seek};
2843
2844 use common::{url::Params, ToParts};
2845 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2846
2847 let mut dd = common::DefaultDelegate;
2848 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2849 dlg.begin(common::MethodInfo {
2850 id: "adsense.accounts.adclients.list",
2851 http_method: hyper::Method::GET,
2852 });
2853
2854 for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
2855 if self._additional_params.contains_key(field) {
2856 dlg.finished(false);
2857 return Err(common::Error::FieldClash(field));
2858 }
2859 }
2860
2861 let mut params = Params::with_capacity(5 + self._additional_params.len());
2862 params.push("accountId", self._account_id);
2863 if let Some(value) = self._page_token.as_ref() {
2864 params.push("pageToken", value);
2865 }
2866 if let Some(value) = self._max_results.as_ref() {
2867 params.push("maxResults", value.to_string());
2868 }
2869
2870 params.extend(self._additional_params.iter());
2871
2872 params.push("alt", "json");
2873 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/adclients";
2874 if self._scopes.is_empty() {
2875 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2876 }
2877
2878 #[allow(clippy::single_element_loop)]
2879 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
2880 url = params.uri_replacement(url, param_name, find_this, false);
2881 }
2882 {
2883 let to_remove = ["accountId"];
2884 params.remove_params(&to_remove);
2885 }
2886
2887 let url = params.parse_with_url(&url);
2888
2889 loop {
2890 let token = match self
2891 .hub
2892 .auth
2893 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2894 .await
2895 {
2896 Ok(token) => token,
2897 Err(e) => match dlg.token(e) {
2898 Ok(token) => token,
2899 Err(e) => {
2900 dlg.finished(false);
2901 return Err(common::Error::MissingToken(e));
2902 }
2903 },
2904 };
2905 let mut req_result = {
2906 let client = &self.hub.client;
2907 dlg.pre_request();
2908 let mut req_builder = hyper::Request::builder()
2909 .method(hyper::Method::GET)
2910 .uri(url.as_str())
2911 .header(USER_AGENT, self.hub._user_agent.clone());
2912
2913 if let Some(token) = token.as_ref() {
2914 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2915 }
2916
2917 let request = req_builder
2918 .header(CONTENT_LENGTH, 0_u64)
2919 .body(common::to_body::<String>(None));
2920
2921 client.request(request.unwrap()).await
2922 };
2923
2924 match req_result {
2925 Err(err) => {
2926 if let common::Retry::After(d) = dlg.http_error(&err) {
2927 sleep(d).await;
2928 continue;
2929 }
2930 dlg.finished(false);
2931 return Err(common::Error::HttpError(err));
2932 }
2933 Ok(res) => {
2934 let (mut parts, body) = res.into_parts();
2935 let mut body = common::Body::new(body);
2936 if !parts.status.is_success() {
2937 let bytes = common::to_bytes(body).await.unwrap_or_default();
2938 let error = serde_json::from_str(&common::to_string(&bytes));
2939 let response = common::to_response(parts, bytes.into());
2940
2941 if let common::Retry::After(d) =
2942 dlg.http_failure(&response, error.as_ref().ok())
2943 {
2944 sleep(d).await;
2945 continue;
2946 }
2947
2948 dlg.finished(false);
2949
2950 return Err(match error {
2951 Ok(value) => common::Error::BadRequest(value),
2952 _ => common::Error::Failure(response),
2953 });
2954 }
2955 let response = {
2956 let bytes = common::to_bytes(body).await.unwrap_or_default();
2957 let encoded = common::to_string(&bytes);
2958 match serde_json::from_str(&encoded) {
2959 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2960 Err(error) => {
2961 dlg.response_json_decode_error(&encoded, &error);
2962 return Err(common::Error::JsonDecodeError(
2963 encoded.to_string(),
2964 error,
2965 ));
2966 }
2967 }
2968 };
2969
2970 dlg.finished(true);
2971 return Ok(response);
2972 }
2973 }
2974 }
2975 }
2976
2977 /// Account for which to list ad clients.
2978 ///
2979 /// Sets the *account id* path property to the given value.
2980 ///
2981 /// Even though the property as already been set when instantiating this call,
2982 /// we provide this method for API completeness.
2983 pub fn account_id(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
2984 self._account_id = new_value.to_string();
2985 self
2986 }
2987 /// 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.
2988 ///
2989 /// Sets the *page token* query property to the given value.
2990 pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
2991 self._page_token = Some(new_value.to_string());
2992 self
2993 }
2994 /// The maximum number of ad clients to include in the response, used for paging.
2995 ///
2996 /// Sets the *max results* query property to the given value.
2997 pub fn max_results(mut self, new_value: i32) -> AccountAdclientListCall<'a, C> {
2998 self._max_results = Some(new_value);
2999 self
3000 }
3001 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3002 /// while executing the actual API request.
3003 ///
3004 /// ````text
3005 /// It should be used to handle progress information, and to implement a certain level of resilience.
3006 /// ````
3007 ///
3008 /// Sets the *delegate* property to the given value.
3009 pub fn delegate(
3010 mut self,
3011 new_value: &'a mut dyn common::Delegate,
3012 ) -> AccountAdclientListCall<'a, C> {
3013 self._delegate = Some(new_value);
3014 self
3015 }
3016
3017 /// Set any additional parameter of the query string used in the request.
3018 /// It should be used to set parameters which are not yet available through their own
3019 /// setters.
3020 ///
3021 /// Please note that this method must not be used to set any of the known parameters
3022 /// which have their own setter method. If done anyway, the request will fail.
3023 ///
3024 /// # Additional Parameters
3025 ///
3026 /// * *alt* (query-string) - Data format for the response.
3027 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3028 /// * *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.
3029 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3030 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3031 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3032 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3033 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientListCall<'a, C>
3034 where
3035 T: AsRef<str>,
3036 {
3037 self._additional_params
3038 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3039 self
3040 }
3041
3042 /// Identifies the authorization scope for the method you are building.
3043 ///
3044 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3045 /// [`Scope::Readonly`].
3046 ///
3047 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3048 /// tokens for more than one scope.
3049 ///
3050 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3051 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3052 /// sufficient, a read-write scope will do as well.
3053 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientListCall<'a, C>
3054 where
3055 St: AsRef<str>,
3056 {
3057 self._scopes.insert(String::from(scope.as_ref()));
3058 self
3059 }
3060 /// Identifies the authorization scope(s) for the method you are building.
3061 ///
3062 /// See [`Self::add_scope()`] for details.
3063 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientListCall<'a, C>
3064 where
3065 I: IntoIterator<Item = St>,
3066 St: AsRef<str>,
3067 {
3068 self._scopes
3069 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3070 self
3071 }
3072
3073 /// Removes all scopes, and no default scope will be used either.
3074 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3075 /// for details).
3076 pub fn clear_scopes(mut self) -> AccountAdclientListCall<'a, C> {
3077 self._scopes.clear();
3078 self
3079 }
3080}
3081
3082/// List all custom channels which the specified ad unit belongs to.
3083///
3084/// A builder for the *adunits.customchannels.list* method supported by a *account* resource.
3085/// It is not used directly, but through a [`AccountMethods`] instance.
3086///
3087/// # Example
3088///
3089/// Instantiate a resource method builder
3090///
3091/// ```test_harness,no_run
3092/// # extern crate hyper;
3093/// # extern crate hyper_rustls;
3094/// # extern crate google_adsense1d4 as adsense1d4;
3095/// # async fn dox() {
3096/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3097///
3098/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3099/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3100/// # .with_native_roots()
3101/// # .unwrap()
3102/// # .https_only()
3103/// # .enable_http2()
3104/// # .build();
3105///
3106/// # let executor = hyper_util::rt::TokioExecutor::new();
3107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3108/// # secret,
3109/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3110/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3111/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3112/// # ),
3113/// # ).build().await.unwrap();
3114///
3115/// # let client = hyper_util::client::legacy::Client::builder(
3116/// # hyper_util::rt::TokioExecutor::new()
3117/// # )
3118/// # .build(
3119/// # hyper_rustls::HttpsConnectorBuilder::new()
3120/// # .with_native_roots()
3121/// # .unwrap()
3122/// # .https_or_http()
3123/// # .enable_http2()
3124/// # .build()
3125/// # );
3126/// # let mut hub = AdSense::new(client, auth);
3127/// // You can configure optional parameters by calling the respective setters at will, and
3128/// // execute the final call using `doit()`.
3129/// // Values shown here are possibly random and not representative !
3130/// let result = hub.accounts().adunits_customchannels_list("accountId", "adClientId", "adUnitId")
3131/// .page_token("et")
3132/// .max_results(-68)
3133/// .doit().await;
3134/// # }
3135/// ```
3136pub struct AccountAdunitCustomchannelListCall<'a, C>
3137where
3138 C: 'a,
3139{
3140 hub: &'a AdSense<C>,
3141 _account_id: String,
3142 _ad_client_id: String,
3143 _ad_unit_id: String,
3144 _page_token: Option<String>,
3145 _max_results: Option<i32>,
3146 _delegate: Option<&'a mut dyn common::Delegate>,
3147 _additional_params: HashMap<String, String>,
3148 _scopes: BTreeSet<String>,
3149}
3150
3151impl<'a, C> common::CallBuilder for AccountAdunitCustomchannelListCall<'a, C> {}
3152
3153impl<'a, C> AccountAdunitCustomchannelListCall<'a, C>
3154where
3155 C: common::Connector,
3156{
3157 /// Perform the operation you have build so far.
3158 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
3159 use std::borrow::Cow;
3160 use std::io::{Read, Seek};
3161
3162 use common::{url::Params, ToParts};
3163 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3164
3165 let mut dd = common::DefaultDelegate;
3166 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3167 dlg.begin(common::MethodInfo {
3168 id: "adsense.accounts.adunits.customchannels.list",
3169 http_method: hyper::Method::GET,
3170 });
3171
3172 for &field in [
3173 "alt",
3174 "accountId",
3175 "adClientId",
3176 "adUnitId",
3177 "pageToken",
3178 "maxResults",
3179 ]
3180 .iter()
3181 {
3182 if self._additional_params.contains_key(field) {
3183 dlg.finished(false);
3184 return Err(common::Error::FieldClash(field));
3185 }
3186 }
3187
3188 let mut params = Params::with_capacity(7 + self._additional_params.len());
3189 params.push("accountId", self._account_id);
3190 params.push("adClientId", self._ad_client_id);
3191 params.push("adUnitId", self._ad_unit_id);
3192 if let Some(value) = self._page_token.as_ref() {
3193 params.push("pageToken", value);
3194 }
3195 if let Some(value) = self._max_results.as_ref() {
3196 params.push("maxResults", value.to_string());
3197 }
3198
3199 params.extend(self._additional_params.iter());
3200
3201 params.push("alt", "json");
3202 let mut url = self.hub._base_url.clone()
3203 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}/customchannels";
3204 if self._scopes.is_empty() {
3205 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3206 }
3207
3208 #[allow(clippy::single_element_loop)]
3209 for &(find_this, param_name) in [
3210 ("{accountId}", "accountId"),
3211 ("{adClientId}", "adClientId"),
3212 ("{adUnitId}", "adUnitId"),
3213 ]
3214 .iter()
3215 {
3216 url = params.uri_replacement(url, param_name, find_this, false);
3217 }
3218 {
3219 let to_remove = ["adUnitId", "adClientId", "accountId"];
3220 params.remove_params(&to_remove);
3221 }
3222
3223 let url = params.parse_with_url(&url);
3224
3225 loop {
3226 let token = match self
3227 .hub
3228 .auth
3229 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3230 .await
3231 {
3232 Ok(token) => token,
3233 Err(e) => match dlg.token(e) {
3234 Ok(token) => token,
3235 Err(e) => {
3236 dlg.finished(false);
3237 return Err(common::Error::MissingToken(e));
3238 }
3239 },
3240 };
3241 let mut req_result = {
3242 let client = &self.hub.client;
3243 dlg.pre_request();
3244 let mut req_builder = hyper::Request::builder()
3245 .method(hyper::Method::GET)
3246 .uri(url.as_str())
3247 .header(USER_AGENT, self.hub._user_agent.clone());
3248
3249 if let Some(token) = token.as_ref() {
3250 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3251 }
3252
3253 let request = req_builder
3254 .header(CONTENT_LENGTH, 0_u64)
3255 .body(common::to_body::<String>(None));
3256
3257 client.request(request.unwrap()).await
3258 };
3259
3260 match req_result {
3261 Err(err) => {
3262 if let common::Retry::After(d) = dlg.http_error(&err) {
3263 sleep(d).await;
3264 continue;
3265 }
3266 dlg.finished(false);
3267 return Err(common::Error::HttpError(err));
3268 }
3269 Ok(res) => {
3270 let (mut parts, body) = res.into_parts();
3271 let mut body = common::Body::new(body);
3272 if !parts.status.is_success() {
3273 let bytes = common::to_bytes(body).await.unwrap_or_default();
3274 let error = serde_json::from_str(&common::to_string(&bytes));
3275 let response = common::to_response(parts, bytes.into());
3276
3277 if let common::Retry::After(d) =
3278 dlg.http_failure(&response, error.as_ref().ok())
3279 {
3280 sleep(d).await;
3281 continue;
3282 }
3283
3284 dlg.finished(false);
3285
3286 return Err(match error {
3287 Ok(value) => common::Error::BadRequest(value),
3288 _ => common::Error::Failure(response),
3289 });
3290 }
3291 let response = {
3292 let bytes = common::to_bytes(body).await.unwrap_or_default();
3293 let encoded = common::to_string(&bytes);
3294 match serde_json::from_str(&encoded) {
3295 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3296 Err(error) => {
3297 dlg.response_json_decode_error(&encoded, &error);
3298 return Err(common::Error::JsonDecodeError(
3299 encoded.to_string(),
3300 error,
3301 ));
3302 }
3303 }
3304 };
3305
3306 dlg.finished(true);
3307 return Ok(response);
3308 }
3309 }
3310 }
3311 }
3312
3313 /// Account to which the ad client belongs.
3314 ///
3315 /// Sets the *account id* path property to the given value.
3316 ///
3317 /// Even though the property as already been set when instantiating this call,
3318 /// we provide this method for API completeness.
3319 pub fn account_id(mut self, new_value: &str) -> AccountAdunitCustomchannelListCall<'a, C> {
3320 self._account_id = new_value.to_string();
3321 self
3322 }
3323 /// Ad client which contains the ad unit.
3324 ///
3325 /// Sets the *ad client id* path property to the given value.
3326 ///
3327 /// Even though the property as already been set when instantiating this call,
3328 /// we provide this method for API completeness.
3329 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitCustomchannelListCall<'a, C> {
3330 self._ad_client_id = new_value.to_string();
3331 self
3332 }
3333 /// Ad unit for which to list custom channels.
3334 ///
3335 /// Sets the *ad unit id* path property to the given value.
3336 ///
3337 /// Even though the property as already been set when instantiating this call,
3338 /// we provide this method for API completeness.
3339 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitCustomchannelListCall<'a, C> {
3340 self._ad_unit_id = new_value.to_string();
3341 self
3342 }
3343 /// 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.
3344 ///
3345 /// Sets the *page token* query property to the given value.
3346 pub fn page_token(mut self, new_value: &str) -> AccountAdunitCustomchannelListCall<'a, C> {
3347 self._page_token = Some(new_value.to_string());
3348 self
3349 }
3350 /// The maximum number of custom channels to include in the response, used for paging.
3351 ///
3352 /// Sets the *max results* query property to the given value.
3353 pub fn max_results(mut self, new_value: i32) -> AccountAdunitCustomchannelListCall<'a, C> {
3354 self._max_results = Some(new_value);
3355 self
3356 }
3357 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3358 /// while executing the actual API request.
3359 ///
3360 /// ````text
3361 /// It should be used to handle progress information, and to implement a certain level of resilience.
3362 /// ````
3363 ///
3364 /// Sets the *delegate* property to the given value.
3365 pub fn delegate(
3366 mut self,
3367 new_value: &'a mut dyn common::Delegate,
3368 ) -> AccountAdunitCustomchannelListCall<'a, C> {
3369 self._delegate = Some(new_value);
3370 self
3371 }
3372
3373 /// Set any additional parameter of the query string used in the request.
3374 /// It should be used to set parameters which are not yet available through their own
3375 /// setters.
3376 ///
3377 /// Please note that this method must not be used to set any of the known parameters
3378 /// which have their own setter method. If done anyway, the request will fail.
3379 ///
3380 /// # Additional Parameters
3381 ///
3382 /// * *alt* (query-string) - Data format for the response.
3383 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3384 /// * *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.
3385 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3386 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3387 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3388 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3389 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitCustomchannelListCall<'a, C>
3390 where
3391 T: AsRef<str>,
3392 {
3393 self._additional_params
3394 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3395 self
3396 }
3397
3398 /// Identifies the authorization scope for the method you are building.
3399 ///
3400 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3401 /// [`Scope::Readonly`].
3402 ///
3403 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3404 /// tokens for more than one scope.
3405 ///
3406 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3407 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3408 /// sufficient, a read-write scope will do as well.
3409 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitCustomchannelListCall<'a, C>
3410 where
3411 St: AsRef<str>,
3412 {
3413 self._scopes.insert(String::from(scope.as_ref()));
3414 self
3415 }
3416 /// Identifies the authorization scope(s) for the method you are building.
3417 ///
3418 /// See [`Self::add_scope()`] for details.
3419 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitCustomchannelListCall<'a, C>
3420 where
3421 I: IntoIterator<Item = St>,
3422 St: AsRef<str>,
3423 {
3424 self._scopes
3425 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3426 self
3427 }
3428
3429 /// Removes all scopes, and no default scope will be used either.
3430 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3431 /// for details).
3432 pub fn clear_scopes(mut self) -> AccountAdunitCustomchannelListCall<'a, C> {
3433 self._scopes.clear();
3434 self
3435 }
3436}
3437
3438/// Gets the specified ad unit in the specified ad client for the specified account.
3439///
3440/// A builder for the *adunits.get* method supported by a *account* resource.
3441/// It is not used directly, but through a [`AccountMethods`] instance.
3442///
3443/// # Example
3444///
3445/// Instantiate a resource method builder
3446///
3447/// ```test_harness,no_run
3448/// # extern crate hyper;
3449/// # extern crate hyper_rustls;
3450/// # extern crate google_adsense1d4 as adsense1d4;
3451/// # async fn dox() {
3452/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3453///
3454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3455/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3456/// # .with_native_roots()
3457/// # .unwrap()
3458/// # .https_only()
3459/// # .enable_http2()
3460/// # .build();
3461///
3462/// # let executor = hyper_util::rt::TokioExecutor::new();
3463/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3464/// # secret,
3465/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3466/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3467/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3468/// # ),
3469/// # ).build().await.unwrap();
3470///
3471/// # let client = hyper_util::client::legacy::Client::builder(
3472/// # hyper_util::rt::TokioExecutor::new()
3473/// # )
3474/// # .build(
3475/// # hyper_rustls::HttpsConnectorBuilder::new()
3476/// # .with_native_roots()
3477/// # .unwrap()
3478/// # .https_or_http()
3479/// # .enable_http2()
3480/// # .build()
3481/// # );
3482/// # let mut hub = AdSense::new(client, auth);
3483/// // You can configure optional parameters by calling the respective setters at will, and
3484/// // execute the final call using `doit()`.
3485/// // Values shown here are possibly random and not representative !
3486/// let result = hub.accounts().adunits_get("accountId", "adClientId", "adUnitId")
3487/// .doit().await;
3488/// # }
3489/// ```
3490pub struct AccountAdunitGetCall<'a, C>
3491where
3492 C: 'a,
3493{
3494 hub: &'a AdSense<C>,
3495 _account_id: String,
3496 _ad_client_id: String,
3497 _ad_unit_id: String,
3498 _delegate: Option<&'a mut dyn common::Delegate>,
3499 _additional_params: HashMap<String, String>,
3500 _scopes: BTreeSet<String>,
3501}
3502
3503impl<'a, C> common::CallBuilder for AccountAdunitGetCall<'a, C> {}
3504
3505impl<'a, C> AccountAdunitGetCall<'a, C>
3506where
3507 C: common::Connector,
3508{
3509 /// Perform the operation you have build so far.
3510 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
3511 use std::borrow::Cow;
3512 use std::io::{Read, Seek};
3513
3514 use common::{url::Params, ToParts};
3515 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3516
3517 let mut dd = common::DefaultDelegate;
3518 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3519 dlg.begin(common::MethodInfo {
3520 id: "adsense.accounts.adunits.get",
3521 http_method: hyper::Method::GET,
3522 });
3523
3524 for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
3525 if self._additional_params.contains_key(field) {
3526 dlg.finished(false);
3527 return Err(common::Error::FieldClash(field));
3528 }
3529 }
3530
3531 let mut params = Params::with_capacity(5 + self._additional_params.len());
3532 params.push("accountId", self._account_id);
3533 params.push("adClientId", self._ad_client_id);
3534 params.push("adUnitId", self._ad_unit_id);
3535
3536 params.extend(self._additional_params.iter());
3537
3538 params.push("alt", "json");
3539 let mut url = self.hub._base_url.clone()
3540 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}";
3541 if self._scopes.is_empty() {
3542 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3543 }
3544
3545 #[allow(clippy::single_element_loop)]
3546 for &(find_this, param_name) in [
3547 ("{accountId}", "accountId"),
3548 ("{adClientId}", "adClientId"),
3549 ("{adUnitId}", "adUnitId"),
3550 ]
3551 .iter()
3552 {
3553 url = params.uri_replacement(url, param_name, find_this, false);
3554 }
3555 {
3556 let to_remove = ["adUnitId", "adClientId", "accountId"];
3557 params.remove_params(&to_remove);
3558 }
3559
3560 let url = params.parse_with_url(&url);
3561
3562 loop {
3563 let token = match self
3564 .hub
3565 .auth
3566 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3567 .await
3568 {
3569 Ok(token) => token,
3570 Err(e) => match dlg.token(e) {
3571 Ok(token) => token,
3572 Err(e) => {
3573 dlg.finished(false);
3574 return Err(common::Error::MissingToken(e));
3575 }
3576 },
3577 };
3578 let mut req_result = {
3579 let client = &self.hub.client;
3580 dlg.pre_request();
3581 let mut req_builder = hyper::Request::builder()
3582 .method(hyper::Method::GET)
3583 .uri(url.as_str())
3584 .header(USER_AGENT, self.hub._user_agent.clone());
3585
3586 if let Some(token) = token.as_ref() {
3587 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3588 }
3589
3590 let request = req_builder
3591 .header(CONTENT_LENGTH, 0_u64)
3592 .body(common::to_body::<String>(None));
3593
3594 client.request(request.unwrap()).await
3595 };
3596
3597 match req_result {
3598 Err(err) => {
3599 if let common::Retry::After(d) = dlg.http_error(&err) {
3600 sleep(d).await;
3601 continue;
3602 }
3603 dlg.finished(false);
3604 return Err(common::Error::HttpError(err));
3605 }
3606 Ok(res) => {
3607 let (mut parts, body) = res.into_parts();
3608 let mut body = common::Body::new(body);
3609 if !parts.status.is_success() {
3610 let bytes = common::to_bytes(body).await.unwrap_or_default();
3611 let error = serde_json::from_str(&common::to_string(&bytes));
3612 let response = common::to_response(parts, bytes.into());
3613
3614 if let common::Retry::After(d) =
3615 dlg.http_failure(&response, error.as_ref().ok())
3616 {
3617 sleep(d).await;
3618 continue;
3619 }
3620
3621 dlg.finished(false);
3622
3623 return Err(match error {
3624 Ok(value) => common::Error::BadRequest(value),
3625 _ => common::Error::Failure(response),
3626 });
3627 }
3628 let response = {
3629 let bytes = common::to_bytes(body).await.unwrap_or_default();
3630 let encoded = common::to_string(&bytes);
3631 match serde_json::from_str(&encoded) {
3632 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3633 Err(error) => {
3634 dlg.response_json_decode_error(&encoded, &error);
3635 return Err(common::Error::JsonDecodeError(
3636 encoded.to_string(),
3637 error,
3638 ));
3639 }
3640 }
3641 };
3642
3643 dlg.finished(true);
3644 return Ok(response);
3645 }
3646 }
3647 }
3648 }
3649
3650 /// Account to which the ad client belongs.
3651 ///
3652 /// Sets the *account id* path property to the given value.
3653 ///
3654 /// Even though the property as already been set when instantiating this call,
3655 /// we provide this method for API completeness.
3656 pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
3657 self._account_id = new_value.to_string();
3658 self
3659 }
3660 /// Ad client for which to get the ad unit.
3661 ///
3662 /// Sets the *ad client id* path property to the given value.
3663 ///
3664 /// Even though the property as already been set when instantiating this call,
3665 /// we provide this method for API completeness.
3666 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
3667 self._ad_client_id = new_value.to_string();
3668 self
3669 }
3670 /// Ad unit to retrieve.
3671 ///
3672 /// Sets the *ad unit id* path property to the given value.
3673 ///
3674 /// Even though the property as already been set when instantiating this call,
3675 /// we provide this method for API completeness.
3676 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
3677 self._ad_unit_id = new_value.to_string();
3678 self
3679 }
3680 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3681 /// while executing the actual API request.
3682 ///
3683 /// ````text
3684 /// It should be used to handle progress information, and to implement a certain level of resilience.
3685 /// ````
3686 ///
3687 /// Sets the *delegate* property to the given value.
3688 pub fn delegate(
3689 mut self,
3690 new_value: &'a mut dyn common::Delegate,
3691 ) -> AccountAdunitGetCall<'a, C> {
3692 self._delegate = Some(new_value);
3693 self
3694 }
3695
3696 /// Set any additional parameter of the query string used in the request.
3697 /// It should be used to set parameters which are not yet available through their own
3698 /// setters.
3699 ///
3700 /// Please note that this method must not be used to set any of the known parameters
3701 /// which have their own setter method. If done anyway, the request will fail.
3702 ///
3703 /// # Additional Parameters
3704 ///
3705 /// * *alt* (query-string) - Data format for the response.
3706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3707 /// * *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.
3708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3710 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3711 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3712 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitGetCall<'a, C>
3713 where
3714 T: AsRef<str>,
3715 {
3716 self._additional_params
3717 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3718 self
3719 }
3720
3721 /// Identifies the authorization scope for the method you are building.
3722 ///
3723 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3724 /// [`Scope::Readonly`].
3725 ///
3726 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3727 /// tokens for more than one scope.
3728 ///
3729 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3730 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3731 /// sufficient, a read-write scope will do as well.
3732 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitGetCall<'a, C>
3733 where
3734 St: AsRef<str>,
3735 {
3736 self._scopes.insert(String::from(scope.as_ref()));
3737 self
3738 }
3739 /// Identifies the authorization scope(s) for the method you are building.
3740 ///
3741 /// See [`Self::add_scope()`] for details.
3742 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitGetCall<'a, C>
3743 where
3744 I: IntoIterator<Item = St>,
3745 St: AsRef<str>,
3746 {
3747 self._scopes
3748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3749 self
3750 }
3751
3752 /// Removes all scopes, and no default scope will be used either.
3753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3754 /// for details).
3755 pub fn clear_scopes(mut self) -> AccountAdunitGetCall<'a, C> {
3756 self._scopes.clear();
3757 self
3758 }
3759}
3760
3761/// Get ad code for the specified ad unit.
3762///
3763/// A builder for the *adunits.getAdCode* method supported by a *account* resource.
3764/// It is not used directly, but through a [`AccountMethods`] instance.
3765///
3766/// # Example
3767///
3768/// Instantiate a resource method builder
3769///
3770/// ```test_harness,no_run
3771/// # extern crate hyper;
3772/// # extern crate hyper_rustls;
3773/// # extern crate google_adsense1d4 as adsense1d4;
3774/// # async fn dox() {
3775/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3776///
3777/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3778/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3779/// # .with_native_roots()
3780/// # .unwrap()
3781/// # .https_only()
3782/// # .enable_http2()
3783/// # .build();
3784///
3785/// # let executor = hyper_util::rt::TokioExecutor::new();
3786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3787/// # secret,
3788/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3789/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3790/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3791/// # ),
3792/// # ).build().await.unwrap();
3793///
3794/// # let client = hyper_util::client::legacy::Client::builder(
3795/// # hyper_util::rt::TokioExecutor::new()
3796/// # )
3797/// # .build(
3798/// # hyper_rustls::HttpsConnectorBuilder::new()
3799/// # .with_native_roots()
3800/// # .unwrap()
3801/// # .https_or_http()
3802/// # .enable_http2()
3803/// # .build()
3804/// # );
3805/// # let mut hub = AdSense::new(client, auth);
3806/// // You can configure optional parameters by calling the respective setters at will, and
3807/// // execute the final call using `doit()`.
3808/// // Values shown here are possibly random and not representative !
3809/// let result = hub.accounts().adunits_get_ad_code("accountId", "adClientId", "adUnitId")
3810/// .doit().await;
3811/// # }
3812/// ```
3813pub struct AccountAdunitGetAdCodeCall<'a, C>
3814where
3815 C: 'a,
3816{
3817 hub: &'a AdSense<C>,
3818 _account_id: String,
3819 _ad_client_id: String,
3820 _ad_unit_id: String,
3821 _delegate: Option<&'a mut dyn common::Delegate>,
3822 _additional_params: HashMap<String, String>,
3823 _scopes: BTreeSet<String>,
3824}
3825
3826impl<'a, C> common::CallBuilder for AccountAdunitGetAdCodeCall<'a, C> {}
3827
3828impl<'a, C> AccountAdunitGetAdCodeCall<'a, C>
3829where
3830 C: common::Connector,
3831{
3832 /// Perform the operation you have build so far.
3833 pub async fn doit(mut self) -> common::Result<(common::Response, AdCode)> {
3834 use std::borrow::Cow;
3835 use std::io::{Read, Seek};
3836
3837 use common::{url::Params, ToParts};
3838 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3839
3840 let mut dd = common::DefaultDelegate;
3841 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3842 dlg.begin(common::MethodInfo {
3843 id: "adsense.accounts.adunits.getAdCode",
3844 http_method: hyper::Method::GET,
3845 });
3846
3847 for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
3848 if self._additional_params.contains_key(field) {
3849 dlg.finished(false);
3850 return Err(common::Error::FieldClash(field));
3851 }
3852 }
3853
3854 let mut params = Params::with_capacity(5 + self._additional_params.len());
3855 params.push("accountId", self._account_id);
3856 params.push("adClientId", self._ad_client_id);
3857 params.push("adUnitId", self._ad_unit_id);
3858
3859 params.extend(self._additional_params.iter());
3860
3861 params.push("alt", "json");
3862 let mut url = self.hub._base_url.clone()
3863 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}/adcode";
3864 if self._scopes.is_empty() {
3865 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3866 }
3867
3868 #[allow(clippy::single_element_loop)]
3869 for &(find_this, param_name) in [
3870 ("{accountId}", "accountId"),
3871 ("{adClientId}", "adClientId"),
3872 ("{adUnitId}", "adUnitId"),
3873 ]
3874 .iter()
3875 {
3876 url = params.uri_replacement(url, param_name, find_this, false);
3877 }
3878 {
3879 let to_remove = ["adUnitId", "adClientId", "accountId"];
3880 params.remove_params(&to_remove);
3881 }
3882
3883 let url = params.parse_with_url(&url);
3884
3885 loop {
3886 let token = match self
3887 .hub
3888 .auth
3889 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3890 .await
3891 {
3892 Ok(token) => token,
3893 Err(e) => match dlg.token(e) {
3894 Ok(token) => token,
3895 Err(e) => {
3896 dlg.finished(false);
3897 return Err(common::Error::MissingToken(e));
3898 }
3899 },
3900 };
3901 let mut req_result = {
3902 let client = &self.hub.client;
3903 dlg.pre_request();
3904 let mut req_builder = hyper::Request::builder()
3905 .method(hyper::Method::GET)
3906 .uri(url.as_str())
3907 .header(USER_AGENT, self.hub._user_agent.clone());
3908
3909 if let Some(token) = token.as_ref() {
3910 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3911 }
3912
3913 let request = req_builder
3914 .header(CONTENT_LENGTH, 0_u64)
3915 .body(common::to_body::<String>(None));
3916
3917 client.request(request.unwrap()).await
3918 };
3919
3920 match req_result {
3921 Err(err) => {
3922 if let common::Retry::After(d) = dlg.http_error(&err) {
3923 sleep(d).await;
3924 continue;
3925 }
3926 dlg.finished(false);
3927 return Err(common::Error::HttpError(err));
3928 }
3929 Ok(res) => {
3930 let (mut parts, body) = res.into_parts();
3931 let mut body = common::Body::new(body);
3932 if !parts.status.is_success() {
3933 let bytes = common::to_bytes(body).await.unwrap_or_default();
3934 let error = serde_json::from_str(&common::to_string(&bytes));
3935 let response = common::to_response(parts, bytes.into());
3936
3937 if let common::Retry::After(d) =
3938 dlg.http_failure(&response, error.as_ref().ok())
3939 {
3940 sleep(d).await;
3941 continue;
3942 }
3943
3944 dlg.finished(false);
3945
3946 return Err(match error {
3947 Ok(value) => common::Error::BadRequest(value),
3948 _ => common::Error::Failure(response),
3949 });
3950 }
3951 let response = {
3952 let bytes = common::to_bytes(body).await.unwrap_or_default();
3953 let encoded = common::to_string(&bytes);
3954 match serde_json::from_str(&encoded) {
3955 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3956 Err(error) => {
3957 dlg.response_json_decode_error(&encoded, &error);
3958 return Err(common::Error::JsonDecodeError(
3959 encoded.to_string(),
3960 error,
3961 ));
3962 }
3963 }
3964 };
3965
3966 dlg.finished(true);
3967 return Ok(response);
3968 }
3969 }
3970 }
3971 }
3972
3973 /// Account which contains the ad client.
3974 ///
3975 /// Sets the *account id* path property to the given value.
3976 ///
3977 /// Even though the property as already been set when instantiating this call,
3978 /// we provide this method for API completeness.
3979 pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
3980 self._account_id = new_value.to_string();
3981 self
3982 }
3983 /// Ad client with contains the ad unit.
3984 ///
3985 /// Sets the *ad client id* path property to the given value.
3986 ///
3987 /// Even though the property as already been set when instantiating this call,
3988 /// we provide this method for API completeness.
3989 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
3990 self._ad_client_id = new_value.to_string();
3991 self
3992 }
3993 /// Ad unit to get the code for.
3994 ///
3995 /// Sets the *ad unit id* path property to the given value.
3996 ///
3997 /// Even though the property as already been set when instantiating this call,
3998 /// we provide this method for API completeness.
3999 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
4000 self._ad_unit_id = new_value.to_string();
4001 self
4002 }
4003 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4004 /// while executing the actual API request.
4005 ///
4006 /// ````text
4007 /// It should be used to handle progress information, and to implement a certain level of resilience.
4008 /// ````
4009 ///
4010 /// Sets the *delegate* property to the given value.
4011 pub fn delegate(
4012 mut self,
4013 new_value: &'a mut dyn common::Delegate,
4014 ) -> AccountAdunitGetAdCodeCall<'a, C> {
4015 self._delegate = Some(new_value);
4016 self
4017 }
4018
4019 /// Set any additional parameter of the query string used in the request.
4020 /// It should be used to set parameters which are not yet available through their own
4021 /// setters.
4022 ///
4023 /// Please note that this method must not be used to set any of the known parameters
4024 /// which have their own setter method. If done anyway, the request will fail.
4025 ///
4026 /// # Additional Parameters
4027 ///
4028 /// * *alt* (query-string) - Data format for the response.
4029 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4030 /// * *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.
4031 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4032 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4033 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4034 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4035 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitGetAdCodeCall<'a, C>
4036 where
4037 T: AsRef<str>,
4038 {
4039 self._additional_params
4040 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4041 self
4042 }
4043
4044 /// Identifies the authorization scope for the method you are building.
4045 ///
4046 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4047 /// [`Scope::Readonly`].
4048 ///
4049 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4050 /// tokens for more than one scope.
4051 ///
4052 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4053 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4054 /// sufficient, a read-write scope will do as well.
4055 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitGetAdCodeCall<'a, C>
4056 where
4057 St: AsRef<str>,
4058 {
4059 self._scopes.insert(String::from(scope.as_ref()));
4060 self
4061 }
4062 /// Identifies the authorization scope(s) for the method you are building.
4063 ///
4064 /// See [`Self::add_scope()`] for details.
4065 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitGetAdCodeCall<'a, C>
4066 where
4067 I: IntoIterator<Item = St>,
4068 St: AsRef<str>,
4069 {
4070 self._scopes
4071 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4072 self
4073 }
4074
4075 /// Removes all scopes, and no default scope will be used either.
4076 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4077 /// for details).
4078 pub fn clear_scopes(mut self) -> AccountAdunitGetAdCodeCall<'a, C> {
4079 self._scopes.clear();
4080 self
4081 }
4082}
4083
4084/// List all ad units in the specified ad client for the specified account.
4085///
4086/// A builder for the *adunits.list* method supported by a *account* resource.
4087/// It is not used directly, but through a [`AccountMethods`] instance.
4088///
4089/// # Example
4090///
4091/// Instantiate a resource method builder
4092///
4093/// ```test_harness,no_run
4094/// # extern crate hyper;
4095/// # extern crate hyper_rustls;
4096/// # extern crate google_adsense1d4 as adsense1d4;
4097/// # async fn dox() {
4098/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4099///
4100/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4101/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4102/// # .with_native_roots()
4103/// # .unwrap()
4104/// # .https_only()
4105/// # .enable_http2()
4106/// # .build();
4107///
4108/// # let executor = hyper_util::rt::TokioExecutor::new();
4109/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4110/// # secret,
4111/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4112/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4113/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4114/// # ),
4115/// # ).build().await.unwrap();
4116///
4117/// # let client = hyper_util::client::legacy::Client::builder(
4118/// # hyper_util::rt::TokioExecutor::new()
4119/// # )
4120/// # .build(
4121/// # hyper_rustls::HttpsConnectorBuilder::new()
4122/// # .with_native_roots()
4123/// # .unwrap()
4124/// # .https_or_http()
4125/// # .enable_http2()
4126/// # .build()
4127/// # );
4128/// # let mut hub = AdSense::new(client, auth);
4129/// // You can configure optional parameters by calling the respective setters at will, and
4130/// // execute the final call using `doit()`.
4131/// // Values shown here are possibly random and not representative !
4132/// let result = hub.accounts().adunits_list("accountId", "adClientId")
4133/// .page_token("consetetur")
4134/// .max_results(-92)
4135/// .include_inactive(true)
4136/// .doit().await;
4137/// # }
4138/// ```
4139pub struct AccountAdunitListCall<'a, C>
4140where
4141 C: 'a,
4142{
4143 hub: &'a AdSense<C>,
4144 _account_id: String,
4145 _ad_client_id: String,
4146 _page_token: Option<String>,
4147 _max_results: Option<i32>,
4148 _include_inactive: Option<bool>,
4149 _delegate: Option<&'a mut dyn common::Delegate>,
4150 _additional_params: HashMap<String, String>,
4151 _scopes: BTreeSet<String>,
4152}
4153
4154impl<'a, C> common::CallBuilder for AccountAdunitListCall<'a, C> {}
4155
4156impl<'a, C> AccountAdunitListCall<'a, C>
4157where
4158 C: common::Connector,
4159{
4160 /// Perform the operation you have build so far.
4161 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnits)> {
4162 use std::borrow::Cow;
4163 use std::io::{Read, Seek};
4164
4165 use common::{url::Params, ToParts};
4166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4167
4168 let mut dd = common::DefaultDelegate;
4169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4170 dlg.begin(common::MethodInfo {
4171 id: "adsense.accounts.adunits.list",
4172 http_method: hyper::Method::GET,
4173 });
4174
4175 for &field in [
4176 "alt",
4177 "accountId",
4178 "adClientId",
4179 "pageToken",
4180 "maxResults",
4181 "includeInactive",
4182 ]
4183 .iter()
4184 {
4185 if self._additional_params.contains_key(field) {
4186 dlg.finished(false);
4187 return Err(common::Error::FieldClash(field));
4188 }
4189 }
4190
4191 let mut params = Params::with_capacity(7 + self._additional_params.len());
4192 params.push("accountId", self._account_id);
4193 params.push("adClientId", self._ad_client_id);
4194 if let Some(value) = self._page_token.as_ref() {
4195 params.push("pageToken", value);
4196 }
4197 if let Some(value) = self._max_results.as_ref() {
4198 params.push("maxResults", value.to_string());
4199 }
4200 if let Some(value) = self._include_inactive.as_ref() {
4201 params.push("includeInactive", value.to_string());
4202 }
4203
4204 params.extend(self._additional_params.iter());
4205
4206 params.push("alt", "json");
4207 let mut url =
4208 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adunits";
4209 if self._scopes.is_empty() {
4210 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4211 }
4212
4213 #[allow(clippy::single_element_loop)]
4214 for &(find_this, param_name) in
4215 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
4216 {
4217 url = params.uri_replacement(url, param_name, find_this, false);
4218 }
4219 {
4220 let to_remove = ["adClientId", "accountId"];
4221 params.remove_params(&to_remove);
4222 }
4223
4224 let url = params.parse_with_url(&url);
4225
4226 loop {
4227 let token = match self
4228 .hub
4229 .auth
4230 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4231 .await
4232 {
4233 Ok(token) => token,
4234 Err(e) => match dlg.token(e) {
4235 Ok(token) => token,
4236 Err(e) => {
4237 dlg.finished(false);
4238 return Err(common::Error::MissingToken(e));
4239 }
4240 },
4241 };
4242 let mut req_result = {
4243 let client = &self.hub.client;
4244 dlg.pre_request();
4245 let mut req_builder = hyper::Request::builder()
4246 .method(hyper::Method::GET)
4247 .uri(url.as_str())
4248 .header(USER_AGENT, self.hub._user_agent.clone());
4249
4250 if let Some(token) = token.as_ref() {
4251 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4252 }
4253
4254 let request = req_builder
4255 .header(CONTENT_LENGTH, 0_u64)
4256 .body(common::to_body::<String>(None));
4257
4258 client.request(request.unwrap()).await
4259 };
4260
4261 match req_result {
4262 Err(err) => {
4263 if let common::Retry::After(d) = dlg.http_error(&err) {
4264 sleep(d).await;
4265 continue;
4266 }
4267 dlg.finished(false);
4268 return Err(common::Error::HttpError(err));
4269 }
4270 Ok(res) => {
4271 let (mut parts, body) = res.into_parts();
4272 let mut body = common::Body::new(body);
4273 if !parts.status.is_success() {
4274 let bytes = common::to_bytes(body).await.unwrap_or_default();
4275 let error = serde_json::from_str(&common::to_string(&bytes));
4276 let response = common::to_response(parts, bytes.into());
4277
4278 if let common::Retry::After(d) =
4279 dlg.http_failure(&response, error.as_ref().ok())
4280 {
4281 sleep(d).await;
4282 continue;
4283 }
4284
4285 dlg.finished(false);
4286
4287 return Err(match error {
4288 Ok(value) => common::Error::BadRequest(value),
4289 _ => common::Error::Failure(response),
4290 });
4291 }
4292 let response = {
4293 let bytes = common::to_bytes(body).await.unwrap_or_default();
4294 let encoded = common::to_string(&bytes);
4295 match serde_json::from_str(&encoded) {
4296 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4297 Err(error) => {
4298 dlg.response_json_decode_error(&encoded, &error);
4299 return Err(common::Error::JsonDecodeError(
4300 encoded.to_string(),
4301 error,
4302 ));
4303 }
4304 }
4305 };
4306
4307 dlg.finished(true);
4308 return Ok(response);
4309 }
4310 }
4311 }
4312 }
4313
4314 /// Account to which the ad client belongs.
4315 ///
4316 /// Sets the *account id* path property to the given value.
4317 ///
4318 /// Even though the property as already been set when instantiating this call,
4319 /// we provide this method for API completeness.
4320 pub fn account_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
4321 self._account_id = new_value.to_string();
4322 self
4323 }
4324 /// Ad client for which to list ad units.
4325 ///
4326 /// Sets the *ad client id* path property to the given value.
4327 ///
4328 /// Even though the property as already been set when instantiating this call,
4329 /// we provide this method for API completeness.
4330 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
4331 self._ad_client_id = new_value.to_string();
4332 self
4333 }
4334 /// A continuation token, used to page through ad units. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
4335 ///
4336 /// Sets the *page token* query property to the given value.
4337 pub fn page_token(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
4338 self._page_token = Some(new_value.to_string());
4339 self
4340 }
4341 /// The maximum number of ad units to include in the response, used for paging.
4342 ///
4343 /// Sets the *max results* query property to the given value.
4344 pub fn max_results(mut self, new_value: i32) -> AccountAdunitListCall<'a, C> {
4345 self._max_results = Some(new_value);
4346 self
4347 }
4348 /// Whether to include inactive ad units. Default: true.
4349 ///
4350 /// Sets the *include inactive* query property to the given value.
4351 pub fn include_inactive(mut self, new_value: bool) -> AccountAdunitListCall<'a, C> {
4352 self._include_inactive = Some(new_value);
4353 self
4354 }
4355 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4356 /// while executing the actual API request.
4357 ///
4358 /// ````text
4359 /// It should be used to handle progress information, and to implement a certain level of resilience.
4360 /// ````
4361 ///
4362 /// Sets the *delegate* property to the given value.
4363 pub fn delegate(
4364 mut self,
4365 new_value: &'a mut dyn common::Delegate,
4366 ) -> AccountAdunitListCall<'a, C> {
4367 self._delegate = Some(new_value);
4368 self
4369 }
4370
4371 /// Set any additional parameter of the query string used in the request.
4372 /// It should be used to set parameters which are not yet available through their own
4373 /// setters.
4374 ///
4375 /// Please note that this method must not be used to set any of the known parameters
4376 /// which have their own setter method. If done anyway, the request will fail.
4377 ///
4378 /// # Additional Parameters
4379 ///
4380 /// * *alt* (query-string) - Data format for the response.
4381 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4382 /// * *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.
4383 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4384 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4385 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4386 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4387 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitListCall<'a, C>
4388 where
4389 T: AsRef<str>,
4390 {
4391 self._additional_params
4392 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4393 self
4394 }
4395
4396 /// Identifies the authorization scope for the method you are building.
4397 ///
4398 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4399 /// [`Scope::Readonly`].
4400 ///
4401 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4402 /// tokens for more than one scope.
4403 ///
4404 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4405 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4406 /// sufficient, a read-write scope will do as well.
4407 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitListCall<'a, C>
4408 where
4409 St: AsRef<str>,
4410 {
4411 self._scopes.insert(String::from(scope.as_ref()));
4412 self
4413 }
4414 /// Identifies the authorization scope(s) for the method you are building.
4415 ///
4416 /// See [`Self::add_scope()`] for details.
4417 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitListCall<'a, C>
4418 where
4419 I: IntoIterator<Item = St>,
4420 St: AsRef<str>,
4421 {
4422 self._scopes
4423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4424 self
4425 }
4426
4427 /// Removes all scopes, and no default scope will be used either.
4428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4429 /// for details).
4430 pub fn clear_scopes(mut self) -> AccountAdunitListCall<'a, C> {
4431 self._scopes.clear();
4432 self
4433 }
4434}
4435
4436/// Dismiss (delete) the specified alert from the specified publisher AdSense account.
4437///
4438/// A builder for the *alerts.delete* method supported by a *account* resource.
4439/// It is not used directly, but through a [`AccountMethods`] instance.
4440///
4441/// # Example
4442///
4443/// Instantiate a resource method builder
4444///
4445/// ```test_harness,no_run
4446/// # extern crate hyper;
4447/// # extern crate hyper_rustls;
4448/// # extern crate google_adsense1d4 as adsense1d4;
4449/// # async fn dox() {
4450/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4451///
4452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4453/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4454/// # .with_native_roots()
4455/// # .unwrap()
4456/// # .https_only()
4457/// # .enable_http2()
4458/// # .build();
4459///
4460/// # let executor = hyper_util::rt::TokioExecutor::new();
4461/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4462/// # secret,
4463/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4464/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4465/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4466/// # ),
4467/// # ).build().await.unwrap();
4468///
4469/// # let client = hyper_util::client::legacy::Client::builder(
4470/// # hyper_util::rt::TokioExecutor::new()
4471/// # )
4472/// # .build(
4473/// # hyper_rustls::HttpsConnectorBuilder::new()
4474/// # .with_native_roots()
4475/// # .unwrap()
4476/// # .https_or_http()
4477/// # .enable_http2()
4478/// # .build()
4479/// # );
4480/// # let mut hub = AdSense::new(client, auth);
4481/// // You can configure optional parameters by calling the respective setters at will, and
4482/// // execute the final call using `doit()`.
4483/// // Values shown here are possibly random and not representative !
4484/// let result = hub.accounts().alerts_delete("accountId", "alertId")
4485/// .doit().await;
4486/// # }
4487/// ```
4488pub struct AccountAlertDeleteCall<'a, C>
4489where
4490 C: 'a,
4491{
4492 hub: &'a AdSense<C>,
4493 _account_id: String,
4494 _alert_id: String,
4495 _delegate: Option<&'a mut dyn common::Delegate>,
4496 _additional_params: HashMap<String, String>,
4497 _scopes: BTreeSet<String>,
4498}
4499
4500impl<'a, C> common::CallBuilder for AccountAlertDeleteCall<'a, C> {}
4501
4502impl<'a, C> AccountAlertDeleteCall<'a, C>
4503where
4504 C: common::Connector,
4505{
4506 /// Perform the operation you have build so far.
4507 pub async fn doit(mut self) -> common::Result<common::Response> {
4508 use std::borrow::Cow;
4509 use std::io::{Read, Seek};
4510
4511 use common::{url::Params, ToParts};
4512 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4513
4514 let mut dd = common::DefaultDelegate;
4515 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4516 dlg.begin(common::MethodInfo {
4517 id: "adsense.accounts.alerts.delete",
4518 http_method: hyper::Method::DELETE,
4519 });
4520
4521 for &field in ["accountId", "alertId"].iter() {
4522 if self._additional_params.contains_key(field) {
4523 dlg.finished(false);
4524 return Err(common::Error::FieldClash(field));
4525 }
4526 }
4527
4528 let mut params = Params::with_capacity(3 + self._additional_params.len());
4529 params.push("accountId", self._account_id);
4530 params.push("alertId", self._alert_id);
4531
4532 params.extend(self._additional_params.iter());
4533
4534 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/alerts/{alertId}";
4535 if self._scopes.is_empty() {
4536 self._scopes.insert(Scope::Full.as_ref().to_string());
4537 }
4538
4539 #[allow(clippy::single_element_loop)]
4540 for &(find_this, param_name) in
4541 [("{accountId}", "accountId"), ("{alertId}", "alertId")].iter()
4542 {
4543 url = params.uri_replacement(url, param_name, find_this, false);
4544 }
4545 {
4546 let to_remove = ["alertId", "accountId"];
4547 params.remove_params(&to_remove);
4548 }
4549
4550 let url = params.parse_with_url(&url);
4551
4552 loop {
4553 let token = match self
4554 .hub
4555 .auth
4556 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4557 .await
4558 {
4559 Ok(token) => token,
4560 Err(e) => match dlg.token(e) {
4561 Ok(token) => token,
4562 Err(e) => {
4563 dlg.finished(false);
4564 return Err(common::Error::MissingToken(e));
4565 }
4566 },
4567 };
4568 let mut req_result = {
4569 let client = &self.hub.client;
4570 dlg.pre_request();
4571 let mut req_builder = hyper::Request::builder()
4572 .method(hyper::Method::DELETE)
4573 .uri(url.as_str())
4574 .header(USER_AGENT, self.hub._user_agent.clone());
4575
4576 if let Some(token) = token.as_ref() {
4577 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4578 }
4579
4580 let request = req_builder
4581 .header(CONTENT_LENGTH, 0_u64)
4582 .body(common::to_body::<String>(None));
4583
4584 client.request(request.unwrap()).await
4585 };
4586
4587 match req_result {
4588 Err(err) => {
4589 if let common::Retry::After(d) = dlg.http_error(&err) {
4590 sleep(d).await;
4591 continue;
4592 }
4593 dlg.finished(false);
4594 return Err(common::Error::HttpError(err));
4595 }
4596 Ok(res) => {
4597 let (mut parts, body) = res.into_parts();
4598 let mut body = common::Body::new(body);
4599 if !parts.status.is_success() {
4600 let bytes = common::to_bytes(body).await.unwrap_or_default();
4601 let error = serde_json::from_str(&common::to_string(&bytes));
4602 let response = common::to_response(parts, bytes.into());
4603
4604 if let common::Retry::After(d) =
4605 dlg.http_failure(&response, error.as_ref().ok())
4606 {
4607 sleep(d).await;
4608 continue;
4609 }
4610
4611 dlg.finished(false);
4612
4613 return Err(match error {
4614 Ok(value) => common::Error::BadRequest(value),
4615 _ => common::Error::Failure(response),
4616 });
4617 }
4618 let response = common::Response::from_parts(parts, body);
4619
4620 dlg.finished(true);
4621 return Ok(response);
4622 }
4623 }
4624 }
4625 }
4626
4627 /// Account which contains the ad unit.
4628 ///
4629 /// Sets the *account id* path property to the given value.
4630 ///
4631 /// Even though the property as already been set when instantiating this call,
4632 /// we provide this method for API completeness.
4633 pub fn account_id(mut self, new_value: &str) -> AccountAlertDeleteCall<'a, C> {
4634 self._account_id = new_value.to_string();
4635 self
4636 }
4637 /// Alert to delete.
4638 ///
4639 /// Sets the *alert id* path property to the given value.
4640 ///
4641 /// Even though the property as already been set when instantiating this call,
4642 /// we provide this method for API completeness.
4643 pub fn alert_id(mut self, new_value: &str) -> AccountAlertDeleteCall<'a, C> {
4644 self._alert_id = new_value.to_string();
4645 self
4646 }
4647 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4648 /// while executing the actual API request.
4649 ///
4650 /// ````text
4651 /// It should be used to handle progress information, and to implement a certain level of resilience.
4652 /// ````
4653 ///
4654 /// Sets the *delegate* property to the given value.
4655 pub fn delegate(
4656 mut self,
4657 new_value: &'a mut dyn common::Delegate,
4658 ) -> AccountAlertDeleteCall<'a, C> {
4659 self._delegate = Some(new_value);
4660 self
4661 }
4662
4663 /// Set any additional parameter of the query string used in the request.
4664 /// It should be used to set parameters which are not yet available through their own
4665 /// setters.
4666 ///
4667 /// Please note that this method must not be used to set any of the known parameters
4668 /// which have their own setter method. If done anyway, the request will fail.
4669 ///
4670 /// # Additional Parameters
4671 ///
4672 /// * *alt* (query-string) - Data format for the response.
4673 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4674 /// * *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.
4675 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4676 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4677 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4678 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4679 pub fn param<T>(mut self, name: T, value: T) -> AccountAlertDeleteCall<'a, C>
4680 where
4681 T: AsRef<str>,
4682 {
4683 self._additional_params
4684 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4685 self
4686 }
4687
4688 /// Identifies the authorization scope for the method you are building.
4689 ///
4690 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4691 /// [`Scope::Full`].
4692 ///
4693 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4694 /// tokens for more than one scope.
4695 ///
4696 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4697 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4698 /// sufficient, a read-write scope will do as well.
4699 pub fn add_scope<St>(mut self, scope: St) -> AccountAlertDeleteCall<'a, C>
4700 where
4701 St: AsRef<str>,
4702 {
4703 self._scopes.insert(String::from(scope.as_ref()));
4704 self
4705 }
4706 /// Identifies the authorization scope(s) for the method you are building.
4707 ///
4708 /// See [`Self::add_scope()`] for details.
4709 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAlertDeleteCall<'a, C>
4710 where
4711 I: IntoIterator<Item = St>,
4712 St: AsRef<str>,
4713 {
4714 self._scopes
4715 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4716 self
4717 }
4718
4719 /// Removes all scopes, and no default scope will be used either.
4720 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4721 /// for details).
4722 pub fn clear_scopes(mut self) -> AccountAlertDeleteCall<'a, C> {
4723 self._scopes.clear();
4724 self
4725 }
4726}
4727
4728/// List the alerts for the specified AdSense account.
4729///
4730/// A builder for the *alerts.list* method supported by a *account* resource.
4731/// It is not used directly, but through a [`AccountMethods`] instance.
4732///
4733/// # Example
4734///
4735/// Instantiate a resource method builder
4736///
4737/// ```test_harness,no_run
4738/// # extern crate hyper;
4739/// # extern crate hyper_rustls;
4740/// # extern crate google_adsense1d4 as adsense1d4;
4741/// # async fn dox() {
4742/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4743///
4744/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4745/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4746/// # .with_native_roots()
4747/// # .unwrap()
4748/// # .https_only()
4749/// # .enable_http2()
4750/// # .build();
4751///
4752/// # let executor = hyper_util::rt::TokioExecutor::new();
4753/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4754/// # secret,
4755/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4756/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4757/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4758/// # ),
4759/// # ).build().await.unwrap();
4760///
4761/// # let client = hyper_util::client::legacy::Client::builder(
4762/// # hyper_util::rt::TokioExecutor::new()
4763/// # )
4764/// # .build(
4765/// # hyper_rustls::HttpsConnectorBuilder::new()
4766/// # .with_native_roots()
4767/// # .unwrap()
4768/// # .https_or_http()
4769/// # .enable_http2()
4770/// # .build()
4771/// # );
4772/// # let mut hub = AdSense::new(client, auth);
4773/// // You can configure optional parameters by calling the respective setters at will, and
4774/// // execute the final call using `doit()`.
4775/// // Values shown here are possibly random and not representative !
4776/// let result = hub.accounts().alerts_list("accountId")
4777/// .locale("Stet")
4778/// .doit().await;
4779/// # }
4780/// ```
4781pub struct AccountAlertListCall<'a, C>
4782where
4783 C: 'a,
4784{
4785 hub: &'a AdSense<C>,
4786 _account_id: String,
4787 _locale: Option<String>,
4788 _delegate: Option<&'a mut dyn common::Delegate>,
4789 _additional_params: HashMap<String, String>,
4790 _scopes: BTreeSet<String>,
4791}
4792
4793impl<'a, C> common::CallBuilder for AccountAlertListCall<'a, C> {}
4794
4795impl<'a, C> AccountAlertListCall<'a, C>
4796where
4797 C: common::Connector,
4798{
4799 /// Perform the operation you have build so far.
4800 pub async fn doit(mut self) -> common::Result<(common::Response, Alerts)> {
4801 use std::borrow::Cow;
4802 use std::io::{Read, Seek};
4803
4804 use common::{url::Params, ToParts};
4805 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4806
4807 let mut dd = common::DefaultDelegate;
4808 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4809 dlg.begin(common::MethodInfo {
4810 id: "adsense.accounts.alerts.list",
4811 http_method: hyper::Method::GET,
4812 });
4813
4814 for &field in ["alt", "accountId", "locale"].iter() {
4815 if self._additional_params.contains_key(field) {
4816 dlg.finished(false);
4817 return Err(common::Error::FieldClash(field));
4818 }
4819 }
4820
4821 let mut params = Params::with_capacity(4 + self._additional_params.len());
4822 params.push("accountId", self._account_id);
4823 if let Some(value) = self._locale.as_ref() {
4824 params.push("locale", value);
4825 }
4826
4827 params.extend(self._additional_params.iter());
4828
4829 params.push("alt", "json");
4830 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/alerts";
4831 if self._scopes.is_empty() {
4832 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4833 }
4834
4835 #[allow(clippy::single_element_loop)]
4836 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
4837 url = params.uri_replacement(url, param_name, find_this, false);
4838 }
4839 {
4840 let to_remove = ["accountId"];
4841 params.remove_params(&to_remove);
4842 }
4843
4844 let url = params.parse_with_url(&url);
4845
4846 loop {
4847 let token = match self
4848 .hub
4849 .auth
4850 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4851 .await
4852 {
4853 Ok(token) => token,
4854 Err(e) => match dlg.token(e) {
4855 Ok(token) => token,
4856 Err(e) => {
4857 dlg.finished(false);
4858 return Err(common::Error::MissingToken(e));
4859 }
4860 },
4861 };
4862 let mut req_result = {
4863 let client = &self.hub.client;
4864 dlg.pre_request();
4865 let mut req_builder = hyper::Request::builder()
4866 .method(hyper::Method::GET)
4867 .uri(url.as_str())
4868 .header(USER_AGENT, self.hub._user_agent.clone());
4869
4870 if let Some(token) = token.as_ref() {
4871 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4872 }
4873
4874 let request = req_builder
4875 .header(CONTENT_LENGTH, 0_u64)
4876 .body(common::to_body::<String>(None));
4877
4878 client.request(request.unwrap()).await
4879 };
4880
4881 match req_result {
4882 Err(err) => {
4883 if let common::Retry::After(d) = dlg.http_error(&err) {
4884 sleep(d).await;
4885 continue;
4886 }
4887 dlg.finished(false);
4888 return Err(common::Error::HttpError(err));
4889 }
4890 Ok(res) => {
4891 let (mut parts, body) = res.into_parts();
4892 let mut body = common::Body::new(body);
4893 if !parts.status.is_success() {
4894 let bytes = common::to_bytes(body).await.unwrap_or_default();
4895 let error = serde_json::from_str(&common::to_string(&bytes));
4896 let response = common::to_response(parts, bytes.into());
4897
4898 if let common::Retry::After(d) =
4899 dlg.http_failure(&response, error.as_ref().ok())
4900 {
4901 sleep(d).await;
4902 continue;
4903 }
4904
4905 dlg.finished(false);
4906
4907 return Err(match error {
4908 Ok(value) => common::Error::BadRequest(value),
4909 _ => common::Error::Failure(response),
4910 });
4911 }
4912 let response = {
4913 let bytes = common::to_bytes(body).await.unwrap_or_default();
4914 let encoded = common::to_string(&bytes);
4915 match serde_json::from_str(&encoded) {
4916 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4917 Err(error) => {
4918 dlg.response_json_decode_error(&encoded, &error);
4919 return Err(common::Error::JsonDecodeError(
4920 encoded.to_string(),
4921 error,
4922 ));
4923 }
4924 }
4925 };
4926
4927 dlg.finished(true);
4928 return Ok(response);
4929 }
4930 }
4931 }
4932 }
4933
4934 /// Account for which to retrieve the alerts.
4935 ///
4936 /// Sets the *account id* path property to the given value.
4937 ///
4938 /// Even though the property as already been set when instantiating this call,
4939 /// we provide this method for API completeness.
4940 pub fn account_id(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
4941 self._account_id = new_value.to_string();
4942 self
4943 }
4944 /// 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.
4945 ///
4946 /// Sets the *locale* query property to the given value.
4947 pub fn locale(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
4948 self._locale = Some(new_value.to_string());
4949 self
4950 }
4951 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4952 /// while executing the actual API request.
4953 ///
4954 /// ````text
4955 /// It should be used to handle progress information, and to implement a certain level of resilience.
4956 /// ````
4957 ///
4958 /// Sets the *delegate* property to the given value.
4959 pub fn delegate(
4960 mut self,
4961 new_value: &'a mut dyn common::Delegate,
4962 ) -> AccountAlertListCall<'a, C> {
4963 self._delegate = Some(new_value);
4964 self
4965 }
4966
4967 /// Set any additional parameter of the query string used in the request.
4968 /// It should be used to set parameters which are not yet available through their own
4969 /// setters.
4970 ///
4971 /// Please note that this method must not be used to set any of the known parameters
4972 /// which have their own setter method. If done anyway, the request will fail.
4973 ///
4974 /// # Additional Parameters
4975 ///
4976 /// * *alt* (query-string) - Data format for the response.
4977 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4978 /// * *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.
4979 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4980 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4981 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4982 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4983 pub fn param<T>(mut self, name: T, value: T) -> AccountAlertListCall<'a, C>
4984 where
4985 T: AsRef<str>,
4986 {
4987 self._additional_params
4988 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4989 self
4990 }
4991
4992 /// Identifies the authorization scope for the method you are building.
4993 ///
4994 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4995 /// [`Scope::Readonly`].
4996 ///
4997 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4998 /// tokens for more than one scope.
4999 ///
5000 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5001 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5002 /// sufficient, a read-write scope will do as well.
5003 pub fn add_scope<St>(mut self, scope: St) -> AccountAlertListCall<'a, C>
5004 where
5005 St: AsRef<str>,
5006 {
5007 self._scopes.insert(String::from(scope.as_ref()));
5008 self
5009 }
5010 /// Identifies the authorization scope(s) for the method you are building.
5011 ///
5012 /// See [`Self::add_scope()`] for details.
5013 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAlertListCall<'a, C>
5014 where
5015 I: IntoIterator<Item = St>,
5016 St: AsRef<str>,
5017 {
5018 self._scopes
5019 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5020 self
5021 }
5022
5023 /// Removes all scopes, and no default scope will be used either.
5024 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5025 /// for details).
5026 pub fn clear_scopes(mut self) -> AccountAlertListCall<'a, C> {
5027 self._scopes.clear();
5028 self
5029 }
5030}
5031
5032/// List all ad units in the specified custom channel.
5033///
5034/// A builder for the *customchannels.adunits.list* method supported by a *account* resource.
5035/// It is not used directly, but through a [`AccountMethods`] instance.
5036///
5037/// # Example
5038///
5039/// Instantiate a resource method builder
5040///
5041/// ```test_harness,no_run
5042/// # extern crate hyper;
5043/// # extern crate hyper_rustls;
5044/// # extern crate google_adsense1d4 as adsense1d4;
5045/// # async fn dox() {
5046/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5047///
5048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5050/// # .with_native_roots()
5051/// # .unwrap()
5052/// # .https_only()
5053/// # .enable_http2()
5054/// # .build();
5055///
5056/// # let executor = hyper_util::rt::TokioExecutor::new();
5057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5058/// # secret,
5059/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5060/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5061/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5062/// # ),
5063/// # ).build().await.unwrap();
5064///
5065/// # let client = hyper_util::client::legacy::Client::builder(
5066/// # hyper_util::rt::TokioExecutor::new()
5067/// # )
5068/// # .build(
5069/// # hyper_rustls::HttpsConnectorBuilder::new()
5070/// # .with_native_roots()
5071/// # .unwrap()
5072/// # .https_or_http()
5073/// # .enable_http2()
5074/// # .build()
5075/// # );
5076/// # let mut hub = AdSense::new(client, auth);
5077/// // You can configure optional parameters by calling the respective setters at will, and
5078/// // execute the final call using `doit()`.
5079/// // Values shown here are possibly random and not representative !
5080/// let result = hub.accounts().customchannels_adunits_list("accountId", "adClientId", "customChannelId")
5081/// .page_token("vero")
5082/// .max_results(-88)
5083/// .include_inactive(true)
5084/// .doit().await;
5085/// # }
5086/// ```
5087pub struct AccountCustomchannelAdunitListCall<'a, C>
5088where
5089 C: 'a,
5090{
5091 hub: &'a AdSense<C>,
5092 _account_id: String,
5093 _ad_client_id: String,
5094 _custom_channel_id: String,
5095 _page_token: Option<String>,
5096 _max_results: Option<i32>,
5097 _include_inactive: Option<bool>,
5098 _delegate: Option<&'a mut dyn common::Delegate>,
5099 _additional_params: HashMap<String, String>,
5100 _scopes: BTreeSet<String>,
5101}
5102
5103impl<'a, C> common::CallBuilder for AccountCustomchannelAdunitListCall<'a, C> {}
5104
5105impl<'a, C> AccountCustomchannelAdunitListCall<'a, C>
5106where
5107 C: common::Connector,
5108{
5109 /// Perform the operation you have build so far.
5110 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnits)> {
5111 use std::borrow::Cow;
5112 use std::io::{Read, Seek};
5113
5114 use common::{url::Params, ToParts};
5115 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5116
5117 let mut dd = common::DefaultDelegate;
5118 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5119 dlg.begin(common::MethodInfo {
5120 id: "adsense.accounts.customchannels.adunits.list",
5121 http_method: hyper::Method::GET,
5122 });
5123
5124 for &field in [
5125 "alt",
5126 "accountId",
5127 "adClientId",
5128 "customChannelId",
5129 "pageToken",
5130 "maxResults",
5131 "includeInactive",
5132 ]
5133 .iter()
5134 {
5135 if self._additional_params.contains_key(field) {
5136 dlg.finished(false);
5137 return Err(common::Error::FieldClash(field));
5138 }
5139 }
5140
5141 let mut params = Params::with_capacity(8 + self._additional_params.len());
5142 params.push("accountId", self._account_id);
5143 params.push("adClientId", self._ad_client_id);
5144 params.push("customChannelId", self._custom_channel_id);
5145 if let Some(value) = self._page_token.as_ref() {
5146 params.push("pageToken", value);
5147 }
5148 if let Some(value) = self._max_results.as_ref() {
5149 params.push("maxResults", value.to_string());
5150 }
5151 if let Some(value) = self._include_inactive.as_ref() {
5152 params.push("includeInactive", value.to_string());
5153 }
5154
5155 params.extend(self._additional_params.iter());
5156
5157 params.push("alt", "json");
5158 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/customchannels/{customChannelId}/adunits";
5159 if self._scopes.is_empty() {
5160 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5161 }
5162
5163 #[allow(clippy::single_element_loop)]
5164 for &(find_this, param_name) in [
5165 ("{accountId}", "accountId"),
5166 ("{adClientId}", "adClientId"),
5167 ("{customChannelId}", "customChannelId"),
5168 ]
5169 .iter()
5170 {
5171 url = params.uri_replacement(url, param_name, find_this, false);
5172 }
5173 {
5174 let to_remove = ["customChannelId", "adClientId", "accountId"];
5175 params.remove_params(&to_remove);
5176 }
5177
5178 let url = params.parse_with_url(&url);
5179
5180 loop {
5181 let token = match self
5182 .hub
5183 .auth
5184 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5185 .await
5186 {
5187 Ok(token) => token,
5188 Err(e) => match dlg.token(e) {
5189 Ok(token) => token,
5190 Err(e) => {
5191 dlg.finished(false);
5192 return Err(common::Error::MissingToken(e));
5193 }
5194 },
5195 };
5196 let mut req_result = {
5197 let client = &self.hub.client;
5198 dlg.pre_request();
5199 let mut req_builder = hyper::Request::builder()
5200 .method(hyper::Method::GET)
5201 .uri(url.as_str())
5202 .header(USER_AGENT, self.hub._user_agent.clone());
5203
5204 if let Some(token) = token.as_ref() {
5205 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5206 }
5207
5208 let request = req_builder
5209 .header(CONTENT_LENGTH, 0_u64)
5210 .body(common::to_body::<String>(None));
5211
5212 client.request(request.unwrap()).await
5213 };
5214
5215 match req_result {
5216 Err(err) => {
5217 if let common::Retry::After(d) = dlg.http_error(&err) {
5218 sleep(d).await;
5219 continue;
5220 }
5221 dlg.finished(false);
5222 return Err(common::Error::HttpError(err));
5223 }
5224 Ok(res) => {
5225 let (mut parts, body) = res.into_parts();
5226 let mut body = common::Body::new(body);
5227 if !parts.status.is_success() {
5228 let bytes = common::to_bytes(body).await.unwrap_or_default();
5229 let error = serde_json::from_str(&common::to_string(&bytes));
5230 let response = common::to_response(parts, bytes.into());
5231
5232 if let common::Retry::After(d) =
5233 dlg.http_failure(&response, error.as_ref().ok())
5234 {
5235 sleep(d).await;
5236 continue;
5237 }
5238
5239 dlg.finished(false);
5240
5241 return Err(match error {
5242 Ok(value) => common::Error::BadRequest(value),
5243 _ => common::Error::Failure(response),
5244 });
5245 }
5246 let response = {
5247 let bytes = common::to_bytes(body).await.unwrap_or_default();
5248 let encoded = common::to_string(&bytes);
5249 match serde_json::from_str(&encoded) {
5250 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5251 Err(error) => {
5252 dlg.response_json_decode_error(&encoded, &error);
5253 return Err(common::Error::JsonDecodeError(
5254 encoded.to_string(),
5255 error,
5256 ));
5257 }
5258 }
5259 };
5260
5261 dlg.finished(true);
5262 return Ok(response);
5263 }
5264 }
5265 }
5266 }
5267
5268 /// Account to which the ad client belongs.
5269 ///
5270 /// Sets the *account id* path property to the given value.
5271 ///
5272 /// Even though the property as already been set when instantiating this call,
5273 /// we provide this method for API completeness.
5274 pub fn account_id(mut self, new_value: &str) -> AccountCustomchannelAdunitListCall<'a, C> {
5275 self._account_id = new_value.to_string();
5276 self
5277 }
5278 /// Ad client which contains the custom channel.
5279 ///
5280 /// Sets the *ad client id* path property to the given value.
5281 ///
5282 /// Even though the property as already been set when instantiating this call,
5283 /// we provide this method for API completeness.
5284 pub fn ad_client_id(mut self, new_value: &str) -> AccountCustomchannelAdunitListCall<'a, C> {
5285 self._ad_client_id = new_value.to_string();
5286 self
5287 }
5288 /// Custom channel for which to list ad units.
5289 ///
5290 /// Sets the *custom channel id* path property to the given value.
5291 ///
5292 /// Even though the property as already been set when instantiating this call,
5293 /// we provide this method for API completeness.
5294 pub fn custom_channel_id(
5295 mut self,
5296 new_value: &str,
5297 ) -> AccountCustomchannelAdunitListCall<'a, C> {
5298 self._custom_channel_id = new_value.to_string();
5299 self
5300 }
5301 /// A continuation token, used to page through ad units. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
5302 ///
5303 /// Sets the *page token* query property to the given value.
5304 pub fn page_token(mut self, new_value: &str) -> AccountCustomchannelAdunitListCall<'a, C> {
5305 self._page_token = Some(new_value.to_string());
5306 self
5307 }
5308 /// The maximum number of ad units to include in the response, used for paging.
5309 ///
5310 /// Sets the *max results* query property to the given value.
5311 pub fn max_results(mut self, new_value: i32) -> AccountCustomchannelAdunitListCall<'a, C> {
5312 self._max_results = Some(new_value);
5313 self
5314 }
5315 /// Whether to include inactive ad units. Default: true.
5316 ///
5317 /// Sets the *include inactive* query property to the given value.
5318 pub fn include_inactive(
5319 mut self,
5320 new_value: bool,
5321 ) -> AccountCustomchannelAdunitListCall<'a, C> {
5322 self._include_inactive = Some(new_value);
5323 self
5324 }
5325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5326 /// while executing the actual API request.
5327 ///
5328 /// ````text
5329 /// It should be used to handle progress information, and to implement a certain level of resilience.
5330 /// ````
5331 ///
5332 /// Sets the *delegate* property to the given value.
5333 pub fn delegate(
5334 mut self,
5335 new_value: &'a mut dyn common::Delegate,
5336 ) -> AccountCustomchannelAdunitListCall<'a, C> {
5337 self._delegate = Some(new_value);
5338 self
5339 }
5340
5341 /// Set any additional parameter of the query string used in the request.
5342 /// It should be used to set parameters which are not yet available through their own
5343 /// setters.
5344 ///
5345 /// Please note that this method must not be used to set any of the known parameters
5346 /// which have their own setter method. If done anyway, the request will fail.
5347 ///
5348 /// # Additional Parameters
5349 ///
5350 /// * *alt* (query-string) - Data format for the response.
5351 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5352 /// * *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.
5353 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5354 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5355 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5356 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5357 pub fn param<T>(mut self, name: T, value: T) -> AccountCustomchannelAdunitListCall<'a, C>
5358 where
5359 T: AsRef<str>,
5360 {
5361 self._additional_params
5362 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5363 self
5364 }
5365
5366 /// Identifies the authorization scope for the method you are building.
5367 ///
5368 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5369 /// [`Scope::Readonly`].
5370 ///
5371 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5372 /// tokens for more than one scope.
5373 ///
5374 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5375 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5376 /// sufficient, a read-write scope will do as well.
5377 pub fn add_scope<St>(mut self, scope: St) -> AccountCustomchannelAdunitListCall<'a, C>
5378 where
5379 St: AsRef<str>,
5380 {
5381 self._scopes.insert(String::from(scope.as_ref()));
5382 self
5383 }
5384 /// Identifies the authorization scope(s) for the method you are building.
5385 ///
5386 /// See [`Self::add_scope()`] for details.
5387 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountCustomchannelAdunitListCall<'a, C>
5388 where
5389 I: IntoIterator<Item = St>,
5390 St: AsRef<str>,
5391 {
5392 self._scopes
5393 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5394 self
5395 }
5396
5397 /// Removes all scopes, and no default scope will be used either.
5398 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5399 /// for details).
5400 pub fn clear_scopes(mut self) -> AccountCustomchannelAdunitListCall<'a, C> {
5401 self._scopes.clear();
5402 self
5403 }
5404}
5405
5406/// Get the specified custom channel from the specified ad client for the specified account.
5407///
5408/// A builder for the *customchannels.get* method supported by a *account* resource.
5409/// It is not used directly, but through a [`AccountMethods`] instance.
5410///
5411/// # Example
5412///
5413/// Instantiate a resource method builder
5414///
5415/// ```test_harness,no_run
5416/// # extern crate hyper;
5417/// # extern crate hyper_rustls;
5418/// # extern crate google_adsense1d4 as adsense1d4;
5419/// # async fn dox() {
5420/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5421///
5422/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5423/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5424/// # .with_native_roots()
5425/// # .unwrap()
5426/// # .https_only()
5427/// # .enable_http2()
5428/// # .build();
5429///
5430/// # let executor = hyper_util::rt::TokioExecutor::new();
5431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5432/// # secret,
5433/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5434/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5435/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5436/// # ),
5437/// # ).build().await.unwrap();
5438///
5439/// # let client = hyper_util::client::legacy::Client::builder(
5440/// # hyper_util::rt::TokioExecutor::new()
5441/// # )
5442/// # .build(
5443/// # hyper_rustls::HttpsConnectorBuilder::new()
5444/// # .with_native_roots()
5445/// # .unwrap()
5446/// # .https_or_http()
5447/// # .enable_http2()
5448/// # .build()
5449/// # );
5450/// # let mut hub = AdSense::new(client, auth);
5451/// // You can configure optional parameters by calling the respective setters at will, and
5452/// // execute the final call using `doit()`.
5453/// // Values shown here are possibly random and not representative !
5454/// let result = hub.accounts().customchannels_get("accountId", "adClientId", "customChannelId")
5455/// .doit().await;
5456/// # }
5457/// ```
5458pub struct AccountCustomchannelGetCall<'a, C>
5459where
5460 C: 'a,
5461{
5462 hub: &'a AdSense<C>,
5463 _account_id: String,
5464 _ad_client_id: String,
5465 _custom_channel_id: String,
5466 _delegate: Option<&'a mut dyn common::Delegate>,
5467 _additional_params: HashMap<String, String>,
5468 _scopes: BTreeSet<String>,
5469}
5470
5471impl<'a, C> common::CallBuilder for AccountCustomchannelGetCall<'a, C> {}
5472
5473impl<'a, C> AccountCustomchannelGetCall<'a, C>
5474where
5475 C: common::Connector,
5476{
5477 /// Perform the operation you have build so far.
5478 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
5479 use std::borrow::Cow;
5480 use std::io::{Read, Seek};
5481
5482 use common::{url::Params, ToParts};
5483 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5484
5485 let mut dd = common::DefaultDelegate;
5486 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5487 dlg.begin(common::MethodInfo {
5488 id: "adsense.accounts.customchannels.get",
5489 http_method: hyper::Method::GET,
5490 });
5491
5492 for &field in ["alt", "accountId", "adClientId", "customChannelId"].iter() {
5493 if self._additional_params.contains_key(field) {
5494 dlg.finished(false);
5495 return Err(common::Error::FieldClash(field));
5496 }
5497 }
5498
5499 let mut params = Params::with_capacity(5 + self._additional_params.len());
5500 params.push("accountId", self._account_id);
5501 params.push("adClientId", self._ad_client_id);
5502 params.push("customChannelId", self._custom_channel_id);
5503
5504 params.extend(self._additional_params.iter());
5505
5506 params.push("alt", "json");
5507 let mut url = self.hub._base_url.clone()
5508 + "accounts/{accountId}/adclients/{adClientId}/customchannels/{customChannelId}";
5509 if self._scopes.is_empty() {
5510 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5511 }
5512
5513 #[allow(clippy::single_element_loop)]
5514 for &(find_this, param_name) in [
5515 ("{accountId}", "accountId"),
5516 ("{adClientId}", "adClientId"),
5517 ("{customChannelId}", "customChannelId"),
5518 ]
5519 .iter()
5520 {
5521 url = params.uri_replacement(url, param_name, find_this, false);
5522 }
5523 {
5524 let to_remove = ["customChannelId", "adClientId", "accountId"];
5525 params.remove_params(&to_remove);
5526 }
5527
5528 let url = params.parse_with_url(&url);
5529
5530 loop {
5531 let token = match self
5532 .hub
5533 .auth
5534 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5535 .await
5536 {
5537 Ok(token) => token,
5538 Err(e) => match dlg.token(e) {
5539 Ok(token) => token,
5540 Err(e) => {
5541 dlg.finished(false);
5542 return Err(common::Error::MissingToken(e));
5543 }
5544 },
5545 };
5546 let mut req_result = {
5547 let client = &self.hub.client;
5548 dlg.pre_request();
5549 let mut req_builder = hyper::Request::builder()
5550 .method(hyper::Method::GET)
5551 .uri(url.as_str())
5552 .header(USER_AGENT, self.hub._user_agent.clone());
5553
5554 if let Some(token) = token.as_ref() {
5555 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5556 }
5557
5558 let request = req_builder
5559 .header(CONTENT_LENGTH, 0_u64)
5560 .body(common::to_body::<String>(None));
5561
5562 client.request(request.unwrap()).await
5563 };
5564
5565 match req_result {
5566 Err(err) => {
5567 if let common::Retry::After(d) = dlg.http_error(&err) {
5568 sleep(d).await;
5569 continue;
5570 }
5571 dlg.finished(false);
5572 return Err(common::Error::HttpError(err));
5573 }
5574 Ok(res) => {
5575 let (mut parts, body) = res.into_parts();
5576 let mut body = common::Body::new(body);
5577 if !parts.status.is_success() {
5578 let bytes = common::to_bytes(body).await.unwrap_or_default();
5579 let error = serde_json::from_str(&common::to_string(&bytes));
5580 let response = common::to_response(parts, bytes.into());
5581
5582 if let common::Retry::After(d) =
5583 dlg.http_failure(&response, error.as_ref().ok())
5584 {
5585 sleep(d).await;
5586 continue;
5587 }
5588
5589 dlg.finished(false);
5590
5591 return Err(match error {
5592 Ok(value) => common::Error::BadRequest(value),
5593 _ => common::Error::Failure(response),
5594 });
5595 }
5596 let response = {
5597 let bytes = common::to_bytes(body).await.unwrap_or_default();
5598 let encoded = common::to_string(&bytes);
5599 match serde_json::from_str(&encoded) {
5600 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5601 Err(error) => {
5602 dlg.response_json_decode_error(&encoded, &error);
5603 return Err(common::Error::JsonDecodeError(
5604 encoded.to_string(),
5605 error,
5606 ));
5607 }
5608 }
5609 };
5610
5611 dlg.finished(true);
5612 return Ok(response);
5613 }
5614 }
5615 }
5616 }
5617
5618 /// Account to which the ad client belongs.
5619 ///
5620 /// Sets the *account id* path property to the given value.
5621 ///
5622 /// Even though the property as already been set when instantiating this call,
5623 /// we provide this method for API completeness.
5624 pub fn account_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
5625 self._account_id = new_value.to_string();
5626 self
5627 }
5628 /// Ad client which contains the custom channel.
5629 ///
5630 /// Sets the *ad client id* path property to the given value.
5631 ///
5632 /// Even though the property as already been set when instantiating this call,
5633 /// we provide this method for API completeness.
5634 pub fn ad_client_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
5635 self._ad_client_id = new_value.to_string();
5636 self
5637 }
5638 /// Custom channel to retrieve.
5639 ///
5640 /// Sets the *custom channel id* path property to the given value.
5641 ///
5642 /// Even though the property as already been set when instantiating this call,
5643 /// we provide this method for API completeness.
5644 pub fn custom_channel_id(mut self, new_value: &str) -> AccountCustomchannelGetCall<'a, C> {
5645 self._custom_channel_id = new_value.to_string();
5646 self
5647 }
5648 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5649 /// while executing the actual API request.
5650 ///
5651 /// ````text
5652 /// It should be used to handle progress information, and to implement a certain level of resilience.
5653 /// ````
5654 ///
5655 /// Sets the *delegate* property to the given value.
5656 pub fn delegate(
5657 mut self,
5658 new_value: &'a mut dyn common::Delegate,
5659 ) -> AccountCustomchannelGetCall<'a, C> {
5660 self._delegate = Some(new_value);
5661 self
5662 }
5663
5664 /// Set any additional parameter of the query string used in the request.
5665 /// It should be used to set parameters which are not yet available through their own
5666 /// setters.
5667 ///
5668 /// Please note that this method must not be used to set any of the known parameters
5669 /// which have their own setter method. If done anyway, the request will fail.
5670 ///
5671 /// # Additional Parameters
5672 ///
5673 /// * *alt* (query-string) - Data format for the response.
5674 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5675 /// * *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.
5676 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5677 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5678 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5679 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5680 pub fn param<T>(mut self, name: T, value: T) -> AccountCustomchannelGetCall<'a, C>
5681 where
5682 T: AsRef<str>,
5683 {
5684 self._additional_params
5685 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5686 self
5687 }
5688
5689 /// Identifies the authorization scope for the method you are building.
5690 ///
5691 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5692 /// [`Scope::Readonly`].
5693 ///
5694 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5695 /// tokens for more than one scope.
5696 ///
5697 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5698 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5699 /// sufficient, a read-write scope will do as well.
5700 pub fn add_scope<St>(mut self, scope: St) -> AccountCustomchannelGetCall<'a, C>
5701 where
5702 St: AsRef<str>,
5703 {
5704 self._scopes.insert(String::from(scope.as_ref()));
5705 self
5706 }
5707 /// Identifies the authorization scope(s) for the method you are building.
5708 ///
5709 /// See [`Self::add_scope()`] for details.
5710 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountCustomchannelGetCall<'a, C>
5711 where
5712 I: IntoIterator<Item = St>,
5713 St: AsRef<str>,
5714 {
5715 self._scopes
5716 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5717 self
5718 }
5719
5720 /// Removes all scopes, and no default scope will be used either.
5721 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5722 /// for details).
5723 pub fn clear_scopes(mut self) -> AccountCustomchannelGetCall<'a, C> {
5724 self._scopes.clear();
5725 self
5726 }
5727}
5728
5729/// List all custom channels in the specified ad client for the specified account.
5730///
5731/// A builder for the *customchannels.list* method supported by a *account* resource.
5732/// It is not used directly, but through a [`AccountMethods`] instance.
5733///
5734/// # Example
5735///
5736/// Instantiate a resource method builder
5737///
5738/// ```test_harness,no_run
5739/// # extern crate hyper;
5740/// # extern crate hyper_rustls;
5741/// # extern crate google_adsense1d4 as adsense1d4;
5742/// # async fn dox() {
5743/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5744///
5745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5746/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5747/// # .with_native_roots()
5748/// # .unwrap()
5749/// # .https_only()
5750/// # .enable_http2()
5751/// # .build();
5752///
5753/// # let executor = hyper_util::rt::TokioExecutor::new();
5754/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5755/// # secret,
5756/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5757/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5758/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5759/// # ),
5760/// # ).build().await.unwrap();
5761///
5762/// # let client = hyper_util::client::legacy::Client::builder(
5763/// # hyper_util::rt::TokioExecutor::new()
5764/// # )
5765/// # .build(
5766/// # hyper_rustls::HttpsConnectorBuilder::new()
5767/// # .with_native_roots()
5768/// # .unwrap()
5769/// # .https_or_http()
5770/// # .enable_http2()
5771/// # .build()
5772/// # );
5773/// # let mut hub = AdSense::new(client, auth);
5774/// // You can configure optional parameters by calling the respective setters at will, and
5775/// // execute the final call using `doit()`.
5776/// // Values shown here are possibly random and not representative !
5777/// let result = hub.accounts().customchannels_list("accountId", "adClientId")
5778/// .page_token("ipsum")
5779/// .max_results(-23)
5780/// .doit().await;
5781/// # }
5782/// ```
5783pub struct AccountCustomchannelListCall<'a, C>
5784where
5785 C: 'a,
5786{
5787 hub: &'a AdSense<C>,
5788 _account_id: String,
5789 _ad_client_id: String,
5790 _page_token: Option<String>,
5791 _max_results: Option<i32>,
5792 _delegate: Option<&'a mut dyn common::Delegate>,
5793 _additional_params: HashMap<String, String>,
5794 _scopes: BTreeSet<String>,
5795}
5796
5797impl<'a, C> common::CallBuilder for AccountCustomchannelListCall<'a, C> {}
5798
5799impl<'a, C> AccountCustomchannelListCall<'a, C>
5800where
5801 C: common::Connector,
5802{
5803 /// Perform the operation you have build so far.
5804 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
5805 use std::borrow::Cow;
5806 use std::io::{Read, Seek};
5807
5808 use common::{url::Params, ToParts};
5809 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5810
5811 let mut dd = common::DefaultDelegate;
5812 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5813 dlg.begin(common::MethodInfo {
5814 id: "adsense.accounts.customchannels.list",
5815 http_method: hyper::Method::GET,
5816 });
5817
5818 for &field in ["alt", "accountId", "adClientId", "pageToken", "maxResults"].iter() {
5819 if self._additional_params.contains_key(field) {
5820 dlg.finished(false);
5821 return Err(common::Error::FieldClash(field));
5822 }
5823 }
5824
5825 let mut params = Params::with_capacity(6 + self._additional_params.len());
5826 params.push("accountId", self._account_id);
5827 params.push("adClientId", self._ad_client_id);
5828 if let Some(value) = self._page_token.as_ref() {
5829 params.push("pageToken", value);
5830 }
5831 if let Some(value) = self._max_results.as_ref() {
5832 params.push("maxResults", value.to_string());
5833 }
5834
5835 params.extend(self._additional_params.iter());
5836
5837 params.push("alt", "json");
5838 let mut url = self.hub._base_url.clone()
5839 + "accounts/{accountId}/adclients/{adClientId}/customchannels";
5840 if self._scopes.is_empty() {
5841 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5842 }
5843
5844 #[allow(clippy::single_element_loop)]
5845 for &(find_this, param_name) in
5846 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
5847 {
5848 url = params.uri_replacement(url, param_name, find_this, false);
5849 }
5850 {
5851 let to_remove = ["adClientId", "accountId"];
5852 params.remove_params(&to_remove);
5853 }
5854
5855 let url = params.parse_with_url(&url);
5856
5857 loop {
5858 let token = match self
5859 .hub
5860 .auth
5861 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5862 .await
5863 {
5864 Ok(token) => token,
5865 Err(e) => match dlg.token(e) {
5866 Ok(token) => token,
5867 Err(e) => {
5868 dlg.finished(false);
5869 return Err(common::Error::MissingToken(e));
5870 }
5871 },
5872 };
5873 let mut req_result = {
5874 let client = &self.hub.client;
5875 dlg.pre_request();
5876 let mut req_builder = hyper::Request::builder()
5877 .method(hyper::Method::GET)
5878 .uri(url.as_str())
5879 .header(USER_AGENT, self.hub._user_agent.clone());
5880
5881 if let Some(token) = token.as_ref() {
5882 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5883 }
5884
5885 let request = req_builder
5886 .header(CONTENT_LENGTH, 0_u64)
5887 .body(common::to_body::<String>(None));
5888
5889 client.request(request.unwrap()).await
5890 };
5891
5892 match req_result {
5893 Err(err) => {
5894 if let common::Retry::After(d) = dlg.http_error(&err) {
5895 sleep(d).await;
5896 continue;
5897 }
5898 dlg.finished(false);
5899 return Err(common::Error::HttpError(err));
5900 }
5901 Ok(res) => {
5902 let (mut parts, body) = res.into_parts();
5903 let mut body = common::Body::new(body);
5904 if !parts.status.is_success() {
5905 let bytes = common::to_bytes(body).await.unwrap_or_default();
5906 let error = serde_json::from_str(&common::to_string(&bytes));
5907 let response = common::to_response(parts, bytes.into());
5908
5909 if let common::Retry::After(d) =
5910 dlg.http_failure(&response, error.as_ref().ok())
5911 {
5912 sleep(d).await;
5913 continue;
5914 }
5915
5916 dlg.finished(false);
5917
5918 return Err(match error {
5919 Ok(value) => common::Error::BadRequest(value),
5920 _ => common::Error::Failure(response),
5921 });
5922 }
5923 let response = {
5924 let bytes = common::to_bytes(body).await.unwrap_or_default();
5925 let encoded = common::to_string(&bytes);
5926 match serde_json::from_str(&encoded) {
5927 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5928 Err(error) => {
5929 dlg.response_json_decode_error(&encoded, &error);
5930 return Err(common::Error::JsonDecodeError(
5931 encoded.to_string(),
5932 error,
5933 ));
5934 }
5935 }
5936 };
5937
5938 dlg.finished(true);
5939 return Ok(response);
5940 }
5941 }
5942 }
5943 }
5944
5945 /// Account to which the ad client belongs.
5946 ///
5947 /// Sets the *account id* path property to the given value.
5948 ///
5949 /// Even though the property as already been set when instantiating this call,
5950 /// we provide this method for API completeness.
5951 pub fn account_id(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
5952 self._account_id = new_value.to_string();
5953 self
5954 }
5955 /// Ad client for which to list custom channels.
5956 ///
5957 /// Sets the *ad client id* path property to the given value.
5958 ///
5959 /// Even though the property as already been set when instantiating this call,
5960 /// we provide this method for API completeness.
5961 pub fn ad_client_id(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
5962 self._ad_client_id = new_value.to_string();
5963 self
5964 }
5965 /// 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.
5966 ///
5967 /// Sets the *page token* query property to the given value.
5968 pub fn page_token(mut self, new_value: &str) -> AccountCustomchannelListCall<'a, C> {
5969 self._page_token = Some(new_value.to_string());
5970 self
5971 }
5972 /// The maximum number of custom channels to include in the response, used for paging.
5973 ///
5974 /// Sets the *max results* query property to the given value.
5975 pub fn max_results(mut self, new_value: i32) -> AccountCustomchannelListCall<'a, C> {
5976 self._max_results = Some(new_value);
5977 self
5978 }
5979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5980 /// while executing the actual API request.
5981 ///
5982 /// ````text
5983 /// It should be used to handle progress information, and to implement a certain level of resilience.
5984 /// ````
5985 ///
5986 /// Sets the *delegate* property to the given value.
5987 pub fn delegate(
5988 mut self,
5989 new_value: &'a mut dyn common::Delegate,
5990 ) -> AccountCustomchannelListCall<'a, C> {
5991 self._delegate = Some(new_value);
5992 self
5993 }
5994
5995 /// Set any additional parameter of the query string used in the request.
5996 /// It should be used to set parameters which are not yet available through their own
5997 /// setters.
5998 ///
5999 /// Please note that this method must not be used to set any of the known parameters
6000 /// which have their own setter method. If done anyway, the request will fail.
6001 ///
6002 /// # Additional Parameters
6003 ///
6004 /// * *alt* (query-string) - Data format for the response.
6005 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6006 /// * *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.
6007 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6008 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6009 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6010 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6011 pub fn param<T>(mut self, name: T, value: T) -> AccountCustomchannelListCall<'a, C>
6012 where
6013 T: AsRef<str>,
6014 {
6015 self._additional_params
6016 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6017 self
6018 }
6019
6020 /// Identifies the authorization scope for the method you are building.
6021 ///
6022 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6023 /// [`Scope::Readonly`].
6024 ///
6025 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6026 /// tokens for more than one scope.
6027 ///
6028 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6029 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6030 /// sufficient, a read-write scope will do as well.
6031 pub fn add_scope<St>(mut self, scope: St) -> AccountCustomchannelListCall<'a, C>
6032 where
6033 St: AsRef<str>,
6034 {
6035 self._scopes.insert(String::from(scope.as_ref()));
6036 self
6037 }
6038 /// Identifies the authorization scope(s) for the method you are building.
6039 ///
6040 /// See [`Self::add_scope()`] for details.
6041 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountCustomchannelListCall<'a, C>
6042 where
6043 I: IntoIterator<Item = St>,
6044 St: AsRef<str>,
6045 {
6046 self._scopes
6047 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6048 self
6049 }
6050
6051 /// Removes all scopes, and no default scope will be used either.
6052 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6053 /// for details).
6054 pub fn clear_scopes(mut self) -> AccountCustomchannelListCall<'a, C> {
6055 self._scopes.clear();
6056 self
6057 }
6058}
6059
6060/// List the payments for the specified AdSense account.
6061///
6062/// A builder for the *payments.list* method supported by a *account* resource.
6063/// It is not used directly, but through a [`AccountMethods`] instance.
6064///
6065/// # Example
6066///
6067/// Instantiate a resource method builder
6068///
6069/// ```test_harness,no_run
6070/// # extern crate hyper;
6071/// # extern crate hyper_rustls;
6072/// # extern crate google_adsense1d4 as adsense1d4;
6073/// # async fn dox() {
6074/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6075///
6076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6078/// # .with_native_roots()
6079/// # .unwrap()
6080/// # .https_only()
6081/// # .enable_http2()
6082/// # .build();
6083///
6084/// # let executor = hyper_util::rt::TokioExecutor::new();
6085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6086/// # secret,
6087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6090/// # ),
6091/// # ).build().await.unwrap();
6092///
6093/// # let client = hyper_util::client::legacy::Client::builder(
6094/// # hyper_util::rt::TokioExecutor::new()
6095/// # )
6096/// # .build(
6097/// # hyper_rustls::HttpsConnectorBuilder::new()
6098/// # .with_native_roots()
6099/// # .unwrap()
6100/// # .https_or_http()
6101/// # .enable_http2()
6102/// # .build()
6103/// # );
6104/// # let mut hub = AdSense::new(client, auth);
6105/// // You can configure optional parameters by calling the respective setters at will, and
6106/// // execute the final call using `doit()`.
6107/// // Values shown here are possibly random and not representative !
6108/// let result = hub.accounts().payments_list("accountId")
6109/// .doit().await;
6110/// # }
6111/// ```
6112pub struct AccountPaymentListCall<'a, C>
6113where
6114 C: 'a,
6115{
6116 hub: &'a AdSense<C>,
6117 _account_id: String,
6118 _delegate: Option<&'a mut dyn common::Delegate>,
6119 _additional_params: HashMap<String, String>,
6120 _scopes: BTreeSet<String>,
6121}
6122
6123impl<'a, C> common::CallBuilder for AccountPaymentListCall<'a, C> {}
6124
6125impl<'a, C> AccountPaymentListCall<'a, C>
6126where
6127 C: common::Connector,
6128{
6129 /// Perform the operation you have build so far.
6130 pub async fn doit(mut self) -> common::Result<(common::Response, Payments)> {
6131 use std::borrow::Cow;
6132 use std::io::{Read, Seek};
6133
6134 use common::{url::Params, ToParts};
6135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6136
6137 let mut dd = common::DefaultDelegate;
6138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6139 dlg.begin(common::MethodInfo {
6140 id: "adsense.accounts.payments.list",
6141 http_method: hyper::Method::GET,
6142 });
6143
6144 for &field in ["alt", "accountId"].iter() {
6145 if self._additional_params.contains_key(field) {
6146 dlg.finished(false);
6147 return Err(common::Error::FieldClash(field));
6148 }
6149 }
6150
6151 let mut params = Params::with_capacity(3 + self._additional_params.len());
6152 params.push("accountId", self._account_id);
6153
6154 params.extend(self._additional_params.iter());
6155
6156 params.push("alt", "json");
6157 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/payments";
6158 if self._scopes.is_empty() {
6159 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6160 }
6161
6162 #[allow(clippy::single_element_loop)]
6163 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
6164 url = params.uri_replacement(url, param_name, find_this, false);
6165 }
6166 {
6167 let to_remove = ["accountId"];
6168 params.remove_params(&to_remove);
6169 }
6170
6171 let url = params.parse_with_url(&url);
6172
6173 loop {
6174 let token = match self
6175 .hub
6176 .auth
6177 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6178 .await
6179 {
6180 Ok(token) => token,
6181 Err(e) => match dlg.token(e) {
6182 Ok(token) => token,
6183 Err(e) => {
6184 dlg.finished(false);
6185 return Err(common::Error::MissingToken(e));
6186 }
6187 },
6188 };
6189 let mut req_result = {
6190 let client = &self.hub.client;
6191 dlg.pre_request();
6192 let mut req_builder = hyper::Request::builder()
6193 .method(hyper::Method::GET)
6194 .uri(url.as_str())
6195 .header(USER_AGENT, self.hub._user_agent.clone());
6196
6197 if let Some(token) = token.as_ref() {
6198 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6199 }
6200
6201 let request = req_builder
6202 .header(CONTENT_LENGTH, 0_u64)
6203 .body(common::to_body::<String>(None));
6204
6205 client.request(request.unwrap()).await
6206 };
6207
6208 match req_result {
6209 Err(err) => {
6210 if let common::Retry::After(d) = dlg.http_error(&err) {
6211 sleep(d).await;
6212 continue;
6213 }
6214 dlg.finished(false);
6215 return Err(common::Error::HttpError(err));
6216 }
6217 Ok(res) => {
6218 let (mut parts, body) = res.into_parts();
6219 let mut body = common::Body::new(body);
6220 if !parts.status.is_success() {
6221 let bytes = common::to_bytes(body).await.unwrap_or_default();
6222 let error = serde_json::from_str(&common::to_string(&bytes));
6223 let response = common::to_response(parts, bytes.into());
6224
6225 if let common::Retry::After(d) =
6226 dlg.http_failure(&response, error.as_ref().ok())
6227 {
6228 sleep(d).await;
6229 continue;
6230 }
6231
6232 dlg.finished(false);
6233
6234 return Err(match error {
6235 Ok(value) => common::Error::BadRequest(value),
6236 _ => common::Error::Failure(response),
6237 });
6238 }
6239 let response = {
6240 let bytes = common::to_bytes(body).await.unwrap_or_default();
6241 let encoded = common::to_string(&bytes);
6242 match serde_json::from_str(&encoded) {
6243 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6244 Err(error) => {
6245 dlg.response_json_decode_error(&encoded, &error);
6246 return Err(common::Error::JsonDecodeError(
6247 encoded.to_string(),
6248 error,
6249 ));
6250 }
6251 }
6252 };
6253
6254 dlg.finished(true);
6255 return Ok(response);
6256 }
6257 }
6258 }
6259 }
6260
6261 /// Account for which to retrieve the payments.
6262 ///
6263 /// Sets the *account id* path property to the given value.
6264 ///
6265 /// Even though the property as already been set when instantiating this call,
6266 /// we provide this method for API completeness.
6267 pub fn account_id(mut self, new_value: &str) -> AccountPaymentListCall<'a, C> {
6268 self._account_id = new_value.to_string();
6269 self
6270 }
6271 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6272 /// while executing the actual API request.
6273 ///
6274 /// ````text
6275 /// It should be used to handle progress information, and to implement a certain level of resilience.
6276 /// ````
6277 ///
6278 /// Sets the *delegate* property to the given value.
6279 pub fn delegate(
6280 mut self,
6281 new_value: &'a mut dyn common::Delegate,
6282 ) -> AccountPaymentListCall<'a, C> {
6283 self._delegate = Some(new_value);
6284 self
6285 }
6286
6287 /// Set any additional parameter of the query string used in the request.
6288 /// It should be used to set parameters which are not yet available through their own
6289 /// setters.
6290 ///
6291 /// Please note that this method must not be used to set any of the known parameters
6292 /// which have their own setter method. If done anyway, the request will fail.
6293 ///
6294 /// # Additional Parameters
6295 ///
6296 /// * *alt* (query-string) - Data format for the response.
6297 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6298 /// * *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.
6299 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6300 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6301 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6302 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6303 pub fn param<T>(mut self, name: T, value: T) -> AccountPaymentListCall<'a, C>
6304 where
6305 T: AsRef<str>,
6306 {
6307 self._additional_params
6308 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6309 self
6310 }
6311
6312 /// Identifies the authorization scope for the method you are building.
6313 ///
6314 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6315 /// [`Scope::Readonly`].
6316 ///
6317 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6318 /// tokens for more than one scope.
6319 ///
6320 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6321 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6322 /// sufficient, a read-write scope will do as well.
6323 pub fn add_scope<St>(mut self, scope: St) -> AccountPaymentListCall<'a, C>
6324 where
6325 St: AsRef<str>,
6326 {
6327 self._scopes.insert(String::from(scope.as_ref()));
6328 self
6329 }
6330 /// Identifies the authorization scope(s) for the method you are building.
6331 ///
6332 /// See [`Self::add_scope()`] for details.
6333 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPaymentListCall<'a, C>
6334 where
6335 I: IntoIterator<Item = St>,
6336 St: AsRef<str>,
6337 {
6338 self._scopes
6339 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6340 self
6341 }
6342
6343 /// Removes all scopes, and no default scope will be used either.
6344 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6345 /// for details).
6346 pub fn clear_scopes(mut self) -> AccountPaymentListCall<'a, C> {
6347 self._scopes.clear();
6348 self
6349 }
6350}
6351
6352/// Generate an AdSense report based on the saved report ID sent in the query parameters.
6353///
6354/// A builder for the *reports.saved.generate* method supported by a *account* resource.
6355/// It is not used directly, but through a [`AccountMethods`] instance.
6356///
6357/// # Example
6358///
6359/// Instantiate a resource method builder
6360///
6361/// ```test_harness,no_run
6362/// # extern crate hyper;
6363/// # extern crate hyper_rustls;
6364/// # extern crate google_adsense1d4 as adsense1d4;
6365/// # async fn dox() {
6366/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6367///
6368/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6369/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6370/// # .with_native_roots()
6371/// # .unwrap()
6372/// # .https_only()
6373/// # .enable_http2()
6374/// # .build();
6375///
6376/// # let executor = hyper_util::rt::TokioExecutor::new();
6377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6378/// # secret,
6379/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6380/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6381/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6382/// # ),
6383/// # ).build().await.unwrap();
6384///
6385/// # let client = hyper_util::client::legacy::Client::builder(
6386/// # hyper_util::rt::TokioExecutor::new()
6387/// # )
6388/// # .build(
6389/// # hyper_rustls::HttpsConnectorBuilder::new()
6390/// # .with_native_roots()
6391/// # .unwrap()
6392/// # .https_or_http()
6393/// # .enable_http2()
6394/// # .build()
6395/// # );
6396/// # let mut hub = AdSense::new(client, auth);
6397/// // You can configure optional parameters by calling the respective setters at will, and
6398/// // execute the final call using `doit()`.
6399/// // Values shown here are possibly random and not representative !
6400/// let result = hub.accounts().reports_saved_generate("accountId", "savedReportId")
6401/// .start_index(-72)
6402/// .max_results(-31)
6403/// .locale("consetetur")
6404/// .doit().await;
6405/// # }
6406/// ```
6407pub struct AccountReportSavedGenerateCall<'a, C>
6408where
6409 C: 'a,
6410{
6411 hub: &'a AdSense<C>,
6412 _account_id: String,
6413 _saved_report_id: String,
6414 _start_index: Option<i32>,
6415 _max_results: Option<i32>,
6416 _locale: Option<String>,
6417 _delegate: Option<&'a mut dyn common::Delegate>,
6418 _additional_params: HashMap<String, String>,
6419 _scopes: BTreeSet<String>,
6420}
6421
6422impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCall<'a, C> {}
6423
6424impl<'a, C> AccountReportSavedGenerateCall<'a, C>
6425where
6426 C: common::Connector,
6427{
6428 /// Perform the operation you have build so far.
6429 pub async fn doit(
6430 mut self,
6431 ) -> common::Result<(common::Response, AdsenseReportsGenerateResponse)> {
6432 use std::borrow::Cow;
6433 use std::io::{Read, Seek};
6434
6435 use common::{url::Params, ToParts};
6436 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6437
6438 let mut dd = common::DefaultDelegate;
6439 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6440 dlg.begin(common::MethodInfo {
6441 id: "adsense.accounts.reports.saved.generate",
6442 http_method: hyper::Method::GET,
6443 });
6444
6445 for &field in [
6446 "alt",
6447 "accountId",
6448 "savedReportId",
6449 "startIndex",
6450 "maxResults",
6451 "locale",
6452 ]
6453 .iter()
6454 {
6455 if self._additional_params.contains_key(field) {
6456 dlg.finished(false);
6457 return Err(common::Error::FieldClash(field));
6458 }
6459 }
6460
6461 let mut params = Params::with_capacity(7 + self._additional_params.len());
6462 params.push("accountId", self._account_id);
6463 params.push("savedReportId", self._saved_report_id);
6464 if let Some(value) = self._start_index.as_ref() {
6465 params.push("startIndex", value.to_string());
6466 }
6467 if let Some(value) = self._max_results.as_ref() {
6468 params.push("maxResults", value.to_string());
6469 }
6470 if let Some(value) = self._locale.as_ref() {
6471 params.push("locale", value);
6472 }
6473
6474 params.extend(self._additional_params.iter());
6475
6476 params.push("alt", "json");
6477 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports/{savedReportId}";
6478 if self._scopes.is_empty() {
6479 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6480 }
6481
6482 #[allow(clippy::single_element_loop)]
6483 for &(find_this, param_name) in [
6484 ("{accountId}", "accountId"),
6485 ("{savedReportId}", "savedReportId"),
6486 ]
6487 .iter()
6488 {
6489 url = params.uri_replacement(url, param_name, find_this, false);
6490 }
6491 {
6492 let to_remove = ["savedReportId", "accountId"];
6493 params.remove_params(&to_remove);
6494 }
6495
6496 let url = params.parse_with_url(&url);
6497
6498 loop {
6499 let token = match self
6500 .hub
6501 .auth
6502 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6503 .await
6504 {
6505 Ok(token) => token,
6506 Err(e) => match dlg.token(e) {
6507 Ok(token) => token,
6508 Err(e) => {
6509 dlg.finished(false);
6510 return Err(common::Error::MissingToken(e));
6511 }
6512 },
6513 };
6514 let mut req_result = {
6515 let client = &self.hub.client;
6516 dlg.pre_request();
6517 let mut req_builder = hyper::Request::builder()
6518 .method(hyper::Method::GET)
6519 .uri(url.as_str())
6520 .header(USER_AGENT, self.hub._user_agent.clone());
6521
6522 if let Some(token) = token.as_ref() {
6523 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6524 }
6525
6526 let request = req_builder
6527 .header(CONTENT_LENGTH, 0_u64)
6528 .body(common::to_body::<String>(None));
6529
6530 client.request(request.unwrap()).await
6531 };
6532
6533 match req_result {
6534 Err(err) => {
6535 if let common::Retry::After(d) = dlg.http_error(&err) {
6536 sleep(d).await;
6537 continue;
6538 }
6539 dlg.finished(false);
6540 return Err(common::Error::HttpError(err));
6541 }
6542 Ok(res) => {
6543 let (mut parts, body) = res.into_parts();
6544 let mut body = common::Body::new(body);
6545 if !parts.status.is_success() {
6546 let bytes = common::to_bytes(body).await.unwrap_or_default();
6547 let error = serde_json::from_str(&common::to_string(&bytes));
6548 let response = common::to_response(parts, bytes.into());
6549
6550 if let common::Retry::After(d) =
6551 dlg.http_failure(&response, error.as_ref().ok())
6552 {
6553 sleep(d).await;
6554 continue;
6555 }
6556
6557 dlg.finished(false);
6558
6559 return Err(match error {
6560 Ok(value) => common::Error::BadRequest(value),
6561 _ => common::Error::Failure(response),
6562 });
6563 }
6564 let response = {
6565 let bytes = common::to_bytes(body).await.unwrap_or_default();
6566 let encoded = common::to_string(&bytes);
6567 match serde_json::from_str(&encoded) {
6568 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6569 Err(error) => {
6570 dlg.response_json_decode_error(&encoded, &error);
6571 return Err(common::Error::JsonDecodeError(
6572 encoded.to_string(),
6573 error,
6574 ));
6575 }
6576 }
6577 };
6578
6579 dlg.finished(true);
6580 return Ok(response);
6581 }
6582 }
6583 }
6584 }
6585
6586 /// Account to which the saved reports belong.
6587 ///
6588 /// Sets the *account id* path property to the given value.
6589 ///
6590 /// Even though the property as already been set when instantiating this call,
6591 /// we provide this method for API completeness.
6592 pub fn account_id(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
6593 self._account_id = new_value.to_string();
6594 self
6595 }
6596 /// The saved report to retrieve.
6597 ///
6598 /// Sets the *saved report id* path property to the given value.
6599 ///
6600 /// Even though the property as already been set when instantiating this call,
6601 /// we provide this method for API completeness.
6602 pub fn saved_report_id(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
6603 self._saved_report_id = new_value.to_string();
6604 self
6605 }
6606 /// Index of the first row of report data to return.
6607 ///
6608 /// Sets the *start index* query property to the given value.
6609 pub fn start_index(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
6610 self._start_index = Some(new_value);
6611 self
6612 }
6613 /// The maximum number of rows of report data to return.
6614 ///
6615 /// Sets the *max results* query property to the given value.
6616 pub fn max_results(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
6617 self._max_results = Some(new_value);
6618 self
6619 }
6620 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
6621 ///
6622 /// Sets the *locale* query property to the given value.
6623 pub fn locale(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
6624 self._locale = Some(new_value.to_string());
6625 self
6626 }
6627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6628 /// while executing the actual API request.
6629 ///
6630 /// ````text
6631 /// It should be used to handle progress information, and to implement a certain level of resilience.
6632 /// ````
6633 ///
6634 /// Sets the *delegate* property to the given value.
6635 pub fn delegate(
6636 mut self,
6637 new_value: &'a mut dyn common::Delegate,
6638 ) -> AccountReportSavedGenerateCall<'a, C> {
6639 self._delegate = Some(new_value);
6640 self
6641 }
6642
6643 /// Set any additional parameter of the query string used in the request.
6644 /// It should be used to set parameters which are not yet available through their own
6645 /// setters.
6646 ///
6647 /// Please note that this method must not be used to set any of the known parameters
6648 /// which have their own setter method. If done anyway, the request will fail.
6649 ///
6650 /// # Additional Parameters
6651 ///
6652 /// * *alt* (query-string) - Data format for the response.
6653 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6654 /// * *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.
6655 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6656 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6657 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6658 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6659 pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCall<'a, C>
6660 where
6661 T: AsRef<str>,
6662 {
6663 self._additional_params
6664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6665 self
6666 }
6667
6668 /// Identifies the authorization scope for the method you are building.
6669 ///
6670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6671 /// [`Scope::Readonly`].
6672 ///
6673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6674 /// tokens for more than one scope.
6675 ///
6676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6678 /// sufficient, a read-write scope will do as well.
6679 pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCall<'a, C>
6680 where
6681 St: AsRef<str>,
6682 {
6683 self._scopes.insert(String::from(scope.as_ref()));
6684 self
6685 }
6686 /// Identifies the authorization scope(s) for the method you are building.
6687 ///
6688 /// See [`Self::add_scope()`] for details.
6689 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCall<'a, C>
6690 where
6691 I: IntoIterator<Item = St>,
6692 St: AsRef<str>,
6693 {
6694 self._scopes
6695 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6696 self
6697 }
6698
6699 /// Removes all scopes, and no default scope will be used either.
6700 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6701 /// for details).
6702 pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCall<'a, C> {
6703 self._scopes.clear();
6704 self
6705 }
6706}
6707
6708/// List all saved reports in the specified AdSense account.
6709///
6710/// A builder for the *reports.saved.list* method supported by a *account* resource.
6711/// It is not used directly, but through a [`AccountMethods`] instance.
6712///
6713/// # Example
6714///
6715/// Instantiate a resource method builder
6716///
6717/// ```test_harness,no_run
6718/// # extern crate hyper;
6719/// # extern crate hyper_rustls;
6720/// # extern crate google_adsense1d4 as adsense1d4;
6721/// # async fn dox() {
6722/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6723///
6724/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6725/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6726/// # .with_native_roots()
6727/// # .unwrap()
6728/// # .https_only()
6729/// # .enable_http2()
6730/// # .build();
6731///
6732/// # let executor = hyper_util::rt::TokioExecutor::new();
6733/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6734/// # secret,
6735/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6736/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6737/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6738/// # ),
6739/// # ).build().await.unwrap();
6740///
6741/// # let client = hyper_util::client::legacy::Client::builder(
6742/// # hyper_util::rt::TokioExecutor::new()
6743/// # )
6744/// # .build(
6745/// # hyper_rustls::HttpsConnectorBuilder::new()
6746/// # .with_native_roots()
6747/// # .unwrap()
6748/// # .https_or_http()
6749/// # .enable_http2()
6750/// # .build()
6751/// # );
6752/// # let mut hub = AdSense::new(client, auth);
6753/// // You can configure optional parameters by calling the respective setters at will, and
6754/// // execute the final call using `doit()`.
6755/// // Values shown here are possibly random and not representative !
6756/// let result = hub.accounts().reports_saved_list("accountId")
6757/// .page_token("sed")
6758/// .max_results(-9)
6759/// .doit().await;
6760/// # }
6761/// ```
6762pub struct AccountReportSavedListCall<'a, C>
6763where
6764 C: 'a,
6765{
6766 hub: &'a AdSense<C>,
6767 _account_id: String,
6768 _page_token: Option<String>,
6769 _max_results: Option<i32>,
6770 _delegate: Option<&'a mut dyn common::Delegate>,
6771 _additional_params: HashMap<String, String>,
6772 _scopes: BTreeSet<String>,
6773}
6774
6775impl<'a, C> common::CallBuilder for AccountReportSavedListCall<'a, C> {}
6776
6777impl<'a, C> AccountReportSavedListCall<'a, C>
6778where
6779 C: common::Connector,
6780{
6781 /// Perform the operation you have build so far.
6782 pub async fn doit(mut self) -> common::Result<(common::Response, SavedReports)> {
6783 use std::borrow::Cow;
6784 use std::io::{Read, Seek};
6785
6786 use common::{url::Params, ToParts};
6787 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6788
6789 let mut dd = common::DefaultDelegate;
6790 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6791 dlg.begin(common::MethodInfo {
6792 id: "adsense.accounts.reports.saved.list",
6793 http_method: hyper::Method::GET,
6794 });
6795
6796 for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
6797 if self._additional_params.contains_key(field) {
6798 dlg.finished(false);
6799 return Err(common::Error::FieldClash(field));
6800 }
6801 }
6802
6803 let mut params = Params::with_capacity(5 + self._additional_params.len());
6804 params.push("accountId", self._account_id);
6805 if let Some(value) = self._page_token.as_ref() {
6806 params.push("pageToken", value);
6807 }
6808 if let Some(value) = self._max_results.as_ref() {
6809 params.push("maxResults", value.to_string());
6810 }
6811
6812 params.extend(self._additional_params.iter());
6813
6814 params.push("alt", "json");
6815 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports/saved";
6816 if self._scopes.is_empty() {
6817 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6818 }
6819
6820 #[allow(clippy::single_element_loop)]
6821 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
6822 url = params.uri_replacement(url, param_name, find_this, false);
6823 }
6824 {
6825 let to_remove = ["accountId"];
6826 params.remove_params(&to_remove);
6827 }
6828
6829 let url = params.parse_with_url(&url);
6830
6831 loop {
6832 let token = match self
6833 .hub
6834 .auth
6835 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6836 .await
6837 {
6838 Ok(token) => token,
6839 Err(e) => match dlg.token(e) {
6840 Ok(token) => token,
6841 Err(e) => {
6842 dlg.finished(false);
6843 return Err(common::Error::MissingToken(e));
6844 }
6845 },
6846 };
6847 let mut req_result = {
6848 let client = &self.hub.client;
6849 dlg.pre_request();
6850 let mut req_builder = hyper::Request::builder()
6851 .method(hyper::Method::GET)
6852 .uri(url.as_str())
6853 .header(USER_AGENT, self.hub._user_agent.clone());
6854
6855 if let Some(token) = token.as_ref() {
6856 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6857 }
6858
6859 let request = req_builder
6860 .header(CONTENT_LENGTH, 0_u64)
6861 .body(common::to_body::<String>(None));
6862
6863 client.request(request.unwrap()).await
6864 };
6865
6866 match req_result {
6867 Err(err) => {
6868 if let common::Retry::After(d) = dlg.http_error(&err) {
6869 sleep(d).await;
6870 continue;
6871 }
6872 dlg.finished(false);
6873 return Err(common::Error::HttpError(err));
6874 }
6875 Ok(res) => {
6876 let (mut parts, body) = res.into_parts();
6877 let mut body = common::Body::new(body);
6878 if !parts.status.is_success() {
6879 let bytes = common::to_bytes(body).await.unwrap_or_default();
6880 let error = serde_json::from_str(&common::to_string(&bytes));
6881 let response = common::to_response(parts, bytes.into());
6882
6883 if let common::Retry::After(d) =
6884 dlg.http_failure(&response, error.as_ref().ok())
6885 {
6886 sleep(d).await;
6887 continue;
6888 }
6889
6890 dlg.finished(false);
6891
6892 return Err(match error {
6893 Ok(value) => common::Error::BadRequest(value),
6894 _ => common::Error::Failure(response),
6895 });
6896 }
6897 let response = {
6898 let bytes = common::to_bytes(body).await.unwrap_or_default();
6899 let encoded = common::to_string(&bytes);
6900 match serde_json::from_str(&encoded) {
6901 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6902 Err(error) => {
6903 dlg.response_json_decode_error(&encoded, &error);
6904 return Err(common::Error::JsonDecodeError(
6905 encoded.to_string(),
6906 error,
6907 ));
6908 }
6909 }
6910 };
6911
6912 dlg.finished(true);
6913 return Ok(response);
6914 }
6915 }
6916 }
6917 }
6918
6919 /// Account to which the saved reports belong.
6920 ///
6921 /// Sets the *account id* path property to the given value.
6922 ///
6923 /// Even though the property as already been set when instantiating this call,
6924 /// we provide this method for API completeness.
6925 pub fn account_id(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
6926 self._account_id = new_value.to_string();
6927 self
6928 }
6929 /// 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.
6930 ///
6931 /// Sets the *page token* query property to the given value.
6932 pub fn page_token(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
6933 self._page_token = Some(new_value.to_string());
6934 self
6935 }
6936 /// The maximum number of saved reports to include in the response, used for paging.
6937 ///
6938 /// Sets the *max results* query property to the given value.
6939 pub fn max_results(mut self, new_value: i32) -> AccountReportSavedListCall<'a, C> {
6940 self._max_results = Some(new_value);
6941 self
6942 }
6943 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6944 /// while executing the actual API request.
6945 ///
6946 /// ````text
6947 /// It should be used to handle progress information, and to implement a certain level of resilience.
6948 /// ````
6949 ///
6950 /// Sets the *delegate* property to the given value.
6951 pub fn delegate(
6952 mut self,
6953 new_value: &'a mut dyn common::Delegate,
6954 ) -> AccountReportSavedListCall<'a, C> {
6955 self._delegate = Some(new_value);
6956 self
6957 }
6958
6959 /// Set any additional parameter of the query string used in the request.
6960 /// It should be used to set parameters which are not yet available through their own
6961 /// setters.
6962 ///
6963 /// Please note that this method must not be used to set any of the known parameters
6964 /// which have their own setter method. If done anyway, the request will fail.
6965 ///
6966 /// # Additional Parameters
6967 ///
6968 /// * *alt* (query-string) - Data format for the response.
6969 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6970 /// * *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.
6971 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6972 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6973 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6974 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6975 pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedListCall<'a, C>
6976 where
6977 T: AsRef<str>,
6978 {
6979 self._additional_params
6980 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6981 self
6982 }
6983
6984 /// Identifies the authorization scope for the method you are building.
6985 ///
6986 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6987 /// [`Scope::Readonly`].
6988 ///
6989 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6990 /// tokens for more than one scope.
6991 ///
6992 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6993 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6994 /// sufficient, a read-write scope will do as well.
6995 pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedListCall<'a, C>
6996 where
6997 St: AsRef<str>,
6998 {
6999 self._scopes.insert(String::from(scope.as_ref()));
7000 self
7001 }
7002 /// Identifies the authorization scope(s) for the method you are building.
7003 ///
7004 /// See [`Self::add_scope()`] for details.
7005 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedListCall<'a, C>
7006 where
7007 I: IntoIterator<Item = St>,
7008 St: AsRef<str>,
7009 {
7010 self._scopes
7011 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7012 self
7013 }
7014
7015 /// Removes all scopes, and no default scope will be used either.
7016 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7017 /// for details).
7018 pub fn clear_scopes(mut self) -> AccountReportSavedListCall<'a, C> {
7019 self._scopes.clear();
7020 self
7021 }
7022}
7023
7024/// Generate an AdSense 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.
7025///
7026/// This method supports **media download**. To enable it, adjust the builder like this:
7027/// `.param("alt", "media")`.
7028/// Please note that due to missing multi-part support on the server side, you will only receive the media,
7029/// but not the `AdsenseReportsGenerateResponse` structure that you would usually get. The latter will be a default value.
7030///
7031/// A builder for the *reports.generate* method supported by a *account* resource.
7032/// It is not used directly, but through a [`AccountMethods`] instance.
7033///
7034/// # Example
7035///
7036/// Instantiate a resource method builder
7037///
7038/// ```test_harness,no_run
7039/// # extern crate hyper;
7040/// # extern crate hyper_rustls;
7041/// # extern crate google_adsense1d4 as adsense1d4;
7042/// # async fn dox() {
7043/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7044///
7045/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7046/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7047/// # .with_native_roots()
7048/// # .unwrap()
7049/// # .https_only()
7050/// # .enable_http2()
7051/// # .build();
7052///
7053/// # let executor = hyper_util::rt::TokioExecutor::new();
7054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7055/// # secret,
7056/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7057/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7058/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7059/// # ),
7060/// # ).build().await.unwrap();
7061///
7062/// # let client = hyper_util::client::legacy::Client::builder(
7063/// # hyper_util::rt::TokioExecutor::new()
7064/// # )
7065/// # .build(
7066/// # hyper_rustls::HttpsConnectorBuilder::new()
7067/// # .with_native_roots()
7068/// # .unwrap()
7069/// # .https_or_http()
7070/// # .enable_http2()
7071/// # .build()
7072/// # );
7073/// # let mut hub = AdSense::new(client, auth);
7074/// // You can configure optional parameters by calling the respective setters at will, and
7075/// // execute the final call using `doit()`.
7076/// // Values shown here are possibly random and not representative !
7077/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
7078/// .use_timezone_reporting(false)
7079/// .start_index(-34)
7080/// .add_sort("dolore")
7081/// .add_metric("dolore")
7082/// .max_results(-78)
7083/// .locale("amet.")
7084/// .add_filter("ea")
7085/// .add_dimension("sadipscing")
7086/// .currency("Lorem")
7087/// .doit().await;
7088/// # }
7089/// ```
7090pub struct AccountReportGenerateCall<'a, C>
7091where
7092 C: 'a,
7093{
7094 hub: &'a AdSense<C>,
7095 _account_id: String,
7096 _start_date: String,
7097 _end_date: String,
7098 _use_timezone_reporting: Option<bool>,
7099 _start_index: Option<i32>,
7100 _sort: Vec<String>,
7101 _metric: Vec<String>,
7102 _max_results: Option<i32>,
7103 _locale: Option<String>,
7104 _filter: Vec<String>,
7105 _dimension: Vec<String>,
7106 _currency: Option<String>,
7107 _delegate: Option<&'a mut dyn common::Delegate>,
7108 _additional_params: HashMap<String, String>,
7109 _scopes: BTreeSet<String>,
7110}
7111
7112impl<'a, C> common::CallBuilder for AccountReportGenerateCall<'a, C> {}
7113
7114impl<'a, C> AccountReportGenerateCall<'a, C>
7115where
7116 C: common::Connector,
7117{
7118 /// Perform the operation you have build so far.
7119 pub async fn doit(
7120 mut self,
7121 ) -> common::Result<(common::Response, AdsenseReportsGenerateResponse)> {
7122 use std::borrow::Cow;
7123 use std::io::{Read, Seek};
7124
7125 use common::{url::Params, ToParts};
7126 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7127
7128 let mut dd = common::DefaultDelegate;
7129 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7130 dlg.begin(common::MethodInfo {
7131 id: "adsense.accounts.reports.generate",
7132 http_method: hyper::Method::GET,
7133 });
7134
7135 for &field in [
7136 "accountId",
7137 "startDate",
7138 "endDate",
7139 "useTimezoneReporting",
7140 "startIndex",
7141 "sort",
7142 "metric",
7143 "maxResults",
7144 "locale",
7145 "filter",
7146 "dimension",
7147 "currency",
7148 ]
7149 .iter()
7150 {
7151 if self._additional_params.contains_key(field) {
7152 dlg.finished(false);
7153 return Err(common::Error::FieldClash(field));
7154 }
7155 }
7156
7157 let mut params = Params::with_capacity(13 + self._additional_params.len());
7158 params.push("accountId", self._account_id);
7159 params.push("startDate", self._start_date);
7160 params.push("endDate", self._end_date);
7161 if let Some(value) = self._use_timezone_reporting.as_ref() {
7162 params.push("useTimezoneReporting", value.to_string());
7163 }
7164 if let Some(value) = self._start_index.as_ref() {
7165 params.push("startIndex", value.to_string());
7166 }
7167 if !self._sort.is_empty() {
7168 for f in self._sort.iter() {
7169 params.push("sort", f);
7170 }
7171 }
7172 if !self._metric.is_empty() {
7173 for f in self._metric.iter() {
7174 params.push("metric", f);
7175 }
7176 }
7177 if let Some(value) = self._max_results.as_ref() {
7178 params.push("maxResults", value.to_string());
7179 }
7180 if let Some(value) = self._locale.as_ref() {
7181 params.push("locale", value);
7182 }
7183 if !self._filter.is_empty() {
7184 for f in self._filter.iter() {
7185 params.push("filter", f);
7186 }
7187 }
7188 if !self._dimension.is_empty() {
7189 for f in self._dimension.iter() {
7190 params.push("dimension", f);
7191 }
7192 }
7193 if let Some(value) = self._currency.as_ref() {
7194 params.push("currency", value);
7195 }
7196
7197 params.extend(self._additional_params.iter());
7198
7199 let (alt_field_missing, enable_resource_parsing) = {
7200 if let Some(value) = params.get("alt") {
7201 (false, value == "json")
7202 } else {
7203 (true, true)
7204 }
7205 };
7206 if alt_field_missing {
7207 params.push("alt", "json");
7208 }
7209 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports";
7210 if self._scopes.is_empty() {
7211 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7212 }
7213
7214 #[allow(clippy::single_element_loop)]
7215 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
7216 url = params.uri_replacement(url, param_name, find_this, false);
7217 }
7218 {
7219 let to_remove = ["accountId"];
7220 params.remove_params(&to_remove);
7221 }
7222
7223 let url = params.parse_with_url(&url);
7224
7225 loop {
7226 let token = match self
7227 .hub
7228 .auth
7229 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7230 .await
7231 {
7232 Ok(token) => token,
7233 Err(e) => match dlg.token(e) {
7234 Ok(token) => token,
7235 Err(e) => {
7236 dlg.finished(false);
7237 return Err(common::Error::MissingToken(e));
7238 }
7239 },
7240 };
7241 let mut req_result = {
7242 let client = &self.hub.client;
7243 dlg.pre_request();
7244 let mut req_builder = hyper::Request::builder()
7245 .method(hyper::Method::GET)
7246 .uri(url.as_str())
7247 .header(USER_AGENT, self.hub._user_agent.clone());
7248
7249 if let Some(token) = token.as_ref() {
7250 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7251 }
7252
7253 let request = req_builder
7254 .header(CONTENT_LENGTH, 0_u64)
7255 .body(common::to_body::<String>(None));
7256
7257 client.request(request.unwrap()).await
7258 };
7259
7260 match req_result {
7261 Err(err) => {
7262 if let common::Retry::After(d) = dlg.http_error(&err) {
7263 sleep(d).await;
7264 continue;
7265 }
7266 dlg.finished(false);
7267 return Err(common::Error::HttpError(err));
7268 }
7269 Ok(res) => {
7270 let (mut parts, body) = res.into_parts();
7271 let mut body = common::Body::new(body);
7272 if !parts.status.is_success() {
7273 let bytes = common::to_bytes(body).await.unwrap_or_default();
7274 let error = serde_json::from_str(&common::to_string(&bytes));
7275 let response = common::to_response(parts, bytes.into());
7276
7277 if let common::Retry::After(d) =
7278 dlg.http_failure(&response, error.as_ref().ok())
7279 {
7280 sleep(d).await;
7281 continue;
7282 }
7283
7284 dlg.finished(false);
7285
7286 return Err(match error {
7287 Ok(value) => common::Error::BadRequest(value),
7288 _ => common::Error::Failure(response),
7289 });
7290 }
7291 let response = if enable_resource_parsing {
7292 let bytes = common::to_bytes(body).await.unwrap_or_default();
7293 let encoded = common::to_string(&bytes);
7294 match serde_json::from_str(&encoded) {
7295 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7296 Err(error) => {
7297 dlg.response_json_decode_error(&encoded, &error);
7298 return Err(common::Error::JsonDecodeError(
7299 encoded.to_string(),
7300 error,
7301 ));
7302 }
7303 }
7304 } else {
7305 (
7306 common::Response::from_parts(parts, body),
7307 Default::default(),
7308 )
7309 };
7310
7311 dlg.finished(true);
7312 return Ok(response);
7313 }
7314 }
7315 }
7316 }
7317
7318 /// Account upon which to report.
7319 ///
7320 /// Sets the *account id* path property to the given value.
7321 ///
7322 /// Even though the property as already been set when instantiating this call,
7323 /// we provide this method for API completeness.
7324 pub fn account_id(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7325 self._account_id = new_value.to_string();
7326 self
7327 }
7328 /// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
7329 ///
7330 /// Sets the *start date* query property to the given value.
7331 ///
7332 /// Even though the property as already been set when instantiating this call,
7333 /// we provide this method for API completeness.
7334 pub fn start_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7335 self._start_date = new_value.to_string();
7336 self
7337 }
7338 /// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
7339 ///
7340 /// Sets the *end date* query property to the given value.
7341 ///
7342 /// Even though the property as already been set when instantiating this call,
7343 /// we provide this method for API completeness.
7344 pub fn end_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7345 self._end_date = new_value.to_string();
7346 self
7347 }
7348 /// Whether the report should be generated in the AdSense account's local timezone. If false default PST/PDT timezone will be used.
7349 ///
7350 /// Sets the *use timezone reporting* query property to the given value.
7351 pub fn use_timezone_reporting(mut self, new_value: bool) -> AccountReportGenerateCall<'a, C> {
7352 self._use_timezone_reporting = Some(new_value);
7353 self
7354 }
7355 /// Index of the first row of report data to return.
7356 ///
7357 /// Sets the *start index* query property to the given value.
7358 pub fn start_index(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
7359 self._start_index = Some(new_value);
7360 self
7361 }
7362 /// 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.
7363 ///
7364 /// Append the given value to the *sort* query property.
7365 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7366 pub fn add_sort(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7367 self._sort.push(new_value.to_string());
7368 self
7369 }
7370 /// Numeric columns to include in the report.
7371 ///
7372 /// Append the given value to the *metric* query property.
7373 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7374 pub fn add_metric(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7375 self._metric.push(new_value.to_string());
7376 self
7377 }
7378 /// The maximum number of rows of report data to return.
7379 ///
7380 /// Sets the *max results* query property to the given value.
7381 pub fn max_results(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
7382 self._max_results = Some(new_value);
7383 self
7384 }
7385 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
7386 ///
7387 /// Sets the *locale* query property to the given value.
7388 pub fn locale(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7389 self._locale = Some(new_value.to_string());
7390 self
7391 }
7392 /// Filters to be run on the report.
7393 ///
7394 /// Append the given value to the *filter* query property.
7395 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7396 pub fn add_filter(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7397 self._filter.push(new_value.to_string());
7398 self
7399 }
7400 /// Dimensions to base the report on.
7401 ///
7402 /// Append the given value to the *dimension* query property.
7403 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
7404 pub fn add_dimension(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7405 self._dimension.push(new_value.to_string());
7406 self
7407 }
7408 /// Optional currency to use when reporting on monetary metrics. Defaults to the account's currency if not set.
7409 ///
7410 /// Sets the *currency* query property to the given value.
7411 pub fn currency(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
7412 self._currency = Some(new_value.to_string());
7413 self
7414 }
7415 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7416 /// while executing the actual API request.
7417 ///
7418 /// ````text
7419 /// It should be used to handle progress information, and to implement a certain level of resilience.
7420 /// ````
7421 ///
7422 /// Sets the *delegate* property to the given value.
7423 pub fn delegate(
7424 mut self,
7425 new_value: &'a mut dyn common::Delegate,
7426 ) -> AccountReportGenerateCall<'a, C> {
7427 self._delegate = Some(new_value);
7428 self
7429 }
7430
7431 /// Set any additional parameter of the query string used in the request.
7432 /// It should be used to set parameters which are not yet available through their own
7433 /// setters.
7434 ///
7435 /// Please note that this method must not be used to set any of the known parameters
7436 /// which have their own setter method. If done anyway, the request will fail.
7437 ///
7438 /// # Additional Parameters
7439 ///
7440 /// * *alt* (query-string) - Data format for the response.
7441 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7442 /// * *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.
7443 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7444 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7445 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7446 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7447 pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCall<'a, C>
7448 where
7449 T: AsRef<str>,
7450 {
7451 self._additional_params
7452 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7453 self
7454 }
7455
7456 /// Identifies the authorization scope for the method you are building.
7457 ///
7458 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7459 /// [`Scope::Readonly`].
7460 ///
7461 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7462 /// tokens for more than one scope.
7463 ///
7464 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7465 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7466 /// sufficient, a read-write scope will do as well.
7467 pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCall<'a, C>
7468 where
7469 St: AsRef<str>,
7470 {
7471 self._scopes.insert(String::from(scope.as_ref()));
7472 self
7473 }
7474 /// Identifies the authorization scope(s) for the method you are building.
7475 ///
7476 /// See [`Self::add_scope()`] for details.
7477 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCall<'a, C>
7478 where
7479 I: IntoIterator<Item = St>,
7480 St: AsRef<str>,
7481 {
7482 self._scopes
7483 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7484 self
7485 }
7486
7487 /// Removes all scopes, and no default scope will be used either.
7488 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7489 /// for details).
7490 pub fn clear_scopes(mut self) -> AccountReportGenerateCall<'a, C> {
7491 self._scopes.clear();
7492 self
7493 }
7494}
7495
7496/// List a specific saved ad style for the specified account.
7497///
7498/// A builder for the *savedadstyles.get* method supported by a *account* resource.
7499/// It is not used directly, but through a [`AccountMethods`] instance.
7500///
7501/// # Example
7502///
7503/// Instantiate a resource method builder
7504///
7505/// ```test_harness,no_run
7506/// # extern crate hyper;
7507/// # extern crate hyper_rustls;
7508/// # extern crate google_adsense1d4 as adsense1d4;
7509/// # async fn dox() {
7510/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7511///
7512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7513/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7514/// # .with_native_roots()
7515/// # .unwrap()
7516/// # .https_only()
7517/// # .enable_http2()
7518/// # .build();
7519///
7520/// # let executor = hyper_util::rt::TokioExecutor::new();
7521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7522/// # secret,
7523/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7524/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7525/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7526/// # ),
7527/// # ).build().await.unwrap();
7528///
7529/// # let client = hyper_util::client::legacy::Client::builder(
7530/// # hyper_util::rt::TokioExecutor::new()
7531/// # )
7532/// # .build(
7533/// # hyper_rustls::HttpsConnectorBuilder::new()
7534/// # .with_native_roots()
7535/// # .unwrap()
7536/// # .https_or_http()
7537/// # .enable_http2()
7538/// # .build()
7539/// # );
7540/// # let mut hub = AdSense::new(client, auth);
7541/// // You can configure optional parameters by calling the respective setters at will, and
7542/// // execute the final call using `doit()`.
7543/// // Values shown here are possibly random and not representative !
7544/// let result = hub.accounts().savedadstyles_get("accountId", "savedAdStyleId")
7545/// .doit().await;
7546/// # }
7547/// ```
7548pub struct AccountSavedadstyleGetCall<'a, C>
7549where
7550 C: 'a,
7551{
7552 hub: &'a AdSense<C>,
7553 _account_id: String,
7554 _saved_ad_style_id: String,
7555 _delegate: Option<&'a mut dyn common::Delegate>,
7556 _additional_params: HashMap<String, String>,
7557 _scopes: BTreeSet<String>,
7558}
7559
7560impl<'a, C> common::CallBuilder for AccountSavedadstyleGetCall<'a, C> {}
7561
7562impl<'a, C> AccountSavedadstyleGetCall<'a, C>
7563where
7564 C: common::Connector,
7565{
7566 /// Perform the operation you have build so far.
7567 pub async fn doit(mut self) -> common::Result<(common::Response, SavedAdStyle)> {
7568 use std::borrow::Cow;
7569 use std::io::{Read, Seek};
7570
7571 use common::{url::Params, ToParts};
7572 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7573
7574 let mut dd = common::DefaultDelegate;
7575 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7576 dlg.begin(common::MethodInfo {
7577 id: "adsense.accounts.savedadstyles.get",
7578 http_method: hyper::Method::GET,
7579 });
7580
7581 for &field in ["alt", "accountId", "savedAdStyleId"].iter() {
7582 if self._additional_params.contains_key(field) {
7583 dlg.finished(false);
7584 return Err(common::Error::FieldClash(field));
7585 }
7586 }
7587
7588 let mut params = Params::with_capacity(4 + self._additional_params.len());
7589 params.push("accountId", self._account_id);
7590 params.push("savedAdStyleId", self._saved_ad_style_id);
7591
7592 params.extend(self._additional_params.iter());
7593
7594 params.push("alt", "json");
7595 let mut url =
7596 self.hub._base_url.clone() + "accounts/{accountId}/savedadstyles/{savedAdStyleId}";
7597 if self._scopes.is_empty() {
7598 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7599 }
7600
7601 #[allow(clippy::single_element_loop)]
7602 for &(find_this, param_name) in [
7603 ("{accountId}", "accountId"),
7604 ("{savedAdStyleId}", "savedAdStyleId"),
7605 ]
7606 .iter()
7607 {
7608 url = params.uri_replacement(url, param_name, find_this, false);
7609 }
7610 {
7611 let to_remove = ["savedAdStyleId", "accountId"];
7612 params.remove_params(&to_remove);
7613 }
7614
7615 let url = params.parse_with_url(&url);
7616
7617 loop {
7618 let token = match self
7619 .hub
7620 .auth
7621 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7622 .await
7623 {
7624 Ok(token) => token,
7625 Err(e) => match dlg.token(e) {
7626 Ok(token) => token,
7627 Err(e) => {
7628 dlg.finished(false);
7629 return Err(common::Error::MissingToken(e));
7630 }
7631 },
7632 };
7633 let mut req_result = {
7634 let client = &self.hub.client;
7635 dlg.pre_request();
7636 let mut req_builder = hyper::Request::builder()
7637 .method(hyper::Method::GET)
7638 .uri(url.as_str())
7639 .header(USER_AGENT, self.hub._user_agent.clone());
7640
7641 if let Some(token) = token.as_ref() {
7642 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7643 }
7644
7645 let request = req_builder
7646 .header(CONTENT_LENGTH, 0_u64)
7647 .body(common::to_body::<String>(None));
7648
7649 client.request(request.unwrap()).await
7650 };
7651
7652 match req_result {
7653 Err(err) => {
7654 if let common::Retry::After(d) = dlg.http_error(&err) {
7655 sleep(d).await;
7656 continue;
7657 }
7658 dlg.finished(false);
7659 return Err(common::Error::HttpError(err));
7660 }
7661 Ok(res) => {
7662 let (mut parts, body) = res.into_parts();
7663 let mut body = common::Body::new(body);
7664 if !parts.status.is_success() {
7665 let bytes = common::to_bytes(body).await.unwrap_or_default();
7666 let error = serde_json::from_str(&common::to_string(&bytes));
7667 let response = common::to_response(parts, bytes.into());
7668
7669 if let common::Retry::After(d) =
7670 dlg.http_failure(&response, error.as_ref().ok())
7671 {
7672 sleep(d).await;
7673 continue;
7674 }
7675
7676 dlg.finished(false);
7677
7678 return Err(match error {
7679 Ok(value) => common::Error::BadRequest(value),
7680 _ => common::Error::Failure(response),
7681 });
7682 }
7683 let response = {
7684 let bytes = common::to_bytes(body).await.unwrap_or_default();
7685 let encoded = common::to_string(&bytes);
7686 match serde_json::from_str(&encoded) {
7687 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7688 Err(error) => {
7689 dlg.response_json_decode_error(&encoded, &error);
7690 return Err(common::Error::JsonDecodeError(
7691 encoded.to_string(),
7692 error,
7693 ));
7694 }
7695 }
7696 };
7697
7698 dlg.finished(true);
7699 return Ok(response);
7700 }
7701 }
7702 }
7703 }
7704
7705 /// Account for which to get the saved ad style.
7706 ///
7707 /// Sets the *account id* path property to the given value.
7708 ///
7709 /// Even though the property as already been set when instantiating this call,
7710 /// we provide this method for API completeness.
7711 pub fn account_id(mut self, new_value: &str) -> AccountSavedadstyleGetCall<'a, C> {
7712 self._account_id = new_value.to_string();
7713 self
7714 }
7715 /// Saved ad style to retrieve.
7716 ///
7717 /// Sets the *saved ad style id* path property to the given value.
7718 ///
7719 /// Even though the property as already been set when instantiating this call,
7720 /// we provide this method for API completeness.
7721 pub fn saved_ad_style_id(mut self, new_value: &str) -> AccountSavedadstyleGetCall<'a, C> {
7722 self._saved_ad_style_id = new_value.to_string();
7723 self
7724 }
7725 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7726 /// while executing the actual API request.
7727 ///
7728 /// ````text
7729 /// It should be used to handle progress information, and to implement a certain level of resilience.
7730 /// ````
7731 ///
7732 /// Sets the *delegate* property to the given value.
7733 pub fn delegate(
7734 mut self,
7735 new_value: &'a mut dyn common::Delegate,
7736 ) -> AccountSavedadstyleGetCall<'a, C> {
7737 self._delegate = Some(new_value);
7738 self
7739 }
7740
7741 /// Set any additional parameter of the query string used in the request.
7742 /// It should be used to set parameters which are not yet available through their own
7743 /// setters.
7744 ///
7745 /// Please note that this method must not be used to set any of the known parameters
7746 /// which have their own setter method. If done anyway, the request will fail.
7747 ///
7748 /// # Additional Parameters
7749 ///
7750 /// * *alt* (query-string) - Data format for the response.
7751 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7752 /// * *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.
7753 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7754 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7755 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7756 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7757 pub fn param<T>(mut self, name: T, value: T) -> AccountSavedadstyleGetCall<'a, C>
7758 where
7759 T: AsRef<str>,
7760 {
7761 self._additional_params
7762 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7763 self
7764 }
7765
7766 /// Identifies the authorization scope for the method you are building.
7767 ///
7768 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7769 /// [`Scope::Readonly`].
7770 ///
7771 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7772 /// tokens for more than one scope.
7773 ///
7774 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7775 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7776 /// sufficient, a read-write scope will do as well.
7777 pub fn add_scope<St>(mut self, scope: St) -> AccountSavedadstyleGetCall<'a, C>
7778 where
7779 St: AsRef<str>,
7780 {
7781 self._scopes.insert(String::from(scope.as_ref()));
7782 self
7783 }
7784 /// Identifies the authorization scope(s) for the method you are building.
7785 ///
7786 /// See [`Self::add_scope()`] for details.
7787 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSavedadstyleGetCall<'a, C>
7788 where
7789 I: IntoIterator<Item = St>,
7790 St: AsRef<str>,
7791 {
7792 self._scopes
7793 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7794 self
7795 }
7796
7797 /// Removes all scopes, and no default scope will be used either.
7798 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7799 /// for details).
7800 pub fn clear_scopes(mut self) -> AccountSavedadstyleGetCall<'a, C> {
7801 self._scopes.clear();
7802 self
7803 }
7804}
7805
7806/// List all saved ad styles in the specified account.
7807///
7808/// A builder for the *savedadstyles.list* method supported by a *account* resource.
7809/// It is not used directly, but through a [`AccountMethods`] instance.
7810///
7811/// # Example
7812///
7813/// Instantiate a resource method builder
7814///
7815/// ```test_harness,no_run
7816/// # extern crate hyper;
7817/// # extern crate hyper_rustls;
7818/// # extern crate google_adsense1d4 as adsense1d4;
7819/// # async fn dox() {
7820/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7821///
7822/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7823/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7824/// # .with_native_roots()
7825/// # .unwrap()
7826/// # .https_only()
7827/// # .enable_http2()
7828/// # .build();
7829///
7830/// # let executor = hyper_util::rt::TokioExecutor::new();
7831/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7832/// # secret,
7833/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7834/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7835/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7836/// # ),
7837/// # ).build().await.unwrap();
7838///
7839/// # let client = hyper_util::client::legacy::Client::builder(
7840/// # hyper_util::rt::TokioExecutor::new()
7841/// # )
7842/// # .build(
7843/// # hyper_rustls::HttpsConnectorBuilder::new()
7844/// # .with_native_roots()
7845/// # .unwrap()
7846/// # .https_or_http()
7847/// # .enable_http2()
7848/// # .build()
7849/// # );
7850/// # let mut hub = AdSense::new(client, auth);
7851/// // You can configure optional parameters by calling the respective setters at will, and
7852/// // execute the final call using `doit()`.
7853/// // Values shown here are possibly random and not representative !
7854/// let result = hub.accounts().savedadstyles_list("accountId")
7855/// .page_token("At")
7856/// .max_results(-43)
7857/// .doit().await;
7858/// # }
7859/// ```
7860pub struct AccountSavedadstyleListCall<'a, C>
7861where
7862 C: 'a,
7863{
7864 hub: &'a AdSense<C>,
7865 _account_id: String,
7866 _page_token: Option<String>,
7867 _max_results: Option<i32>,
7868 _delegate: Option<&'a mut dyn common::Delegate>,
7869 _additional_params: HashMap<String, String>,
7870 _scopes: BTreeSet<String>,
7871}
7872
7873impl<'a, C> common::CallBuilder for AccountSavedadstyleListCall<'a, C> {}
7874
7875impl<'a, C> AccountSavedadstyleListCall<'a, C>
7876where
7877 C: common::Connector,
7878{
7879 /// Perform the operation you have build so far.
7880 pub async fn doit(mut self) -> common::Result<(common::Response, SavedAdStyles)> {
7881 use std::borrow::Cow;
7882 use std::io::{Read, Seek};
7883
7884 use common::{url::Params, ToParts};
7885 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7886
7887 let mut dd = common::DefaultDelegate;
7888 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7889 dlg.begin(common::MethodInfo {
7890 id: "adsense.accounts.savedadstyles.list",
7891 http_method: hyper::Method::GET,
7892 });
7893
7894 for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
7895 if self._additional_params.contains_key(field) {
7896 dlg.finished(false);
7897 return Err(common::Error::FieldClash(field));
7898 }
7899 }
7900
7901 let mut params = Params::with_capacity(5 + self._additional_params.len());
7902 params.push("accountId", self._account_id);
7903 if let Some(value) = self._page_token.as_ref() {
7904 params.push("pageToken", value);
7905 }
7906 if let Some(value) = self._max_results.as_ref() {
7907 params.push("maxResults", value.to_string());
7908 }
7909
7910 params.extend(self._additional_params.iter());
7911
7912 params.push("alt", "json");
7913 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/savedadstyles";
7914 if self._scopes.is_empty() {
7915 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7916 }
7917
7918 #[allow(clippy::single_element_loop)]
7919 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
7920 url = params.uri_replacement(url, param_name, find_this, false);
7921 }
7922 {
7923 let to_remove = ["accountId"];
7924 params.remove_params(&to_remove);
7925 }
7926
7927 let url = params.parse_with_url(&url);
7928
7929 loop {
7930 let token = match self
7931 .hub
7932 .auth
7933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7934 .await
7935 {
7936 Ok(token) => token,
7937 Err(e) => match dlg.token(e) {
7938 Ok(token) => token,
7939 Err(e) => {
7940 dlg.finished(false);
7941 return Err(common::Error::MissingToken(e));
7942 }
7943 },
7944 };
7945 let mut req_result = {
7946 let client = &self.hub.client;
7947 dlg.pre_request();
7948 let mut req_builder = hyper::Request::builder()
7949 .method(hyper::Method::GET)
7950 .uri(url.as_str())
7951 .header(USER_AGENT, self.hub._user_agent.clone());
7952
7953 if let Some(token) = token.as_ref() {
7954 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7955 }
7956
7957 let request = req_builder
7958 .header(CONTENT_LENGTH, 0_u64)
7959 .body(common::to_body::<String>(None));
7960
7961 client.request(request.unwrap()).await
7962 };
7963
7964 match req_result {
7965 Err(err) => {
7966 if let common::Retry::After(d) = dlg.http_error(&err) {
7967 sleep(d).await;
7968 continue;
7969 }
7970 dlg.finished(false);
7971 return Err(common::Error::HttpError(err));
7972 }
7973 Ok(res) => {
7974 let (mut parts, body) = res.into_parts();
7975 let mut body = common::Body::new(body);
7976 if !parts.status.is_success() {
7977 let bytes = common::to_bytes(body).await.unwrap_or_default();
7978 let error = serde_json::from_str(&common::to_string(&bytes));
7979 let response = common::to_response(parts, bytes.into());
7980
7981 if let common::Retry::After(d) =
7982 dlg.http_failure(&response, error.as_ref().ok())
7983 {
7984 sleep(d).await;
7985 continue;
7986 }
7987
7988 dlg.finished(false);
7989
7990 return Err(match error {
7991 Ok(value) => common::Error::BadRequest(value),
7992 _ => common::Error::Failure(response),
7993 });
7994 }
7995 let response = {
7996 let bytes = common::to_bytes(body).await.unwrap_or_default();
7997 let encoded = common::to_string(&bytes);
7998 match serde_json::from_str(&encoded) {
7999 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8000 Err(error) => {
8001 dlg.response_json_decode_error(&encoded, &error);
8002 return Err(common::Error::JsonDecodeError(
8003 encoded.to_string(),
8004 error,
8005 ));
8006 }
8007 }
8008 };
8009
8010 dlg.finished(true);
8011 return Ok(response);
8012 }
8013 }
8014 }
8015 }
8016
8017 /// Account for which to list saved ad styles.
8018 ///
8019 /// Sets the *account id* path property to the given value.
8020 ///
8021 /// Even though the property as already been set when instantiating this call,
8022 /// we provide this method for API completeness.
8023 pub fn account_id(mut self, new_value: &str) -> AccountSavedadstyleListCall<'a, C> {
8024 self._account_id = new_value.to_string();
8025 self
8026 }
8027 /// A continuation token, used to page through saved ad styles. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
8028 ///
8029 /// Sets the *page token* query property to the given value.
8030 pub fn page_token(mut self, new_value: &str) -> AccountSavedadstyleListCall<'a, C> {
8031 self._page_token = Some(new_value.to_string());
8032 self
8033 }
8034 /// The maximum number of saved ad styles to include in the response, used for paging.
8035 ///
8036 /// Sets the *max results* query property to the given value.
8037 pub fn max_results(mut self, new_value: i32) -> AccountSavedadstyleListCall<'a, C> {
8038 self._max_results = Some(new_value);
8039 self
8040 }
8041 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8042 /// while executing the actual API request.
8043 ///
8044 /// ````text
8045 /// It should be used to handle progress information, and to implement a certain level of resilience.
8046 /// ````
8047 ///
8048 /// Sets the *delegate* property to the given value.
8049 pub fn delegate(
8050 mut self,
8051 new_value: &'a mut dyn common::Delegate,
8052 ) -> AccountSavedadstyleListCall<'a, C> {
8053 self._delegate = Some(new_value);
8054 self
8055 }
8056
8057 /// Set any additional parameter of the query string used in the request.
8058 /// It should be used to set parameters which are not yet available through their own
8059 /// setters.
8060 ///
8061 /// Please note that this method must not be used to set any of the known parameters
8062 /// which have their own setter method. If done anyway, the request will fail.
8063 ///
8064 /// # Additional Parameters
8065 ///
8066 /// * *alt* (query-string) - Data format for the response.
8067 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8068 /// * *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.
8069 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8070 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8071 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8072 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8073 pub fn param<T>(mut self, name: T, value: T) -> AccountSavedadstyleListCall<'a, C>
8074 where
8075 T: AsRef<str>,
8076 {
8077 self._additional_params
8078 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8079 self
8080 }
8081
8082 /// Identifies the authorization scope for the method you are building.
8083 ///
8084 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8085 /// [`Scope::Readonly`].
8086 ///
8087 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8088 /// tokens for more than one scope.
8089 ///
8090 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8091 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8092 /// sufficient, a read-write scope will do as well.
8093 pub fn add_scope<St>(mut self, scope: St) -> AccountSavedadstyleListCall<'a, C>
8094 where
8095 St: AsRef<str>,
8096 {
8097 self._scopes.insert(String::from(scope.as_ref()));
8098 self
8099 }
8100 /// Identifies the authorization scope(s) for the method you are building.
8101 ///
8102 /// See [`Self::add_scope()`] for details.
8103 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSavedadstyleListCall<'a, C>
8104 where
8105 I: IntoIterator<Item = St>,
8106 St: AsRef<str>,
8107 {
8108 self._scopes
8109 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8110 self
8111 }
8112
8113 /// Removes all scopes, and no default scope will be used either.
8114 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8115 /// for details).
8116 pub fn clear_scopes(mut self) -> AccountSavedadstyleListCall<'a, C> {
8117 self._scopes.clear();
8118 self
8119 }
8120}
8121
8122/// List all URL channels in the specified ad client for the specified account.
8123///
8124/// A builder for the *urlchannels.list* method supported by a *account* resource.
8125/// It is not used directly, but through a [`AccountMethods`] instance.
8126///
8127/// # Example
8128///
8129/// Instantiate a resource method builder
8130///
8131/// ```test_harness,no_run
8132/// # extern crate hyper;
8133/// # extern crate hyper_rustls;
8134/// # extern crate google_adsense1d4 as adsense1d4;
8135/// # async fn dox() {
8136/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8137///
8138/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8139/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8140/// # .with_native_roots()
8141/// # .unwrap()
8142/// # .https_only()
8143/// # .enable_http2()
8144/// # .build();
8145///
8146/// # let executor = hyper_util::rt::TokioExecutor::new();
8147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8148/// # secret,
8149/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8150/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8151/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8152/// # ),
8153/// # ).build().await.unwrap();
8154///
8155/// # let client = hyper_util::client::legacy::Client::builder(
8156/// # hyper_util::rt::TokioExecutor::new()
8157/// # )
8158/// # .build(
8159/// # hyper_rustls::HttpsConnectorBuilder::new()
8160/// # .with_native_roots()
8161/// # .unwrap()
8162/// # .https_or_http()
8163/// # .enable_http2()
8164/// # .build()
8165/// # );
8166/// # let mut hub = AdSense::new(client, auth);
8167/// // You can configure optional parameters by calling the respective setters at will, and
8168/// // execute the final call using `doit()`.
8169/// // Values shown here are possibly random and not representative !
8170/// let result = hub.accounts().urlchannels_list("accountId", "adClientId")
8171/// .page_token("tempor")
8172/// .max_results(-32)
8173/// .doit().await;
8174/// # }
8175/// ```
8176pub struct AccountUrlchannelListCall<'a, C>
8177where
8178 C: 'a,
8179{
8180 hub: &'a AdSense<C>,
8181 _account_id: String,
8182 _ad_client_id: String,
8183 _page_token: Option<String>,
8184 _max_results: Option<i32>,
8185 _delegate: Option<&'a mut dyn common::Delegate>,
8186 _additional_params: HashMap<String, String>,
8187 _scopes: BTreeSet<String>,
8188}
8189
8190impl<'a, C> common::CallBuilder for AccountUrlchannelListCall<'a, C> {}
8191
8192impl<'a, C> AccountUrlchannelListCall<'a, C>
8193where
8194 C: common::Connector,
8195{
8196 /// Perform the operation you have build so far.
8197 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannels)> {
8198 use std::borrow::Cow;
8199 use std::io::{Read, Seek};
8200
8201 use common::{url::Params, ToParts};
8202 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8203
8204 let mut dd = common::DefaultDelegate;
8205 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8206 dlg.begin(common::MethodInfo {
8207 id: "adsense.accounts.urlchannels.list",
8208 http_method: hyper::Method::GET,
8209 });
8210
8211 for &field in ["alt", "accountId", "adClientId", "pageToken", "maxResults"].iter() {
8212 if self._additional_params.contains_key(field) {
8213 dlg.finished(false);
8214 return Err(common::Error::FieldClash(field));
8215 }
8216 }
8217
8218 let mut params = Params::with_capacity(6 + self._additional_params.len());
8219 params.push("accountId", self._account_id);
8220 params.push("adClientId", self._ad_client_id);
8221 if let Some(value) = self._page_token.as_ref() {
8222 params.push("pageToken", value);
8223 }
8224 if let Some(value) = self._max_results.as_ref() {
8225 params.push("maxResults", value.to_string());
8226 }
8227
8228 params.extend(self._additional_params.iter());
8229
8230 params.push("alt", "json");
8231 let mut url =
8232 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/urlchannels";
8233 if self._scopes.is_empty() {
8234 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8235 }
8236
8237 #[allow(clippy::single_element_loop)]
8238 for &(find_this, param_name) in
8239 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
8240 {
8241 url = params.uri_replacement(url, param_name, find_this, false);
8242 }
8243 {
8244 let to_remove = ["adClientId", "accountId"];
8245 params.remove_params(&to_remove);
8246 }
8247
8248 let url = params.parse_with_url(&url);
8249
8250 loop {
8251 let token = match self
8252 .hub
8253 .auth
8254 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8255 .await
8256 {
8257 Ok(token) => token,
8258 Err(e) => match dlg.token(e) {
8259 Ok(token) => token,
8260 Err(e) => {
8261 dlg.finished(false);
8262 return Err(common::Error::MissingToken(e));
8263 }
8264 },
8265 };
8266 let mut req_result = {
8267 let client = &self.hub.client;
8268 dlg.pre_request();
8269 let mut req_builder = hyper::Request::builder()
8270 .method(hyper::Method::GET)
8271 .uri(url.as_str())
8272 .header(USER_AGENT, self.hub._user_agent.clone());
8273
8274 if let Some(token) = token.as_ref() {
8275 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8276 }
8277
8278 let request = req_builder
8279 .header(CONTENT_LENGTH, 0_u64)
8280 .body(common::to_body::<String>(None));
8281
8282 client.request(request.unwrap()).await
8283 };
8284
8285 match req_result {
8286 Err(err) => {
8287 if let common::Retry::After(d) = dlg.http_error(&err) {
8288 sleep(d).await;
8289 continue;
8290 }
8291 dlg.finished(false);
8292 return Err(common::Error::HttpError(err));
8293 }
8294 Ok(res) => {
8295 let (mut parts, body) = res.into_parts();
8296 let mut body = common::Body::new(body);
8297 if !parts.status.is_success() {
8298 let bytes = common::to_bytes(body).await.unwrap_or_default();
8299 let error = serde_json::from_str(&common::to_string(&bytes));
8300 let response = common::to_response(parts, bytes.into());
8301
8302 if let common::Retry::After(d) =
8303 dlg.http_failure(&response, error.as_ref().ok())
8304 {
8305 sleep(d).await;
8306 continue;
8307 }
8308
8309 dlg.finished(false);
8310
8311 return Err(match error {
8312 Ok(value) => common::Error::BadRequest(value),
8313 _ => common::Error::Failure(response),
8314 });
8315 }
8316 let response = {
8317 let bytes = common::to_bytes(body).await.unwrap_or_default();
8318 let encoded = common::to_string(&bytes);
8319 match serde_json::from_str(&encoded) {
8320 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8321 Err(error) => {
8322 dlg.response_json_decode_error(&encoded, &error);
8323 return Err(common::Error::JsonDecodeError(
8324 encoded.to_string(),
8325 error,
8326 ));
8327 }
8328 }
8329 };
8330
8331 dlg.finished(true);
8332 return Ok(response);
8333 }
8334 }
8335 }
8336 }
8337
8338 /// Account to which the ad client belongs.
8339 ///
8340 /// Sets the *account id* path property to the given value.
8341 ///
8342 /// Even though the property as already been set when instantiating this call,
8343 /// we provide this method for API completeness.
8344 pub fn account_id(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
8345 self._account_id = new_value.to_string();
8346 self
8347 }
8348 /// Ad client for which to list URL channels.
8349 ///
8350 /// Sets the *ad client id* path property to the given value.
8351 ///
8352 /// Even though the property as already been set when instantiating this call,
8353 /// we provide this method for API completeness.
8354 pub fn ad_client_id(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
8355 self._ad_client_id = new_value.to_string();
8356 self
8357 }
8358 /// 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.
8359 ///
8360 /// Sets the *page token* query property to the given value.
8361 pub fn page_token(mut self, new_value: &str) -> AccountUrlchannelListCall<'a, C> {
8362 self._page_token = Some(new_value.to_string());
8363 self
8364 }
8365 /// The maximum number of URL channels to include in the response, used for paging.
8366 ///
8367 /// Sets the *max results* query property to the given value.
8368 pub fn max_results(mut self, new_value: i32) -> AccountUrlchannelListCall<'a, C> {
8369 self._max_results = Some(new_value);
8370 self
8371 }
8372 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8373 /// while executing the actual API request.
8374 ///
8375 /// ````text
8376 /// It should be used to handle progress information, and to implement a certain level of resilience.
8377 /// ````
8378 ///
8379 /// Sets the *delegate* property to the given value.
8380 pub fn delegate(
8381 mut self,
8382 new_value: &'a mut dyn common::Delegate,
8383 ) -> AccountUrlchannelListCall<'a, C> {
8384 self._delegate = Some(new_value);
8385 self
8386 }
8387
8388 /// Set any additional parameter of the query string used in the request.
8389 /// It should be used to set parameters which are not yet available through their own
8390 /// setters.
8391 ///
8392 /// Please note that this method must not be used to set any of the known parameters
8393 /// which have their own setter method. If done anyway, the request will fail.
8394 ///
8395 /// # Additional Parameters
8396 ///
8397 /// * *alt* (query-string) - Data format for the response.
8398 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8399 /// * *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.
8400 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8401 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8402 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8403 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8404 pub fn param<T>(mut self, name: T, value: T) -> AccountUrlchannelListCall<'a, C>
8405 where
8406 T: AsRef<str>,
8407 {
8408 self._additional_params
8409 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8410 self
8411 }
8412
8413 /// Identifies the authorization scope for the method you are building.
8414 ///
8415 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8416 /// [`Scope::Readonly`].
8417 ///
8418 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8419 /// tokens for more than one scope.
8420 ///
8421 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8422 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8423 /// sufficient, a read-write scope will do as well.
8424 pub fn add_scope<St>(mut self, scope: St) -> AccountUrlchannelListCall<'a, C>
8425 where
8426 St: AsRef<str>,
8427 {
8428 self._scopes.insert(String::from(scope.as_ref()));
8429 self
8430 }
8431 /// Identifies the authorization scope(s) for the method you are building.
8432 ///
8433 /// See [`Self::add_scope()`] for details.
8434 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUrlchannelListCall<'a, C>
8435 where
8436 I: IntoIterator<Item = St>,
8437 St: AsRef<str>,
8438 {
8439 self._scopes
8440 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8441 self
8442 }
8443
8444 /// Removes all scopes, and no default scope will be used either.
8445 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8446 /// for details).
8447 pub fn clear_scopes(mut self) -> AccountUrlchannelListCall<'a, C> {
8448 self._scopes.clear();
8449 self
8450 }
8451}
8452
8453/// Get information about the selected AdSense account.
8454///
8455/// A builder for the *get* method supported by a *account* resource.
8456/// It is not used directly, but through a [`AccountMethods`] instance.
8457///
8458/// # Example
8459///
8460/// Instantiate a resource method builder
8461///
8462/// ```test_harness,no_run
8463/// # extern crate hyper;
8464/// # extern crate hyper_rustls;
8465/// # extern crate google_adsense1d4 as adsense1d4;
8466/// # async fn dox() {
8467/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8468///
8469/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8470/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8471/// # .with_native_roots()
8472/// # .unwrap()
8473/// # .https_only()
8474/// # .enable_http2()
8475/// # .build();
8476///
8477/// # let executor = hyper_util::rt::TokioExecutor::new();
8478/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8479/// # secret,
8480/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8481/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8482/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8483/// # ),
8484/// # ).build().await.unwrap();
8485///
8486/// # let client = hyper_util::client::legacy::Client::builder(
8487/// # hyper_util::rt::TokioExecutor::new()
8488/// # )
8489/// # .build(
8490/// # hyper_rustls::HttpsConnectorBuilder::new()
8491/// # .with_native_roots()
8492/// # .unwrap()
8493/// # .https_or_http()
8494/// # .enable_http2()
8495/// # .build()
8496/// # );
8497/// # let mut hub = AdSense::new(client, auth);
8498/// // You can configure optional parameters by calling the respective setters at will, and
8499/// // execute the final call using `doit()`.
8500/// // Values shown here are possibly random and not representative !
8501/// let result = hub.accounts().get("accountId")
8502/// .tree(true)
8503/// .doit().await;
8504/// # }
8505/// ```
8506pub struct AccountGetCall<'a, C>
8507where
8508 C: 'a,
8509{
8510 hub: &'a AdSense<C>,
8511 _account_id: String,
8512 _tree: Option<bool>,
8513 _delegate: Option<&'a mut dyn common::Delegate>,
8514 _additional_params: HashMap<String, String>,
8515 _scopes: BTreeSet<String>,
8516}
8517
8518impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
8519
8520impl<'a, C> AccountGetCall<'a, C>
8521where
8522 C: common::Connector,
8523{
8524 /// Perform the operation you have build so far.
8525 pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
8526 use std::borrow::Cow;
8527 use std::io::{Read, Seek};
8528
8529 use common::{url::Params, ToParts};
8530 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8531
8532 let mut dd = common::DefaultDelegate;
8533 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8534 dlg.begin(common::MethodInfo {
8535 id: "adsense.accounts.get",
8536 http_method: hyper::Method::GET,
8537 });
8538
8539 for &field in ["alt", "accountId", "tree"].iter() {
8540 if self._additional_params.contains_key(field) {
8541 dlg.finished(false);
8542 return Err(common::Error::FieldClash(field));
8543 }
8544 }
8545
8546 let mut params = Params::with_capacity(4 + self._additional_params.len());
8547 params.push("accountId", self._account_id);
8548 if let Some(value) = self._tree.as_ref() {
8549 params.push("tree", value.to_string());
8550 }
8551
8552 params.extend(self._additional_params.iter());
8553
8554 params.push("alt", "json");
8555 let mut url = self.hub._base_url.clone() + "accounts/{accountId}";
8556 if self._scopes.is_empty() {
8557 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8558 }
8559
8560 #[allow(clippy::single_element_loop)]
8561 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
8562 url = params.uri_replacement(url, param_name, find_this, false);
8563 }
8564 {
8565 let to_remove = ["accountId"];
8566 params.remove_params(&to_remove);
8567 }
8568
8569 let url = params.parse_with_url(&url);
8570
8571 loop {
8572 let token = match self
8573 .hub
8574 .auth
8575 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8576 .await
8577 {
8578 Ok(token) => token,
8579 Err(e) => match dlg.token(e) {
8580 Ok(token) => token,
8581 Err(e) => {
8582 dlg.finished(false);
8583 return Err(common::Error::MissingToken(e));
8584 }
8585 },
8586 };
8587 let mut req_result = {
8588 let client = &self.hub.client;
8589 dlg.pre_request();
8590 let mut req_builder = hyper::Request::builder()
8591 .method(hyper::Method::GET)
8592 .uri(url.as_str())
8593 .header(USER_AGENT, self.hub._user_agent.clone());
8594
8595 if let Some(token) = token.as_ref() {
8596 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8597 }
8598
8599 let request = req_builder
8600 .header(CONTENT_LENGTH, 0_u64)
8601 .body(common::to_body::<String>(None));
8602
8603 client.request(request.unwrap()).await
8604 };
8605
8606 match req_result {
8607 Err(err) => {
8608 if let common::Retry::After(d) = dlg.http_error(&err) {
8609 sleep(d).await;
8610 continue;
8611 }
8612 dlg.finished(false);
8613 return Err(common::Error::HttpError(err));
8614 }
8615 Ok(res) => {
8616 let (mut parts, body) = res.into_parts();
8617 let mut body = common::Body::new(body);
8618 if !parts.status.is_success() {
8619 let bytes = common::to_bytes(body).await.unwrap_or_default();
8620 let error = serde_json::from_str(&common::to_string(&bytes));
8621 let response = common::to_response(parts, bytes.into());
8622
8623 if let common::Retry::After(d) =
8624 dlg.http_failure(&response, error.as_ref().ok())
8625 {
8626 sleep(d).await;
8627 continue;
8628 }
8629
8630 dlg.finished(false);
8631
8632 return Err(match error {
8633 Ok(value) => common::Error::BadRequest(value),
8634 _ => common::Error::Failure(response),
8635 });
8636 }
8637 let response = {
8638 let bytes = common::to_bytes(body).await.unwrap_or_default();
8639 let encoded = common::to_string(&bytes);
8640 match serde_json::from_str(&encoded) {
8641 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8642 Err(error) => {
8643 dlg.response_json_decode_error(&encoded, &error);
8644 return Err(common::Error::JsonDecodeError(
8645 encoded.to_string(),
8646 error,
8647 ));
8648 }
8649 }
8650 };
8651
8652 dlg.finished(true);
8653 return Ok(response);
8654 }
8655 }
8656 }
8657 }
8658
8659 /// Account to get information about.
8660 ///
8661 /// Sets the *account id* path property to the given value.
8662 ///
8663 /// Even though the property as already been set when instantiating this call,
8664 /// we provide this method for API completeness.
8665 pub fn account_id(mut self, new_value: &str) -> AccountGetCall<'a, C> {
8666 self._account_id = new_value.to_string();
8667 self
8668 }
8669 /// Whether the tree of sub accounts should be returned.
8670 ///
8671 /// Sets the *tree* query property to the given value.
8672 pub fn tree(mut self, new_value: bool) -> AccountGetCall<'a, C> {
8673 self._tree = Some(new_value);
8674 self
8675 }
8676 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8677 /// while executing the actual API request.
8678 ///
8679 /// ````text
8680 /// It should be used to handle progress information, and to implement a certain level of resilience.
8681 /// ````
8682 ///
8683 /// Sets the *delegate* property to the given value.
8684 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
8685 self._delegate = Some(new_value);
8686 self
8687 }
8688
8689 /// Set any additional parameter of the query string used in the request.
8690 /// It should be used to set parameters which are not yet available through their own
8691 /// setters.
8692 ///
8693 /// Please note that this method must not be used to set any of the known parameters
8694 /// which have their own setter method. If done anyway, the request will fail.
8695 ///
8696 /// # Additional Parameters
8697 ///
8698 /// * *alt* (query-string) - Data format for the response.
8699 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8700 /// * *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.
8701 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8702 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8703 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8704 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8705 pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
8706 where
8707 T: AsRef<str>,
8708 {
8709 self._additional_params
8710 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8711 self
8712 }
8713
8714 /// Identifies the authorization scope for the method you are building.
8715 ///
8716 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8717 /// [`Scope::Readonly`].
8718 ///
8719 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8720 /// tokens for more than one scope.
8721 ///
8722 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8723 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8724 /// sufficient, a read-write scope will do as well.
8725 pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
8726 where
8727 St: AsRef<str>,
8728 {
8729 self._scopes.insert(String::from(scope.as_ref()));
8730 self
8731 }
8732 /// Identifies the authorization scope(s) for the method you are building.
8733 ///
8734 /// See [`Self::add_scope()`] for details.
8735 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
8736 where
8737 I: IntoIterator<Item = St>,
8738 St: AsRef<str>,
8739 {
8740 self._scopes
8741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8742 self
8743 }
8744
8745 /// Removes all scopes, and no default scope will be used either.
8746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8747 /// for details).
8748 pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
8749 self._scopes.clear();
8750 self
8751 }
8752}
8753
8754/// List all accounts available to this AdSense account.
8755///
8756/// A builder for the *list* method supported by a *account* resource.
8757/// It is not used directly, but through a [`AccountMethods`] instance.
8758///
8759/// # Example
8760///
8761/// Instantiate a resource method builder
8762///
8763/// ```test_harness,no_run
8764/// # extern crate hyper;
8765/// # extern crate hyper_rustls;
8766/// # extern crate google_adsense1d4 as adsense1d4;
8767/// # async fn dox() {
8768/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8769///
8770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8771/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8772/// # .with_native_roots()
8773/// # .unwrap()
8774/// # .https_only()
8775/// # .enable_http2()
8776/// # .build();
8777///
8778/// # let executor = hyper_util::rt::TokioExecutor::new();
8779/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8780/// # secret,
8781/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8782/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8783/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8784/// # ),
8785/// # ).build().await.unwrap();
8786///
8787/// # let client = hyper_util::client::legacy::Client::builder(
8788/// # hyper_util::rt::TokioExecutor::new()
8789/// # )
8790/// # .build(
8791/// # hyper_rustls::HttpsConnectorBuilder::new()
8792/// # .with_native_roots()
8793/// # .unwrap()
8794/// # .https_or_http()
8795/// # .enable_http2()
8796/// # .build()
8797/// # );
8798/// # let mut hub = AdSense::new(client, auth);
8799/// // You can configure optional parameters by calling the respective setters at will, and
8800/// // execute the final call using `doit()`.
8801/// // Values shown here are possibly random and not representative !
8802/// let result = hub.accounts().list()
8803/// .page_token("est")
8804/// .max_results(-30)
8805/// .doit().await;
8806/// # }
8807/// ```
8808pub struct AccountListCall<'a, C>
8809where
8810 C: 'a,
8811{
8812 hub: &'a AdSense<C>,
8813 _page_token: Option<String>,
8814 _max_results: Option<i32>,
8815 _delegate: Option<&'a mut dyn common::Delegate>,
8816 _additional_params: HashMap<String, String>,
8817 _scopes: BTreeSet<String>,
8818}
8819
8820impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
8821
8822impl<'a, C> AccountListCall<'a, C>
8823where
8824 C: common::Connector,
8825{
8826 /// Perform the operation you have build so far.
8827 pub async fn doit(mut self) -> common::Result<(common::Response, Accounts)> {
8828 use std::borrow::Cow;
8829 use std::io::{Read, Seek};
8830
8831 use common::{url::Params, ToParts};
8832 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8833
8834 let mut dd = common::DefaultDelegate;
8835 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8836 dlg.begin(common::MethodInfo {
8837 id: "adsense.accounts.list",
8838 http_method: hyper::Method::GET,
8839 });
8840
8841 for &field in ["alt", "pageToken", "maxResults"].iter() {
8842 if self._additional_params.contains_key(field) {
8843 dlg.finished(false);
8844 return Err(common::Error::FieldClash(field));
8845 }
8846 }
8847
8848 let mut params = Params::with_capacity(4 + self._additional_params.len());
8849 if let Some(value) = self._page_token.as_ref() {
8850 params.push("pageToken", value);
8851 }
8852 if let Some(value) = self._max_results.as_ref() {
8853 params.push("maxResults", value.to_string());
8854 }
8855
8856 params.extend(self._additional_params.iter());
8857
8858 params.push("alt", "json");
8859 let mut url = self.hub._base_url.clone() + "accounts";
8860 if self._scopes.is_empty() {
8861 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8862 }
8863
8864 let url = params.parse_with_url(&url);
8865
8866 loop {
8867 let token = match self
8868 .hub
8869 .auth
8870 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8871 .await
8872 {
8873 Ok(token) => token,
8874 Err(e) => match dlg.token(e) {
8875 Ok(token) => token,
8876 Err(e) => {
8877 dlg.finished(false);
8878 return Err(common::Error::MissingToken(e));
8879 }
8880 },
8881 };
8882 let mut req_result = {
8883 let client = &self.hub.client;
8884 dlg.pre_request();
8885 let mut req_builder = hyper::Request::builder()
8886 .method(hyper::Method::GET)
8887 .uri(url.as_str())
8888 .header(USER_AGENT, self.hub._user_agent.clone());
8889
8890 if let Some(token) = token.as_ref() {
8891 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8892 }
8893
8894 let request = req_builder
8895 .header(CONTENT_LENGTH, 0_u64)
8896 .body(common::to_body::<String>(None));
8897
8898 client.request(request.unwrap()).await
8899 };
8900
8901 match req_result {
8902 Err(err) => {
8903 if let common::Retry::After(d) = dlg.http_error(&err) {
8904 sleep(d).await;
8905 continue;
8906 }
8907 dlg.finished(false);
8908 return Err(common::Error::HttpError(err));
8909 }
8910 Ok(res) => {
8911 let (mut parts, body) = res.into_parts();
8912 let mut body = common::Body::new(body);
8913 if !parts.status.is_success() {
8914 let bytes = common::to_bytes(body).await.unwrap_or_default();
8915 let error = serde_json::from_str(&common::to_string(&bytes));
8916 let response = common::to_response(parts, bytes.into());
8917
8918 if let common::Retry::After(d) =
8919 dlg.http_failure(&response, error.as_ref().ok())
8920 {
8921 sleep(d).await;
8922 continue;
8923 }
8924
8925 dlg.finished(false);
8926
8927 return Err(match error {
8928 Ok(value) => common::Error::BadRequest(value),
8929 _ => common::Error::Failure(response),
8930 });
8931 }
8932 let response = {
8933 let bytes = common::to_bytes(body).await.unwrap_or_default();
8934 let encoded = common::to_string(&bytes);
8935 match serde_json::from_str(&encoded) {
8936 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8937 Err(error) => {
8938 dlg.response_json_decode_error(&encoded, &error);
8939 return Err(common::Error::JsonDecodeError(
8940 encoded.to_string(),
8941 error,
8942 ));
8943 }
8944 }
8945 };
8946
8947 dlg.finished(true);
8948 return Ok(response);
8949 }
8950 }
8951 }
8952 }
8953
8954 /// 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.
8955 ///
8956 /// Sets the *page token* query property to the given value.
8957 pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C> {
8958 self._page_token = Some(new_value.to_string());
8959 self
8960 }
8961 /// The maximum number of accounts to include in the response, used for paging.
8962 ///
8963 /// Sets the *max results* query property to the given value.
8964 pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C> {
8965 self._max_results = Some(new_value);
8966 self
8967 }
8968 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8969 /// while executing the actual API request.
8970 ///
8971 /// ````text
8972 /// It should be used to handle progress information, and to implement a certain level of resilience.
8973 /// ````
8974 ///
8975 /// Sets the *delegate* property to the given value.
8976 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
8977 self._delegate = Some(new_value);
8978 self
8979 }
8980
8981 /// Set any additional parameter of the query string used in the request.
8982 /// It should be used to set parameters which are not yet available through their own
8983 /// setters.
8984 ///
8985 /// Please note that this method must not be used to set any of the known parameters
8986 /// which have their own setter method. If done anyway, the request will fail.
8987 ///
8988 /// # Additional Parameters
8989 ///
8990 /// * *alt* (query-string) - Data format for the response.
8991 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8992 /// * *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.
8993 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8994 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8995 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8996 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8997 pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
8998 where
8999 T: AsRef<str>,
9000 {
9001 self._additional_params
9002 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9003 self
9004 }
9005
9006 /// Identifies the authorization scope for the method you are building.
9007 ///
9008 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9009 /// [`Scope::Readonly`].
9010 ///
9011 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9012 /// tokens for more than one scope.
9013 ///
9014 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9015 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9016 /// sufficient, a read-write scope will do as well.
9017 pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
9018 where
9019 St: AsRef<str>,
9020 {
9021 self._scopes.insert(String::from(scope.as_ref()));
9022 self
9023 }
9024 /// Identifies the authorization scope(s) for the method you are building.
9025 ///
9026 /// See [`Self::add_scope()`] for details.
9027 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
9028 where
9029 I: IntoIterator<Item = St>,
9030 St: AsRef<str>,
9031 {
9032 self._scopes
9033 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9034 self
9035 }
9036
9037 /// Removes all scopes, and no default scope will be used either.
9038 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9039 /// for details).
9040 pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
9041 self._scopes.clear();
9042 self
9043 }
9044}
9045
9046/// List all ad clients in this AdSense account.
9047///
9048/// A builder for the *list* method supported by a *adclient* resource.
9049/// It is not used directly, but through a [`AdclientMethods`] instance.
9050///
9051/// # Example
9052///
9053/// Instantiate a resource method builder
9054///
9055/// ```test_harness,no_run
9056/// # extern crate hyper;
9057/// # extern crate hyper_rustls;
9058/// # extern crate google_adsense1d4 as adsense1d4;
9059/// # async fn dox() {
9060/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9061///
9062/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9063/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9064/// # .with_native_roots()
9065/// # .unwrap()
9066/// # .https_only()
9067/// # .enable_http2()
9068/// # .build();
9069///
9070/// # let executor = hyper_util::rt::TokioExecutor::new();
9071/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9072/// # secret,
9073/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9074/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9075/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9076/// # ),
9077/// # ).build().await.unwrap();
9078///
9079/// # let client = hyper_util::client::legacy::Client::builder(
9080/// # hyper_util::rt::TokioExecutor::new()
9081/// # )
9082/// # .build(
9083/// # hyper_rustls::HttpsConnectorBuilder::new()
9084/// # .with_native_roots()
9085/// # .unwrap()
9086/// # .https_or_http()
9087/// # .enable_http2()
9088/// # .build()
9089/// # );
9090/// # let mut hub = AdSense::new(client, auth);
9091/// // You can configure optional parameters by calling the respective setters at will, and
9092/// // execute the final call using `doit()`.
9093/// // Values shown here are possibly random and not representative !
9094/// let result = hub.adclients().list()
9095/// .page_token("diam")
9096/// .max_results(-19)
9097/// .doit().await;
9098/// # }
9099/// ```
9100pub struct AdclientListCall<'a, C>
9101where
9102 C: 'a,
9103{
9104 hub: &'a AdSense<C>,
9105 _page_token: Option<String>,
9106 _max_results: Option<i32>,
9107 _delegate: Option<&'a mut dyn common::Delegate>,
9108 _additional_params: HashMap<String, String>,
9109 _scopes: BTreeSet<String>,
9110}
9111
9112impl<'a, C> common::CallBuilder for AdclientListCall<'a, C> {}
9113
9114impl<'a, C> AdclientListCall<'a, C>
9115where
9116 C: common::Connector,
9117{
9118 /// Perform the operation you have build so far.
9119 pub async fn doit(mut self) -> common::Result<(common::Response, AdClients)> {
9120 use std::borrow::Cow;
9121 use std::io::{Read, Seek};
9122
9123 use common::{url::Params, ToParts};
9124 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9125
9126 let mut dd = common::DefaultDelegate;
9127 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9128 dlg.begin(common::MethodInfo {
9129 id: "adsense.adclients.list",
9130 http_method: hyper::Method::GET,
9131 });
9132
9133 for &field in ["alt", "pageToken", "maxResults"].iter() {
9134 if self._additional_params.contains_key(field) {
9135 dlg.finished(false);
9136 return Err(common::Error::FieldClash(field));
9137 }
9138 }
9139
9140 let mut params = Params::with_capacity(4 + self._additional_params.len());
9141 if let Some(value) = self._page_token.as_ref() {
9142 params.push("pageToken", value);
9143 }
9144 if let Some(value) = self._max_results.as_ref() {
9145 params.push("maxResults", value.to_string());
9146 }
9147
9148 params.extend(self._additional_params.iter());
9149
9150 params.push("alt", "json");
9151 let mut url = self.hub._base_url.clone() + "adclients";
9152 if self._scopes.is_empty() {
9153 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9154 }
9155
9156 let url = params.parse_with_url(&url);
9157
9158 loop {
9159 let token = match self
9160 .hub
9161 .auth
9162 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9163 .await
9164 {
9165 Ok(token) => token,
9166 Err(e) => match dlg.token(e) {
9167 Ok(token) => token,
9168 Err(e) => {
9169 dlg.finished(false);
9170 return Err(common::Error::MissingToken(e));
9171 }
9172 },
9173 };
9174 let mut req_result = {
9175 let client = &self.hub.client;
9176 dlg.pre_request();
9177 let mut req_builder = hyper::Request::builder()
9178 .method(hyper::Method::GET)
9179 .uri(url.as_str())
9180 .header(USER_AGENT, self.hub._user_agent.clone());
9181
9182 if let Some(token) = token.as_ref() {
9183 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9184 }
9185
9186 let request = req_builder
9187 .header(CONTENT_LENGTH, 0_u64)
9188 .body(common::to_body::<String>(None));
9189
9190 client.request(request.unwrap()).await
9191 };
9192
9193 match req_result {
9194 Err(err) => {
9195 if let common::Retry::After(d) = dlg.http_error(&err) {
9196 sleep(d).await;
9197 continue;
9198 }
9199 dlg.finished(false);
9200 return Err(common::Error::HttpError(err));
9201 }
9202 Ok(res) => {
9203 let (mut parts, body) = res.into_parts();
9204 let mut body = common::Body::new(body);
9205 if !parts.status.is_success() {
9206 let bytes = common::to_bytes(body).await.unwrap_or_default();
9207 let error = serde_json::from_str(&common::to_string(&bytes));
9208 let response = common::to_response(parts, bytes.into());
9209
9210 if let common::Retry::After(d) =
9211 dlg.http_failure(&response, error.as_ref().ok())
9212 {
9213 sleep(d).await;
9214 continue;
9215 }
9216
9217 dlg.finished(false);
9218
9219 return Err(match error {
9220 Ok(value) => common::Error::BadRequest(value),
9221 _ => common::Error::Failure(response),
9222 });
9223 }
9224 let response = {
9225 let bytes = common::to_bytes(body).await.unwrap_or_default();
9226 let encoded = common::to_string(&bytes);
9227 match serde_json::from_str(&encoded) {
9228 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9229 Err(error) => {
9230 dlg.response_json_decode_error(&encoded, &error);
9231 return Err(common::Error::JsonDecodeError(
9232 encoded.to_string(),
9233 error,
9234 ));
9235 }
9236 }
9237 };
9238
9239 dlg.finished(true);
9240 return Ok(response);
9241 }
9242 }
9243 }
9244 }
9245
9246 /// 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.
9247 ///
9248 /// Sets the *page token* query property to the given value.
9249 pub fn page_token(mut self, new_value: &str) -> AdclientListCall<'a, C> {
9250 self._page_token = Some(new_value.to_string());
9251 self
9252 }
9253 /// The maximum number of ad clients to include in the response, used for paging.
9254 ///
9255 /// Sets the *max results* query property to the given value.
9256 pub fn max_results(mut self, new_value: i32) -> AdclientListCall<'a, C> {
9257 self._max_results = Some(new_value);
9258 self
9259 }
9260 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9261 /// while executing the actual API request.
9262 ///
9263 /// ````text
9264 /// It should be used to handle progress information, and to implement a certain level of resilience.
9265 /// ````
9266 ///
9267 /// Sets the *delegate* property to the given value.
9268 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdclientListCall<'a, C> {
9269 self._delegate = Some(new_value);
9270 self
9271 }
9272
9273 /// Set any additional parameter of the query string used in the request.
9274 /// It should be used to set parameters which are not yet available through their own
9275 /// setters.
9276 ///
9277 /// Please note that this method must not be used to set any of the known parameters
9278 /// which have their own setter method. If done anyway, the request will fail.
9279 ///
9280 /// # Additional Parameters
9281 ///
9282 /// * *alt* (query-string) - Data format for the response.
9283 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9284 /// * *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.
9285 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9286 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9287 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9288 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9289 pub fn param<T>(mut self, name: T, value: T) -> AdclientListCall<'a, C>
9290 where
9291 T: AsRef<str>,
9292 {
9293 self._additional_params
9294 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9295 self
9296 }
9297
9298 /// Identifies the authorization scope for the method you are building.
9299 ///
9300 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9301 /// [`Scope::Readonly`].
9302 ///
9303 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9304 /// tokens for more than one scope.
9305 ///
9306 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9307 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9308 /// sufficient, a read-write scope will do as well.
9309 pub fn add_scope<St>(mut self, scope: St) -> AdclientListCall<'a, C>
9310 where
9311 St: AsRef<str>,
9312 {
9313 self._scopes.insert(String::from(scope.as_ref()));
9314 self
9315 }
9316 /// Identifies the authorization scope(s) for the method you are building.
9317 ///
9318 /// See [`Self::add_scope()`] for details.
9319 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdclientListCall<'a, C>
9320 where
9321 I: IntoIterator<Item = St>,
9322 St: AsRef<str>,
9323 {
9324 self._scopes
9325 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9326 self
9327 }
9328
9329 /// Removes all scopes, and no default scope will be used either.
9330 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9331 /// for details).
9332 pub fn clear_scopes(mut self) -> AdclientListCall<'a, C> {
9333 self._scopes.clear();
9334 self
9335 }
9336}
9337
9338/// List all custom channels which the specified ad unit belongs to.
9339///
9340/// A builder for the *customchannels.list* method supported by a *adunit* resource.
9341/// It is not used directly, but through a [`AdunitMethods`] instance.
9342///
9343/// # Example
9344///
9345/// Instantiate a resource method builder
9346///
9347/// ```test_harness,no_run
9348/// # extern crate hyper;
9349/// # extern crate hyper_rustls;
9350/// # extern crate google_adsense1d4 as adsense1d4;
9351/// # async fn dox() {
9352/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9353///
9354/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9355/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9356/// # .with_native_roots()
9357/// # .unwrap()
9358/// # .https_only()
9359/// # .enable_http2()
9360/// # .build();
9361///
9362/// # let executor = hyper_util::rt::TokioExecutor::new();
9363/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9364/// # secret,
9365/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9366/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9367/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9368/// # ),
9369/// # ).build().await.unwrap();
9370///
9371/// # let client = hyper_util::client::legacy::Client::builder(
9372/// # hyper_util::rt::TokioExecutor::new()
9373/// # )
9374/// # .build(
9375/// # hyper_rustls::HttpsConnectorBuilder::new()
9376/// # .with_native_roots()
9377/// # .unwrap()
9378/// # .https_or_http()
9379/// # .enable_http2()
9380/// # .build()
9381/// # );
9382/// # let mut hub = AdSense::new(client, auth);
9383/// // You can configure optional parameters by calling the respective setters at will, and
9384/// // execute the final call using `doit()`.
9385/// // Values shown here are possibly random and not representative !
9386/// let result = hub.adunits().customchannels_list("adClientId", "adUnitId")
9387/// .page_token("sed")
9388/// .max_results(-11)
9389/// .doit().await;
9390/// # }
9391/// ```
9392pub struct AdunitCustomchannelListCall<'a, C>
9393where
9394 C: 'a,
9395{
9396 hub: &'a AdSense<C>,
9397 _ad_client_id: String,
9398 _ad_unit_id: String,
9399 _page_token: Option<String>,
9400 _max_results: Option<i32>,
9401 _delegate: Option<&'a mut dyn common::Delegate>,
9402 _additional_params: HashMap<String, String>,
9403 _scopes: BTreeSet<String>,
9404}
9405
9406impl<'a, C> common::CallBuilder for AdunitCustomchannelListCall<'a, C> {}
9407
9408impl<'a, C> AdunitCustomchannelListCall<'a, C>
9409where
9410 C: common::Connector,
9411{
9412 /// Perform the operation you have build so far.
9413 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
9414 use std::borrow::Cow;
9415 use std::io::{Read, Seek};
9416
9417 use common::{url::Params, ToParts};
9418 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9419
9420 let mut dd = common::DefaultDelegate;
9421 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9422 dlg.begin(common::MethodInfo {
9423 id: "adsense.adunits.customchannels.list",
9424 http_method: hyper::Method::GET,
9425 });
9426
9427 for &field in ["alt", "adClientId", "adUnitId", "pageToken", "maxResults"].iter() {
9428 if self._additional_params.contains_key(field) {
9429 dlg.finished(false);
9430 return Err(common::Error::FieldClash(field));
9431 }
9432 }
9433
9434 let mut params = Params::with_capacity(6 + self._additional_params.len());
9435 params.push("adClientId", self._ad_client_id);
9436 params.push("adUnitId", self._ad_unit_id);
9437 if let Some(value) = self._page_token.as_ref() {
9438 params.push("pageToken", value);
9439 }
9440 if let Some(value) = self._max_results.as_ref() {
9441 params.push("maxResults", value.to_string());
9442 }
9443
9444 params.extend(self._additional_params.iter());
9445
9446 params.push("alt", "json");
9447 let mut url =
9448 self.hub._base_url.clone() + "adclients/{adClientId}/adunits/{adUnitId}/customchannels";
9449 if self._scopes.is_empty() {
9450 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9451 }
9452
9453 #[allow(clippy::single_element_loop)]
9454 for &(find_this, param_name) in
9455 [("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].iter()
9456 {
9457 url = params.uri_replacement(url, param_name, find_this, false);
9458 }
9459 {
9460 let to_remove = ["adUnitId", "adClientId"];
9461 params.remove_params(&to_remove);
9462 }
9463
9464 let url = params.parse_with_url(&url);
9465
9466 loop {
9467 let token = match self
9468 .hub
9469 .auth
9470 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9471 .await
9472 {
9473 Ok(token) => token,
9474 Err(e) => match dlg.token(e) {
9475 Ok(token) => token,
9476 Err(e) => {
9477 dlg.finished(false);
9478 return Err(common::Error::MissingToken(e));
9479 }
9480 },
9481 };
9482 let mut req_result = {
9483 let client = &self.hub.client;
9484 dlg.pre_request();
9485 let mut req_builder = hyper::Request::builder()
9486 .method(hyper::Method::GET)
9487 .uri(url.as_str())
9488 .header(USER_AGENT, self.hub._user_agent.clone());
9489
9490 if let Some(token) = token.as_ref() {
9491 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9492 }
9493
9494 let request = req_builder
9495 .header(CONTENT_LENGTH, 0_u64)
9496 .body(common::to_body::<String>(None));
9497
9498 client.request(request.unwrap()).await
9499 };
9500
9501 match req_result {
9502 Err(err) => {
9503 if let common::Retry::After(d) = dlg.http_error(&err) {
9504 sleep(d).await;
9505 continue;
9506 }
9507 dlg.finished(false);
9508 return Err(common::Error::HttpError(err));
9509 }
9510 Ok(res) => {
9511 let (mut parts, body) = res.into_parts();
9512 let mut body = common::Body::new(body);
9513 if !parts.status.is_success() {
9514 let bytes = common::to_bytes(body).await.unwrap_or_default();
9515 let error = serde_json::from_str(&common::to_string(&bytes));
9516 let response = common::to_response(parts, bytes.into());
9517
9518 if let common::Retry::After(d) =
9519 dlg.http_failure(&response, error.as_ref().ok())
9520 {
9521 sleep(d).await;
9522 continue;
9523 }
9524
9525 dlg.finished(false);
9526
9527 return Err(match error {
9528 Ok(value) => common::Error::BadRequest(value),
9529 _ => common::Error::Failure(response),
9530 });
9531 }
9532 let response = {
9533 let bytes = common::to_bytes(body).await.unwrap_or_default();
9534 let encoded = common::to_string(&bytes);
9535 match serde_json::from_str(&encoded) {
9536 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9537 Err(error) => {
9538 dlg.response_json_decode_error(&encoded, &error);
9539 return Err(common::Error::JsonDecodeError(
9540 encoded.to_string(),
9541 error,
9542 ));
9543 }
9544 }
9545 };
9546
9547 dlg.finished(true);
9548 return Ok(response);
9549 }
9550 }
9551 }
9552 }
9553
9554 /// Ad client which contains the ad unit.
9555 ///
9556 /// Sets the *ad client id* path property to the given value.
9557 ///
9558 /// Even though the property as already been set when instantiating this call,
9559 /// we provide this method for API completeness.
9560 pub fn ad_client_id(mut self, new_value: &str) -> AdunitCustomchannelListCall<'a, C> {
9561 self._ad_client_id = new_value.to_string();
9562 self
9563 }
9564 /// Ad unit for which to list custom channels.
9565 ///
9566 /// Sets the *ad unit id* path property to the given value.
9567 ///
9568 /// Even though the property as already been set when instantiating this call,
9569 /// we provide this method for API completeness.
9570 pub fn ad_unit_id(mut self, new_value: &str) -> AdunitCustomchannelListCall<'a, C> {
9571 self._ad_unit_id = new_value.to_string();
9572 self
9573 }
9574 /// 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.
9575 ///
9576 /// Sets the *page token* query property to the given value.
9577 pub fn page_token(mut self, new_value: &str) -> AdunitCustomchannelListCall<'a, C> {
9578 self._page_token = Some(new_value.to_string());
9579 self
9580 }
9581 /// The maximum number of custom channels to include in the response, used for paging.
9582 ///
9583 /// Sets the *max results* query property to the given value.
9584 pub fn max_results(mut self, new_value: i32) -> AdunitCustomchannelListCall<'a, C> {
9585 self._max_results = Some(new_value);
9586 self
9587 }
9588 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9589 /// while executing the actual API request.
9590 ///
9591 /// ````text
9592 /// It should be used to handle progress information, and to implement a certain level of resilience.
9593 /// ````
9594 ///
9595 /// Sets the *delegate* property to the given value.
9596 pub fn delegate(
9597 mut self,
9598 new_value: &'a mut dyn common::Delegate,
9599 ) -> AdunitCustomchannelListCall<'a, C> {
9600 self._delegate = Some(new_value);
9601 self
9602 }
9603
9604 /// Set any additional parameter of the query string used in the request.
9605 /// It should be used to set parameters which are not yet available through their own
9606 /// setters.
9607 ///
9608 /// Please note that this method must not be used to set any of the known parameters
9609 /// which have their own setter method. If done anyway, the request will fail.
9610 ///
9611 /// # Additional Parameters
9612 ///
9613 /// * *alt* (query-string) - Data format for the response.
9614 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9615 /// * *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.
9616 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9617 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9618 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9619 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9620 pub fn param<T>(mut self, name: T, value: T) -> AdunitCustomchannelListCall<'a, C>
9621 where
9622 T: AsRef<str>,
9623 {
9624 self._additional_params
9625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9626 self
9627 }
9628
9629 /// Identifies the authorization scope for the method you are building.
9630 ///
9631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9632 /// [`Scope::Readonly`].
9633 ///
9634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9635 /// tokens for more than one scope.
9636 ///
9637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9639 /// sufficient, a read-write scope will do as well.
9640 pub fn add_scope<St>(mut self, scope: St) -> AdunitCustomchannelListCall<'a, C>
9641 where
9642 St: AsRef<str>,
9643 {
9644 self._scopes.insert(String::from(scope.as_ref()));
9645 self
9646 }
9647 /// Identifies the authorization scope(s) for the method you are building.
9648 ///
9649 /// See [`Self::add_scope()`] for details.
9650 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdunitCustomchannelListCall<'a, C>
9651 where
9652 I: IntoIterator<Item = St>,
9653 St: AsRef<str>,
9654 {
9655 self._scopes
9656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9657 self
9658 }
9659
9660 /// Removes all scopes, and no default scope will be used either.
9661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9662 /// for details).
9663 pub fn clear_scopes(mut self) -> AdunitCustomchannelListCall<'a, C> {
9664 self._scopes.clear();
9665 self
9666 }
9667}
9668
9669/// Gets the specified ad unit in the specified ad client.
9670///
9671/// A builder for the *get* method supported by a *adunit* resource.
9672/// It is not used directly, but through a [`AdunitMethods`] instance.
9673///
9674/// # Example
9675///
9676/// Instantiate a resource method builder
9677///
9678/// ```test_harness,no_run
9679/// # extern crate hyper;
9680/// # extern crate hyper_rustls;
9681/// # extern crate google_adsense1d4 as adsense1d4;
9682/// # async fn dox() {
9683/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9684///
9685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9687/// # .with_native_roots()
9688/// # .unwrap()
9689/// # .https_only()
9690/// # .enable_http2()
9691/// # .build();
9692///
9693/// # let executor = hyper_util::rt::TokioExecutor::new();
9694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9695/// # secret,
9696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9697/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9698/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9699/// # ),
9700/// # ).build().await.unwrap();
9701///
9702/// # let client = hyper_util::client::legacy::Client::builder(
9703/// # hyper_util::rt::TokioExecutor::new()
9704/// # )
9705/// # .build(
9706/// # hyper_rustls::HttpsConnectorBuilder::new()
9707/// # .with_native_roots()
9708/// # .unwrap()
9709/// # .https_or_http()
9710/// # .enable_http2()
9711/// # .build()
9712/// # );
9713/// # let mut hub = AdSense::new(client, auth);
9714/// // You can configure optional parameters by calling the respective setters at will, and
9715/// // execute the final call using `doit()`.
9716/// // Values shown here are possibly random and not representative !
9717/// let result = hub.adunits().get("adClientId", "adUnitId")
9718/// .doit().await;
9719/// # }
9720/// ```
9721pub struct AdunitGetCall<'a, C>
9722where
9723 C: 'a,
9724{
9725 hub: &'a AdSense<C>,
9726 _ad_client_id: String,
9727 _ad_unit_id: String,
9728 _delegate: Option<&'a mut dyn common::Delegate>,
9729 _additional_params: HashMap<String, String>,
9730 _scopes: BTreeSet<String>,
9731}
9732
9733impl<'a, C> common::CallBuilder for AdunitGetCall<'a, C> {}
9734
9735impl<'a, C> AdunitGetCall<'a, C>
9736where
9737 C: common::Connector,
9738{
9739 /// Perform the operation you have build so far.
9740 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
9741 use std::borrow::Cow;
9742 use std::io::{Read, Seek};
9743
9744 use common::{url::Params, ToParts};
9745 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9746
9747 let mut dd = common::DefaultDelegate;
9748 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9749 dlg.begin(common::MethodInfo {
9750 id: "adsense.adunits.get",
9751 http_method: hyper::Method::GET,
9752 });
9753
9754 for &field in ["alt", "adClientId", "adUnitId"].iter() {
9755 if self._additional_params.contains_key(field) {
9756 dlg.finished(false);
9757 return Err(common::Error::FieldClash(field));
9758 }
9759 }
9760
9761 let mut params = Params::with_capacity(4 + self._additional_params.len());
9762 params.push("adClientId", self._ad_client_id);
9763 params.push("adUnitId", self._ad_unit_id);
9764
9765 params.extend(self._additional_params.iter());
9766
9767 params.push("alt", "json");
9768 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/adunits/{adUnitId}";
9769 if self._scopes.is_empty() {
9770 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9771 }
9772
9773 #[allow(clippy::single_element_loop)]
9774 for &(find_this, param_name) in
9775 [("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].iter()
9776 {
9777 url = params.uri_replacement(url, param_name, find_this, false);
9778 }
9779 {
9780 let to_remove = ["adUnitId", "adClientId"];
9781 params.remove_params(&to_remove);
9782 }
9783
9784 let url = params.parse_with_url(&url);
9785
9786 loop {
9787 let token = match self
9788 .hub
9789 .auth
9790 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9791 .await
9792 {
9793 Ok(token) => token,
9794 Err(e) => match dlg.token(e) {
9795 Ok(token) => token,
9796 Err(e) => {
9797 dlg.finished(false);
9798 return Err(common::Error::MissingToken(e));
9799 }
9800 },
9801 };
9802 let mut req_result = {
9803 let client = &self.hub.client;
9804 dlg.pre_request();
9805 let mut req_builder = hyper::Request::builder()
9806 .method(hyper::Method::GET)
9807 .uri(url.as_str())
9808 .header(USER_AGENT, self.hub._user_agent.clone());
9809
9810 if let Some(token) = token.as_ref() {
9811 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9812 }
9813
9814 let request = req_builder
9815 .header(CONTENT_LENGTH, 0_u64)
9816 .body(common::to_body::<String>(None));
9817
9818 client.request(request.unwrap()).await
9819 };
9820
9821 match req_result {
9822 Err(err) => {
9823 if let common::Retry::After(d) = dlg.http_error(&err) {
9824 sleep(d).await;
9825 continue;
9826 }
9827 dlg.finished(false);
9828 return Err(common::Error::HttpError(err));
9829 }
9830 Ok(res) => {
9831 let (mut parts, body) = res.into_parts();
9832 let mut body = common::Body::new(body);
9833 if !parts.status.is_success() {
9834 let bytes = common::to_bytes(body).await.unwrap_or_default();
9835 let error = serde_json::from_str(&common::to_string(&bytes));
9836 let response = common::to_response(parts, bytes.into());
9837
9838 if let common::Retry::After(d) =
9839 dlg.http_failure(&response, error.as_ref().ok())
9840 {
9841 sleep(d).await;
9842 continue;
9843 }
9844
9845 dlg.finished(false);
9846
9847 return Err(match error {
9848 Ok(value) => common::Error::BadRequest(value),
9849 _ => common::Error::Failure(response),
9850 });
9851 }
9852 let response = {
9853 let bytes = common::to_bytes(body).await.unwrap_or_default();
9854 let encoded = common::to_string(&bytes);
9855 match serde_json::from_str(&encoded) {
9856 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9857 Err(error) => {
9858 dlg.response_json_decode_error(&encoded, &error);
9859 return Err(common::Error::JsonDecodeError(
9860 encoded.to_string(),
9861 error,
9862 ));
9863 }
9864 }
9865 };
9866
9867 dlg.finished(true);
9868 return Ok(response);
9869 }
9870 }
9871 }
9872 }
9873
9874 /// Ad client for which to get the ad unit.
9875 ///
9876 /// Sets the *ad client id* path property to the given value.
9877 ///
9878 /// Even though the property as already been set when instantiating this call,
9879 /// we provide this method for API completeness.
9880 pub fn ad_client_id(mut self, new_value: &str) -> AdunitGetCall<'a, C> {
9881 self._ad_client_id = new_value.to_string();
9882 self
9883 }
9884 /// Ad unit to retrieve.
9885 ///
9886 /// Sets the *ad unit id* path property to the given value.
9887 ///
9888 /// Even though the property as already been set when instantiating this call,
9889 /// we provide this method for API completeness.
9890 pub fn ad_unit_id(mut self, new_value: &str) -> AdunitGetCall<'a, C> {
9891 self._ad_unit_id = new_value.to_string();
9892 self
9893 }
9894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9895 /// while executing the actual API request.
9896 ///
9897 /// ````text
9898 /// It should be used to handle progress information, and to implement a certain level of resilience.
9899 /// ````
9900 ///
9901 /// Sets the *delegate* property to the given value.
9902 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdunitGetCall<'a, C> {
9903 self._delegate = Some(new_value);
9904 self
9905 }
9906
9907 /// Set any additional parameter of the query string used in the request.
9908 /// It should be used to set parameters which are not yet available through their own
9909 /// setters.
9910 ///
9911 /// Please note that this method must not be used to set any of the known parameters
9912 /// which have their own setter method. If done anyway, the request will fail.
9913 ///
9914 /// # Additional Parameters
9915 ///
9916 /// * *alt* (query-string) - Data format for the response.
9917 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9918 /// * *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.
9919 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9920 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9921 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9922 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9923 pub fn param<T>(mut self, name: T, value: T) -> AdunitGetCall<'a, C>
9924 where
9925 T: AsRef<str>,
9926 {
9927 self._additional_params
9928 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9929 self
9930 }
9931
9932 /// Identifies the authorization scope for the method you are building.
9933 ///
9934 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9935 /// [`Scope::Readonly`].
9936 ///
9937 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9938 /// tokens for more than one scope.
9939 ///
9940 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9941 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9942 /// sufficient, a read-write scope will do as well.
9943 pub fn add_scope<St>(mut self, scope: St) -> AdunitGetCall<'a, C>
9944 where
9945 St: AsRef<str>,
9946 {
9947 self._scopes.insert(String::from(scope.as_ref()));
9948 self
9949 }
9950 /// Identifies the authorization scope(s) for the method you are building.
9951 ///
9952 /// See [`Self::add_scope()`] for details.
9953 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdunitGetCall<'a, C>
9954 where
9955 I: IntoIterator<Item = St>,
9956 St: AsRef<str>,
9957 {
9958 self._scopes
9959 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9960 self
9961 }
9962
9963 /// Removes all scopes, and no default scope will be used either.
9964 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9965 /// for details).
9966 pub fn clear_scopes(mut self) -> AdunitGetCall<'a, C> {
9967 self._scopes.clear();
9968 self
9969 }
9970}
9971
9972/// Get ad code for the specified ad unit.
9973///
9974/// A builder for the *getAdCode* method supported by a *adunit* resource.
9975/// It is not used directly, but through a [`AdunitMethods`] instance.
9976///
9977/// # Example
9978///
9979/// Instantiate a resource method builder
9980///
9981/// ```test_harness,no_run
9982/// # extern crate hyper;
9983/// # extern crate hyper_rustls;
9984/// # extern crate google_adsense1d4 as adsense1d4;
9985/// # async fn dox() {
9986/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9987///
9988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9990/// # .with_native_roots()
9991/// # .unwrap()
9992/// # .https_only()
9993/// # .enable_http2()
9994/// # .build();
9995///
9996/// # let executor = hyper_util::rt::TokioExecutor::new();
9997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9998/// # secret,
9999/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10000/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10001/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10002/// # ),
10003/// # ).build().await.unwrap();
10004///
10005/// # let client = hyper_util::client::legacy::Client::builder(
10006/// # hyper_util::rt::TokioExecutor::new()
10007/// # )
10008/// # .build(
10009/// # hyper_rustls::HttpsConnectorBuilder::new()
10010/// # .with_native_roots()
10011/// # .unwrap()
10012/// # .https_or_http()
10013/// # .enable_http2()
10014/// # .build()
10015/// # );
10016/// # let mut hub = AdSense::new(client, auth);
10017/// // You can configure optional parameters by calling the respective setters at will, and
10018/// // execute the final call using `doit()`.
10019/// // Values shown here are possibly random and not representative !
10020/// let result = hub.adunits().get_ad_code("adClientId", "adUnitId")
10021/// .doit().await;
10022/// # }
10023/// ```
10024pub struct AdunitGetAdCodeCall<'a, C>
10025where
10026 C: 'a,
10027{
10028 hub: &'a AdSense<C>,
10029 _ad_client_id: String,
10030 _ad_unit_id: String,
10031 _delegate: Option<&'a mut dyn common::Delegate>,
10032 _additional_params: HashMap<String, String>,
10033 _scopes: BTreeSet<String>,
10034}
10035
10036impl<'a, C> common::CallBuilder for AdunitGetAdCodeCall<'a, C> {}
10037
10038impl<'a, C> AdunitGetAdCodeCall<'a, C>
10039where
10040 C: common::Connector,
10041{
10042 /// Perform the operation you have build so far.
10043 pub async fn doit(mut self) -> common::Result<(common::Response, AdCode)> {
10044 use std::borrow::Cow;
10045 use std::io::{Read, Seek};
10046
10047 use common::{url::Params, ToParts};
10048 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10049
10050 let mut dd = common::DefaultDelegate;
10051 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10052 dlg.begin(common::MethodInfo {
10053 id: "adsense.adunits.getAdCode",
10054 http_method: hyper::Method::GET,
10055 });
10056
10057 for &field in ["alt", "adClientId", "adUnitId"].iter() {
10058 if self._additional_params.contains_key(field) {
10059 dlg.finished(false);
10060 return Err(common::Error::FieldClash(field));
10061 }
10062 }
10063
10064 let mut params = Params::with_capacity(4 + self._additional_params.len());
10065 params.push("adClientId", self._ad_client_id);
10066 params.push("adUnitId", self._ad_unit_id);
10067
10068 params.extend(self._additional_params.iter());
10069
10070 params.push("alt", "json");
10071 let mut url =
10072 self.hub._base_url.clone() + "adclients/{adClientId}/adunits/{adUnitId}/adcode";
10073 if self._scopes.is_empty() {
10074 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10075 }
10076
10077 #[allow(clippy::single_element_loop)]
10078 for &(find_this, param_name) in
10079 [("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].iter()
10080 {
10081 url = params.uri_replacement(url, param_name, find_this, false);
10082 }
10083 {
10084 let to_remove = ["adUnitId", "adClientId"];
10085 params.remove_params(&to_remove);
10086 }
10087
10088 let url = params.parse_with_url(&url);
10089
10090 loop {
10091 let token = match self
10092 .hub
10093 .auth
10094 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10095 .await
10096 {
10097 Ok(token) => token,
10098 Err(e) => match dlg.token(e) {
10099 Ok(token) => token,
10100 Err(e) => {
10101 dlg.finished(false);
10102 return Err(common::Error::MissingToken(e));
10103 }
10104 },
10105 };
10106 let mut req_result = {
10107 let client = &self.hub.client;
10108 dlg.pre_request();
10109 let mut req_builder = hyper::Request::builder()
10110 .method(hyper::Method::GET)
10111 .uri(url.as_str())
10112 .header(USER_AGENT, self.hub._user_agent.clone());
10113
10114 if let Some(token) = token.as_ref() {
10115 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10116 }
10117
10118 let request = req_builder
10119 .header(CONTENT_LENGTH, 0_u64)
10120 .body(common::to_body::<String>(None));
10121
10122 client.request(request.unwrap()).await
10123 };
10124
10125 match req_result {
10126 Err(err) => {
10127 if let common::Retry::After(d) = dlg.http_error(&err) {
10128 sleep(d).await;
10129 continue;
10130 }
10131 dlg.finished(false);
10132 return Err(common::Error::HttpError(err));
10133 }
10134 Ok(res) => {
10135 let (mut parts, body) = res.into_parts();
10136 let mut body = common::Body::new(body);
10137 if !parts.status.is_success() {
10138 let bytes = common::to_bytes(body).await.unwrap_or_default();
10139 let error = serde_json::from_str(&common::to_string(&bytes));
10140 let response = common::to_response(parts, bytes.into());
10141
10142 if let common::Retry::After(d) =
10143 dlg.http_failure(&response, error.as_ref().ok())
10144 {
10145 sleep(d).await;
10146 continue;
10147 }
10148
10149 dlg.finished(false);
10150
10151 return Err(match error {
10152 Ok(value) => common::Error::BadRequest(value),
10153 _ => common::Error::Failure(response),
10154 });
10155 }
10156 let response = {
10157 let bytes = common::to_bytes(body).await.unwrap_or_default();
10158 let encoded = common::to_string(&bytes);
10159 match serde_json::from_str(&encoded) {
10160 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10161 Err(error) => {
10162 dlg.response_json_decode_error(&encoded, &error);
10163 return Err(common::Error::JsonDecodeError(
10164 encoded.to_string(),
10165 error,
10166 ));
10167 }
10168 }
10169 };
10170
10171 dlg.finished(true);
10172 return Ok(response);
10173 }
10174 }
10175 }
10176 }
10177
10178 /// Ad client with contains the ad unit.
10179 ///
10180 /// Sets the *ad client id* path property to the given value.
10181 ///
10182 /// Even though the property as already been set when instantiating this call,
10183 /// we provide this method for API completeness.
10184 pub fn ad_client_id(mut self, new_value: &str) -> AdunitGetAdCodeCall<'a, C> {
10185 self._ad_client_id = new_value.to_string();
10186 self
10187 }
10188 /// Ad unit to get the code for.
10189 ///
10190 /// Sets the *ad unit id* path property to the given value.
10191 ///
10192 /// Even though the property as already been set when instantiating this call,
10193 /// we provide this method for API completeness.
10194 pub fn ad_unit_id(mut self, new_value: &str) -> AdunitGetAdCodeCall<'a, C> {
10195 self._ad_unit_id = new_value.to_string();
10196 self
10197 }
10198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10199 /// while executing the actual API request.
10200 ///
10201 /// ````text
10202 /// It should be used to handle progress information, and to implement a certain level of resilience.
10203 /// ````
10204 ///
10205 /// Sets the *delegate* property to the given value.
10206 pub fn delegate(
10207 mut self,
10208 new_value: &'a mut dyn common::Delegate,
10209 ) -> AdunitGetAdCodeCall<'a, C> {
10210 self._delegate = Some(new_value);
10211 self
10212 }
10213
10214 /// Set any additional parameter of the query string used in the request.
10215 /// It should be used to set parameters which are not yet available through their own
10216 /// setters.
10217 ///
10218 /// Please note that this method must not be used to set any of the known parameters
10219 /// which have their own setter method. If done anyway, the request will fail.
10220 ///
10221 /// # Additional Parameters
10222 ///
10223 /// * *alt* (query-string) - Data format for the response.
10224 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10225 /// * *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.
10226 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10227 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10228 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10229 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10230 pub fn param<T>(mut self, name: T, value: T) -> AdunitGetAdCodeCall<'a, C>
10231 where
10232 T: AsRef<str>,
10233 {
10234 self._additional_params
10235 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10236 self
10237 }
10238
10239 /// Identifies the authorization scope for the method you are building.
10240 ///
10241 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10242 /// [`Scope::Readonly`].
10243 ///
10244 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10245 /// tokens for more than one scope.
10246 ///
10247 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10248 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10249 /// sufficient, a read-write scope will do as well.
10250 pub fn add_scope<St>(mut self, scope: St) -> AdunitGetAdCodeCall<'a, C>
10251 where
10252 St: AsRef<str>,
10253 {
10254 self._scopes.insert(String::from(scope.as_ref()));
10255 self
10256 }
10257 /// Identifies the authorization scope(s) for the method you are building.
10258 ///
10259 /// See [`Self::add_scope()`] for details.
10260 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdunitGetAdCodeCall<'a, C>
10261 where
10262 I: IntoIterator<Item = St>,
10263 St: AsRef<str>,
10264 {
10265 self._scopes
10266 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10267 self
10268 }
10269
10270 /// Removes all scopes, and no default scope will be used either.
10271 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10272 /// for details).
10273 pub fn clear_scopes(mut self) -> AdunitGetAdCodeCall<'a, C> {
10274 self._scopes.clear();
10275 self
10276 }
10277}
10278
10279/// List all ad units in the specified ad client for this AdSense account.
10280///
10281/// A builder for the *list* method supported by a *adunit* resource.
10282/// It is not used directly, but through a [`AdunitMethods`] instance.
10283///
10284/// # Example
10285///
10286/// Instantiate a resource method builder
10287///
10288/// ```test_harness,no_run
10289/// # extern crate hyper;
10290/// # extern crate hyper_rustls;
10291/// # extern crate google_adsense1d4 as adsense1d4;
10292/// # async fn dox() {
10293/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10294///
10295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10297/// # .with_native_roots()
10298/// # .unwrap()
10299/// # .https_only()
10300/// # .enable_http2()
10301/// # .build();
10302///
10303/// # let executor = hyper_util::rt::TokioExecutor::new();
10304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10305/// # secret,
10306/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10307/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10308/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10309/// # ),
10310/// # ).build().await.unwrap();
10311///
10312/// # let client = hyper_util::client::legacy::Client::builder(
10313/// # hyper_util::rt::TokioExecutor::new()
10314/// # )
10315/// # .build(
10316/// # hyper_rustls::HttpsConnectorBuilder::new()
10317/// # .with_native_roots()
10318/// # .unwrap()
10319/// # .https_or_http()
10320/// # .enable_http2()
10321/// # .build()
10322/// # );
10323/// # let mut hub = AdSense::new(client, auth);
10324/// // You can configure optional parameters by calling the respective setters at will, and
10325/// // execute the final call using `doit()`.
10326/// // Values shown here are possibly random and not representative !
10327/// let result = hub.adunits().list("adClientId")
10328/// .page_token("At")
10329/// .max_results(-45)
10330/// .include_inactive(true)
10331/// .doit().await;
10332/// # }
10333/// ```
10334pub struct AdunitListCall<'a, C>
10335where
10336 C: 'a,
10337{
10338 hub: &'a AdSense<C>,
10339 _ad_client_id: String,
10340 _page_token: Option<String>,
10341 _max_results: Option<i32>,
10342 _include_inactive: Option<bool>,
10343 _delegate: Option<&'a mut dyn common::Delegate>,
10344 _additional_params: HashMap<String, String>,
10345 _scopes: BTreeSet<String>,
10346}
10347
10348impl<'a, C> common::CallBuilder for AdunitListCall<'a, C> {}
10349
10350impl<'a, C> AdunitListCall<'a, C>
10351where
10352 C: common::Connector,
10353{
10354 /// Perform the operation you have build so far.
10355 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnits)> {
10356 use std::borrow::Cow;
10357 use std::io::{Read, Seek};
10358
10359 use common::{url::Params, ToParts};
10360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10361
10362 let mut dd = common::DefaultDelegate;
10363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10364 dlg.begin(common::MethodInfo {
10365 id: "adsense.adunits.list",
10366 http_method: hyper::Method::GET,
10367 });
10368
10369 for &field in [
10370 "alt",
10371 "adClientId",
10372 "pageToken",
10373 "maxResults",
10374 "includeInactive",
10375 ]
10376 .iter()
10377 {
10378 if self._additional_params.contains_key(field) {
10379 dlg.finished(false);
10380 return Err(common::Error::FieldClash(field));
10381 }
10382 }
10383
10384 let mut params = Params::with_capacity(6 + self._additional_params.len());
10385 params.push("adClientId", self._ad_client_id);
10386 if let Some(value) = self._page_token.as_ref() {
10387 params.push("pageToken", value);
10388 }
10389 if let Some(value) = self._max_results.as_ref() {
10390 params.push("maxResults", value.to_string());
10391 }
10392 if let Some(value) = self._include_inactive.as_ref() {
10393 params.push("includeInactive", value.to_string());
10394 }
10395
10396 params.extend(self._additional_params.iter());
10397
10398 params.push("alt", "json");
10399 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/adunits";
10400 if self._scopes.is_empty() {
10401 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10402 }
10403
10404 #[allow(clippy::single_element_loop)]
10405 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
10406 url = params.uri_replacement(url, param_name, find_this, false);
10407 }
10408 {
10409 let to_remove = ["adClientId"];
10410 params.remove_params(&to_remove);
10411 }
10412
10413 let url = params.parse_with_url(&url);
10414
10415 loop {
10416 let token = match self
10417 .hub
10418 .auth
10419 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10420 .await
10421 {
10422 Ok(token) => token,
10423 Err(e) => match dlg.token(e) {
10424 Ok(token) => token,
10425 Err(e) => {
10426 dlg.finished(false);
10427 return Err(common::Error::MissingToken(e));
10428 }
10429 },
10430 };
10431 let mut req_result = {
10432 let client = &self.hub.client;
10433 dlg.pre_request();
10434 let mut req_builder = hyper::Request::builder()
10435 .method(hyper::Method::GET)
10436 .uri(url.as_str())
10437 .header(USER_AGENT, self.hub._user_agent.clone());
10438
10439 if let Some(token) = token.as_ref() {
10440 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10441 }
10442
10443 let request = req_builder
10444 .header(CONTENT_LENGTH, 0_u64)
10445 .body(common::to_body::<String>(None));
10446
10447 client.request(request.unwrap()).await
10448 };
10449
10450 match req_result {
10451 Err(err) => {
10452 if let common::Retry::After(d) = dlg.http_error(&err) {
10453 sleep(d).await;
10454 continue;
10455 }
10456 dlg.finished(false);
10457 return Err(common::Error::HttpError(err));
10458 }
10459 Ok(res) => {
10460 let (mut parts, body) = res.into_parts();
10461 let mut body = common::Body::new(body);
10462 if !parts.status.is_success() {
10463 let bytes = common::to_bytes(body).await.unwrap_or_default();
10464 let error = serde_json::from_str(&common::to_string(&bytes));
10465 let response = common::to_response(parts, bytes.into());
10466
10467 if let common::Retry::After(d) =
10468 dlg.http_failure(&response, error.as_ref().ok())
10469 {
10470 sleep(d).await;
10471 continue;
10472 }
10473
10474 dlg.finished(false);
10475
10476 return Err(match error {
10477 Ok(value) => common::Error::BadRequest(value),
10478 _ => common::Error::Failure(response),
10479 });
10480 }
10481 let response = {
10482 let bytes = common::to_bytes(body).await.unwrap_or_default();
10483 let encoded = common::to_string(&bytes);
10484 match serde_json::from_str(&encoded) {
10485 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10486 Err(error) => {
10487 dlg.response_json_decode_error(&encoded, &error);
10488 return Err(common::Error::JsonDecodeError(
10489 encoded.to_string(),
10490 error,
10491 ));
10492 }
10493 }
10494 };
10495
10496 dlg.finished(true);
10497 return Ok(response);
10498 }
10499 }
10500 }
10501 }
10502
10503 /// Ad client for which to list ad units.
10504 ///
10505 /// Sets the *ad client id* path property to the given value.
10506 ///
10507 /// Even though the property as already been set when instantiating this call,
10508 /// we provide this method for API completeness.
10509 pub fn ad_client_id(mut self, new_value: &str) -> AdunitListCall<'a, C> {
10510 self._ad_client_id = new_value.to_string();
10511 self
10512 }
10513 /// A continuation token, used to page through ad units. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
10514 ///
10515 /// Sets the *page token* query property to the given value.
10516 pub fn page_token(mut self, new_value: &str) -> AdunitListCall<'a, C> {
10517 self._page_token = Some(new_value.to_string());
10518 self
10519 }
10520 /// The maximum number of ad units to include in the response, used for paging.
10521 ///
10522 /// Sets the *max results* query property to the given value.
10523 pub fn max_results(mut self, new_value: i32) -> AdunitListCall<'a, C> {
10524 self._max_results = Some(new_value);
10525 self
10526 }
10527 /// Whether to include inactive ad units. Default: true.
10528 ///
10529 /// Sets the *include inactive* query property to the given value.
10530 pub fn include_inactive(mut self, new_value: bool) -> AdunitListCall<'a, C> {
10531 self._include_inactive = Some(new_value);
10532 self
10533 }
10534 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10535 /// while executing the actual API request.
10536 ///
10537 /// ````text
10538 /// It should be used to handle progress information, and to implement a certain level of resilience.
10539 /// ````
10540 ///
10541 /// Sets the *delegate* property to the given value.
10542 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdunitListCall<'a, C> {
10543 self._delegate = Some(new_value);
10544 self
10545 }
10546
10547 /// Set any additional parameter of the query string used in the request.
10548 /// It should be used to set parameters which are not yet available through their own
10549 /// setters.
10550 ///
10551 /// Please note that this method must not be used to set any of the known parameters
10552 /// which have their own setter method. If done anyway, the request will fail.
10553 ///
10554 /// # Additional Parameters
10555 ///
10556 /// * *alt* (query-string) - Data format for the response.
10557 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10558 /// * *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.
10559 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10560 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10561 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10562 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10563 pub fn param<T>(mut self, name: T, value: T) -> AdunitListCall<'a, C>
10564 where
10565 T: AsRef<str>,
10566 {
10567 self._additional_params
10568 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10569 self
10570 }
10571
10572 /// Identifies the authorization scope for the method you are building.
10573 ///
10574 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10575 /// [`Scope::Readonly`].
10576 ///
10577 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10578 /// tokens for more than one scope.
10579 ///
10580 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10581 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10582 /// sufficient, a read-write scope will do as well.
10583 pub fn add_scope<St>(mut self, scope: St) -> AdunitListCall<'a, C>
10584 where
10585 St: AsRef<str>,
10586 {
10587 self._scopes.insert(String::from(scope.as_ref()));
10588 self
10589 }
10590 /// Identifies the authorization scope(s) for the method you are building.
10591 ///
10592 /// See [`Self::add_scope()`] for details.
10593 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdunitListCall<'a, C>
10594 where
10595 I: IntoIterator<Item = St>,
10596 St: AsRef<str>,
10597 {
10598 self._scopes
10599 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10600 self
10601 }
10602
10603 /// Removes all scopes, and no default scope will be used either.
10604 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10605 /// for details).
10606 pub fn clear_scopes(mut self) -> AdunitListCall<'a, C> {
10607 self._scopes.clear();
10608 self
10609 }
10610}
10611
10612/// Dismiss (delete) the specified alert from the publisher's AdSense account.
10613///
10614/// A builder for the *delete* method supported by a *alert* resource.
10615/// It is not used directly, but through a [`AlertMethods`] instance.
10616///
10617/// # Example
10618///
10619/// Instantiate a resource method builder
10620///
10621/// ```test_harness,no_run
10622/// # extern crate hyper;
10623/// # extern crate hyper_rustls;
10624/// # extern crate google_adsense1d4 as adsense1d4;
10625/// # async fn dox() {
10626/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10627///
10628/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10629/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10630/// # .with_native_roots()
10631/// # .unwrap()
10632/// # .https_only()
10633/// # .enable_http2()
10634/// # .build();
10635///
10636/// # let executor = hyper_util::rt::TokioExecutor::new();
10637/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10638/// # secret,
10639/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10640/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10641/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10642/// # ),
10643/// # ).build().await.unwrap();
10644///
10645/// # let client = hyper_util::client::legacy::Client::builder(
10646/// # hyper_util::rt::TokioExecutor::new()
10647/// # )
10648/// # .build(
10649/// # hyper_rustls::HttpsConnectorBuilder::new()
10650/// # .with_native_roots()
10651/// # .unwrap()
10652/// # .https_or_http()
10653/// # .enable_http2()
10654/// # .build()
10655/// # );
10656/// # let mut hub = AdSense::new(client, auth);
10657/// // You can configure optional parameters by calling the respective setters at will, and
10658/// // execute the final call using `doit()`.
10659/// // Values shown here are possibly random and not representative !
10660/// let result = hub.alerts().delete("alertId")
10661/// .doit().await;
10662/// # }
10663/// ```
10664pub struct AlertDeleteCall<'a, C>
10665where
10666 C: 'a,
10667{
10668 hub: &'a AdSense<C>,
10669 _alert_id: String,
10670 _delegate: Option<&'a mut dyn common::Delegate>,
10671 _additional_params: HashMap<String, String>,
10672 _scopes: BTreeSet<String>,
10673}
10674
10675impl<'a, C> common::CallBuilder for AlertDeleteCall<'a, C> {}
10676
10677impl<'a, C> AlertDeleteCall<'a, C>
10678where
10679 C: common::Connector,
10680{
10681 /// Perform the operation you have build so far.
10682 pub async fn doit(mut self) -> common::Result<common::Response> {
10683 use std::borrow::Cow;
10684 use std::io::{Read, Seek};
10685
10686 use common::{url::Params, ToParts};
10687 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10688
10689 let mut dd = common::DefaultDelegate;
10690 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10691 dlg.begin(common::MethodInfo {
10692 id: "adsense.alerts.delete",
10693 http_method: hyper::Method::DELETE,
10694 });
10695
10696 for &field in ["alertId"].iter() {
10697 if self._additional_params.contains_key(field) {
10698 dlg.finished(false);
10699 return Err(common::Error::FieldClash(field));
10700 }
10701 }
10702
10703 let mut params = Params::with_capacity(2 + self._additional_params.len());
10704 params.push("alertId", self._alert_id);
10705
10706 params.extend(self._additional_params.iter());
10707
10708 let mut url = self.hub._base_url.clone() + "alerts/{alertId}";
10709 if self._scopes.is_empty() {
10710 self._scopes.insert(Scope::Full.as_ref().to_string());
10711 }
10712
10713 #[allow(clippy::single_element_loop)]
10714 for &(find_this, param_name) in [("{alertId}", "alertId")].iter() {
10715 url = params.uri_replacement(url, param_name, find_this, false);
10716 }
10717 {
10718 let to_remove = ["alertId"];
10719 params.remove_params(&to_remove);
10720 }
10721
10722 let url = params.parse_with_url(&url);
10723
10724 loop {
10725 let token = match self
10726 .hub
10727 .auth
10728 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10729 .await
10730 {
10731 Ok(token) => token,
10732 Err(e) => match dlg.token(e) {
10733 Ok(token) => token,
10734 Err(e) => {
10735 dlg.finished(false);
10736 return Err(common::Error::MissingToken(e));
10737 }
10738 },
10739 };
10740 let mut req_result = {
10741 let client = &self.hub.client;
10742 dlg.pre_request();
10743 let mut req_builder = hyper::Request::builder()
10744 .method(hyper::Method::DELETE)
10745 .uri(url.as_str())
10746 .header(USER_AGENT, self.hub._user_agent.clone());
10747
10748 if let Some(token) = token.as_ref() {
10749 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10750 }
10751
10752 let request = req_builder
10753 .header(CONTENT_LENGTH, 0_u64)
10754 .body(common::to_body::<String>(None));
10755
10756 client.request(request.unwrap()).await
10757 };
10758
10759 match req_result {
10760 Err(err) => {
10761 if let common::Retry::After(d) = dlg.http_error(&err) {
10762 sleep(d).await;
10763 continue;
10764 }
10765 dlg.finished(false);
10766 return Err(common::Error::HttpError(err));
10767 }
10768 Ok(res) => {
10769 let (mut parts, body) = res.into_parts();
10770 let mut body = common::Body::new(body);
10771 if !parts.status.is_success() {
10772 let bytes = common::to_bytes(body).await.unwrap_or_default();
10773 let error = serde_json::from_str(&common::to_string(&bytes));
10774 let response = common::to_response(parts, bytes.into());
10775
10776 if let common::Retry::After(d) =
10777 dlg.http_failure(&response, error.as_ref().ok())
10778 {
10779 sleep(d).await;
10780 continue;
10781 }
10782
10783 dlg.finished(false);
10784
10785 return Err(match error {
10786 Ok(value) => common::Error::BadRequest(value),
10787 _ => common::Error::Failure(response),
10788 });
10789 }
10790 let response = common::Response::from_parts(parts, body);
10791
10792 dlg.finished(true);
10793 return Ok(response);
10794 }
10795 }
10796 }
10797 }
10798
10799 /// Alert to delete.
10800 ///
10801 /// Sets the *alert id* path property to the given value.
10802 ///
10803 /// Even though the property as already been set when instantiating this call,
10804 /// we provide this method for API completeness.
10805 pub fn alert_id(mut self, new_value: &str) -> AlertDeleteCall<'a, C> {
10806 self._alert_id = new_value.to_string();
10807 self
10808 }
10809 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10810 /// while executing the actual API request.
10811 ///
10812 /// ````text
10813 /// It should be used to handle progress information, and to implement a certain level of resilience.
10814 /// ````
10815 ///
10816 /// Sets the *delegate* property to the given value.
10817 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlertDeleteCall<'a, C> {
10818 self._delegate = Some(new_value);
10819 self
10820 }
10821
10822 /// Set any additional parameter of the query string used in the request.
10823 /// It should be used to set parameters which are not yet available through their own
10824 /// setters.
10825 ///
10826 /// Please note that this method must not be used to set any of the known parameters
10827 /// which have their own setter method. If done anyway, the request will fail.
10828 ///
10829 /// # Additional Parameters
10830 ///
10831 /// * *alt* (query-string) - Data format for the response.
10832 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10833 /// * *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.
10834 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10835 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10836 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10837 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10838 pub fn param<T>(mut self, name: T, value: T) -> AlertDeleteCall<'a, C>
10839 where
10840 T: AsRef<str>,
10841 {
10842 self._additional_params
10843 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10844 self
10845 }
10846
10847 /// Identifies the authorization scope for the method you are building.
10848 ///
10849 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10850 /// [`Scope::Full`].
10851 ///
10852 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10853 /// tokens for more than one scope.
10854 ///
10855 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10856 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10857 /// sufficient, a read-write scope will do as well.
10858 pub fn add_scope<St>(mut self, scope: St) -> AlertDeleteCall<'a, C>
10859 where
10860 St: AsRef<str>,
10861 {
10862 self._scopes.insert(String::from(scope.as_ref()));
10863 self
10864 }
10865 /// Identifies the authorization scope(s) for the method you are building.
10866 ///
10867 /// See [`Self::add_scope()`] for details.
10868 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlertDeleteCall<'a, C>
10869 where
10870 I: IntoIterator<Item = St>,
10871 St: AsRef<str>,
10872 {
10873 self._scopes
10874 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10875 self
10876 }
10877
10878 /// Removes all scopes, and no default scope will be used either.
10879 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10880 /// for details).
10881 pub fn clear_scopes(mut self) -> AlertDeleteCall<'a, C> {
10882 self._scopes.clear();
10883 self
10884 }
10885}
10886
10887/// List the alerts for this AdSense account.
10888///
10889/// A builder for the *list* method supported by a *alert* resource.
10890/// It is not used directly, but through a [`AlertMethods`] instance.
10891///
10892/// # Example
10893///
10894/// Instantiate a resource method builder
10895///
10896/// ```test_harness,no_run
10897/// # extern crate hyper;
10898/// # extern crate hyper_rustls;
10899/// # extern crate google_adsense1d4 as adsense1d4;
10900/// # async fn dox() {
10901/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10902///
10903/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10904/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10905/// # .with_native_roots()
10906/// # .unwrap()
10907/// # .https_only()
10908/// # .enable_http2()
10909/// # .build();
10910///
10911/// # let executor = hyper_util::rt::TokioExecutor::new();
10912/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10913/// # secret,
10914/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10915/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10916/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10917/// # ),
10918/// # ).build().await.unwrap();
10919///
10920/// # let client = hyper_util::client::legacy::Client::builder(
10921/// # hyper_util::rt::TokioExecutor::new()
10922/// # )
10923/// # .build(
10924/// # hyper_rustls::HttpsConnectorBuilder::new()
10925/// # .with_native_roots()
10926/// # .unwrap()
10927/// # .https_or_http()
10928/// # .enable_http2()
10929/// # .build()
10930/// # );
10931/// # let mut hub = AdSense::new(client, auth);
10932/// // You can configure optional parameters by calling the respective setters at will, and
10933/// // execute the final call using `doit()`.
10934/// // Values shown here are possibly random and not representative !
10935/// let result = hub.alerts().list()
10936/// .locale("erat")
10937/// .doit().await;
10938/// # }
10939/// ```
10940pub struct AlertListCall<'a, C>
10941where
10942 C: 'a,
10943{
10944 hub: &'a AdSense<C>,
10945 _locale: Option<String>,
10946 _delegate: Option<&'a mut dyn common::Delegate>,
10947 _additional_params: HashMap<String, String>,
10948 _scopes: BTreeSet<String>,
10949}
10950
10951impl<'a, C> common::CallBuilder for AlertListCall<'a, C> {}
10952
10953impl<'a, C> AlertListCall<'a, C>
10954where
10955 C: common::Connector,
10956{
10957 /// Perform the operation you have build so far.
10958 pub async fn doit(mut self) -> common::Result<(common::Response, Alerts)> {
10959 use std::borrow::Cow;
10960 use std::io::{Read, Seek};
10961
10962 use common::{url::Params, ToParts};
10963 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10964
10965 let mut dd = common::DefaultDelegate;
10966 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10967 dlg.begin(common::MethodInfo {
10968 id: "adsense.alerts.list",
10969 http_method: hyper::Method::GET,
10970 });
10971
10972 for &field in ["alt", "locale"].iter() {
10973 if self._additional_params.contains_key(field) {
10974 dlg.finished(false);
10975 return Err(common::Error::FieldClash(field));
10976 }
10977 }
10978
10979 let mut params = Params::with_capacity(3 + self._additional_params.len());
10980 if let Some(value) = self._locale.as_ref() {
10981 params.push("locale", value);
10982 }
10983
10984 params.extend(self._additional_params.iter());
10985
10986 params.push("alt", "json");
10987 let mut url = self.hub._base_url.clone() + "alerts";
10988 if self._scopes.is_empty() {
10989 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10990 }
10991
10992 let url = params.parse_with_url(&url);
10993
10994 loop {
10995 let token = match self
10996 .hub
10997 .auth
10998 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10999 .await
11000 {
11001 Ok(token) => token,
11002 Err(e) => match dlg.token(e) {
11003 Ok(token) => token,
11004 Err(e) => {
11005 dlg.finished(false);
11006 return Err(common::Error::MissingToken(e));
11007 }
11008 },
11009 };
11010 let mut req_result = {
11011 let client = &self.hub.client;
11012 dlg.pre_request();
11013 let mut req_builder = hyper::Request::builder()
11014 .method(hyper::Method::GET)
11015 .uri(url.as_str())
11016 .header(USER_AGENT, self.hub._user_agent.clone());
11017
11018 if let Some(token) = token.as_ref() {
11019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11020 }
11021
11022 let request = req_builder
11023 .header(CONTENT_LENGTH, 0_u64)
11024 .body(common::to_body::<String>(None));
11025
11026 client.request(request.unwrap()).await
11027 };
11028
11029 match req_result {
11030 Err(err) => {
11031 if let common::Retry::After(d) = dlg.http_error(&err) {
11032 sleep(d).await;
11033 continue;
11034 }
11035 dlg.finished(false);
11036 return Err(common::Error::HttpError(err));
11037 }
11038 Ok(res) => {
11039 let (mut parts, body) = res.into_parts();
11040 let mut body = common::Body::new(body);
11041 if !parts.status.is_success() {
11042 let bytes = common::to_bytes(body).await.unwrap_or_default();
11043 let error = serde_json::from_str(&common::to_string(&bytes));
11044 let response = common::to_response(parts, bytes.into());
11045
11046 if let common::Retry::After(d) =
11047 dlg.http_failure(&response, error.as_ref().ok())
11048 {
11049 sleep(d).await;
11050 continue;
11051 }
11052
11053 dlg.finished(false);
11054
11055 return Err(match error {
11056 Ok(value) => common::Error::BadRequest(value),
11057 _ => common::Error::Failure(response),
11058 });
11059 }
11060 let response = {
11061 let bytes = common::to_bytes(body).await.unwrap_or_default();
11062 let encoded = common::to_string(&bytes);
11063 match serde_json::from_str(&encoded) {
11064 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11065 Err(error) => {
11066 dlg.response_json_decode_error(&encoded, &error);
11067 return Err(common::Error::JsonDecodeError(
11068 encoded.to_string(),
11069 error,
11070 ));
11071 }
11072 }
11073 };
11074
11075 dlg.finished(true);
11076 return Ok(response);
11077 }
11078 }
11079 }
11080 }
11081
11082 /// 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.
11083 ///
11084 /// Sets the *locale* query property to the given value.
11085 pub fn locale(mut self, new_value: &str) -> AlertListCall<'a, C> {
11086 self._locale = Some(new_value.to_string());
11087 self
11088 }
11089 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11090 /// while executing the actual API request.
11091 ///
11092 /// ````text
11093 /// It should be used to handle progress information, and to implement a certain level of resilience.
11094 /// ````
11095 ///
11096 /// Sets the *delegate* property to the given value.
11097 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AlertListCall<'a, C> {
11098 self._delegate = Some(new_value);
11099 self
11100 }
11101
11102 /// Set any additional parameter of the query string used in the request.
11103 /// It should be used to set parameters which are not yet available through their own
11104 /// setters.
11105 ///
11106 /// Please note that this method must not be used to set any of the known parameters
11107 /// which have their own setter method. If done anyway, the request will fail.
11108 ///
11109 /// # Additional Parameters
11110 ///
11111 /// * *alt* (query-string) - Data format for the response.
11112 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11113 /// * *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.
11114 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11115 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11116 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11117 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11118 pub fn param<T>(mut self, name: T, value: T) -> AlertListCall<'a, C>
11119 where
11120 T: AsRef<str>,
11121 {
11122 self._additional_params
11123 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11124 self
11125 }
11126
11127 /// Identifies the authorization scope for the method you are building.
11128 ///
11129 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11130 /// [`Scope::Readonly`].
11131 ///
11132 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11133 /// tokens for more than one scope.
11134 ///
11135 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11136 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11137 /// sufficient, a read-write scope will do as well.
11138 pub fn add_scope<St>(mut self, scope: St) -> AlertListCall<'a, C>
11139 where
11140 St: AsRef<str>,
11141 {
11142 self._scopes.insert(String::from(scope.as_ref()));
11143 self
11144 }
11145 /// Identifies the authorization scope(s) for the method you are building.
11146 ///
11147 /// See [`Self::add_scope()`] for details.
11148 pub fn add_scopes<I, St>(mut self, scopes: I) -> AlertListCall<'a, C>
11149 where
11150 I: IntoIterator<Item = St>,
11151 St: AsRef<str>,
11152 {
11153 self._scopes
11154 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11155 self
11156 }
11157
11158 /// Removes all scopes, and no default scope will be used either.
11159 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11160 /// for details).
11161 pub fn clear_scopes(mut self) -> AlertListCall<'a, C> {
11162 self._scopes.clear();
11163 self
11164 }
11165}
11166
11167/// List all ad units in the specified custom channel.
11168///
11169/// A builder for the *adunits.list* method supported by a *customchannel* resource.
11170/// It is not used directly, but through a [`CustomchannelMethods`] instance.
11171///
11172/// # Example
11173///
11174/// Instantiate a resource method builder
11175///
11176/// ```test_harness,no_run
11177/// # extern crate hyper;
11178/// # extern crate hyper_rustls;
11179/// # extern crate google_adsense1d4 as adsense1d4;
11180/// # async fn dox() {
11181/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11182///
11183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11185/// # .with_native_roots()
11186/// # .unwrap()
11187/// # .https_only()
11188/// # .enable_http2()
11189/// # .build();
11190///
11191/// # let executor = hyper_util::rt::TokioExecutor::new();
11192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11193/// # secret,
11194/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11195/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11196/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11197/// # ),
11198/// # ).build().await.unwrap();
11199///
11200/// # let client = hyper_util::client::legacy::Client::builder(
11201/// # hyper_util::rt::TokioExecutor::new()
11202/// # )
11203/// # .build(
11204/// # hyper_rustls::HttpsConnectorBuilder::new()
11205/// # .with_native_roots()
11206/// # .unwrap()
11207/// # .https_or_http()
11208/// # .enable_http2()
11209/// # .build()
11210/// # );
11211/// # let mut hub = AdSense::new(client, auth);
11212/// // You can configure optional parameters by calling the respective setters at will, and
11213/// // execute the final call using `doit()`.
11214/// // Values shown here are possibly random and not representative !
11215/// let result = hub.customchannels().adunits_list("adClientId", "customChannelId")
11216/// .page_token("est")
11217/// .max_results(-24)
11218/// .include_inactive(false)
11219/// .doit().await;
11220/// # }
11221/// ```
11222pub struct CustomchannelAdunitListCall<'a, C>
11223where
11224 C: 'a,
11225{
11226 hub: &'a AdSense<C>,
11227 _ad_client_id: String,
11228 _custom_channel_id: String,
11229 _page_token: Option<String>,
11230 _max_results: Option<i32>,
11231 _include_inactive: Option<bool>,
11232 _delegate: Option<&'a mut dyn common::Delegate>,
11233 _additional_params: HashMap<String, String>,
11234 _scopes: BTreeSet<String>,
11235}
11236
11237impl<'a, C> common::CallBuilder for CustomchannelAdunitListCall<'a, C> {}
11238
11239impl<'a, C> CustomchannelAdunitListCall<'a, C>
11240where
11241 C: common::Connector,
11242{
11243 /// Perform the operation you have build so far.
11244 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnits)> {
11245 use std::borrow::Cow;
11246 use std::io::{Read, Seek};
11247
11248 use common::{url::Params, ToParts};
11249 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11250
11251 let mut dd = common::DefaultDelegate;
11252 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11253 dlg.begin(common::MethodInfo {
11254 id: "adsense.customchannels.adunits.list",
11255 http_method: hyper::Method::GET,
11256 });
11257
11258 for &field in [
11259 "alt",
11260 "adClientId",
11261 "customChannelId",
11262 "pageToken",
11263 "maxResults",
11264 "includeInactive",
11265 ]
11266 .iter()
11267 {
11268 if self._additional_params.contains_key(field) {
11269 dlg.finished(false);
11270 return Err(common::Error::FieldClash(field));
11271 }
11272 }
11273
11274 let mut params = Params::with_capacity(7 + self._additional_params.len());
11275 params.push("adClientId", self._ad_client_id);
11276 params.push("customChannelId", self._custom_channel_id);
11277 if let Some(value) = self._page_token.as_ref() {
11278 params.push("pageToken", value);
11279 }
11280 if let Some(value) = self._max_results.as_ref() {
11281 params.push("maxResults", value.to_string());
11282 }
11283 if let Some(value) = self._include_inactive.as_ref() {
11284 params.push("includeInactive", value.to_string());
11285 }
11286
11287 params.extend(self._additional_params.iter());
11288
11289 params.push("alt", "json");
11290 let mut url = self.hub._base_url.clone()
11291 + "adclients/{adClientId}/customchannels/{customChannelId}/adunits";
11292 if self._scopes.is_empty() {
11293 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11294 }
11295
11296 #[allow(clippy::single_element_loop)]
11297 for &(find_this, param_name) in [
11298 ("{adClientId}", "adClientId"),
11299 ("{customChannelId}", "customChannelId"),
11300 ]
11301 .iter()
11302 {
11303 url = params.uri_replacement(url, param_name, find_this, false);
11304 }
11305 {
11306 let to_remove = ["customChannelId", "adClientId"];
11307 params.remove_params(&to_remove);
11308 }
11309
11310 let url = params.parse_with_url(&url);
11311
11312 loop {
11313 let token = match self
11314 .hub
11315 .auth
11316 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11317 .await
11318 {
11319 Ok(token) => token,
11320 Err(e) => match dlg.token(e) {
11321 Ok(token) => token,
11322 Err(e) => {
11323 dlg.finished(false);
11324 return Err(common::Error::MissingToken(e));
11325 }
11326 },
11327 };
11328 let mut req_result = {
11329 let client = &self.hub.client;
11330 dlg.pre_request();
11331 let mut req_builder = hyper::Request::builder()
11332 .method(hyper::Method::GET)
11333 .uri(url.as_str())
11334 .header(USER_AGENT, self.hub._user_agent.clone());
11335
11336 if let Some(token) = token.as_ref() {
11337 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11338 }
11339
11340 let request = req_builder
11341 .header(CONTENT_LENGTH, 0_u64)
11342 .body(common::to_body::<String>(None));
11343
11344 client.request(request.unwrap()).await
11345 };
11346
11347 match req_result {
11348 Err(err) => {
11349 if let common::Retry::After(d) = dlg.http_error(&err) {
11350 sleep(d).await;
11351 continue;
11352 }
11353 dlg.finished(false);
11354 return Err(common::Error::HttpError(err));
11355 }
11356 Ok(res) => {
11357 let (mut parts, body) = res.into_parts();
11358 let mut body = common::Body::new(body);
11359 if !parts.status.is_success() {
11360 let bytes = common::to_bytes(body).await.unwrap_or_default();
11361 let error = serde_json::from_str(&common::to_string(&bytes));
11362 let response = common::to_response(parts, bytes.into());
11363
11364 if let common::Retry::After(d) =
11365 dlg.http_failure(&response, error.as_ref().ok())
11366 {
11367 sleep(d).await;
11368 continue;
11369 }
11370
11371 dlg.finished(false);
11372
11373 return Err(match error {
11374 Ok(value) => common::Error::BadRequest(value),
11375 _ => common::Error::Failure(response),
11376 });
11377 }
11378 let response = {
11379 let bytes = common::to_bytes(body).await.unwrap_or_default();
11380 let encoded = common::to_string(&bytes);
11381 match serde_json::from_str(&encoded) {
11382 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11383 Err(error) => {
11384 dlg.response_json_decode_error(&encoded, &error);
11385 return Err(common::Error::JsonDecodeError(
11386 encoded.to_string(),
11387 error,
11388 ));
11389 }
11390 }
11391 };
11392
11393 dlg.finished(true);
11394 return Ok(response);
11395 }
11396 }
11397 }
11398 }
11399
11400 /// Ad client which contains the custom channel.
11401 ///
11402 /// Sets the *ad client id* path property to the given value.
11403 ///
11404 /// Even though the property as already been set when instantiating this call,
11405 /// we provide this method for API completeness.
11406 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelAdunitListCall<'a, C> {
11407 self._ad_client_id = new_value.to_string();
11408 self
11409 }
11410 /// Custom channel for which to list ad units.
11411 ///
11412 /// Sets the *custom channel id* path property to the given value.
11413 ///
11414 /// Even though the property as already been set when instantiating this call,
11415 /// we provide this method for API completeness.
11416 pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelAdunitListCall<'a, C> {
11417 self._custom_channel_id = new_value.to_string();
11418 self
11419 }
11420 /// A continuation token, used to page through ad units. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
11421 ///
11422 /// Sets the *page token* query property to the given value.
11423 pub fn page_token(mut self, new_value: &str) -> CustomchannelAdunitListCall<'a, C> {
11424 self._page_token = Some(new_value.to_string());
11425 self
11426 }
11427 /// The maximum number of ad units to include in the response, used for paging.
11428 ///
11429 /// Sets the *max results* query property to the given value.
11430 pub fn max_results(mut self, new_value: i32) -> CustomchannelAdunitListCall<'a, C> {
11431 self._max_results = Some(new_value);
11432 self
11433 }
11434 /// Whether to include inactive ad units. Default: true.
11435 ///
11436 /// Sets the *include inactive* query property to the given value.
11437 pub fn include_inactive(mut self, new_value: bool) -> CustomchannelAdunitListCall<'a, C> {
11438 self._include_inactive = Some(new_value);
11439 self
11440 }
11441 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11442 /// while executing the actual API request.
11443 ///
11444 /// ````text
11445 /// It should be used to handle progress information, and to implement a certain level of resilience.
11446 /// ````
11447 ///
11448 /// Sets the *delegate* property to the given value.
11449 pub fn delegate(
11450 mut self,
11451 new_value: &'a mut dyn common::Delegate,
11452 ) -> CustomchannelAdunitListCall<'a, C> {
11453 self._delegate = Some(new_value);
11454 self
11455 }
11456
11457 /// Set any additional parameter of the query string used in the request.
11458 /// It should be used to set parameters which are not yet available through their own
11459 /// setters.
11460 ///
11461 /// Please note that this method must not be used to set any of the known parameters
11462 /// which have their own setter method. If done anyway, the request will fail.
11463 ///
11464 /// # Additional Parameters
11465 ///
11466 /// * *alt* (query-string) - Data format for the response.
11467 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11468 /// * *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.
11469 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11470 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11471 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11472 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11473 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelAdunitListCall<'a, C>
11474 where
11475 T: AsRef<str>,
11476 {
11477 self._additional_params
11478 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11479 self
11480 }
11481
11482 /// Identifies the authorization scope for the method you are building.
11483 ///
11484 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11485 /// [`Scope::Readonly`].
11486 ///
11487 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11488 /// tokens for more than one scope.
11489 ///
11490 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11491 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11492 /// sufficient, a read-write scope will do as well.
11493 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelAdunitListCall<'a, C>
11494 where
11495 St: AsRef<str>,
11496 {
11497 self._scopes.insert(String::from(scope.as_ref()));
11498 self
11499 }
11500 /// Identifies the authorization scope(s) for the method you are building.
11501 ///
11502 /// See [`Self::add_scope()`] for details.
11503 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelAdunitListCall<'a, C>
11504 where
11505 I: IntoIterator<Item = St>,
11506 St: AsRef<str>,
11507 {
11508 self._scopes
11509 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11510 self
11511 }
11512
11513 /// Removes all scopes, and no default scope will be used either.
11514 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11515 /// for details).
11516 pub fn clear_scopes(mut self) -> CustomchannelAdunitListCall<'a, C> {
11517 self._scopes.clear();
11518 self
11519 }
11520}
11521
11522/// Get the specified custom channel from the specified ad client.
11523///
11524/// A builder for the *get* method supported by a *customchannel* resource.
11525/// It is not used directly, but through a [`CustomchannelMethods`] instance.
11526///
11527/// # Example
11528///
11529/// Instantiate a resource method builder
11530///
11531/// ```test_harness,no_run
11532/// # extern crate hyper;
11533/// # extern crate hyper_rustls;
11534/// # extern crate google_adsense1d4 as adsense1d4;
11535/// # async fn dox() {
11536/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11537///
11538/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11539/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11540/// # .with_native_roots()
11541/// # .unwrap()
11542/// # .https_only()
11543/// # .enable_http2()
11544/// # .build();
11545///
11546/// # let executor = hyper_util::rt::TokioExecutor::new();
11547/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11548/// # secret,
11549/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11550/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11551/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11552/// # ),
11553/// # ).build().await.unwrap();
11554///
11555/// # let client = hyper_util::client::legacy::Client::builder(
11556/// # hyper_util::rt::TokioExecutor::new()
11557/// # )
11558/// # .build(
11559/// # hyper_rustls::HttpsConnectorBuilder::new()
11560/// # .with_native_roots()
11561/// # .unwrap()
11562/// # .https_or_http()
11563/// # .enable_http2()
11564/// # .build()
11565/// # );
11566/// # let mut hub = AdSense::new(client, auth);
11567/// // You can configure optional parameters by calling the respective setters at will, and
11568/// // execute the final call using `doit()`.
11569/// // Values shown here are possibly random and not representative !
11570/// let result = hub.customchannels().get("adClientId", "customChannelId")
11571/// .doit().await;
11572/// # }
11573/// ```
11574pub struct CustomchannelGetCall<'a, C>
11575where
11576 C: 'a,
11577{
11578 hub: &'a AdSense<C>,
11579 _ad_client_id: String,
11580 _custom_channel_id: String,
11581 _delegate: Option<&'a mut dyn common::Delegate>,
11582 _additional_params: HashMap<String, String>,
11583 _scopes: BTreeSet<String>,
11584}
11585
11586impl<'a, C> common::CallBuilder for CustomchannelGetCall<'a, C> {}
11587
11588impl<'a, C> CustomchannelGetCall<'a, C>
11589where
11590 C: common::Connector,
11591{
11592 /// Perform the operation you have build so far.
11593 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
11594 use std::borrow::Cow;
11595 use std::io::{Read, Seek};
11596
11597 use common::{url::Params, ToParts};
11598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11599
11600 let mut dd = common::DefaultDelegate;
11601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11602 dlg.begin(common::MethodInfo {
11603 id: "adsense.customchannels.get",
11604 http_method: hyper::Method::GET,
11605 });
11606
11607 for &field in ["alt", "adClientId", "customChannelId"].iter() {
11608 if self._additional_params.contains_key(field) {
11609 dlg.finished(false);
11610 return Err(common::Error::FieldClash(field));
11611 }
11612 }
11613
11614 let mut params = Params::with_capacity(4 + self._additional_params.len());
11615 params.push("adClientId", self._ad_client_id);
11616 params.push("customChannelId", self._custom_channel_id);
11617
11618 params.extend(self._additional_params.iter());
11619
11620 params.push("alt", "json");
11621 let mut url =
11622 self.hub._base_url.clone() + "adclients/{adClientId}/customchannels/{customChannelId}";
11623 if self._scopes.is_empty() {
11624 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11625 }
11626
11627 #[allow(clippy::single_element_loop)]
11628 for &(find_this, param_name) in [
11629 ("{adClientId}", "adClientId"),
11630 ("{customChannelId}", "customChannelId"),
11631 ]
11632 .iter()
11633 {
11634 url = params.uri_replacement(url, param_name, find_this, false);
11635 }
11636 {
11637 let to_remove = ["customChannelId", "adClientId"];
11638 params.remove_params(&to_remove);
11639 }
11640
11641 let url = params.parse_with_url(&url);
11642
11643 loop {
11644 let token = match self
11645 .hub
11646 .auth
11647 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11648 .await
11649 {
11650 Ok(token) => token,
11651 Err(e) => match dlg.token(e) {
11652 Ok(token) => token,
11653 Err(e) => {
11654 dlg.finished(false);
11655 return Err(common::Error::MissingToken(e));
11656 }
11657 },
11658 };
11659 let mut req_result = {
11660 let client = &self.hub.client;
11661 dlg.pre_request();
11662 let mut req_builder = hyper::Request::builder()
11663 .method(hyper::Method::GET)
11664 .uri(url.as_str())
11665 .header(USER_AGENT, self.hub._user_agent.clone());
11666
11667 if let Some(token) = token.as_ref() {
11668 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11669 }
11670
11671 let request = req_builder
11672 .header(CONTENT_LENGTH, 0_u64)
11673 .body(common::to_body::<String>(None));
11674
11675 client.request(request.unwrap()).await
11676 };
11677
11678 match req_result {
11679 Err(err) => {
11680 if let common::Retry::After(d) = dlg.http_error(&err) {
11681 sleep(d).await;
11682 continue;
11683 }
11684 dlg.finished(false);
11685 return Err(common::Error::HttpError(err));
11686 }
11687 Ok(res) => {
11688 let (mut parts, body) = res.into_parts();
11689 let mut body = common::Body::new(body);
11690 if !parts.status.is_success() {
11691 let bytes = common::to_bytes(body).await.unwrap_or_default();
11692 let error = serde_json::from_str(&common::to_string(&bytes));
11693 let response = common::to_response(parts, bytes.into());
11694
11695 if let common::Retry::After(d) =
11696 dlg.http_failure(&response, error.as_ref().ok())
11697 {
11698 sleep(d).await;
11699 continue;
11700 }
11701
11702 dlg.finished(false);
11703
11704 return Err(match error {
11705 Ok(value) => common::Error::BadRequest(value),
11706 _ => common::Error::Failure(response),
11707 });
11708 }
11709 let response = {
11710 let bytes = common::to_bytes(body).await.unwrap_or_default();
11711 let encoded = common::to_string(&bytes);
11712 match serde_json::from_str(&encoded) {
11713 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11714 Err(error) => {
11715 dlg.response_json_decode_error(&encoded, &error);
11716 return Err(common::Error::JsonDecodeError(
11717 encoded.to_string(),
11718 error,
11719 ));
11720 }
11721 }
11722 };
11723
11724 dlg.finished(true);
11725 return Ok(response);
11726 }
11727 }
11728 }
11729 }
11730
11731 /// Ad client which contains the custom channel.
11732 ///
11733 /// Sets the *ad client id* path property to the given value.
11734 ///
11735 /// Even though the property as already been set when instantiating this call,
11736 /// we provide this method for API completeness.
11737 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C> {
11738 self._ad_client_id = new_value.to_string();
11739 self
11740 }
11741 /// Custom channel to retrieve.
11742 ///
11743 /// Sets the *custom channel id* path property to the given value.
11744 ///
11745 /// Even though the property as already been set when instantiating this call,
11746 /// we provide this method for API completeness.
11747 pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C> {
11748 self._custom_channel_id = new_value.to_string();
11749 self
11750 }
11751 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11752 /// while executing the actual API request.
11753 ///
11754 /// ````text
11755 /// It should be used to handle progress information, and to implement a certain level of resilience.
11756 /// ````
11757 ///
11758 /// Sets the *delegate* property to the given value.
11759 pub fn delegate(
11760 mut self,
11761 new_value: &'a mut dyn common::Delegate,
11762 ) -> CustomchannelGetCall<'a, C> {
11763 self._delegate = Some(new_value);
11764 self
11765 }
11766
11767 /// Set any additional parameter of the query string used in the request.
11768 /// It should be used to set parameters which are not yet available through their own
11769 /// setters.
11770 ///
11771 /// Please note that this method must not be used to set any of the known parameters
11772 /// which have their own setter method. If done anyway, the request will fail.
11773 ///
11774 /// # Additional Parameters
11775 ///
11776 /// * *alt* (query-string) - Data format for the response.
11777 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11778 /// * *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.
11779 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11780 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11781 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11782 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11783 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelGetCall<'a, C>
11784 where
11785 T: AsRef<str>,
11786 {
11787 self._additional_params
11788 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11789 self
11790 }
11791
11792 /// Identifies the authorization scope for the method you are building.
11793 ///
11794 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11795 /// [`Scope::Readonly`].
11796 ///
11797 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11798 /// tokens for more than one scope.
11799 ///
11800 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11801 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11802 /// sufficient, a read-write scope will do as well.
11803 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelGetCall<'a, C>
11804 where
11805 St: AsRef<str>,
11806 {
11807 self._scopes.insert(String::from(scope.as_ref()));
11808 self
11809 }
11810 /// Identifies the authorization scope(s) for the method you are building.
11811 ///
11812 /// See [`Self::add_scope()`] for details.
11813 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelGetCall<'a, C>
11814 where
11815 I: IntoIterator<Item = St>,
11816 St: AsRef<str>,
11817 {
11818 self._scopes
11819 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11820 self
11821 }
11822
11823 /// Removes all scopes, and no default scope will be used either.
11824 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11825 /// for details).
11826 pub fn clear_scopes(mut self) -> CustomchannelGetCall<'a, C> {
11827 self._scopes.clear();
11828 self
11829 }
11830}
11831
11832/// List all custom channels in the specified ad client for this AdSense account.
11833///
11834/// A builder for the *list* method supported by a *customchannel* resource.
11835/// It is not used directly, but through a [`CustomchannelMethods`] instance.
11836///
11837/// # Example
11838///
11839/// Instantiate a resource method builder
11840///
11841/// ```test_harness,no_run
11842/// # extern crate hyper;
11843/// # extern crate hyper_rustls;
11844/// # extern crate google_adsense1d4 as adsense1d4;
11845/// # async fn dox() {
11846/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11847///
11848/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11849/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11850/// # .with_native_roots()
11851/// # .unwrap()
11852/// # .https_only()
11853/// # .enable_http2()
11854/// # .build();
11855///
11856/// # let executor = hyper_util::rt::TokioExecutor::new();
11857/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11858/// # secret,
11859/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11860/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11861/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11862/// # ),
11863/// # ).build().await.unwrap();
11864///
11865/// # let client = hyper_util::client::legacy::Client::builder(
11866/// # hyper_util::rt::TokioExecutor::new()
11867/// # )
11868/// # .build(
11869/// # hyper_rustls::HttpsConnectorBuilder::new()
11870/// # .with_native_roots()
11871/// # .unwrap()
11872/// # .https_or_http()
11873/// # .enable_http2()
11874/// # .build()
11875/// # );
11876/// # let mut hub = AdSense::new(client, auth);
11877/// // You can configure optional parameters by calling the respective setters at will, and
11878/// // execute the final call using `doit()`.
11879/// // Values shown here are possibly random and not representative !
11880/// let result = hub.customchannels().list("adClientId")
11881/// .page_token("aliquyam")
11882/// .max_results(-94)
11883/// .doit().await;
11884/// # }
11885/// ```
11886pub struct CustomchannelListCall<'a, C>
11887where
11888 C: 'a,
11889{
11890 hub: &'a AdSense<C>,
11891 _ad_client_id: String,
11892 _page_token: Option<String>,
11893 _max_results: Option<i32>,
11894 _delegate: Option<&'a mut dyn common::Delegate>,
11895 _additional_params: HashMap<String, String>,
11896 _scopes: BTreeSet<String>,
11897}
11898
11899impl<'a, C> common::CallBuilder for CustomchannelListCall<'a, C> {}
11900
11901impl<'a, C> CustomchannelListCall<'a, C>
11902where
11903 C: common::Connector,
11904{
11905 /// Perform the operation you have build so far.
11906 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
11907 use std::borrow::Cow;
11908 use std::io::{Read, Seek};
11909
11910 use common::{url::Params, ToParts};
11911 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11912
11913 let mut dd = common::DefaultDelegate;
11914 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11915 dlg.begin(common::MethodInfo {
11916 id: "adsense.customchannels.list",
11917 http_method: hyper::Method::GET,
11918 });
11919
11920 for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
11921 if self._additional_params.contains_key(field) {
11922 dlg.finished(false);
11923 return Err(common::Error::FieldClash(field));
11924 }
11925 }
11926
11927 let mut params = Params::with_capacity(5 + self._additional_params.len());
11928 params.push("adClientId", self._ad_client_id);
11929 if let Some(value) = self._page_token.as_ref() {
11930 params.push("pageToken", value);
11931 }
11932 if let Some(value) = self._max_results.as_ref() {
11933 params.push("maxResults", value.to_string());
11934 }
11935
11936 params.extend(self._additional_params.iter());
11937
11938 params.push("alt", "json");
11939 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/customchannels";
11940 if self._scopes.is_empty() {
11941 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11942 }
11943
11944 #[allow(clippy::single_element_loop)]
11945 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
11946 url = params.uri_replacement(url, param_name, find_this, false);
11947 }
11948 {
11949 let to_remove = ["adClientId"];
11950 params.remove_params(&to_remove);
11951 }
11952
11953 let url = params.parse_with_url(&url);
11954
11955 loop {
11956 let token = match self
11957 .hub
11958 .auth
11959 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11960 .await
11961 {
11962 Ok(token) => token,
11963 Err(e) => match dlg.token(e) {
11964 Ok(token) => token,
11965 Err(e) => {
11966 dlg.finished(false);
11967 return Err(common::Error::MissingToken(e));
11968 }
11969 },
11970 };
11971 let mut req_result = {
11972 let client = &self.hub.client;
11973 dlg.pre_request();
11974 let mut req_builder = hyper::Request::builder()
11975 .method(hyper::Method::GET)
11976 .uri(url.as_str())
11977 .header(USER_AGENT, self.hub._user_agent.clone());
11978
11979 if let Some(token) = token.as_ref() {
11980 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11981 }
11982
11983 let request = req_builder
11984 .header(CONTENT_LENGTH, 0_u64)
11985 .body(common::to_body::<String>(None));
11986
11987 client.request(request.unwrap()).await
11988 };
11989
11990 match req_result {
11991 Err(err) => {
11992 if let common::Retry::After(d) = dlg.http_error(&err) {
11993 sleep(d).await;
11994 continue;
11995 }
11996 dlg.finished(false);
11997 return Err(common::Error::HttpError(err));
11998 }
11999 Ok(res) => {
12000 let (mut parts, body) = res.into_parts();
12001 let mut body = common::Body::new(body);
12002 if !parts.status.is_success() {
12003 let bytes = common::to_bytes(body).await.unwrap_or_default();
12004 let error = serde_json::from_str(&common::to_string(&bytes));
12005 let response = common::to_response(parts, bytes.into());
12006
12007 if let common::Retry::After(d) =
12008 dlg.http_failure(&response, error.as_ref().ok())
12009 {
12010 sleep(d).await;
12011 continue;
12012 }
12013
12014 dlg.finished(false);
12015
12016 return Err(match error {
12017 Ok(value) => common::Error::BadRequest(value),
12018 _ => common::Error::Failure(response),
12019 });
12020 }
12021 let response = {
12022 let bytes = common::to_bytes(body).await.unwrap_or_default();
12023 let encoded = common::to_string(&bytes);
12024 match serde_json::from_str(&encoded) {
12025 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12026 Err(error) => {
12027 dlg.response_json_decode_error(&encoded, &error);
12028 return Err(common::Error::JsonDecodeError(
12029 encoded.to_string(),
12030 error,
12031 ));
12032 }
12033 }
12034 };
12035
12036 dlg.finished(true);
12037 return Ok(response);
12038 }
12039 }
12040 }
12041 }
12042
12043 /// Ad client for which to list custom channels.
12044 ///
12045 /// Sets the *ad client id* path property to the given value.
12046 ///
12047 /// Even though the property as already been set when instantiating this call,
12048 /// we provide this method for API completeness.
12049 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelListCall<'a, C> {
12050 self._ad_client_id = new_value.to_string();
12051 self
12052 }
12053 /// 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.
12054 ///
12055 /// Sets the *page token* query property to the given value.
12056 pub fn page_token(mut self, new_value: &str) -> CustomchannelListCall<'a, C> {
12057 self._page_token = Some(new_value.to_string());
12058 self
12059 }
12060 /// The maximum number of custom channels to include in the response, used for paging.
12061 ///
12062 /// Sets the *max results* query property to the given value.
12063 pub fn max_results(mut self, new_value: i32) -> CustomchannelListCall<'a, C> {
12064 self._max_results = Some(new_value);
12065 self
12066 }
12067 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12068 /// while executing the actual API request.
12069 ///
12070 /// ````text
12071 /// It should be used to handle progress information, and to implement a certain level of resilience.
12072 /// ````
12073 ///
12074 /// Sets the *delegate* property to the given value.
12075 pub fn delegate(
12076 mut self,
12077 new_value: &'a mut dyn common::Delegate,
12078 ) -> CustomchannelListCall<'a, C> {
12079 self._delegate = Some(new_value);
12080 self
12081 }
12082
12083 /// Set any additional parameter of the query string used in the request.
12084 /// It should be used to set parameters which are not yet available through their own
12085 /// setters.
12086 ///
12087 /// Please note that this method must not be used to set any of the known parameters
12088 /// which have their own setter method. If done anyway, the request will fail.
12089 ///
12090 /// # Additional Parameters
12091 ///
12092 /// * *alt* (query-string) - Data format for the response.
12093 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12094 /// * *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.
12095 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12096 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12097 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12098 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12099 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelListCall<'a, C>
12100 where
12101 T: AsRef<str>,
12102 {
12103 self._additional_params
12104 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12105 self
12106 }
12107
12108 /// Identifies the authorization scope for the method you are building.
12109 ///
12110 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12111 /// [`Scope::Readonly`].
12112 ///
12113 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12114 /// tokens for more than one scope.
12115 ///
12116 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12117 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12118 /// sufficient, a read-write scope will do as well.
12119 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelListCall<'a, C>
12120 where
12121 St: AsRef<str>,
12122 {
12123 self._scopes.insert(String::from(scope.as_ref()));
12124 self
12125 }
12126 /// Identifies the authorization scope(s) for the method you are building.
12127 ///
12128 /// See [`Self::add_scope()`] for details.
12129 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelListCall<'a, C>
12130 where
12131 I: IntoIterator<Item = St>,
12132 St: AsRef<str>,
12133 {
12134 self._scopes
12135 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12136 self
12137 }
12138
12139 /// Removes all scopes, and no default scope will be used either.
12140 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12141 /// for details).
12142 pub fn clear_scopes(mut self) -> CustomchannelListCall<'a, C> {
12143 self._scopes.clear();
12144 self
12145 }
12146}
12147
12148/// List the metadata for the dimensions available to this AdSense account.
12149///
12150/// A builder for the *dimensions.list* method supported by a *metadata* resource.
12151/// It is not used directly, but through a [`MetadataMethods`] instance.
12152///
12153/// # Example
12154///
12155/// Instantiate a resource method builder
12156///
12157/// ```test_harness,no_run
12158/// # extern crate hyper;
12159/// # extern crate hyper_rustls;
12160/// # extern crate google_adsense1d4 as adsense1d4;
12161/// # async fn dox() {
12162/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12163///
12164/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12165/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12166/// # .with_native_roots()
12167/// # .unwrap()
12168/// # .https_only()
12169/// # .enable_http2()
12170/// # .build();
12171///
12172/// # let executor = hyper_util::rt::TokioExecutor::new();
12173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12174/// # secret,
12175/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12176/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12177/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12178/// # ),
12179/// # ).build().await.unwrap();
12180///
12181/// # let client = hyper_util::client::legacy::Client::builder(
12182/// # hyper_util::rt::TokioExecutor::new()
12183/// # )
12184/// # .build(
12185/// # hyper_rustls::HttpsConnectorBuilder::new()
12186/// # .with_native_roots()
12187/// # .unwrap()
12188/// # .https_or_http()
12189/// # .enable_http2()
12190/// # .build()
12191/// # );
12192/// # let mut hub = AdSense::new(client, auth);
12193/// // You can configure optional parameters by calling the respective setters at will, and
12194/// // execute the final call using `doit()`.
12195/// // Values shown here are possibly random and not representative !
12196/// let result = hub.metadata().dimensions_list()
12197/// .doit().await;
12198/// # }
12199/// ```
12200pub struct MetadataDimensionListCall<'a, C>
12201where
12202 C: 'a,
12203{
12204 hub: &'a AdSense<C>,
12205 _delegate: Option<&'a mut dyn common::Delegate>,
12206 _additional_params: HashMap<String, String>,
12207 _scopes: BTreeSet<String>,
12208}
12209
12210impl<'a, C> common::CallBuilder for MetadataDimensionListCall<'a, C> {}
12211
12212impl<'a, C> MetadataDimensionListCall<'a, C>
12213where
12214 C: common::Connector,
12215{
12216 /// Perform the operation you have build so far.
12217 pub async fn doit(mut self) -> common::Result<(common::Response, Metadata)> {
12218 use std::borrow::Cow;
12219 use std::io::{Read, Seek};
12220
12221 use common::{url::Params, ToParts};
12222 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12223
12224 let mut dd = common::DefaultDelegate;
12225 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12226 dlg.begin(common::MethodInfo {
12227 id: "adsense.metadata.dimensions.list",
12228 http_method: hyper::Method::GET,
12229 });
12230
12231 for &field in ["alt"].iter() {
12232 if self._additional_params.contains_key(field) {
12233 dlg.finished(false);
12234 return Err(common::Error::FieldClash(field));
12235 }
12236 }
12237
12238 let mut params = Params::with_capacity(2 + self._additional_params.len());
12239
12240 params.extend(self._additional_params.iter());
12241
12242 params.push("alt", "json");
12243 let mut url = self.hub._base_url.clone() + "metadata/dimensions";
12244 if self._scopes.is_empty() {
12245 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12246 }
12247
12248 let url = params.parse_with_url(&url);
12249
12250 loop {
12251 let token = match self
12252 .hub
12253 .auth
12254 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12255 .await
12256 {
12257 Ok(token) => token,
12258 Err(e) => match dlg.token(e) {
12259 Ok(token) => token,
12260 Err(e) => {
12261 dlg.finished(false);
12262 return Err(common::Error::MissingToken(e));
12263 }
12264 },
12265 };
12266 let mut req_result = {
12267 let client = &self.hub.client;
12268 dlg.pre_request();
12269 let mut req_builder = hyper::Request::builder()
12270 .method(hyper::Method::GET)
12271 .uri(url.as_str())
12272 .header(USER_AGENT, self.hub._user_agent.clone());
12273
12274 if let Some(token) = token.as_ref() {
12275 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12276 }
12277
12278 let request = req_builder
12279 .header(CONTENT_LENGTH, 0_u64)
12280 .body(common::to_body::<String>(None));
12281
12282 client.request(request.unwrap()).await
12283 };
12284
12285 match req_result {
12286 Err(err) => {
12287 if let common::Retry::After(d) = dlg.http_error(&err) {
12288 sleep(d).await;
12289 continue;
12290 }
12291 dlg.finished(false);
12292 return Err(common::Error::HttpError(err));
12293 }
12294 Ok(res) => {
12295 let (mut parts, body) = res.into_parts();
12296 let mut body = common::Body::new(body);
12297 if !parts.status.is_success() {
12298 let bytes = common::to_bytes(body).await.unwrap_or_default();
12299 let error = serde_json::from_str(&common::to_string(&bytes));
12300 let response = common::to_response(parts, bytes.into());
12301
12302 if let common::Retry::After(d) =
12303 dlg.http_failure(&response, error.as_ref().ok())
12304 {
12305 sleep(d).await;
12306 continue;
12307 }
12308
12309 dlg.finished(false);
12310
12311 return Err(match error {
12312 Ok(value) => common::Error::BadRequest(value),
12313 _ => common::Error::Failure(response),
12314 });
12315 }
12316 let response = {
12317 let bytes = common::to_bytes(body).await.unwrap_or_default();
12318 let encoded = common::to_string(&bytes);
12319 match serde_json::from_str(&encoded) {
12320 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12321 Err(error) => {
12322 dlg.response_json_decode_error(&encoded, &error);
12323 return Err(common::Error::JsonDecodeError(
12324 encoded.to_string(),
12325 error,
12326 ));
12327 }
12328 }
12329 };
12330
12331 dlg.finished(true);
12332 return Ok(response);
12333 }
12334 }
12335 }
12336 }
12337
12338 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12339 /// while executing the actual API request.
12340 ///
12341 /// ````text
12342 /// It should be used to handle progress information, and to implement a certain level of resilience.
12343 /// ````
12344 ///
12345 /// Sets the *delegate* property to the given value.
12346 pub fn delegate(
12347 mut self,
12348 new_value: &'a mut dyn common::Delegate,
12349 ) -> MetadataDimensionListCall<'a, C> {
12350 self._delegate = Some(new_value);
12351 self
12352 }
12353
12354 /// Set any additional parameter of the query string used in the request.
12355 /// It should be used to set parameters which are not yet available through their own
12356 /// setters.
12357 ///
12358 /// Please note that this method must not be used to set any of the known parameters
12359 /// which have their own setter method. If done anyway, the request will fail.
12360 ///
12361 /// # Additional Parameters
12362 ///
12363 /// * *alt* (query-string) - Data format for the response.
12364 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12365 /// * *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.
12366 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12367 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12368 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12369 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12370 pub fn param<T>(mut self, name: T, value: T) -> MetadataDimensionListCall<'a, C>
12371 where
12372 T: AsRef<str>,
12373 {
12374 self._additional_params
12375 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12376 self
12377 }
12378
12379 /// Identifies the authorization scope for the method you are building.
12380 ///
12381 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12382 /// [`Scope::Readonly`].
12383 ///
12384 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12385 /// tokens for more than one scope.
12386 ///
12387 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12388 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12389 /// sufficient, a read-write scope will do as well.
12390 pub fn add_scope<St>(mut self, scope: St) -> MetadataDimensionListCall<'a, C>
12391 where
12392 St: AsRef<str>,
12393 {
12394 self._scopes.insert(String::from(scope.as_ref()));
12395 self
12396 }
12397 /// Identifies the authorization scope(s) for the method you are building.
12398 ///
12399 /// See [`Self::add_scope()`] for details.
12400 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetadataDimensionListCall<'a, C>
12401 where
12402 I: IntoIterator<Item = St>,
12403 St: AsRef<str>,
12404 {
12405 self._scopes
12406 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12407 self
12408 }
12409
12410 /// Removes all scopes, and no default scope will be used either.
12411 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12412 /// for details).
12413 pub fn clear_scopes(mut self) -> MetadataDimensionListCall<'a, C> {
12414 self._scopes.clear();
12415 self
12416 }
12417}
12418
12419/// List the metadata for the metrics available to this AdSense account.
12420///
12421/// A builder for the *metrics.list* method supported by a *metadata* resource.
12422/// It is not used directly, but through a [`MetadataMethods`] instance.
12423///
12424/// # Example
12425///
12426/// Instantiate a resource method builder
12427///
12428/// ```test_harness,no_run
12429/// # extern crate hyper;
12430/// # extern crate hyper_rustls;
12431/// # extern crate google_adsense1d4 as adsense1d4;
12432/// # async fn dox() {
12433/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12434///
12435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12436/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12437/// # .with_native_roots()
12438/// # .unwrap()
12439/// # .https_only()
12440/// # .enable_http2()
12441/// # .build();
12442///
12443/// # let executor = hyper_util::rt::TokioExecutor::new();
12444/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12445/// # secret,
12446/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12447/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12448/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12449/// # ),
12450/// # ).build().await.unwrap();
12451///
12452/// # let client = hyper_util::client::legacy::Client::builder(
12453/// # hyper_util::rt::TokioExecutor::new()
12454/// # )
12455/// # .build(
12456/// # hyper_rustls::HttpsConnectorBuilder::new()
12457/// # .with_native_roots()
12458/// # .unwrap()
12459/// # .https_or_http()
12460/// # .enable_http2()
12461/// # .build()
12462/// # );
12463/// # let mut hub = AdSense::new(client, auth);
12464/// // You can configure optional parameters by calling the respective setters at will, and
12465/// // execute the final call using `doit()`.
12466/// // Values shown here are possibly random and not representative !
12467/// let result = hub.metadata().metrics_list()
12468/// .doit().await;
12469/// # }
12470/// ```
12471pub struct MetadataMetricListCall<'a, C>
12472where
12473 C: 'a,
12474{
12475 hub: &'a AdSense<C>,
12476 _delegate: Option<&'a mut dyn common::Delegate>,
12477 _additional_params: HashMap<String, String>,
12478 _scopes: BTreeSet<String>,
12479}
12480
12481impl<'a, C> common::CallBuilder for MetadataMetricListCall<'a, C> {}
12482
12483impl<'a, C> MetadataMetricListCall<'a, C>
12484where
12485 C: common::Connector,
12486{
12487 /// Perform the operation you have build so far.
12488 pub async fn doit(mut self) -> common::Result<(common::Response, Metadata)> {
12489 use std::borrow::Cow;
12490 use std::io::{Read, Seek};
12491
12492 use common::{url::Params, ToParts};
12493 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12494
12495 let mut dd = common::DefaultDelegate;
12496 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12497 dlg.begin(common::MethodInfo {
12498 id: "adsense.metadata.metrics.list",
12499 http_method: hyper::Method::GET,
12500 });
12501
12502 for &field in ["alt"].iter() {
12503 if self._additional_params.contains_key(field) {
12504 dlg.finished(false);
12505 return Err(common::Error::FieldClash(field));
12506 }
12507 }
12508
12509 let mut params = Params::with_capacity(2 + self._additional_params.len());
12510
12511 params.extend(self._additional_params.iter());
12512
12513 params.push("alt", "json");
12514 let mut url = self.hub._base_url.clone() + "metadata/metrics";
12515 if self._scopes.is_empty() {
12516 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12517 }
12518
12519 let url = params.parse_with_url(&url);
12520
12521 loop {
12522 let token = match self
12523 .hub
12524 .auth
12525 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12526 .await
12527 {
12528 Ok(token) => token,
12529 Err(e) => match dlg.token(e) {
12530 Ok(token) => token,
12531 Err(e) => {
12532 dlg.finished(false);
12533 return Err(common::Error::MissingToken(e));
12534 }
12535 },
12536 };
12537 let mut req_result = {
12538 let client = &self.hub.client;
12539 dlg.pre_request();
12540 let mut req_builder = hyper::Request::builder()
12541 .method(hyper::Method::GET)
12542 .uri(url.as_str())
12543 .header(USER_AGENT, self.hub._user_agent.clone());
12544
12545 if let Some(token) = token.as_ref() {
12546 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12547 }
12548
12549 let request = req_builder
12550 .header(CONTENT_LENGTH, 0_u64)
12551 .body(common::to_body::<String>(None));
12552
12553 client.request(request.unwrap()).await
12554 };
12555
12556 match req_result {
12557 Err(err) => {
12558 if let common::Retry::After(d) = dlg.http_error(&err) {
12559 sleep(d).await;
12560 continue;
12561 }
12562 dlg.finished(false);
12563 return Err(common::Error::HttpError(err));
12564 }
12565 Ok(res) => {
12566 let (mut parts, body) = res.into_parts();
12567 let mut body = common::Body::new(body);
12568 if !parts.status.is_success() {
12569 let bytes = common::to_bytes(body).await.unwrap_or_default();
12570 let error = serde_json::from_str(&common::to_string(&bytes));
12571 let response = common::to_response(parts, bytes.into());
12572
12573 if let common::Retry::After(d) =
12574 dlg.http_failure(&response, error.as_ref().ok())
12575 {
12576 sleep(d).await;
12577 continue;
12578 }
12579
12580 dlg.finished(false);
12581
12582 return Err(match error {
12583 Ok(value) => common::Error::BadRequest(value),
12584 _ => common::Error::Failure(response),
12585 });
12586 }
12587 let response = {
12588 let bytes = common::to_bytes(body).await.unwrap_or_default();
12589 let encoded = common::to_string(&bytes);
12590 match serde_json::from_str(&encoded) {
12591 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12592 Err(error) => {
12593 dlg.response_json_decode_error(&encoded, &error);
12594 return Err(common::Error::JsonDecodeError(
12595 encoded.to_string(),
12596 error,
12597 ));
12598 }
12599 }
12600 };
12601
12602 dlg.finished(true);
12603 return Ok(response);
12604 }
12605 }
12606 }
12607 }
12608
12609 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12610 /// while executing the actual API request.
12611 ///
12612 /// ````text
12613 /// It should be used to handle progress information, and to implement a certain level of resilience.
12614 /// ````
12615 ///
12616 /// Sets the *delegate* property to the given value.
12617 pub fn delegate(
12618 mut self,
12619 new_value: &'a mut dyn common::Delegate,
12620 ) -> MetadataMetricListCall<'a, C> {
12621 self._delegate = Some(new_value);
12622 self
12623 }
12624
12625 /// Set any additional parameter of the query string used in the request.
12626 /// It should be used to set parameters which are not yet available through their own
12627 /// setters.
12628 ///
12629 /// Please note that this method must not be used to set any of the known parameters
12630 /// which have their own setter method. If done anyway, the request will fail.
12631 ///
12632 /// # Additional Parameters
12633 ///
12634 /// * *alt* (query-string) - Data format for the response.
12635 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12636 /// * *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.
12637 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12638 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12639 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12640 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12641 pub fn param<T>(mut self, name: T, value: T) -> MetadataMetricListCall<'a, C>
12642 where
12643 T: AsRef<str>,
12644 {
12645 self._additional_params
12646 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12647 self
12648 }
12649
12650 /// Identifies the authorization scope for the method you are building.
12651 ///
12652 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12653 /// [`Scope::Readonly`].
12654 ///
12655 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12656 /// tokens for more than one scope.
12657 ///
12658 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12659 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12660 /// sufficient, a read-write scope will do as well.
12661 pub fn add_scope<St>(mut self, scope: St) -> MetadataMetricListCall<'a, C>
12662 where
12663 St: AsRef<str>,
12664 {
12665 self._scopes.insert(String::from(scope.as_ref()));
12666 self
12667 }
12668 /// Identifies the authorization scope(s) for the method you are building.
12669 ///
12670 /// See [`Self::add_scope()`] for details.
12671 pub fn add_scopes<I, St>(mut self, scopes: I) -> MetadataMetricListCall<'a, C>
12672 where
12673 I: IntoIterator<Item = St>,
12674 St: AsRef<str>,
12675 {
12676 self._scopes
12677 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12678 self
12679 }
12680
12681 /// Removes all scopes, and no default scope will be used either.
12682 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12683 /// for details).
12684 pub fn clear_scopes(mut self) -> MetadataMetricListCall<'a, C> {
12685 self._scopes.clear();
12686 self
12687 }
12688}
12689
12690/// List the payments for this AdSense account.
12691///
12692/// A builder for the *list* method supported by a *payment* resource.
12693/// It is not used directly, but through a [`PaymentMethods`] instance.
12694///
12695/// # Example
12696///
12697/// Instantiate a resource method builder
12698///
12699/// ```test_harness,no_run
12700/// # extern crate hyper;
12701/// # extern crate hyper_rustls;
12702/// # extern crate google_adsense1d4 as adsense1d4;
12703/// # async fn dox() {
12704/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12705///
12706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12707/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12708/// # .with_native_roots()
12709/// # .unwrap()
12710/// # .https_only()
12711/// # .enable_http2()
12712/// # .build();
12713///
12714/// # let executor = hyper_util::rt::TokioExecutor::new();
12715/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12716/// # secret,
12717/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12718/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12719/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12720/// # ),
12721/// # ).build().await.unwrap();
12722///
12723/// # let client = hyper_util::client::legacy::Client::builder(
12724/// # hyper_util::rt::TokioExecutor::new()
12725/// # )
12726/// # .build(
12727/// # hyper_rustls::HttpsConnectorBuilder::new()
12728/// # .with_native_roots()
12729/// # .unwrap()
12730/// # .https_or_http()
12731/// # .enable_http2()
12732/// # .build()
12733/// # );
12734/// # let mut hub = AdSense::new(client, auth);
12735/// // You can configure optional parameters by calling the respective setters at will, and
12736/// // execute the final call using `doit()`.
12737/// // Values shown here are possibly random and not representative !
12738/// let result = hub.payments().list()
12739/// .doit().await;
12740/// # }
12741/// ```
12742pub struct PaymentListCall<'a, C>
12743where
12744 C: 'a,
12745{
12746 hub: &'a AdSense<C>,
12747 _delegate: Option<&'a mut dyn common::Delegate>,
12748 _additional_params: HashMap<String, String>,
12749 _scopes: BTreeSet<String>,
12750}
12751
12752impl<'a, C> common::CallBuilder for PaymentListCall<'a, C> {}
12753
12754impl<'a, C> PaymentListCall<'a, C>
12755where
12756 C: common::Connector,
12757{
12758 /// Perform the operation you have build so far.
12759 pub async fn doit(mut self) -> common::Result<(common::Response, Payments)> {
12760 use std::borrow::Cow;
12761 use std::io::{Read, Seek};
12762
12763 use common::{url::Params, ToParts};
12764 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12765
12766 let mut dd = common::DefaultDelegate;
12767 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12768 dlg.begin(common::MethodInfo {
12769 id: "adsense.payments.list",
12770 http_method: hyper::Method::GET,
12771 });
12772
12773 for &field in ["alt"].iter() {
12774 if self._additional_params.contains_key(field) {
12775 dlg.finished(false);
12776 return Err(common::Error::FieldClash(field));
12777 }
12778 }
12779
12780 let mut params = Params::with_capacity(2 + self._additional_params.len());
12781
12782 params.extend(self._additional_params.iter());
12783
12784 params.push("alt", "json");
12785 let mut url = self.hub._base_url.clone() + "payments";
12786 if self._scopes.is_empty() {
12787 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12788 }
12789
12790 let url = params.parse_with_url(&url);
12791
12792 loop {
12793 let token = match self
12794 .hub
12795 .auth
12796 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12797 .await
12798 {
12799 Ok(token) => token,
12800 Err(e) => match dlg.token(e) {
12801 Ok(token) => token,
12802 Err(e) => {
12803 dlg.finished(false);
12804 return Err(common::Error::MissingToken(e));
12805 }
12806 },
12807 };
12808 let mut req_result = {
12809 let client = &self.hub.client;
12810 dlg.pre_request();
12811 let mut req_builder = hyper::Request::builder()
12812 .method(hyper::Method::GET)
12813 .uri(url.as_str())
12814 .header(USER_AGENT, self.hub._user_agent.clone());
12815
12816 if let Some(token) = token.as_ref() {
12817 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12818 }
12819
12820 let request = req_builder
12821 .header(CONTENT_LENGTH, 0_u64)
12822 .body(common::to_body::<String>(None));
12823
12824 client.request(request.unwrap()).await
12825 };
12826
12827 match req_result {
12828 Err(err) => {
12829 if let common::Retry::After(d) = dlg.http_error(&err) {
12830 sleep(d).await;
12831 continue;
12832 }
12833 dlg.finished(false);
12834 return Err(common::Error::HttpError(err));
12835 }
12836 Ok(res) => {
12837 let (mut parts, body) = res.into_parts();
12838 let mut body = common::Body::new(body);
12839 if !parts.status.is_success() {
12840 let bytes = common::to_bytes(body).await.unwrap_or_default();
12841 let error = serde_json::from_str(&common::to_string(&bytes));
12842 let response = common::to_response(parts, bytes.into());
12843
12844 if let common::Retry::After(d) =
12845 dlg.http_failure(&response, error.as_ref().ok())
12846 {
12847 sleep(d).await;
12848 continue;
12849 }
12850
12851 dlg.finished(false);
12852
12853 return Err(match error {
12854 Ok(value) => common::Error::BadRequest(value),
12855 _ => common::Error::Failure(response),
12856 });
12857 }
12858 let response = {
12859 let bytes = common::to_bytes(body).await.unwrap_or_default();
12860 let encoded = common::to_string(&bytes);
12861 match serde_json::from_str(&encoded) {
12862 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12863 Err(error) => {
12864 dlg.response_json_decode_error(&encoded, &error);
12865 return Err(common::Error::JsonDecodeError(
12866 encoded.to_string(),
12867 error,
12868 ));
12869 }
12870 }
12871 };
12872
12873 dlg.finished(true);
12874 return Ok(response);
12875 }
12876 }
12877 }
12878 }
12879
12880 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12881 /// while executing the actual API request.
12882 ///
12883 /// ````text
12884 /// It should be used to handle progress information, and to implement a certain level of resilience.
12885 /// ````
12886 ///
12887 /// Sets the *delegate* property to the given value.
12888 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PaymentListCall<'a, C> {
12889 self._delegate = Some(new_value);
12890 self
12891 }
12892
12893 /// Set any additional parameter of the query string used in the request.
12894 /// It should be used to set parameters which are not yet available through their own
12895 /// setters.
12896 ///
12897 /// Please note that this method must not be used to set any of the known parameters
12898 /// which have their own setter method. If done anyway, the request will fail.
12899 ///
12900 /// # Additional Parameters
12901 ///
12902 /// * *alt* (query-string) - Data format for the response.
12903 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12904 /// * *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.
12905 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12906 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12907 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12908 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12909 pub fn param<T>(mut self, name: T, value: T) -> PaymentListCall<'a, C>
12910 where
12911 T: AsRef<str>,
12912 {
12913 self._additional_params
12914 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12915 self
12916 }
12917
12918 /// Identifies the authorization scope for the method you are building.
12919 ///
12920 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12921 /// [`Scope::Readonly`].
12922 ///
12923 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12924 /// tokens for more than one scope.
12925 ///
12926 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12927 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12928 /// sufficient, a read-write scope will do as well.
12929 pub fn add_scope<St>(mut self, scope: St) -> PaymentListCall<'a, C>
12930 where
12931 St: AsRef<str>,
12932 {
12933 self._scopes.insert(String::from(scope.as_ref()));
12934 self
12935 }
12936 /// Identifies the authorization scope(s) for the method you are building.
12937 ///
12938 /// See [`Self::add_scope()`] for details.
12939 pub fn add_scopes<I, St>(mut self, scopes: I) -> PaymentListCall<'a, C>
12940 where
12941 I: IntoIterator<Item = St>,
12942 St: AsRef<str>,
12943 {
12944 self._scopes
12945 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12946 self
12947 }
12948
12949 /// Removes all scopes, and no default scope will be used either.
12950 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12951 /// for details).
12952 pub fn clear_scopes(mut self) -> PaymentListCall<'a, C> {
12953 self._scopes.clear();
12954 self
12955 }
12956}
12957
12958/// Generate an AdSense report based on the saved report ID sent in the query parameters.
12959///
12960/// A builder for the *saved.generate* method supported by a *report* resource.
12961/// It is not used directly, but through a [`ReportMethods`] instance.
12962///
12963/// # Example
12964///
12965/// Instantiate a resource method builder
12966///
12967/// ```test_harness,no_run
12968/// # extern crate hyper;
12969/// # extern crate hyper_rustls;
12970/// # extern crate google_adsense1d4 as adsense1d4;
12971/// # async fn dox() {
12972/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12973///
12974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12975/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12976/// # .with_native_roots()
12977/// # .unwrap()
12978/// # .https_only()
12979/// # .enable_http2()
12980/// # .build();
12981///
12982/// # let executor = hyper_util::rt::TokioExecutor::new();
12983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12984/// # secret,
12985/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12986/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12987/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12988/// # ),
12989/// # ).build().await.unwrap();
12990///
12991/// # let client = hyper_util::client::legacy::Client::builder(
12992/// # hyper_util::rt::TokioExecutor::new()
12993/// # )
12994/// # .build(
12995/// # hyper_rustls::HttpsConnectorBuilder::new()
12996/// # .with_native_roots()
12997/// # .unwrap()
12998/// # .https_or_http()
12999/// # .enable_http2()
13000/// # .build()
13001/// # );
13002/// # let mut hub = AdSense::new(client, auth);
13003/// // You can configure optional parameters by calling the respective setters at will, and
13004/// // execute the final call using `doit()`.
13005/// // Values shown here are possibly random and not representative !
13006/// let result = hub.reports().saved_generate("savedReportId")
13007/// .start_index(-42)
13008/// .max_results(-57)
13009/// .locale("sit")
13010/// .doit().await;
13011/// # }
13012/// ```
13013pub struct ReportSavedGenerateCall<'a, C>
13014where
13015 C: 'a,
13016{
13017 hub: &'a AdSense<C>,
13018 _saved_report_id: String,
13019 _start_index: Option<i32>,
13020 _max_results: Option<i32>,
13021 _locale: Option<String>,
13022 _delegate: Option<&'a mut dyn common::Delegate>,
13023 _additional_params: HashMap<String, String>,
13024 _scopes: BTreeSet<String>,
13025}
13026
13027impl<'a, C> common::CallBuilder for ReportSavedGenerateCall<'a, C> {}
13028
13029impl<'a, C> ReportSavedGenerateCall<'a, C>
13030where
13031 C: common::Connector,
13032{
13033 /// Perform the operation you have build so far.
13034 pub async fn doit(
13035 mut self,
13036 ) -> common::Result<(common::Response, AdsenseReportsGenerateResponse)> {
13037 use std::borrow::Cow;
13038 use std::io::{Read, Seek};
13039
13040 use common::{url::Params, ToParts};
13041 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13042
13043 let mut dd = common::DefaultDelegate;
13044 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13045 dlg.begin(common::MethodInfo {
13046 id: "adsense.reports.saved.generate",
13047 http_method: hyper::Method::GET,
13048 });
13049
13050 for &field in ["alt", "savedReportId", "startIndex", "maxResults", "locale"].iter() {
13051 if self._additional_params.contains_key(field) {
13052 dlg.finished(false);
13053 return Err(common::Error::FieldClash(field));
13054 }
13055 }
13056
13057 let mut params = Params::with_capacity(6 + self._additional_params.len());
13058 params.push("savedReportId", self._saved_report_id);
13059 if let Some(value) = self._start_index.as_ref() {
13060 params.push("startIndex", value.to_string());
13061 }
13062 if let Some(value) = self._max_results.as_ref() {
13063 params.push("maxResults", value.to_string());
13064 }
13065 if let Some(value) = self._locale.as_ref() {
13066 params.push("locale", value);
13067 }
13068
13069 params.extend(self._additional_params.iter());
13070
13071 params.push("alt", "json");
13072 let mut url = self.hub._base_url.clone() + "reports/{savedReportId}";
13073 if self._scopes.is_empty() {
13074 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13075 }
13076
13077 #[allow(clippy::single_element_loop)]
13078 for &(find_this, param_name) in [("{savedReportId}", "savedReportId")].iter() {
13079 url = params.uri_replacement(url, param_name, find_this, false);
13080 }
13081 {
13082 let to_remove = ["savedReportId"];
13083 params.remove_params(&to_remove);
13084 }
13085
13086 let url = params.parse_with_url(&url);
13087
13088 loop {
13089 let token = match self
13090 .hub
13091 .auth
13092 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13093 .await
13094 {
13095 Ok(token) => token,
13096 Err(e) => match dlg.token(e) {
13097 Ok(token) => token,
13098 Err(e) => {
13099 dlg.finished(false);
13100 return Err(common::Error::MissingToken(e));
13101 }
13102 },
13103 };
13104 let mut req_result = {
13105 let client = &self.hub.client;
13106 dlg.pre_request();
13107 let mut req_builder = hyper::Request::builder()
13108 .method(hyper::Method::GET)
13109 .uri(url.as_str())
13110 .header(USER_AGENT, self.hub._user_agent.clone());
13111
13112 if let Some(token) = token.as_ref() {
13113 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13114 }
13115
13116 let request = req_builder
13117 .header(CONTENT_LENGTH, 0_u64)
13118 .body(common::to_body::<String>(None));
13119
13120 client.request(request.unwrap()).await
13121 };
13122
13123 match req_result {
13124 Err(err) => {
13125 if let common::Retry::After(d) = dlg.http_error(&err) {
13126 sleep(d).await;
13127 continue;
13128 }
13129 dlg.finished(false);
13130 return Err(common::Error::HttpError(err));
13131 }
13132 Ok(res) => {
13133 let (mut parts, body) = res.into_parts();
13134 let mut body = common::Body::new(body);
13135 if !parts.status.is_success() {
13136 let bytes = common::to_bytes(body).await.unwrap_or_default();
13137 let error = serde_json::from_str(&common::to_string(&bytes));
13138 let response = common::to_response(parts, bytes.into());
13139
13140 if let common::Retry::After(d) =
13141 dlg.http_failure(&response, error.as_ref().ok())
13142 {
13143 sleep(d).await;
13144 continue;
13145 }
13146
13147 dlg.finished(false);
13148
13149 return Err(match error {
13150 Ok(value) => common::Error::BadRequest(value),
13151 _ => common::Error::Failure(response),
13152 });
13153 }
13154 let response = {
13155 let bytes = common::to_bytes(body).await.unwrap_or_default();
13156 let encoded = common::to_string(&bytes);
13157 match serde_json::from_str(&encoded) {
13158 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13159 Err(error) => {
13160 dlg.response_json_decode_error(&encoded, &error);
13161 return Err(common::Error::JsonDecodeError(
13162 encoded.to_string(),
13163 error,
13164 ));
13165 }
13166 }
13167 };
13168
13169 dlg.finished(true);
13170 return Ok(response);
13171 }
13172 }
13173 }
13174 }
13175
13176 /// The saved report to retrieve.
13177 ///
13178 /// Sets the *saved report id* path property to the given value.
13179 ///
13180 /// Even though the property as already been set when instantiating this call,
13181 /// we provide this method for API completeness.
13182 pub fn saved_report_id(mut self, new_value: &str) -> ReportSavedGenerateCall<'a, C> {
13183 self._saved_report_id = new_value.to_string();
13184 self
13185 }
13186 /// Index of the first row of report data to return.
13187 ///
13188 /// Sets the *start index* query property to the given value.
13189 pub fn start_index(mut self, new_value: i32) -> ReportSavedGenerateCall<'a, C> {
13190 self._start_index = Some(new_value);
13191 self
13192 }
13193 /// The maximum number of rows of report data to return.
13194 ///
13195 /// Sets the *max results* query property to the given value.
13196 pub fn max_results(mut self, new_value: i32) -> ReportSavedGenerateCall<'a, C> {
13197 self._max_results = Some(new_value);
13198 self
13199 }
13200 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
13201 ///
13202 /// Sets the *locale* query property to the given value.
13203 pub fn locale(mut self, new_value: &str) -> ReportSavedGenerateCall<'a, C> {
13204 self._locale = Some(new_value.to_string());
13205 self
13206 }
13207 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13208 /// while executing the actual API request.
13209 ///
13210 /// ````text
13211 /// It should be used to handle progress information, and to implement a certain level of resilience.
13212 /// ````
13213 ///
13214 /// Sets the *delegate* property to the given value.
13215 pub fn delegate(
13216 mut self,
13217 new_value: &'a mut dyn common::Delegate,
13218 ) -> ReportSavedGenerateCall<'a, C> {
13219 self._delegate = Some(new_value);
13220 self
13221 }
13222
13223 /// Set any additional parameter of the query string used in the request.
13224 /// It should be used to set parameters which are not yet available through their own
13225 /// setters.
13226 ///
13227 /// Please note that this method must not be used to set any of the known parameters
13228 /// which have their own setter method. If done anyway, the request will fail.
13229 ///
13230 /// # Additional Parameters
13231 ///
13232 /// * *alt* (query-string) - Data format for the response.
13233 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13234 /// * *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.
13235 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13236 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13237 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13238 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13239 pub fn param<T>(mut self, name: T, value: T) -> ReportSavedGenerateCall<'a, C>
13240 where
13241 T: AsRef<str>,
13242 {
13243 self._additional_params
13244 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13245 self
13246 }
13247
13248 /// Identifies the authorization scope for the method you are building.
13249 ///
13250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13251 /// [`Scope::Readonly`].
13252 ///
13253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13254 /// tokens for more than one scope.
13255 ///
13256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13258 /// sufficient, a read-write scope will do as well.
13259 pub fn add_scope<St>(mut self, scope: St) -> ReportSavedGenerateCall<'a, C>
13260 where
13261 St: AsRef<str>,
13262 {
13263 self._scopes.insert(String::from(scope.as_ref()));
13264 self
13265 }
13266 /// Identifies the authorization scope(s) for the method you are building.
13267 ///
13268 /// See [`Self::add_scope()`] for details.
13269 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportSavedGenerateCall<'a, C>
13270 where
13271 I: IntoIterator<Item = St>,
13272 St: AsRef<str>,
13273 {
13274 self._scopes
13275 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13276 self
13277 }
13278
13279 /// Removes all scopes, and no default scope will be used either.
13280 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13281 /// for details).
13282 pub fn clear_scopes(mut self) -> ReportSavedGenerateCall<'a, C> {
13283 self._scopes.clear();
13284 self
13285 }
13286}
13287
13288/// List all saved reports in this AdSense account.
13289///
13290/// A builder for the *saved.list* method supported by a *report* resource.
13291/// It is not used directly, but through a [`ReportMethods`] instance.
13292///
13293/// # Example
13294///
13295/// Instantiate a resource method builder
13296///
13297/// ```test_harness,no_run
13298/// # extern crate hyper;
13299/// # extern crate hyper_rustls;
13300/// # extern crate google_adsense1d4 as adsense1d4;
13301/// # async fn dox() {
13302/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13303///
13304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13306/// # .with_native_roots()
13307/// # .unwrap()
13308/// # .https_only()
13309/// # .enable_http2()
13310/// # .build();
13311///
13312/// # let executor = hyper_util::rt::TokioExecutor::new();
13313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13314/// # secret,
13315/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13316/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13317/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13318/// # ),
13319/// # ).build().await.unwrap();
13320///
13321/// # let client = hyper_util::client::legacy::Client::builder(
13322/// # hyper_util::rt::TokioExecutor::new()
13323/// # )
13324/// # .build(
13325/// # hyper_rustls::HttpsConnectorBuilder::new()
13326/// # .with_native_roots()
13327/// # .unwrap()
13328/// # .https_or_http()
13329/// # .enable_http2()
13330/// # .build()
13331/// # );
13332/// # let mut hub = AdSense::new(client, auth);
13333/// // You can configure optional parameters by calling the respective setters at will, and
13334/// // execute the final call using `doit()`.
13335/// // Values shown here are possibly random and not representative !
13336/// let result = hub.reports().saved_list()
13337/// .page_token("sed")
13338/// .max_results(-75)
13339/// .doit().await;
13340/// # }
13341/// ```
13342pub struct ReportSavedListCall<'a, C>
13343where
13344 C: 'a,
13345{
13346 hub: &'a AdSense<C>,
13347 _page_token: Option<String>,
13348 _max_results: Option<i32>,
13349 _delegate: Option<&'a mut dyn common::Delegate>,
13350 _additional_params: HashMap<String, String>,
13351 _scopes: BTreeSet<String>,
13352}
13353
13354impl<'a, C> common::CallBuilder for ReportSavedListCall<'a, C> {}
13355
13356impl<'a, C> ReportSavedListCall<'a, C>
13357where
13358 C: common::Connector,
13359{
13360 /// Perform the operation you have build so far.
13361 pub async fn doit(mut self) -> common::Result<(common::Response, SavedReports)> {
13362 use std::borrow::Cow;
13363 use std::io::{Read, Seek};
13364
13365 use common::{url::Params, ToParts};
13366 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13367
13368 let mut dd = common::DefaultDelegate;
13369 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13370 dlg.begin(common::MethodInfo {
13371 id: "adsense.reports.saved.list",
13372 http_method: hyper::Method::GET,
13373 });
13374
13375 for &field in ["alt", "pageToken", "maxResults"].iter() {
13376 if self._additional_params.contains_key(field) {
13377 dlg.finished(false);
13378 return Err(common::Error::FieldClash(field));
13379 }
13380 }
13381
13382 let mut params = Params::with_capacity(4 + self._additional_params.len());
13383 if let Some(value) = self._page_token.as_ref() {
13384 params.push("pageToken", value);
13385 }
13386 if let Some(value) = self._max_results.as_ref() {
13387 params.push("maxResults", value.to_string());
13388 }
13389
13390 params.extend(self._additional_params.iter());
13391
13392 params.push("alt", "json");
13393 let mut url = self.hub._base_url.clone() + "reports/saved";
13394 if self._scopes.is_empty() {
13395 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13396 }
13397
13398 let url = params.parse_with_url(&url);
13399
13400 loop {
13401 let token = match self
13402 .hub
13403 .auth
13404 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13405 .await
13406 {
13407 Ok(token) => token,
13408 Err(e) => match dlg.token(e) {
13409 Ok(token) => token,
13410 Err(e) => {
13411 dlg.finished(false);
13412 return Err(common::Error::MissingToken(e));
13413 }
13414 },
13415 };
13416 let mut req_result = {
13417 let client = &self.hub.client;
13418 dlg.pre_request();
13419 let mut req_builder = hyper::Request::builder()
13420 .method(hyper::Method::GET)
13421 .uri(url.as_str())
13422 .header(USER_AGENT, self.hub._user_agent.clone());
13423
13424 if let Some(token) = token.as_ref() {
13425 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13426 }
13427
13428 let request = req_builder
13429 .header(CONTENT_LENGTH, 0_u64)
13430 .body(common::to_body::<String>(None));
13431
13432 client.request(request.unwrap()).await
13433 };
13434
13435 match req_result {
13436 Err(err) => {
13437 if let common::Retry::After(d) = dlg.http_error(&err) {
13438 sleep(d).await;
13439 continue;
13440 }
13441 dlg.finished(false);
13442 return Err(common::Error::HttpError(err));
13443 }
13444 Ok(res) => {
13445 let (mut parts, body) = res.into_parts();
13446 let mut body = common::Body::new(body);
13447 if !parts.status.is_success() {
13448 let bytes = common::to_bytes(body).await.unwrap_or_default();
13449 let error = serde_json::from_str(&common::to_string(&bytes));
13450 let response = common::to_response(parts, bytes.into());
13451
13452 if let common::Retry::After(d) =
13453 dlg.http_failure(&response, error.as_ref().ok())
13454 {
13455 sleep(d).await;
13456 continue;
13457 }
13458
13459 dlg.finished(false);
13460
13461 return Err(match error {
13462 Ok(value) => common::Error::BadRequest(value),
13463 _ => common::Error::Failure(response),
13464 });
13465 }
13466 let response = {
13467 let bytes = common::to_bytes(body).await.unwrap_or_default();
13468 let encoded = common::to_string(&bytes);
13469 match serde_json::from_str(&encoded) {
13470 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13471 Err(error) => {
13472 dlg.response_json_decode_error(&encoded, &error);
13473 return Err(common::Error::JsonDecodeError(
13474 encoded.to_string(),
13475 error,
13476 ));
13477 }
13478 }
13479 };
13480
13481 dlg.finished(true);
13482 return Ok(response);
13483 }
13484 }
13485 }
13486 }
13487
13488 /// 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.
13489 ///
13490 /// Sets the *page token* query property to the given value.
13491 pub fn page_token(mut self, new_value: &str) -> ReportSavedListCall<'a, C> {
13492 self._page_token = Some(new_value.to_string());
13493 self
13494 }
13495 /// The maximum number of saved reports to include in the response, used for paging.
13496 ///
13497 /// Sets the *max results* query property to the given value.
13498 pub fn max_results(mut self, new_value: i32) -> ReportSavedListCall<'a, C> {
13499 self._max_results = Some(new_value);
13500 self
13501 }
13502 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13503 /// while executing the actual API request.
13504 ///
13505 /// ````text
13506 /// It should be used to handle progress information, and to implement a certain level of resilience.
13507 /// ````
13508 ///
13509 /// Sets the *delegate* property to the given value.
13510 pub fn delegate(
13511 mut self,
13512 new_value: &'a mut dyn common::Delegate,
13513 ) -> ReportSavedListCall<'a, C> {
13514 self._delegate = Some(new_value);
13515 self
13516 }
13517
13518 /// Set any additional parameter of the query string used in the request.
13519 /// It should be used to set parameters which are not yet available through their own
13520 /// setters.
13521 ///
13522 /// Please note that this method must not be used to set any of the known parameters
13523 /// which have their own setter method. If done anyway, the request will fail.
13524 ///
13525 /// # Additional Parameters
13526 ///
13527 /// * *alt* (query-string) - Data format for the response.
13528 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13529 /// * *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.
13530 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13531 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13532 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13533 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13534 pub fn param<T>(mut self, name: T, value: T) -> ReportSavedListCall<'a, C>
13535 where
13536 T: AsRef<str>,
13537 {
13538 self._additional_params
13539 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13540 self
13541 }
13542
13543 /// Identifies the authorization scope for the method you are building.
13544 ///
13545 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13546 /// [`Scope::Readonly`].
13547 ///
13548 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13549 /// tokens for more than one scope.
13550 ///
13551 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13552 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13553 /// sufficient, a read-write scope will do as well.
13554 pub fn add_scope<St>(mut self, scope: St) -> ReportSavedListCall<'a, C>
13555 where
13556 St: AsRef<str>,
13557 {
13558 self._scopes.insert(String::from(scope.as_ref()));
13559 self
13560 }
13561 /// Identifies the authorization scope(s) for the method you are building.
13562 ///
13563 /// See [`Self::add_scope()`] for details.
13564 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportSavedListCall<'a, C>
13565 where
13566 I: IntoIterator<Item = St>,
13567 St: AsRef<str>,
13568 {
13569 self._scopes
13570 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13571 self
13572 }
13573
13574 /// Removes all scopes, and no default scope will be used either.
13575 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13576 /// for details).
13577 pub fn clear_scopes(mut self) -> ReportSavedListCall<'a, C> {
13578 self._scopes.clear();
13579 self
13580 }
13581}
13582
13583/// Generate an AdSense 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.
13584///
13585/// This method supports **media download**. To enable it, adjust the builder like this:
13586/// `.param("alt", "media")`.
13587/// Please note that due to missing multi-part support on the server side, you will only receive the media,
13588/// but not the `AdsenseReportsGenerateResponse` structure that you would usually get. The latter will be a default value.
13589///
13590/// A builder for the *generate* method supported by a *report* resource.
13591/// It is not used directly, but through a [`ReportMethods`] instance.
13592///
13593/// # Example
13594///
13595/// Instantiate a resource method builder
13596///
13597/// ```test_harness,no_run
13598/// # extern crate hyper;
13599/// # extern crate hyper_rustls;
13600/// # extern crate google_adsense1d4 as adsense1d4;
13601/// # async fn dox() {
13602/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13603///
13604/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13605/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13606/// # .with_native_roots()
13607/// # .unwrap()
13608/// # .https_only()
13609/// # .enable_http2()
13610/// # .build();
13611///
13612/// # let executor = hyper_util::rt::TokioExecutor::new();
13613/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13614/// # secret,
13615/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13616/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13617/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13618/// # ),
13619/// # ).build().await.unwrap();
13620///
13621/// # let client = hyper_util::client::legacy::Client::builder(
13622/// # hyper_util::rt::TokioExecutor::new()
13623/// # )
13624/// # .build(
13625/// # hyper_rustls::HttpsConnectorBuilder::new()
13626/// # .with_native_roots()
13627/// # .unwrap()
13628/// # .https_or_http()
13629/// # .enable_http2()
13630/// # .build()
13631/// # );
13632/// # let mut hub = AdSense::new(client, auth);
13633/// // You can configure optional parameters by calling the respective setters at will, and
13634/// // execute the final call using `doit()`.
13635/// // Values shown here are possibly random and not representative !
13636/// let result = hub.reports().generate("startDate", "endDate")
13637/// .use_timezone_reporting(true)
13638/// .start_index(-10)
13639/// .add_sort("et")
13640/// .add_metric("At")
13641/// .max_results(-84)
13642/// .locale("eirmod")
13643/// .add_filter("Lorem")
13644/// .add_dimension("accusam")
13645/// .currency("amet")
13646/// .add_account_id("erat")
13647/// .doit().await;
13648/// # }
13649/// ```
13650pub struct ReportGenerateCall<'a, C>
13651where
13652 C: 'a,
13653{
13654 hub: &'a AdSense<C>,
13655 _start_date: String,
13656 _end_date: String,
13657 _use_timezone_reporting: Option<bool>,
13658 _start_index: Option<i32>,
13659 _sort: Vec<String>,
13660 _metric: Vec<String>,
13661 _max_results: Option<i32>,
13662 _locale: Option<String>,
13663 _filter: Vec<String>,
13664 _dimension: Vec<String>,
13665 _currency: Option<String>,
13666 _account_id: Vec<String>,
13667 _delegate: Option<&'a mut dyn common::Delegate>,
13668 _additional_params: HashMap<String, String>,
13669 _scopes: BTreeSet<String>,
13670}
13671
13672impl<'a, C> common::CallBuilder for ReportGenerateCall<'a, C> {}
13673
13674impl<'a, C> ReportGenerateCall<'a, C>
13675where
13676 C: common::Connector,
13677{
13678 /// Perform the operation you have build so far.
13679 pub async fn doit(
13680 mut self,
13681 ) -> common::Result<(common::Response, AdsenseReportsGenerateResponse)> {
13682 use std::borrow::Cow;
13683 use std::io::{Read, Seek};
13684
13685 use common::{url::Params, ToParts};
13686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13687
13688 let mut dd = common::DefaultDelegate;
13689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13690 dlg.begin(common::MethodInfo {
13691 id: "adsense.reports.generate",
13692 http_method: hyper::Method::GET,
13693 });
13694
13695 for &field in [
13696 "startDate",
13697 "endDate",
13698 "useTimezoneReporting",
13699 "startIndex",
13700 "sort",
13701 "metric",
13702 "maxResults",
13703 "locale",
13704 "filter",
13705 "dimension",
13706 "currency",
13707 "accountId",
13708 ]
13709 .iter()
13710 {
13711 if self._additional_params.contains_key(field) {
13712 dlg.finished(false);
13713 return Err(common::Error::FieldClash(field));
13714 }
13715 }
13716
13717 let mut params = Params::with_capacity(13 + self._additional_params.len());
13718 params.push("startDate", self._start_date);
13719 params.push("endDate", self._end_date);
13720 if let Some(value) = self._use_timezone_reporting.as_ref() {
13721 params.push("useTimezoneReporting", value.to_string());
13722 }
13723 if let Some(value) = self._start_index.as_ref() {
13724 params.push("startIndex", value.to_string());
13725 }
13726 if !self._sort.is_empty() {
13727 for f in self._sort.iter() {
13728 params.push("sort", f);
13729 }
13730 }
13731 if !self._metric.is_empty() {
13732 for f in self._metric.iter() {
13733 params.push("metric", f);
13734 }
13735 }
13736 if let Some(value) = self._max_results.as_ref() {
13737 params.push("maxResults", value.to_string());
13738 }
13739 if let Some(value) = self._locale.as_ref() {
13740 params.push("locale", value);
13741 }
13742 if !self._filter.is_empty() {
13743 for f in self._filter.iter() {
13744 params.push("filter", f);
13745 }
13746 }
13747 if !self._dimension.is_empty() {
13748 for f in self._dimension.iter() {
13749 params.push("dimension", f);
13750 }
13751 }
13752 if let Some(value) = self._currency.as_ref() {
13753 params.push("currency", value);
13754 }
13755 if !self._account_id.is_empty() {
13756 for f in self._account_id.iter() {
13757 params.push("accountId", f);
13758 }
13759 }
13760
13761 params.extend(self._additional_params.iter());
13762
13763 let (alt_field_missing, enable_resource_parsing) = {
13764 if let Some(value) = params.get("alt") {
13765 (false, value == "json")
13766 } else {
13767 (true, true)
13768 }
13769 };
13770 if alt_field_missing {
13771 params.push("alt", "json");
13772 }
13773 let mut url = self.hub._base_url.clone() + "reports";
13774 if self._scopes.is_empty() {
13775 self._scopes.insert(Scope::Readonly.as_ref().to_string());
13776 }
13777
13778 let url = params.parse_with_url(&url);
13779
13780 loop {
13781 let token = match self
13782 .hub
13783 .auth
13784 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13785 .await
13786 {
13787 Ok(token) => token,
13788 Err(e) => match dlg.token(e) {
13789 Ok(token) => token,
13790 Err(e) => {
13791 dlg.finished(false);
13792 return Err(common::Error::MissingToken(e));
13793 }
13794 },
13795 };
13796 let mut req_result = {
13797 let client = &self.hub.client;
13798 dlg.pre_request();
13799 let mut req_builder = hyper::Request::builder()
13800 .method(hyper::Method::GET)
13801 .uri(url.as_str())
13802 .header(USER_AGENT, self.hub._user_agent.clone());
13803
13804 if let Some(token) = token.as_ref() {
13805 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13806 }
13807
13808 let request = req_builder
13809 .header(CONTENT_LENGTH, 0_u64)
13810 .body(common::to_body::<String>(None));
13811
13812 client.request(request.unwrap()).await
13813 };
13814
13815 match req_result {
13816 Err(err) => {
13817 if let common::Retry::After(d) = dlg.http_error(&err) {
13818 sleep(d).await;
13819 continue;
13820 }
13821 dlg.finished(false);
13822 return Err(common::Error::HttpError(err));
13823 }
13824 Ok(res) => {
13825 let (mut parts, body) = res.into_parts();
13826 let mut body = common::Body::new(body);
13827 if !parts.status.is_success() {
13828 let bytes = common::to_bytes(body).await.unwrap_or_default();
13829 let error = serde_json::from_str(&common::to_string(&bytes));
13830 let response = common::to_response(parts, bytes.into());
13831
13832 if let common::Retry::After(d) =
13833 dlg.http_failure(&response, error.as_ref().ok())
13834 {
13835 sleep(d).await;
13836 continue;
13837 }
13838
13839 dlg.finished(false);
13840
13841 return Err(match error {
13842 Ok(value) => common::Error::BadRequest(value),
13843 _ => common::Error::Failure(response),
13844 });
13845 }
13846 let response = if enable_resource_parsing {
13847 let bytes = common::to_bytes(body).await.unwrap_or_default();
13848 let encoded = common::to_string(&bytes);
13849 match serde_json::from_str(&encoded) {
13850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13851 Err(error) => {
13852 dlg.response_json_decode_error(&encoded, &error);
13853 return Err(common::Error::JsonDecodeError(
13854 encoded.to_string(),
13855 error,
13856 ));
13857 }
13858 }
13859 } else {
13860 (
13861 common::Response::from_parts(parts, body),
13862 Default::default(),
13863 )
13864 };
13865
13866 dlg.finished(true);
13867 return Ok(response);
13868 }
13869 }
13870 }
13871 }
13872
13873 /// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
13874 ///
13875 /// Sets the *start date* query property to the given value.
13876 ///
13877 /// Even though the property as already been set when instantiating this call,
13878 /// we provide this method for API completeness.
13879 pub fn start_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13880 self._start_date = new_value.to_string();
13881 self
13882 }
13883 /// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
13884 ///
13885 /// Sets the *end date* query property to the given value.
13886 ///
13887 /// Even though the property as already been set when instantiating this call,
13888 /// we provide this method for API completeness.
13889 pub fn end_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13890 self._end_date = new_value.to_string();
13891 self
13892 }
13893 /// Whether the report should be generated in the AdSense account's local timezone. If false default PST/PDT timezone will be used.
13894 ///
13895 /// Sets the *use timezone reporting* query property to the given value.
13896 pub fn use_timezone_reporting(mut self, new_value: bool) -> ReportGenerateCall<'a, C> {
13897 self._use_timezone_reporting = Some(new_value);
13898 self
13899 }
13900 /// Index of the first row of report data to return.
13901 ///
13902 /// Sets the *start index* query property to the given value.
13903 pub fn start_index(mut self, new_value: i32) -> ReportGenerateCall<'a, C> {
13904 self._start_index = Some(new_value);
13905 self
13906 }
13907 /// 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.
13908 ///
13909 /// Append the given value to the *sort* query property.
13910 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13911 pub fn add_sort(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13912 self._sort.push(new_value.to_string());
13913 self
13914 }
13915 /// Numeric columns to include in the report.
13916 ///
13917 /// Append the given value to the *metric* query property.
13918 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13919 pub fn add_metric(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13920 self._metric.push(new_value.to_string());
13921 self
13922 }
13923 /// The maximum number of rows of report data to return.
13924 ///
13925 /// Sets the *max results* query property to the given value.
13926 pub fn max_results(mut self, new_value: i32) -> ReportGenerateCall<'a, C> {
13927 self._max_results = Some(new_value);
13928 self
13929 }
13930 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
13931 ///
13932 /// Sets the *locale* query property to the given value.
13933 pub fn locale(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13934 self._locale = Some(new_value.to_string());
13935 self
13936 }
13937 /// Filters to be run on the report.
13938 ///
13939 /// Append the given value to the *filter* query property.
13940 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13941 pub fn add_filter(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13942 self._filter.push(new_value.to_string());
13943 self
13944 }
13945 /// Dimensions to base the report on.
13946 ///
13947 /// Append the given value to the *dimension* query property.
13948 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13949 pub fn add_dimension(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13950 self._dimension.push(new_value.to_string());
13951 self
13952 }
13953 /// Optional currency to use when reporting on monetary metrics. Defaults to the account's currency if not set.
13954 ///
13955 /// Sets the *currency* query property to the given value.
13956 pub fn currency(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13957 self._currency = Some(new_value.to_string());
13958 self
13959 }
13960 /// Accounts upon which to report.
13961 ///
13962 /// Append the given value to the *account id* query property.
13963 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13964 pub fn add_account_id(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
13965 self._account_id.push(new_value.to_string());
13966 self
13967 }
13968 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13969 /// while executing the actual API request.
13970 ///
13971 /// ````text
13972 /// It should be used to handle progress information, and to implement a certain level of resilience.
13973 /// ````
13974 ///
13975 /// Sets the *delegate* property to the given value.
13976 pub fn delegate(
13977 mut self,
13978 new_value: &'a mut dyn common::Delegate,
13979 ) -> ReportGenerateCall<'a, C> {
13980 self._delegate = Some(new_value);
13981 self
13982 }
13983
13984 /// Set any additional parameter of the query string used in the request.
13985 /// It should be used to set parameters which are not yet available through their own
13986 /// setters.
13987 ///
13988 /// Please note that this method must not be used to set any of the known parameters
13989 /// which have their own setter method. If done anyway, the request will fail.
13990 ///
13991 /// # Additional Parameters
13992 ///
13993 /// * *alt* (query-string) - Data format for the response.
13994 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13995 /// * *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.
13996 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13997 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13998 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13999 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14000 pub fn param<T>(mut self, name: T, value: T) -> ReportGenerateCall<'a, C>
14001 where
14002 T: AsRef<str>,
14003 {
14004 self._additional_params
14005 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14006 self
14007 }
14008
14009 /// Identifies the authorization scope for the method you are building.
14010 ///
14011 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14012 /// [`Scope::Readonly`].
14013 ///
14014 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14015 /// tokens for more than one scope.
14016 ///
14017 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14018 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14019 /// sufficient, a read-write scope will do as well.
14020 pub fn add_scope<St>(mut self, scope: St) -> ReportGenerateCall<'a, C>
14021 where
14022 St: AsRef<str>,
14023 {
14024 self._scopes.insert(String::from(scope.as_ref()));
14025 self
14026 }
14027 /// Identifies the authorization scope(s) for the method you are building.
14028 ///
14029 /// See [`Self::add_scope()`] for details.
14030 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportGenerateCall<'a, C>
14031 where
14032 I: IntoIterator<Item = St>,
14033 St: AsRef<str>,
14034 {
14035 self._scopes
14036 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14037 self
14038 }
14039
14040 /// Removes all scopes, and no default scope will be used either.
14041 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14042 /// for details).
14043 pub fn clear_scopes(mut self) -> ReportGenerateCall<'a, C> {
14044 self._scopes.clear();
14045 self
14046 }
14047}
14048
14049/// Get a specific saved ad style from the user's account.
14050///
14051/// A builder for the *get* method supported by a *savedadstyle* resource.
14052/// It is not used directly, but through a [`SavedadstyleMethods`] instance.
14053///
14054/// # Example
14055///
14056/// Instantiate a resource method builder
14057///
14058/// ```test_harness,no_run
14059/// # extern crate hyper;
14060/// # extern crate hyper_rustls;
14061/// # extern crate google_adsense1d4 as adsense1d4;
14062/// # async fn dox() {
14063/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14064///
14065/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14066/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14067/// # .with_native_roots()
14068/// # .unwrap()
14069/// # .https_only()
14070/// # .enable_http2()
14071/// # .build();
14072///
14073/// # let executor = hyper_util::rt::TokioExecutor::new();
14074/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14075/// # secret,
14076/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14077/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14078/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14079/// # ),
14080/// # ).build().await.unwrap();
14081///
14082/// # let client = hyper_util::client::legacy::Client::builder(
14083/// # hyper_util::rt::TokioExecutor::new()
14084/// # )
14085/// # .build(
14086/// # hyper_rustls::HttpsConnectorBuilder::new()
14087/// # .with_native_roots()
14088/// # .unwrap()
14089/// # .https_or_http()
14090/// # .enable_http2()
14091/// # .build()
14092/// # );
14093/// # let mut hub = AdSense::new(client, auth);
14094/// // You can configure optional parameters by calling the respective setters at will, and
14095/// // execute the final call using `doit()`.
14096/// // Values shown here are possibly random and not representative !
14097/// let result = hub.savedadstyles().get("savedAdStyleId")
14098/// .doit().await;
14099/// # }
14100/// ```
14101pub struct SavedadstyleGetCall<'a, C>
14102where
14103 C: 'a,
14104{
14105 hub: &'a AdSense<C>,
14106 _saved_ad_style_id: String,
14107 _delegate: Option<&'a mut dyn common::Delegate>,
14108 _additional_params: HashMap<String, String>,
14109 _scopes: BTreeSet<String>,
14110}
14111
14112impl<'a, C> common::CallBuilder for SavedadstyleGetCall<'a, C> {}
14113
14114impl<'a, C> SavedadstyleGetCall<'a, C>
14115where
14116 C: common::Connector,
14117{
14118 /// Perform the operation you have build so far.
14119 pub async fn doit(mut self) -> common::Result<(common::Response, SavedAdStyle)> {
14120 use std::borrow::Cow;
14121 use std::io::{Read, Seek};
14122
14123 use common::{url::Params, ToParts};
14124 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14125
14126 let mut dd = common::DefaultDelegate;
14127 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14128 dlg.begin(common::MethodInfo {
14129 id: "adsense.savedadstyles.get",
14130 http_method: hyper::Method::GET,
14131 });
14132
14133 for &field in ["alt", "savedAdStyleId"].iter() {
14134 if self._additional_params.contains_key(field) {
14135 dlg.finished(false);
14136 return Err(common::Error::FieldClash(field));
14137 }
14138 }
14139
14140 let mut params = Params::with_capacity(3 + self._additional_params.len());
14141 params.push("savedAdStyleId", self._saved_ad_style_id);
14142
14143 params.extend(self._additional_params.iter());
14144
14145 params.push("alt", "json");
14146 let mut url = self.hub._base_url.clone() + "savedadstyles/{savedAdStyleId}";
14147 if self._scopes.is_empty() {
14148 self._scopes.insert(Scope::Readonly.as_ref().to_string());
14149 }
14150
14151 #[allow(clippy::single_element_loop)]
14152 for &(find_this, param_name) in [("{savedAdStyleId}", "savedAdStyleId")].iter() {
14153 url = params.uri_replacement(url, param_name, find_this, false);
14154 }
14155 {
14156 let to_remove = ["savedAdStyleId"];
14157 params.remove_params(&to_remove);
14158 }
14159
14160 let url = params.parse_with_url(&url);
14161
14162 loop {
14163 let token = match self
14164 .hub
14165 .auth
14166 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14167 .await
14168 {
14169 Ok(token) => token,
14170 Err(e) => match dlg.token(e) {
14171 Ok(token) => token,
14172 Err(e) => {
14173 dlg.finished(false);
14174 return Err(common::Error::MissingToken(e));
14175 }
14176 },
14177 };
14178 let mut req_result = {
14179 let client = &self.hub.client;
14180 dlg.pre_request();
14181 let mut req_builder = hyper::Request::builder()
14182 .method(hyper::Method::GET)
14183 .uri(url.as_str())
14184 .header(USER_AGENT, self.hub._user_agent.clone());
14185
14186 if let Some(token) = token.as_ref() {
14187 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14188 }
14189
14190 let request = req_builder
14191 .header(CONTENT_LENGTH, 0_u64)
14192 .body(common::to_body::<String>(None));
14193
14194 client.request(request.unwrap()).await
14195 };
14196
14197 match req_result {
14198 Err(err) => {
14199 if let common::Retry::After(d) = dlg.http_error(&err) {
14200 sleep(d).await;
14201 continue;
14202 }
14203 dlg.finished(false);
14204 return Err(common::Error::HttpError(err));
14205 }
14206 Ok(res) => {
14207 let (mut parts, body) = res.into_parts();
14208 let mut body = common::Body::new(body);
14209 if !parts.status.is_success() {
14210 let bytes = common::to_bytes(body).await.unwrap_or_default();
14211 let error = serde_json::from_str(&common::to_string(&bytes));
14212 let response = common::to_response(parts, bytes.into());
14213
14214 if let common::Retry::After(d) =
14215 dlg.http_failure(&response, error.as_ref().ok())
14216 {
14217 sleep(d).await;
14218 continue;
14219 }
14220
14221 dlg.finished(false);
14222
14223 return Err(match error {
14224 Ok(value) => common::Error::BadRequest(value),
14225 _ => common::Error::Failure(response),
14226 });
14227 }
14228 let response = {
14229 let bytes = common::to_bytes(body).await.unwrap_or_default();
14230 let encoded = common::to_string(&bytes);
14231 match serde_json::from_str(&encoded) {
14232 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14233 Err(error) => {
14234 dlg.response_json_decode_error(&encoded, &error);
14235 return Err(common::Error::JsonDecodeError(
14236 encoded.to_string(),
14237 error,
14238 ));
14239 }
14240 }
14241 };
14242
14243 dlg.finished(true);
14244 return Ok(response);
14245 }
14246 }
14247 }
14248 }
14249
14250 /// Saved ad style to retrieve.
14251 ///
14252 /// Sets the *saved ad style id* path property to the given value.
14253 ///
14254 /// Even though the property as already been set when instantiating this call,
14255 /// we provide this method for API completeness.
14256 pub fn saved_ad_style_id(mut self, new_value: &str) -> SavedadstyleGetCall<'a, C> {
14257 self._saved_ad_style_id = new_value.to_string();
14258 self
14259 }
14260 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14261 /// while executing the actual API request.
14262 ///
14263 /// ````text
14264 /// It should be used to handle progress information, and to implement a certain level of resilience.
14265 /// ````
14266 ///
14267 /// Sets the *delegate* property to the given value.
14268 pub fn delegate(
14269 mut self,
14270 new_value: &'a mut dyn common::Delegate,
14271 ) -> SavedadstyleGetCall<'a, C> {
14272 self._delegate = Some(new_value);
14273 self
14274 }
14275
14276 /// Set any additional parameter of the query string used in the request.
14277 /// It should be used to set parameters which are not yet available through their own
14278 /// setters.
14279 ///
14280 /// Please note that this method must not be used to set any of the known parameters
14281 /// which have their own setter method. If done anyway, the request will fail.
14282 ///
14283 /// # Additional Parameters
14284 ///
14285 /// * *alt* (query-string) - Data format for the response.
14286 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14287 /// * *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.
14288 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14289 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14290 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14291 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14292 pub fn param<T>(mut self, name: T, value: T) -> SavedadstyleGetCall<'a, C>
14293 where
14294 T: AsRef<str>,
14295 {
14296 self._additional_params
14297 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14298 self
14299 }
14300
14301 /// Identifies the authorization scope for the method you are building.
14302 ///
14303 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14304 /// [`Scope::Readonly`].
14305 ///
14306 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14307 /// tokens for more than one scope.
14308 ///
14309 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14310 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14311 /// sufficient, a read-write scope will do as well.
14312 pub fn add_scope<St>(mut self, scope: St) -> SavedadstyleGetCall<'a, C>
14313 where
14314 St: AsRef<str>,
14315 {
14316 self._scopes.insert(String::from(scope.as_ref()));
14317 self
14318 }
14319 /// Identifies the authorization scope(s) for the method you are building.
14320 ///
14321 /// See [`Self::add_scope()`] for details.
14322 pub fn add_scopes<I, St>(mut self, scopes: I) -> SavedadstyleGetCall<'a, C>
14323 where
14324 I: IntoIterator<Item = St>,
14325 St: AsRef<str>,
14326 {
14327 self._scopes
14328 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14329 self
14330 }
14331
14332 /// Removes all scopes, and no default scope will be used either.
14333 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14334 /// for details).
14335 pub fn clear_scopes(mut self) -> SavedadstyleGetCall<'a, C> {
14336 self._scopes.clear();
14337 self
14338 }
14339}
14340
14341/// List all saved ad styles in the user's account.
14342///
14343/// A builder for the *list* method supported by a *savedadstyle* resource.
14344/// It is not used directly, but through a [`SavedadstyleMethods`] instance.
14345///
14346/// # Example
14347///
14348/// Instantiate a resource method builder
14349///
14350/// ```test_harness,no_run
14351/// # extern crate hyper;
14352/// # extern crate hyper_rustls;
14353/// # extern crate google_adsense1d4 as adsense1d4;
14354/// # async fn dox() {
14355/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14356///
14357/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14358/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14359/// # .with_native_roots()
14360/// # .unwrap()
14361/// # .https_only()
14362/// # .enable_http2()
14363/// # .build();
14364///
14365/// # let executor = hyper_util::rt::TokioExecutor::new();
14366/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14367/// # secret,
14368/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14369/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14370/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14371/// # ),
14372/// # ).build().await.unwrap();
14373///
14374/// # let client = hyper_util::client::legacy::Client::builder(
14375/// # hyper_util::rt::TokioExecutor::new()
14376/// # )
14377/// # .build(
14378/// # hyper_rustls::HttpsConnectorBuilder::new()
14379/// # .with_native_roots()
14380/// # .unwrap()
14381/// # .https_or_http()
14382/// # .enable_http2()
14383/// # .build()
14384/// # );
14385/// # let mut hub = AdSense::new(client, auth);
14386/// // You can configure optional parameters by calling the respective setters at will, and
14387/// // execute the final call using `doit()`.
14388/// // Values shown here are possibly random and not representative !
14389/// let result = hub.savedadstyles().list()
14390/// .page_token("erat")
14391/// .max_results(-73)
14392/// .doit().await;
14393/// # }
14394/// ```
14395pub struct SavedadstyleListCall<'a, C>
14396where
14397 C: 'a,
14398{
14399 hub: &'a AdSense<C>,
14400 _page_token: Option<String>,
14401 _max_results: Option<i32>,
14402 _delegate: Option<&'a mut dyn common::Delegate>,
14403 _additional_params: HashMap<String, String>,
14404 _scopes: BTreeSet<String>,
14405}
14406
14407impl<'a, C> common::CallBuilder for SavedadstyleListCall<'a, C> {}
14408
14409impl<'a, C> SavedadstyleListCall<'a, C>
14410where
14411 C: common::Connector,
14412{
14413 /// Perform the operation you have build so far.
14414 pub async fn doit(mut self) -> common::Result<(common::Response, SavedAdStyles)> {
14415 use std::borrow::Cow;
14416 use std::io::{Read, Seek};
14417
14418 use common::{url::Params, ToParts};
14419 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14420
14421 let mut dd = common::DefaultDelegate;
14422 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14423 dlg.begin(common::MethodInfo {
14424 id: "adsense.savedadstyles.list",
14425 http_method: hyper::Method::GET,
14426 });
14427
14428 for &field in ["alt", "pageToken", "maxResults"].iter() {
14429 if self._additional_params.contains_key(field) {
14430 dlg.finished(false);
14431 return Err(common::Error::FieldClash(field));
14432 }
14433 }
14434
14435 let mut params = Params::with_capacity(4 + self._additional_params.len());
14436 if let Some(value) = self._page_token.as_ref() {
14437 params.push("pageToken", value);
14438 }
14439 if let Some(value) = self._max_results.as_ref() {
14440 params.push("maxResults", value.to_string());
14441 }
14442
14443 params.extend(self._additional_params.iter());
14444
14445 params.push("alt", "json");
14446 let mut url = self.hub._base_url.clone() + "savedadstyles";
14447 if self._scopes.is_empty() {
14448 self._scopes.insert(Scope::Readonly.as_ref().to_string());
14449 }
14450
14451 let url = params.parse_with_url(&url);
14452
14453 loop {
14454 let token = match self
14455 .hub
14456 .auth
14457 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14458 .await
14459 {
14460 Ok(token) => token,
14461 Err(e) => match dlg.token(e) {
14462 Ok(token) => token,
14463 Err(e) => {
14464 dlg.finished(false);
14465 return Err(common::Error::MissingToken(e));
14466 }
14467 },
14468 };
14469 let mut req_result = {
14470 let client = &self.hub.client;
14471 dlg.pre_request();
14472 let mut req_builder = hyper::Request::builder()
14473 .method(hyper::Method::GET)
14474 .uri(url.as_str())
14475 .header(USER_AGENT, self.hub._user_agent.clone());
14476
14477 if let Some(token) = token.as_ref() {
14478 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14479 }
14480
14481 let request = req_builder
14482 .header(CONTENT_LENGTH, 0_u64)
14483 .body(common::to_body::<String>(None));
14484
14485 client.request(request.unwrap()).await
14486 };
14487
14488 match req_result {
14489 Err(err) => {
14490 if let common::Retry::After(d) = dlg.http_error(&err) {
14491 sleep(d).await;
14492 continue;
14493 }
14494 dlg.finished(false);
14495 return Err(common::Error::HttpError(err));
14496 }
14497 Ok(res) => {
14498 let (mut parts, body) = res.into_parts();
14499 let mut body = common::Body::new(body);
14500 if !parts.status.is_success() {
14501 let bytes = common::to_bytes(body).await.unwrap_or_default();
14502 let error = serde_json::from_str(&common::to_string(&bytes));
14503 let response = common::to_response(parts, bytes.into());
14504
14505 if let common::Retry::After(d) =
14506 dlg.http_failure(&response, error.as_ref().ok())
14507 {
14508 sleep(d).await;
14509 continue;
14510 }
14511
14512 dlg.finished(false);
14513
14514 return Err(match error {
14515 Ok(value) => common::Error::BadRequest(value),
14516 _ => common::Error::Failure(response),
14517 });
14518 }
14519 let response = {
14520 let bytes = common::to_bytes(body).await.unwrap_or_default();
14521 let encoded = common::to_string(&bytes);
14522 match serde_json::from_str(&encoded) {
14523 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14524 Err(error) => {
14525 dlg.response_json_decode_error(&encoded, &error);
14526 return Err(common::Error::JsonDecodeError(
14527 encoded.to_string(),
14528 error,
14529 ));
14530 }
14531 }
14532 };
14533
14534 dlg.finished(true);
14535 return Ok(response);
14536 }
14537 }
14538 }
14539 }
14540
14541 /// A continuation token, used to page through saved ad styles. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
14542 ///
14543 /// Sets the *page token* query property to the given value.
14544 pub fn page_token(mut self, new_value: &str) -> SavedadstyleListCall<'a, C> {
14545 self._page_token = Some(new_value.to_string());
14546 self
14547 }
14548 /// The maximum number of saved ad styles to include in the response, used for paging.
14549 ///
14550 /// Sets the *max results* query property to the given value.
14551 pub fn max_results(mut self, new_value: i32) -> SavedadstyleListCall<'a, C> {
14552 self._max_results = Some(new_value);
14553 self
14554 }
14555 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14556 /// while executing the actual API request.
14557 ///
14558 /// ````text
14559 /// It should be used to handle progress information, and to implement a certain level of resilience.
14560 /// ````
14561 ///
14562 /// Sets the *delegate* property to the given value.
14563 pub fn delegate(
14564 mut self,
14565 new_value: &'a mut dyn common::Delegate,
14566 ) -> SavedadstyleListCall<'a, C> {
14567 self._delegate = Some(new_value);
14568 self
14569 }
14570
14571 /// Set any additional parameter of the query string used in the request.
14572 /// It should be used to set parameters which are not yet available through their own
14573 /// setters.
14574 ///
14575 /// Please note that this method must not be used to set any of the known parameters
14576 /// which have their own setter method. If done anyway, the request will fail.
14577 ///
14578 /// # Additional Parameters
14579 ///
14580 /// * *alt* (query-string) - Data format for the response.
14581 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14582 /// * *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.
14583 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14584 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14585 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14586 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14587 pub fn param<T>(mut self, name: T, value: T) -> SavedadstyleListCall<'a, C>
14588 where
14589 T: AsRef<str>,
14590 {
14591 self._additional_params
14592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14593 self
14594 }
14595
14596 /// Identifies the authorization scope for the method you are building.
14597 ///
14598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14599 /// [`Scope::Readonly`].
14600 ///
14601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14602 /// tokens for more than one scope.
14603 ///
14604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14606 /// sufficient, a read-write scope will do as well.
14607 pub fn add_scope<St>(mut self, scope: St) -> SavedadstyleListCall<'a, C>
14608 where
14609 St: AsRef<str>,
14610 {
14611 self._scopes.insert(String::from(scope.as_ref()));
14612 self
14613 }
14614 /// Identifies the authorization scope(s) for the method you are building.
14615 ///
14616 /// See [`Self::add_scope()`] for details.
14617 pub fn add_scopes<I, St>(mut self, scopes: I) -> SavedadstyleListCall<'a, C>
14618 where
14619 I: IntoIterator<Item = St>,
14620 St: AsRef<str>,
14621 {
14622 self._scopes
14623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14624 self
14625 }
14626
14627 /// Removes all scopes, and no default scope will be used either.
14628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14629 /// for details).
14630 pub fn clear_scopes(mut self) -> SavedadstyleListCall<'a, C> {
14631 self._scopes.clear();
14632 self
14633 }
14634}
14635
14636/// List all URL channels in the specified ad client for this AdSense account.
14637///
14638/// A builder for the *list* method supported by a *urlchannel* resource.
14639/// It is not used directly, but through a [`UrlchannelMethods`] instance.
14640///
14641/// # Example
14642///
14643/// Instantiate a resource method builder
14644///
14645/// ```test_harness,no_run
14646/// # extern crate hyper;
14647/// # extern crate hyper_rustls;
14648/// # extern crate google_adsense1d4 as adsense1d4;
14649/// # async fn dox() {
14650/// # use adsense1d4::{AdSense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14651///
14652/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14653/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14654/// # .with_native_roots()
14655/// # .unwrap()
14656/// # .https_only()
14657/// # .enable_http2()
14658/// # .build();
14659///
14660/// # let executor = hyper_util::rt::TokioExecutor::new();
14661/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14662/// # secret,
14663/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14664/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14665/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14666/// # ),
14667/// # ).build().await.unwrap();
14668///
14669/// # let client = hyper_util::client::legacy::Client::builder(
14670/// # hyper_util::rt::TokioExecutor::new()
14671/// # )
14672/// # .build(
14673/// # hyper_rustls::HttpsConnectorBuilder::new()
14674/// # .with_native_roots()
14675/// # .unwrap()
14676/// # .https_or_http()
14677/// # .enable_http2()
14678/// # .build()
14679/// # );
14680/// # let mut hub = AdSense::new(client, auth);
14681/// // You can configure optional parameters by calling the respective setters at will, and
14682/// // execute the final call using `doit()`.
14683/// // Values shown here are possibly random and not representative !
14684/// let result = hub.urlchannels().list("adClientId")
14685/// .page_token("takimata")
14686/// .max_results(-51)
14687/// .doit().await;
14688/// # }
14689/// ```
14690pub struct UrlchannelListCall<'a, C>
14691where
14692 C: 'a,
14693{
14694 hub: &'a AdSense<C>,
14695 _ad_client_id: String,
14696 _page_token: Option<String>,
14697 _max_results: Option<i32>,
14698 _delegate: Option<&'a mut dyn common::Delegate>,
14699 _additional_params: HashMap<String, String>,
14700 _scopes: BTreeSet<String>,
14701}
14702
14703impl<'a, C> common::CallBuilder for UrlchannelListCall<'a, C> {}
14704
14705impl<'a, C> UrlchannelListCall<'a, C>
14706where
14707 C: common::Connector,
14708{
14709 /// Perform the operation you have build so far.
14710 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannels)> {
14711 use std::borrow::Cow;
14712 use std::io::{Read, Seek};
14713
14714 use common::{url::Params, ToParts};
14715 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14716
14717 let mut dd = common::DefaultDelegate;
14718 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14719 dlg.begin(common::MethodInfo {
14720 id: "adsense.urlchannels.list",
14721 http_method: hyper::Method::GET,
14722 });
14723
14724 for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
14725 if self._additional_params.contains_key(field) {
14726 dlg.finished(false);
14727 return Err(common::Error::FieldClash(field));
14728 }
14729 }
14730
14731 let mut params = Params::with_capacity(5 + self._additional_params.len());
14732 params.push("adClientId", self._ad_client_id);
14733 if let Some(value) = self._page_token.as_ref() {
14734 params.push("pageToken", value);
14735 }
14736 if let Some(value) = self._max_results.as_ref() {
14737 params.push("maxResults", value.to_string());
14738 }
14739
14740 params.extend(self._additional_params.iter());
14741
14742 params.push("alt", "json");
14743 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/urlchannels";
14744 if self._scopes.is_empty() {
14745 self._scopes.insert(Scope::Readonly.as_ref().to_string());
14746 }
14747
14748 #[allow(clippy::single_element_loop)]
14749 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
14750 url = params.uri_replacement(url, param_name, find_this, false);
14751 }
14752 {
14753 let to_remove = ["adClientId"];
14754 params.remove_params(&to_remove);
14755 }
14756
14757 let url = params.parse_with_url(&url);
14758
14759 loop {
14760 let token = match self
14761 .hub
14762 .auth
14763 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14764 .await
14765 {
14766 Ok(token) => token,
14767 Err(e) => match dlg.token(e) {
14768 Ok(token) => token,
14769 Err(e) => {
14770 dlg.finished(false);
14771 return Err(common::Error::MissingToken(e));
14772 }
14773 },
14774 };
14775 let mut req_result = {
14776 let client = &self.hub.client;
14777 dlg.pre_request();
14778 let mut req_builder = hyper::Request::builder()
14779 .method(hyper::Method::GET)
14780 .uri(url.as_str())
14781 .header(USER_AGENT, self.hub._user_agent.clone());
14782
14783 if let Some(token) = token.as_ref() {
14784 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14785 }
14786
14787 let request = req_builder
14788 .header(CONTENT_LENGTH, 0_u64)
14789 .body(common::to_body::<String>(None));
14790
14791 client.request(request.unwrap()).await
14792 };
14793
14794 match req_result {
14795 Err(err) => {
14796 if let common::Retry::After(d) = dlg.http_error(&err) {
14797 sleep(d).await;
14798 continue;
14799 }
14800 dlg.finished(false);
14801 return Err(common::Error::HttpError(err));
14802 }
14803 Ok(res) => {
14804 let (mut parts, body) = res.into_parts();
14805 let mut body = common::Body::new(body);
14806 if !parts.status.is_success() {
14807 let bytes = common::to_bytes(body).await.unwrap_or_default();
14808 let error = serde_json::from_str(&common::to_string(&bytes));
14809 let response = common::to_response(parts, bytes.into());
14810
14811 if let common::Retry::After(d) =
14812 dlg.http_failure(&response, error.as_ref().ok())
14813 {
14814 sleep(d).await;
14815 continue;
14816 }
14817
14818 dlg.finished(false);
14819
14820 return Err(match error {
14821 Ok(value) => common::Error::BadRequest(value),
14822 _ => common::Error::Failure(response),
14823 });
14824 }
14825 let response = {
14826 let bytes = common::to_bytes(body).await.unwrap_or_default();
14827 let encoded = common::to_string(&bytes);
14828 match serde_json::from_str(&encoded) {
14829 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14830 Err(error) => {
14831 dlg.response_json_decode_error(&encoded, &error);
14832 return Err(common::Error::JsonDecodeError(
14833 encoded.to_string(),
14834 error,
14835 ));
14836 }
14837 }
14838 };
14839
14840 dlg.finished(true);
14841 return Ok(response);
14842 }
14843 }
14844 }
14845 }
14846
14847 /// Ad client for which to list URL channels.
14848 ///
14849 /// Sets the *ad client id* path property to the given value.
14850 ///
14851 /// Even though the property as already been set when instantiating this call,
14852 /// we provide this method for API completeness.
14853 pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelListCall<'a, C> {
14854 self._ad_client_id = new_value.to_string();
14855 self
14856 }
14857 /// 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.
14858 ///
14859 /// Sets the *page token* query property to the given value.
14860 pub fn page_token(mut self, new_value: &str) -> UrlchannelListCall<'a, C> {
14861 self._page_token = Some(new_value.to_string());
14862 self
14863 }
14864 /// The maximum number of URL channels to include in the response, used for paging.
14865 ///
14866 /// Sets the *max results* query property to the given value.
14867 pub fn max_results(mut self, new_value: i32) -> UrlchannelListCall<'a, C> {
14868 self._max_results = Some(new_value);
14869 self
14870 }
14871 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14872 /// while executing the actual API request.
14873 ///
14874 /// ````text
14875 /// It should be used to handle progress information, and to implement a certain level of resilience.
14876 /// ````
14877 ///
14878 /// Sets the *delegate* property to the given value.
14879 pub fn delegate(
14880 mut self,
14881 new_value: &'a mut dyn common::Delegate,
14882 ) -> UrlchannelListCall<'a, C> {
14883 self._delegate = Some(new_value);
14884 self
14885 }
14886
14887 /// Set any additional parameter of the query string used in the request.
14888 /// It should be used to set parameters which are not yet available through their own
14889 /// setters.
14890 ///
14891 /// Please note that this method must not be used to set any of the known parameters
14892 /// which have their own setter method. If done anyway, the request will fail.
14893 ///
14894 /// # Additional Parameters
14895 ///
14896 /// * *alt* (query-string) - Data format for the response.
14897 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14898 /// * *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.
14899 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14900 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14901 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14902 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14903 pub fn param<T>(mut self, name: T, value: T) -> UrlchannelListCall<'a, C>
14904 where
14905 T: AsRef<str>,
14906 {
14907 self._additional_params
14908 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14909 self
14910 }
14911
14912 /// Identifies the authorization scope for the method you are building.
14913 ///
14914 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14915 /// [`Scope::Readonly`].
14916 ///
14917 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14918 /// tokens for more than one scope.
14919 ///
14920 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14921 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14922 /// sufficient, a read-write scope will do as well.
14923 pub fn add_scope<St>(mut self, scope: St) -> UrlchannelListCall<'a, C>
14924 where
14925 St: AsRef<str>,
14926 {
14927 self._scopes.insert(String::from(scope.as_ref()));
14928 self
14929 }
14930 /// Identifies the authorization scope(s) for the method you are building.
14931 ///
14932 /// See [`Self::add_scope()`] for details.
14933 pub fn add_scopes<I, St>(mut self, scopes: I) -> UrlchannelListCall<'a, C>
14934 where
14935 I: IntoIterator<Item = St>,
14936 St: AsRef<str>,
14937 {
14938 self._scopes
14939 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14940 self
14941 }
14942
14943 /// Removes all scopes, and no default scope will be used either.
14944 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14945 /// for details).
14946 pub fn clear_scopes(mut self) -> UrlchannelListCall<'a, C> {
14947 self._scopes.clear();
14948 self
14949 }
14950}