google_adsensehost4d1/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 host data and associated accounts
17 Full,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::Full => "https://www.googleapis.com/auth/adsensehost",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::Full
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all AdSenseHost related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_adsensehost4d1 as adsensehost4d1;
49/// use adsensehost4d1::{Result, Error};
50/// # async fn dox() {
51/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62/// .with_native_roots()
63/// .unwrap()
64/// .https_only()
65/// .enable_http2()
66/// .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70/// secret,
71/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72/// yup_oauth2::client::CustomHyperClientBuilder::from(
73/// hyper_util::client::legacy::Client::builder(executor).build(connector),
74/// ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78/// hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81/// hyper_rustls::HttpsConnectorBuilder::new()
82/// .with_native_roots()
83/// .unwrap()
84/// .https_or_http()
85/// .enable_http2()
86/// .build()
87/// );
88/// let mut hub = AdSenseHost::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
93/// .start_index(51)
94/// .add_sort("sed")
95/// .add_metric("ut")
96/// .max_results(89)
97/// .locale("rebum.")
98/// .add_filter("est")
99/// .add_dimension("ipsum")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct AdSenseHost<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for AdSenseHost<C> {}
131
132impl<'a, C> AdSenseHost<C> {
133 pub fn new<A: 'static + common::GetToken>(
134 client: common::Client<C>,
135 auth: A,
136 ) -> AdSenseHost<C> {
137 AdSenseHost {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://www.googleapis.com/adsensehost/v4.1/".to_string(),
142 _root_url: "https://www.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn accounts(&'a self) -> AccountMethods<'a, C> {
147 AccountMethods { hub: self }
148 }
149 pub fn adclients(&'a self) -> AdclientMethods<'a, C> {
150 AdclientMethods { hub: self }
151 }
152 pub fn associationsessions(&'a self) -> AssociationsessionMethods<'a, C> {
153 AssociationsessionMethods { hub: self }
154 }
155 pub fn customchannels(&'a self) -> CustomchannelMethods<'a, C> {
156 CustomchannelMethods { hub: self }
157 }
158 pub fn reports(&'a self) -> ReportMethods<'a, C> {
159 ReportMethods { hub: self }
160 }
161 pub fn urlchannels(&'a self) -> UrlchannelMethods<'a, C> {
162 UrlchannelMethods { hub: self }
163 }
164
165 /// Set the user-agent header field to use in all requests to the server.
166 /// It defaults to `google-api-rust-client/7.0.0`.
167 ///
168 /// Returns the previously set user-agent.
169 pub fn user_agent(&mut self, agent_name: String) -> String {
170 std::mem::replace(&mut self._user_agent, agent_name)
171 }
172
173 /// Set the base url to use in all requests to the server.
174 /// It defaults to `https://www.googleapis.com/adsensehost/v4.1/`.
175 ///
176 /// Returns the previously set base url.
177 pub fn base_url(&mut self, new_base_url: String) -> String {
178 std::mem::replace(&mut self._base_url, new_base_url)
179 }
180
181 /// Set the root url to use in all requests to the server.
182 /// It defaults to `https://www.googleapis.com/`.
183 ///
184 /// Returns the previously set root url.
185 pub fn root_url(&mut self, new_root_url: String) -> String {
186 std::mem::replace(&mut self._root_url, new_root_url)
187 }
188}
189
190// ############
191// SCHEMAS ###
192// ##########
193/// There is no detailed description.
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [adclients get accounts](AccountAdclientGetCall) (none)
201/// * [adclients list accounts](AccountAdclientListCall) (none)
202/// * [adunits delete accounts](AccountAdunitDeleteCall) (none)
203/// * [adunits get accounts](AccountAdunitGetCall) (none)
204/// * [adunits get ad code accounts](AccountAdunitGetAdCodeCall) (none)
205/// * [adunits insert accounts](AccountAdunitInsertCall) (none)
206/// * [adunits list accounts](AccountAdunitListCall) (none)
207/// * [adunits patch accounts](AccountAdunitPatchCall) (none)
208/// * [adunits update accounts](AccountAdunitUpdateCall) (none)
209/// * [reports generate accounts](AccountReportGenerateCall) (none)
210/// * [get accounts](AccountGetCall) (response)
211/// * [list accounts](AccountListCall) (none)
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct Account {
216 /// Unique identifier of this account.
217 pub id: Option<String>,
218 /// Kind of resource this is, in this case adsensehost#account.
219 pub kind: Option<String>,
220 /// Name of this account.
221 pub name: Option<String>,
222 /// Approval status of this account. One of: PENDING, APPROVED, DISABLED.
223 pub status: Option<String>,
224}
225
226impl common::Resource for Account {}
227impl common::ResponseResult for Account {}
228
229/// There is no detailed description.
230///
231/// # Activities
232///
233/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
235///
236/// * [list accounts](AccountListCall) (response)
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct Accounts {
241 /// ETag of this response for caching purposes.
242 pub etag: Option<String>,
243 /// The accounts returned in this list response.
244 pub items: Option<Vec<Account>>,
245 /// Kind of list this is, in this case adsensehost#accounts.
246 pub kind: Option<String>,
247}
248
249impl common::ResponseResult for Accounts {}
250
251/// There is no detailed description.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [adclients get accounts](AccountAdclientGetCall) (response)
259/// * [get adclients](AdclientGetCall) (response)
260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
261#[serde_with::serde_as]
262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
263pub struct AdClient {
264 /// Whether this ad client is opted in to ARC.
265 #[serde(rename = "arcOptIn")]
266 pub arc_opt_in: Option<bool>,
267 /// Unique identifier of this ad client.
268 pub id: Option<String>,
269 /// Kind of resource this is, in this case adsensehost#adClient.
270 pub kind: Option<String>,
271 /// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension.
272 #[serde(rename = "productCode")]
273 pub product_code: Option<String>,
274 /// Whether this ad client supports being reported on.
275 #[serde(rename = "supportsReporting")]
276 pub supports_reporting: Option<bool>,
277}
278
279impl common::Resource for AdClient {}
280impl common::ResponseResult for AdClient {}
281
282/// There is no detailed description.
283///
284/// # Activities
285///
286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
288///
289/// * [adclients list accounts](AccountAdclientListCall) (response)
290/// * [list adclients](AdclientListCall) (response)
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct AdClients {
295 /// ETag of this response for caching purposes.
296 pub etag: Option<String>,
297 /// The ad clients returned in this list response.
298 pub items: Option<Vec<AdClient>>,
299 /// Kind of list this is, in this case adsensehost#adClients.
300 pub kind: Option<String>,
301 /// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this.
302 #[serde(rename = "nextPageToken")]
303 pub next_page_token: Option<String>,
304}
305
306impl common::ResponseResult for AdClients {}
307
308/// There is no detailed description.
309///
310/// # Activities
311///
312/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
313/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
314///
315/// * [adunits get ad code accounts](AccountAdunitGetAdCodeCall) (response)
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct AdCode {
320 /// The ad code snippet.
321 #[serde(rename = "adCode")]
322 pub ad_code: Option<String>,
323 /// Kind this is, in this case adsensehost#adCode.
324 pub kind: Option<String>,
325}
326
327impl common::ResponseResult for AdCode {}
328
329/// There is no detailed description.
330///
331/// This type is not used in any activity, and only used as *part* of another schema.
332///
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct AdStyle {
337 /// The colors included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
338 pub colors: Option<AdStyleColors>,
339 /// The style of the corners in the ad (deprecated: never populated, ignored).
340 pub corners: Option<String>,
341 /// The font which is included in the style.
342 pub font: Option<AdStyleFont>,
343 /// Kind this is, in this case adsensehost#adStyle.
344 pub kind: Option<String>,
345}
346
347impl common::Part for AdStyle {}
348
349/// There is no detailed description.
350///
351/// # Activities
352///
353/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
354/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
355///
356/// * [adunits delete accounts](AccountAdunitDeleteCall) (response)
357/// * [adunits get accounts](AccountAdunitGetCall) (response)
358/// * [adunits insert accounts](AccountAdunitInsertCall) (request|response)
359/// * [adunits patch accounts](AccountAdunitPatchCall) (request|response)
360/// * [adunits update accounts](AccountAdunitUpdateCall) (request|response)
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct AdUnit {
365 /// Identity code of this ad unit, not necessarily unique across ad clients.
366 pub code: Option<String>,
367 /// Settings specific to content ads (AFC) and highend mobile content ads (AFMC - deprecated).
368 #[serde(rename = "contentAdsSettings")]
369 pub content_ads_settings: Option<AdUnitContentAdsSettings>,
370 /// Custom style information specific to this ad unit.
371 #[serde(rename = "customStyle")]
372 pub custom_style: Option<AdStyle>,
373 /// 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.
374 pub id: Option<String>,
375 /// Kind of resource this is, in this case adsensehost#adUnit.
376 pub kind: Option<String>,
377 /// Settings specific to WAP mobile content ads (AFMC - deprecated).
378 #[serde(rename = "mobileContentAdsSettings")]
379 pub mobile_content_ads_settings: Option<AdUnitMobileContentAdsSettings>,
380 /// Name of this ad unit.
381 pub name: Option<String>,
382 /// Status of this ad unit. Possible values are:
383 /// NEW: Indicates that the ad unit was created within the last seven days and does not yet have any activity associated with it.
384 ///
385 /// ACTIVE: Indicates that there has been activity on this ad unit in the last seven days.
386 ///
387 /// INACTIVE: Indicates that there has been no activity on this ad unit in the last seven days.
388 pub status: Option<String>,
389}
390
391impl common::RequestValue for AdUnit {}
392impl common::ResponseResult for AdUnit {}
393
394/// There is no detailed description.
395///
396/// # Activities
397///
398/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
399/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
400///
401/// * [adunits list accounts](AccountAdunitListCall) (response)
402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
403#[serde_with::serde_as]
404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
405pub struct AdUnits {
406 /// ETag of this response for caching purposes.
407 pub etag: Option<String>,
408 /// The ad units returned in this list response.
409 pub items: Option<Vec<AdUnit>>,
410 /// Kind of list this is, in this case adsensehost#adUnits.
411 pub kind: Option<String>,
412 /// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this.
413 #[serde(rename = "nextPageToken")]
414 pub next_page_token: Option<String>,
415}
416
417impl common::ResponseResult for AdUnits {}
418
419/// There is no detailed description.
420///
421/// # Activities
422///
423/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
424/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
425///
426/// * [start associationsessions](AssociationsessionStartCall) (response)
427/// * [verify associationsessions](AssociationsessionVerifyCall) (response)
428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
429#[serde_with::serde_as]
430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
431pub struct AssociationSession {
432 /// Hosted account id of the associated publisher after association. Present if status is ACCEPTED.
433 #[serde(rename = "accountId")]
434 pub account_id: Option<String>,
435 /// Unique identifier of this association session.
436 pub id: Option<String>,
437 /// Kind of resource this is, in this case adsensehost#associationSession.
438 pub kind: Option<String>,
439 /// The products to associate with the user. Options: AFC, AFG, AFV, AFS (deprecated), AFMC (deprecated)
440 #[serde(rename = "productCodes")]
441 pub product_codes: Option<Vec<String>>,
442 /// Redirect URL of this association session. Used to redirect users into the AdSense association flow.
443 #[serde(rename = "redirectUrl")]
444 pub redirect_url: Option<String>,
445 /// Status of the completed association, available once the association callback token has been verified. One of ACCEPTED, REJECTED, or ERROR.
446 pub status: Option<String>,
447 /// The preferred locale of the user themselves when going through the AdSense association flow.
448 #[serde(rename = "userLocale")]
449 pub user_locale: Option<String>,
450 /// The locale of the user's hosted website.
451 #[serde(rename = "websiteLocale")]
452 pub website_locale: Option<String>,
453 /// The URL of the user's hosted website.
454 #[serde(rename = "websiteUrl")]
455 pub website_url: Option<String>,
456}
457
458impl common::Resource for AssociationSession {}
459impl common::ResponseResult for AssociationSession {}
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/// * [delete customchannels](CustomchannelDeleteCall) (response)
469/// * [get customchannels](CustomchannelGetCall) (response)
470/// * [insert customchannels](CustomchannelInsertCall) (request|response)
471/// * [patch customchannels](CustomchannelPatchCall) (request|response)
472/// * [update customchannels](CustomchannelUpdateCall) (request|response)
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct CustomChannel {
477 /// Code of this custom channel, not necessarily unique across ad clients.
478 pub code: Option<String>,
479 /// 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.
480 pub id: Option<String>,
481 /// Kind of resource this is, in this case adsensehost#customChannel.
482 pub kind: Option<String>,
483 /// Name of this custom channel.
484 pub name: Option<String>,
485}
486
487impl common::RequestValue for CustomChannel {}
488impl common::Resource for CustomChannel {}
489impl common::ResponseResult for CustomChannel {}
490
491/// There is no detailed description.
492///
493/// # Activities
494///
495/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
496/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
497///
498/// * [list customchannels](CustomchannelListCall) (response)
499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
500#[serde_with::serde_as]
501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
502pub struct CustomChannels {
503 /// ETag of this response for caching purposes.
504 pub etag: Option<String>,
505 /// The custom channels returned in this list response.
506 pub items: Option<Vec<CustomChannel>>,
507 /// Kind of list this is, in this case adsensehost#customChannels.
508 pub kind: Option<String>,
509 /// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
510 #[serde(rename = "nextPageToken")]
511 pub next_page_token: Option<String>,
512}
513
514impl common::ResponseResult for CustomChannels {}
515
516/// There is no detailed description.
517///
518/// # Activities
519///
520/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
521/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
522///
523/// * [reports generate accounts](AccountReportGenerateCall) (response)
524/// * [generate reports](ReportGenerateCall) (response)
525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
526#[serde_with::serde_as]
527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
528pub struct Report {
529 /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
530 pub averages: Option<Vec<String>>,
531 /// 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.
532 pub headers: Option<Vec<ReportHeaders>>,
533 /// Kind this is, in this case adsensehost#report.
534 pub kind: Option<String>,
535 /// 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.
536 pub rows: Option<Vec<Vec<String>>>,
537 /// 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.
538 #[serde(rename = "totalMatchedRows")]
539 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
540 pub total_matched_rows: Option<i64>,
541 /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
542 pub totals: Option<Vec<String>>,
543 /// Any warnings associated with generation of the report.
544 pub warnings: Option<Vec<String>>,
545}
546
547impl common::Resource for Report {}
548impl common::ResponseResult for Report {}
549
550/// There is no detailed description.
551///
552/// # Activities
553///
554/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
555/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
556///
557/// * [delete urlchannels](UrlchannelDeleteCall) (response)
558/// * [insert urlchannels](UrlchannelInsertCall) (request|response)
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct UrlChannel {
563 /// 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.
564 pub id: Option<String>,
565 /// Kind of resource this is, in this case adsensehost#urlChannel.
566 pub kind: Option<String>,
567 /// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home
568 #[serde(rename = "urlPattern")]
569 pub url_pattern: Option<String>,
570}
571
572impl common::RequestValue for UrlChannel {}
573impl common::Resource for UrlChannel {}
574impl common::ResponseResult for UrlChannel {}
575
576/// There is no detailed description.
577///
578/// # Activities
579///
580/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
581/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
582///
583/// * [list urlchannels](UrlchannelListCall) (response)
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct UrlChannels {
588 /// ETag of this response for caching purposes.
589 pub etag: Option<String>,
590 /// The URL channels returned in this list response.
591 pub items: Option<Vec<UrlChannel>>,
592 /// Kind of list this is, in this case adsensehost#urlChannels.
593 pub kind: Option<String>,
594 /// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
595 #[serde(rename = "nextPageToken")]
596 pub next_page_token: Option<String>,
597}
598
599impl common::ResponseResult for UrlChannels {}
600
601/// The colors included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
602///
603/// This type is not used in any activity, and only used as *part* of another schema.
604///
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct AdStyleColors {
609 /// The color of the ad background.
610 pub background: Option<String>,
611 /// The color of the ad border.
612 pub border: Option<String>,
613 /// The color of the ad text.
614 pub text: Option<String>,
615 /// The color of the ad title.
616 pub title: Option<String>,
617 /// The color of the ad url.
618 pub url: Option<String>,
619}
620
621impl common::NestedType for AdStyleColors {}
622impl common::Part for AdStyleColors {}
623
624/// The font which is included in the style.
625///
626/// This type is not used in any activity, and only used as *part* of another schema.
627///
628#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
629#[serde_with::serde_as]
630#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
631pub struct AdStyleFont {
632 /// The family of the font. Possible values are: ACCOUNT_DEFAULT_FAMILY, ADSENSE_DEFAULT_FAMILY, ARIAL, TIMES and VERDANA.
633 pub family: Option<String>,
634 /// The size of the font. Possible values are: ACCOUNT_DEFAULT_SIZE, ADSENSE_DEFAULT_SIZE, SMALL, MEDIUM and LARGE.
635 pub size: Option<String>,
636}
637
638impl common::NestedType for AdStyleFont {}
639impl common::Part for AdStyleFont {}
640
641/// Settings specific to content ads (AFC) and highend mobile content ads (AFMC - deprecated).
642///
643/// This type is not used in any activity, and only used as *part* of another schema.
644///
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct AdUnitContentAdsSettings {
649 /// The backup option to be used in instances where no ad is available.
650 #[serde(rename = "backupOption")]
651 pub backup_option: Option<AdUnitContentAdsSettingsBackupOption>,
652 /// Size of this ad unit. Size values are in the form SIZE_{width}_{height}.
653 pub size: Option<String>,
654 /// Type of this ad unit. Possible values are TEXT, TEXT_IMAGE, IMAGE and LINK.
655 #[serde(rename = "type")]
656 pub type_: Option<String>,
657}
658
659impl common::NestedType for AdUnitContentAdsSettings {}
660impl common::Part for AdUnitContentAdsSettings {}
661
662/// The backup option to be used in instances where no ad is available.
663///
664/// This type is not used in any activity, and only used as *part* of another schema.
665///
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct AdUnitContentAdsSettingsBackupOption {
670 /// Color to use when type is set to COLOR. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
671 pub color: Option<String>,
672 /// Type of the backup option. Possible values are BLANK, COLOR and URL.
673 #[serde(rename = "type")]
674 pub type_: Option<String>,
675 /// URL to use when type is set to URL.
676 pub url: Option<String>,
677}
678
679impl common::NestedType for AdUnitContentAdsSettingsBackupOption {}
680impl common::Part for AdUnitContentAdsSettingsBackupOption {}
681
682/// Settings specific to WAP mobile content ads (AFMC - deprecated).
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 AdUnitMobileContentAdsSettings {
690 /// The markup language to use for this ad unit.
691 #[serde(rename = "markupLanguage")]
692 pub markup_language: Option<String>,
693 /// The scripting language to use for this ad unit.
694 #[serde(rename = "scriptingLanguage")]
695 pub scripting_language: Option<String>,
696 /// Size of this ad unit.
697 pub size: Option<String>,
698 /// Type of this ad unit.
699 #[serde(rename = "type")]
700 pub type_: Option<String>,
701}
702
703impl common::NestedType for AdUnitMobileContentAdsSettings {}
704impl common::Part for AdUnitMobileContentAdsSettings {}
705
706/// 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.
707///
708/// This type is not used in any activity, and only used as *part* of another schema.
709///
710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
711#[serde_with::serde_as]
712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
713pub struct ReportHeaders {
714 /// The currency of this column. Only present if the header type is METRIC_CURRENCY.
715 pub currency: Option<String>,
716 /// The name of the header.
717 pub name: Option<String>,
718 /// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY.
719 #[serde(rename = "type")]
720 pub type_: Option<String>,
721}
722
723impl common::NestedType for ReportHeaders {}
724impl common::Part for ReportHeaders {}
725
726// ###################
727// MethodBuilders ###
728// #################
729
730/// A builder providing access to all methods supported on *account* resources.
731/// It is not used directly, but through the [`AdSenseHost`] hub.
732///
733/// # Example
734///
735/// Instantiate a resource builder
736///
737/// ```test_harness,no_run
738/// extern crate hyper;
739/// extern crate hyper_rustls;
740/// extern crate google_adsensehost4d1 as adsensehost4d1;
741///
742/// # async fn dox() {
743/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
744///
745/// let secret: yup_oauth2::ApplicationSecret = Default::default();
746/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
747/// .with_native_roots()
748/// .unwrap()
749/// .https_only()
750/// .enable_http2()
751/// .build();
752///
753/// let executor = hyper_util::rt::TokioExecutor::new();
754/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
755/// secret,
756/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
757/// yup_oauth2::client::CustomHyperClientBuilder::from(
758/// hyper_util::client::legacy::Client::builder(executor).build(connector),
759/// ),
760/// ).build().await.unwrap();
761///
762/// let client = hyper_util::client::legacy::Client::builder(
763/// hyper_util::rt::TokioExecutor::new()
764/// )
765/// .build(
766/// hyper_rustls::HttpsConnectorBuilder::new()
767/// .with_native_roots()
768/// .unwrap()
769/// .https_or_http()
770/// .enable_http2()
771/// .build()
772/// );
773/// let mut hub = AdSenseHost::new(client, auth);
774/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
775/// // like `adclients_get(...)`, `adclients_list(...)`, `adunits_delete(...)`, `adunits_get(...)`, `adunits_get_ad_code(...)`, `adunits_insert(...)`, `adunits_list(...)`, `adunits_patch(...)`, `adunits_update(...)`, `get(...)`, `list(...)` and `reports_generate(...)`
776/// // to build up your call.
777/// let rb = hub.accounts();
778/// # }
779/// ```
780pub struct AccountMethods<'a, C>
781where
782 C: 'a,
783{
784 hub: &'a AdSenseHost<C>,
785}
786
787impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
788
789impl<'a, C> AccountMethods<'a, C> {
790 /// Create a builder to help you perform the following task:
791 ///
792 /// Get information about one of the ad clients in the specified publisher's AdSense account.
793 ///
794 /// # Arguments
795 ///
796 /// * `accountId` - Account which contains the ad client.
797 /// * `adClientId` - Ad client to get.
798 pub fn adclients_get(
799 &self,
800 account_id: &str,
801 ad_client_id: &str,
802 ) -> AccountAdclientGetCall<'a, C> {
803 AccountAdclientGetCall {
804 hub: self.hub,
805 _account_id: account_id.to_string(),
806 _ad_client_id: ad_client_id.to_string(),
807 _delegate: Default::default(),
808 _additional_params: Default::default(),
809 _scopes: Default::default(),
810 }
811 }
812
813 /// Create a builder to help you perform the following task:
814 ///
815 /// List all hosted ad clients in the specified hosted account.
816 ///
817 /// # Arguments
818 ///
819 /// * `accountId` - Account for which to list ad clients.
820 pub fn adclients_list(&self, account_id: &str) -> AccountAdclientListCall<'a, C> {
821 AccountAdclientListCall {
822 hub: self.hub,
823 _account_id: account_id.to_string(),
824 _page_token: Default::default(),
825 _max_results: Default::default(),
826 _delegate: Default::default(),
827 _additional_params: Default::default(),
828 _scopes: Default::default(),
829 }
830 }
831
832 /// Create a builder to help you perform the following task:
833 ///
834 /// Delete the specified ad unit from the specified publisher AdSense account.
835 ///
836 /// # Arguments
837 ///
838 /// * `accountId` - Account which contains the ad unit.
839 /// * `adClientId` - Ad client for which to get ad unit.
840 /// * `adUnitId` - Ad unit to delete.
841 pub fn adunits_delete(
842 &self,
843 account_id: &str,
844 ad_client_id: &str,
845 ad_unit_id: &str,
846 ) -> AccountAdunitDeleteCall<'a, C> {
847 AccountAdunitDeleteCall {
848 hub: self.hub,
849 _account_id: account_id.to_string(),
850 _ad_client_id: ad_client_id.to_string(),
851 _ad_unit_id: ad_unit_id.to_string(),
852 _delegate: Default::default(),
853 _additional_params: Default::default(),
854 _scopes: Default::default(),
855 }
856 }
857
858 /// Create a builder to help you perform the following task:
859 ///
860 /// Get the specified host ad unit in this AdSense account.
861 ///
862 /// # Arguments
863 ///
864 /// * `accountId` - Account which contains the ad unit.
865 /// * `adClientId` - Ad client for which to get ad unit.
866 /// * `adUnitId` - Ad unit to get.
867 pub fn adunits_get(
868 &self,
869 account_id: &str,
870 ad_client_id: &str,
871 ad_unit_id: &str,
872 ) -> AccountAdunitGetCall<'a, C> {
873 AccountAdunitGetCall {
874 hub: self.hub,
875 _account_id: account_id.to_string(),
876 _ad_client_id: ad_client_id.to_string(),
877 _ad_unit_id: ad_unit_id.to_string(),
878 _delegate: Default::default(),
879 _additional_params: Default::default(),
880 _scopes: Default::default(),
881 }
882 }
883
884 /// Create a builder to help you perform the following task:
885 ///
886 /// Get ad code for the specified ad unit, attaching the specified host custom channels.
887 ///
888 /// # Arguments
889 ///
890 /// * `accountId` - Account which contains the ad client.
891 /// * `adClientId` - Ad client with contains the ad unit.
892 /// * `adUnitId` - Ad unit to get the code for.
893 pub fn adunits_get_ad_code(
894 &self,
895 account_id: &str,
896 ad_client_id: &str,
897 ad_unit_id: &str,
898 ) -> AccountAdunitGetAdCodeCall<'a, C> {
899 AccountAdunitGetAdCodeCall {
900 hub: self.hub,
901 _account_id: account_id.to_string(),
902 _ad_client_id: ad_client_id.to_string(),
903 _ad_unit_id: ad_unit_id.to_string(),
904 _host_custom_channel_id: Default::default(),
905 _delegate: Default::default(),
906 _additional_params: Default::default(),
907 _scopes: Default::default(),
908 }
909 }
910
911 /// Create a builder to help you perform the following task:
912 ///
913 /// Insert the supplied ad unit into the specified publisher AdSense account.
914 ///
915 /// # Arguments
916 ///
917 /// * `request` - No description provided.
918 /// * `accountId` - Account which will contain the ad unit.
919 /// * `adClientId` - Ad client into which to insert the ad unit.
920 pub fn adunits_insert(
921 &self,
922 request: AdUnit,
923 account_id: &str,
924 ad_client_id: &str,
925 ) -> AccountAdunitInsertCall<'a, C> {
926 AccountAdunitInsertCall {
927 hub: self.hub,
928 _request: request,
929 _account_id: account_id.to_string(),
930 _ad_client_id: ad_client_id.to_string(),
931 _delegate: Default::default(),
932 _additional_params: Default::default(),
933 _scopes: Default::default(),
934 }
935 }
936
937 /// Create a builder to help you perform the following task:
938 ///
939 /// List all ad units in the specified publisher's AdSense account.
940 ///
941 /// # Arguments
942 ///
943 /// * `accountId` - Account which contains the ad client.
944 /// * `adClientId` - Ad client for which to list ad units.
945 pub fn adunits_list(
946 &self,
947 account_id: &str,
948 ad_client_id: &str,
949 ) -> AccountAdunitListCall<'a, C> {
950 AccountAdunitListCall {
951 hub: self.hub,
952 _account_id: account_id.to_string(),
953 _ad_client_id: ad_client_id.to_string(),
954 _page_token: Default::default(),
955 _max_results: Default::default(),
956 _include_inactive: Default::default(),
957 _delegate: Default::default(),
958 _additional_params: Default::default(),
959 _scopes: Default::default(),
960 }
961 }
962
963 /// Create a builder to help you perform the following task:
964 ///
965 /// Update the supplied ad unit in the specified publisher AdSense account. This method supports patch semantics.
966 ///
967 /// # Arguments
968 ///
969 /// * `request` - No description provided.
970 /// * `accountId` - Account which contains the ad client.
971 /// * `adClientId` - Ad client which contains the ad unit.
972 /// * `adUnitId` - Ad unit to get.
973 pub fn adunits_patch(
974 &self,
975 request: AdUnit,
976 account_id: &str,
977 ad_client_id: &str,
978 ad_unit_id: &str,
979 ) -> AccountAdunitPatchCall<'a, C> {
980 AccountAdunitPatchCall {
981 hub: self.hub,
982 _request: request,
983 _account_id: account_id.to_string(),
984 _ad_client_id: ad_client_id.to_string(),
985 _ad_unit_id: ad_unit_id.to_string(),
986 _delegate: Default::default(),
987 _additional_params: Default::default(),
988 _scopes: Default::default(),
989 }
990 }
991
992 /// Create a builder to help you perform the following task:
993 ///
994 /// Update the supplied ad unit in the specified publisher AdSense account.
995 ///
996 /// # Arguments
997 ///
998 /// * `request` - No description provided.
999 /// * `accountId` - Account which contains the ad client.
1000 /// * `adClientId` - Ad client which contains the ad unit.
1001 pub fn adunits_update(
1002 &self,
1003 request: AdUnit,
1004 account_id: &str,
1005 ad_client_id: &str,
1006 ) -> AccountAdunitUpdateCall<'a, C> {
1007 AccountAdunitUpdateCall {
1008 hub: self.hub,
1009 _request: request,
1010 _account_id: account_id.to_string(),
1011 _ad_client_id: ad_client_id.to_string(),
1012 _delegate: Default::default(),
1013 _additional_params: Default::default(),
1014 _scopes: Default::default(),
1015 }
1016 }
1017
1018 /// Create a builder to help you perform the following task:
1019 ///
1020 /// 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.
1021 ///
1022 /// # Arguments
1023 ///
1024 /// * `accountId` - Hosted account upon which to report.
1025 /// * `startDate` - Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
1026 /// * `endDate` - End of the date range to report on in "YYYY-MM-DD" format, inclusive.
1027 pub fn reports_generate(
1028 &self,
1029 account_id: &str,
1030 start_date: &str,
1031 end_date: &str,
1032 ) -> AccountReportGenerateCall<'a, C> {
1033 AccountReportGenerateCall {
1034 hub: self.hub,
1035 _account_id: account_id.to_string(),
1036 _start_date: start_date.to_string(),
1037 _end_date: end_date.to_string(),
1038 _start_index: Default::default(),
1039 _sort: Default::default(),
1040 _metric: Default::default(),
1041 _max_results: Default::default(),
1042 _locale: Default::default(),
1043 _filter: Default::default(),
1044 _dimension: Default::default(),
1045 _delegate: Default::default(),
1046 _additional_params: Default::default(),
1047 _scopes: Default::default(),
1048 }
1049 }
1050
1051 /// Create a builder to help you perform the following task:
1052 ///
1053 /// Get information about the selected associated AdSense account.
1054 ///
1055 /// # Arguments
1056 ///
1057 /// * `accountId` - Account to get information about.
1058 pub fn get(&self, account_id: &str) -> AccountGetCall<'a, C> {
1059 AccountGetCall {
1060 hub: self.hub,
1061 _account_id: account_id.to_string(),
1062 _delegate: Default::default(),
1063 _additional_params: Default::default(),
1064 _scopes: Default::default(),
1065 }
1066 }
1067
1068 /// Create a builder to help you perform the following task:
1069 ///
1070 /// List hosted accounts associated with this AdSense account by ad client id.
1071 ///
1072 /// # Arguments
1073 ///
1074 /// * `filterAdClientId` - Ad clients to list accounts for.
1075 pub fn list(&self, filter_ad_client_id: &Vec<String>) -> AccountListCall<'a, C> {
1076 AccountListCall {
1077 hub: self.hub,
1078 _filter_ad_client_id: filter_ad_client_id.clone(),
1079 _delegate: Default::default(),
1080 _additional_params: Default::default(),
1081 _scopes: Default::default(),
1082 }
1083 }
1084}
1085
1086/// A builder providing access to all methods supported on *adclient* resources.
1087/// It is not used directly, but through the [`AdSenseHost`] hub.
1088///
1089/// # Example
1090///
1091/// Instantiate a resource builder
1092///
1093/// ```test_harness,no_run
1094/// extern crate hyper;
1095/// extern crate hyper_rustls;
1096/// extern crate google_adsensehost4d1 as adsensehost4d1;
1097///
1098/// # async fn dox() {
1099/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1100///
1101/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1102/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1103/// .with_native_roots()
1104/// .unwrap()
1105/// .https_only()
1106/// .enable_http2()
1107/// .build();
1108///
1109/// let executor = hyper_util::rt::TokioExecutor::new();
1110/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1111/// secret,
1112/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1113/// yup_oauth2::client::CustomHyperClientBuilder::from(
1114/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1115/// ),
1116/// ).build().await.unwrap();
1117///
1118/// let client = hyper_util::client::legacy::Client::builder(
1119/// hyper_util::rt::TokioExecutor::new()
1120/// )
1121/// .build(
1122/// hyper_rustls::HttpsConnectorBuilder::new()
1123/// .with_native_roots()
1124/// .unwrap()
1125/// .https_or_http()
1126/// .enable_http2()
1127/// .build()
1128/// );
1129/// let mut hub = AdSenseHost::new(client, auth);
1130/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1131/// // like `get(...)` and `list(...)`
1132/// // to build up your call.
1133/// let rb = hub.adclients();
1134/// # }
1135/// ```
1136pub struct AdclientMethods<'a, C>
1137where
1138 C: 'a,
1139{
1140 hub: &'a AdSenseHost<C>,
1141}
1142
1143impl<'a, C> common::MethodsBuilder for AdclientMethods<'a, C> {}
1144
1145impl<'a, C> AdclientMethods<'a, C> {
1146 /// Create a builder to help you perform the following task:
1147 ///
1148 /// Get information about one of the ad clients in the Host AdSense account.
1149 ///
1150 /// # Arguments
1151 ///
1152 /// * `adClientId` - Ad client to get.
1153 pub fn get(&self, ad_client_id: &str) -> AdclientGetCall<'a, C> {
1154 AdclientGetCall {
1155 hub: self.hub,
1156 _ad_client_id: ad_client_id.to_string(),
1157 _delegate: Default::default(),
1158 _additional_params: Default::default(),
1159 _scopes: Default::default(),
1160 }
1161 }
1162
1163 /// Create a builder to help you perform the following task:
1164 ///
1165 /// List all host ad clients in this AdSense account.
1166 pub fn list(&self) -> AdclientListCall<'a, C> {
1167 AdclientListCall {
1168 hub: self.hub,
1169 _page_token: Default::default(),
1170 _max_results: Default::default(),
1171 _delegate: Default::default(),
1172 _additional_params: Default::default(),
1173 _scopes: Default::default(),
1174 }
1175 }
1176}
1177
1178/// A builder providing access to all methods supported on *associationsession* resources.
1179/// It is not used directly, but through the [`AdSenseHost`] hub.
1180///
1181/// # Example
1182///
1183/// Instantiate a resource builder
1184///
1185/// ```test_harness,no_run
1186/// extern crate hyper;
1187/// extern crate hyper_rustls;
1188/// extern crate google_adsensehost4d1 as adsensehost4d1;
1189///
1190/// # async fn dox() {
1191/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1192///
1193/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1194/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1195/// .with_native_roots()
1196/// .unwrap()
1197/// .https_only()
1198/// .enable_http2()
1199/// .build();
1200///
1201/// let executor = hyper_util::rt::TokioExecutor::new();
1202/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1203/// secret,
1204/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1205/// yup_oauth2::client::CustomHyperClientBuilder::from(
1206/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1207/// ),
1208/// ).build().await.unwrap();
1209///
1210/// let client = hyper_util::client::legacy::Client::builder(
1211/// hyper_util::rt::TokioExecutor::new()
1212/// )
1213/// .build(
1214/// hyper_rustls::HttpsConnectorBuilder::new()
1215/// .with_native_roots()
1216/// .unwrap()
1217/// .https_or_http()
1218/// .enable_http2()
1219/// .build()
1220/// );
1221/// let mut hub = AdSenseHost::new(client, auth);
1222/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1223/// // like `start(...)` and `verify(...)`
1224/// // to build up your call.
1225/// let rb = hub.associationsessions();
1226/// # }
1227/// ```
1228pub struct AssociationsessionMethods<'a, C>
1229where
1230 C: 'a,
1231{
1232 hub: &'a AdSenseHost<C>,
1233}
1234
1235impl<'a, C> common::MethodsBuilder for AssociationsessionMethods<'a, C> {}
1236
1237impl<'a, C> AssociationsessionMethods<'a, C> {
1238 /// Create a builder to help you perform the following task:
1239 ///
1240 /// Create an association session for initiating an association with an AdSense user.
1241 ///
1242 /// # Arguments
1243 ///
1244 /// * `productCode` - Products to associate with the user.
1245 /// * `websiteUrl` - The URL of the user's hosted website.
1246 pub fn start(
1247 &self,
1248 product_code: &Vec<String>,
1249 website_url: &str,
1250 ) -> AssociationsessionStartCall<'a, C> {
1251 AssociationsessionStartCall {
1252 hub: self.hub,
1253 _product_code: product_code.clone(),
1254 _website_url: website_url.to_string(),
1255 _website_locale: Default::default(),
1256 _user_locale: Default::default(),
1257 _callback_url: Default::default(),
1258 _delegate: Default::default(),
1259 _additional_params: Default::default(),
1260 _scopes: Default::default(),
1261 }
1262 }
1263
1264 /// Create a builder to help you perform the following task:
1265 ///
1266 /// Verify an association session after the association callback returns from AdSense signup.
1267 ///
1268 /// # Arguments
1269 ///
1270 /// * `token` - The token returned to the association callback URL.
1271 pub fn verify(&self, token: &str) -> AssociationsessionVerifyCall<'a, C> {
1272 AssociationsessionVerifyCall {
1273 hub: self.hub,
1274 _token: token.to_string(),
1275 _delegate: Default::default(),
1276 _additional_params: Default::default(),
1277 _scopes: Default::default(),
1278 }
1279 }
1280}
1281
1282/// A builder providing access to all methods supported on *customchannel* resources.
1283/// It is not used directly, but through the [`AdSenseHost`] hub.
1284///
1285/// # Example
1286///
1287/// Instantiate a resource builder
1288///
1289/// ```test_harness,no_run
1290/// extern crate hyper;
1291/// extern crate hyper_rustls;
1292/// extern crate google_adsensehost4d1 as adsensehost4d1;
1293///
1294/// # async fn dox() {
1295/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1296///
1297/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1298/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1299/// .with_native_roots()
1300/// .unwrap()
1301/// .https_only()
1302/// .enable_http2()
1303/// .build();
1304///
1305/// let executor = hyper_util::rt::TokioExecutor::new();
1306/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1307/// secret,
1308/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1309/// yup_oauth2::client::CustomHyperClientBuilder::from(
1310/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1311/// ),
1312/// ).build().await.unwrap();
1313///
1314/// let client = hyper_util::client::legacy::Client::builder(
1315/// hyper_util::rt::TokioExecutor::new()
1316/// )
1317/// .build(
1318/// hyper_rustls::HttpsConnectorBuilder::new()
1319/// .with_native_roots()
1320/// .unwrap()
1321/// .https_or_http()
1322/// .enable_http2()
1323/// .build()
1324/// );
1325/// let mut hub = AdSenseHost::new(client, auth);
1326/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1327/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
1328/// // to build up your call.
1329/// let rb = hub.customchannels();
1330/// # }
1331/// ```
1332pub struct CustomchannelMethods<'a, C>
1333where
1334 C: 'a,
1335{
1336 hub: &'a AdSenseHost<C>,
1337}
1338
1339impl<'a, C> common::MethodsBuilder for CustomchannelMethods<'a, C> {}
1340
1341impl<'a, C> CustomchannelMethods<'a, C> {
1342 /// Create a builder to help you perform the following task:
1343 ///
1344 /// Delete a specific custom channel from the host AdSense account.
1345 ///
1346 /// # Arguments
1347 ///
1348 /// * `adClientId` - Ad client from which to delete the custom channel.
1349 /// * `customChannelId` - Custom channel to delete.
1350 pub fn delete(
1351 &self,
1352 ad_client_id: &str,
1353 custom_channel_id: &str,
1354 ) -> CustomchannelDeleteCall<'a, C> {
1355 CustomchannelDeleteCall {
1356 hub: self.hub,
1357 _ad_client_id: ad_client_id.to_string(),
1358 _custom_channel_id: custom_channel_id.to_string(),
1359 _delegate: Default::default(),
1360 _additional_params: Default::default(),
1361 _scopes: Default::default(),
1362 }
1363 }
1364
1365 /// Create a builder to help you perform the following task:
1366 ///
1367 /// Get a specific custom channel from the host AdSense account.
1368 ///
1369 /// # Arguments
1370 ///
1371 /// * `adClientId` - Ad client from which to get the custom channel.
1372 /// * `customChannelId` - Custom channel to get.
1373 pub fn get(&self, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelGetCall<'a, C> {
1374 CustomchannelGetCall {
1375 hub: self.hub,
1376 _ad_client_id: ad_client_id.to_string(),
1377 _custom_channel_id: custom_channel_id.to_string(),
1378 _delegate: Default::default(),
1379 _additional_params: Default::default(),
1380 _scopes: Default::default(),
1381 }
1382 }
1383
1384 /// Create a builder to help you perform the following task:
1385 ///
1386 /// Add a new custom channel to the host AdSense account.
1387 ///
1388 /// # Arguments
1389 ///
1390 /// * `request` - No description provided.
1391 /// * `adClientId` - Ad client to which the new custom channel will be added.
1392 pub fn insert(
1393 &self,
1394 request: CustomChannel,
1395 ad_client_id: &str,
1396 ) -> CustomchannelInsertCall<'a, C> {
1397 CustomchannelInsertCall {
1398 hub: self.hub,
1399 _request: request,
1400 _ad_client_id: ad_client_id.to_string(),
1401 _delegate: Default::default(),
1402 _additional_params: Default::default(),
1403 _scopes: Default::default(),
1404 }
1405 }
1406
1407 /// Create a builder to help you perform the following task:
1408 ///
1409 /// List all host custom channels in this AdSense account.
1410 ///
1411 /// # Arguments
1412 ///
1413 /// * `adClientId` - Ad client for which to list custom channels.
1414 pub fn list(&self, ad_client_id: &str) -> CustomchannelListCall<'a, C> {
1415 CustomchannelListCall {
1416 hub: self.hub,
1417 _ad_client_id: ad_client_id.to_string(),
1418 _page_token: Default::default(),
1419 _max_results: Default::default(),
1420 _delegate: Default::default(),
1421 _additional_params: Default::default(),
1422 _scopes: Default::default(),
1423 }
1424 }
1425
1426 /// Create a builder to help you perform the following task:
1427 ///
1428 /// Update a custom channel in the host AdSense account. This method supports patch semantics.
1429 ///
1430 /// # Arguments
1431 ///
1432 /// * `request` - No description provided.
1433 /// * `adClientId` - Ad client in which the custom channel will be updated.
1434 /// * `customChannelId` - Custom channel to get.
1435 pub fn patch(
1436 &self,
1437 request: CustomChannel,
1438 ad_client_id: &str,
1439 custom_channel_id: &str,
1440 ) -> CustomchannelPatchCall<'a, C> {
1441 CustomchannelPatchCall {
1442 hub: self.hub,
1443 _request: request,
1444 _ad_client_id: ad_client_id.to_string(),
1445 _custom_channel_id: custom_channel_id.to_string(),
1446 _delegate: Default::default(),
1447 _additional_params: Default::default(),
1448 _scopes: Default::default(),
1449 }
1450 }
1451
1452 /// Create a builder to help you perform the following task:
1453 ///
1454 /// Update a custom channel in the host AdSense account.
1455 ///
1456 /// # Arguments
1457 ///
1458 /// * `request` - No description provided.
1459 /// * `adClientId` - Ad client in which the custom channel will be updated.
1460 pub fn update(
1461 &self,
1462 request: CustomChannel,
1463 ad_client_id: &str,
1464 ) -> CustomchannelUpdateCall<'a, C> {
1465 CustomchannelUpdateCall {
1466 hub: self.hub,
1467 _request: request,
1468 _ad_client_id: ad_client_id.to_string(),
1469 _delegate: Default::default(),
1470 _additional_params: Default::default(),
1471 _scopes: Default::default(),
1472 }
1473 }
1474}
1475
1476/// A builder providing access to all methods supported on *report* resources.
1477/// It is not used directly, but through the [`AdSenseHost`] hub.
1478///
1479/// # Example
1480///
1481/// Instantiate a resource builder
1482///
1483/// ```test_harness,no_run
1484/// extern crate hyper;
1485/// extern crate hyper_rustls;
1486/// extern crate google_adsensehost4d1 as adsensehost4d1;
1487///
1488/// # async fn dox() {
1489/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1490///
1491/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1492/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1493/// .with_native_roots()
1494/// .unwrap()
1495/// .https_only()
1496/// .enable_http2()
1497/// .build();
1498///
1499/// let executor = hyper_util::rt::TokioExecutor::new();
1500/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1501/// secret,
1502/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1503/// yup_oauth2::client::CustomHyperClientBuilder::from(
1504/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1505/// ),
1506/// ).build().await.unwrap();
1507///
1508/// let client = hyper_util::client::legacy::Client::builder(
1509/// hyper_util::rt::TokioExecutor::new()
1510/// )
1511/// .build(
1512/// hyper_rustls::HttpsConnectorBuilder::new()
1513/// .with_native_roots()
1514/// .unwrap()
1515/// .https_or_http()
1516/// .enable_http2()
1517/// .build()
1518/// );
1519/// let mut hub = AdSenseHost::new(client, auth);
1520/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1521/// // like `generate(...)`
1522/// // to build up your call.
1523/// let rb = hub.reports();
1524/// # }
1525/// ```
1526pub struct ReportMethods<'a, C>
1527where
1528 C: 'a,
1529{
1530 hub: &'a AdSenseHost<C>,
1531}
1532
1533impl<'a, C> common::MethodsBuilder for ReportMethods<'a, C> {}
1534
1535impl<'a, C> ReportMethods<'a, C> {
1536 /// Create a builder to help you perform the following task:
1537 ///
1538 /// 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.
1539 ///
1540 /// # Arguments
1541 ///
1542 /// * `startDate` - Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
1543 /// * `endDate` - End of the date range to report on in "YYYY-MM-DD" format, inclusive.
1544 pub fn generate(&self, start_date: &str, end_date: &str) -> ReportGenerateCall<'a, C> {
1545 ReportGenerateCall {
1546 hub: self.hub,
1547 _start_date: start_date.to_string(),
1548 _end_date: end_date.to_string(),
1549 _start_index: Default::default(),
1550 _sort: Default::default(),
1551 _metric: Default::default(),
1552 _max_results: Default::default(),
1553 _locale: Default::default(),
1554 _filter: Default::default(),
1555 _dimension: Default::default(),
1556 _delegate: Default::default(),
1557 _additional_params: Default::default(),
1558 _scopes: Default::default(),
1559 }
1560 }
1561}
1562
1563/// A builder providing access to all methods supported on *urlchannel* resources.
1564/// It is not used directly, but through the [`AdSenseHost`] hub.
1565///
1566/// # Example
1567///
1568/// Instantiate a resource builder
1569///
1570/// ```test_harness,no_run
1571/// extern crate hyper;
1572/// extern crate hyper_rustls;
1573/// extern crate google_adsensehost4d1 as adsensehost4d1;
1574///
1575/// # async fn dox() {
1576/// use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1577///
1578/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1579/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1580/// .with_native_roots()
1581/// .unwrap()
1582/// .https_only()
1583/// .enable_http2()
1584/// .build();
1585///
1586/// let executor = hyper_util::rt::TokioExecutor::new();
1587/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1588/// secret,
1589/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1590/// yup_oauth2::client::CustomHyperClientBuilder::from(
1591/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1592/// ),
1593/// ).build().await.unwrap();
1594///
1595/// let client = hyper_util::client::legacy::Client::builder(
1596/// hyper_util::rt::TokioExecutor::new()
1597/// )
1598/// .build(
1599/// hyper_rustls::HttpsConnectorBuilder::new()
1600/// .with_native_roots()
1601/// .unwrap()
1602/// .https_or_http()
1603/// .enable_http2()
1604/// .build()
1605/// );
1606/// let mut hub = AdSenseHost::new(client, auth);
1607/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1608/// // like `delete(...)`, `insert(...)` and `list(...)`
1609/// // to build up your call.
1610/// let rb = hub.urlchannels();
1611/// # }
1612/// ```
1613pub struct UrlchannelMethods<'a, C>
1614where
1615 C: 'a,
1616{
1617 hub: &'a AdSenseHost<C>,
1618}
1619
1620impl<'a, C> common::MethodsBuilder for UrlchannelMethods<'a, C> {}
1621
1622impl<'a, C> UrlchannelMethods<'a, C> {
1623 /// Create a builder to help you perform the following task:
1624 ///
1625 /// Delete a URL channel from the host AdSense account.
1626 ///
1627 /// # Arguments
1628 ///
1629 /// * `adClientId` - Ad client from which to delete the URL channel.
1630 /// * `urlChannelId` - URL channel to delete.
1631 pub fn delete(&self, ad_client_id: &str, url_channel_id: &str) -> UrlchannelDeleteCall<'a, C> {
1632 UrlchannelDeleteCall {
1633 hub: self.hub,
1634 _ad_client_id: ad_client_id.to_string(),
1635 _url_channel_id: url_channel_id.to_string(),
1636 _delegate: Default::default(),
1637 _additional_params: Default::default(),
1638 _scopes: Default::default(),
1639 }
1640 }
1641
1642 /// Create a builder to help you perform the following task:
1643 ///
1644 /// Add a new URL channel to the host AdSense account.
1645 ///
1646 /// # Arguments
1647 ///
1648 /// * `request` - No description provided.
1649 /// * `adClientId` - Ad client to which the new URL channel will be added.
1650 pub fn insert(&self, request: UrlChannel, ad_client_id: &str) -> UrlchannelInsertCall<'a, C> {
1651 UrlchannelInsertCall {
1652 hub: self.hub,
1653 _request: request,
1654 _ad_client_id: ad_client_id.to_string(),
1655 _delegate: Default::default(),
1656 _additional_params: Default::default(),
1657 _scopes: Default::default(),
1658 }
1659 }
1660
1661 /// Create a builder to help you perform the following task:
1662 ///
1663 /// List all host URL channels in the host AdSense account.
1664 ///
1665 /// # Arguments
1666 ///
1667 /// * `adClientId` - Ad client for which to list URL channels.
1668 pub fn list(&self, ad_client_id: &str) -> UrlchannelListCall<'a, C> {
1669 UrlchannelListCall {
1670 hub: self.hub,
1671 _ad_client_id: ad_client_id.to_string(),
1672 _page_token: Default::default(),
1673 _max_results: Default::default(),
1674 _delegate: Default::default(),
1675 _additional_params: Default::default(),
1676 _scopes: Default::default(),
1677 }
1678 }
1679}
1680
1681// ###################
1682// CallBuilders ###
1683// #################
1684
1685/// Get information about one of the ad clients in the specified publisher's AdSense account.
1686///
1687/// A builder for the *adclients.get* method supported by a *account* resource.
1688/// It is not used directly, but through a [`AccountMethods`] instance.
1689///
1690/// # Example
1691///
1692/// Instantiate a resource method builder
1693///
1694/// ```test_harness,no_run
1695/// # extern crate hyper;
1696/// # extern crate hyper_rustls;
1697/// # extern crate google_adsensehost4d1 as adsensehost4d1;
1698/// # async fn dox() {
1699/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1700///
1701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1703/// # .with_native_roots()
1704/// # .unwrap()
1705/// # .https_only()
1706/// # .enable_http2()
1707/// # .build();
1708///
1709/// # let executor = hyper_util::rt::TokioExecutor::new();
1710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1711/// # secret,
1712/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1713/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1714/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1715/// # ),
1716/// # ).build().await.unwrap();
1717///
1718/// # let client = hyper_util::client::legacy::Client::builder(
1719/// # hyper_util::rt::TokioExecutor::new()
1720/// # )
1721/// # .build(
1722/// # hyper_rustls::HttpsConnectorBuilder::new()
1723/// # .with_native_roots()
1724/// # .unwrap()
1725/// # .https_or_http()
1726/// # .enable_http2()
1727/// # .build()
1728/// # );
1729/// # let mut hub = AdSenseHost::new(client, auth);
1730/// // You can configure optional parameters by calling the respective setters at will, and
1731/// // execute the final call using `doit()`.
1732/// // Values shown here are possibly random and not representative !
1733/// let result = hub.accounts().adclients_get("accountId", "adClientId")
1734/// .doit().await;
1735/// # }
1736/// ```
1737pub struct AccountAdclientGetCall<'a, C>
1738where
1739 C: 'a,
1740{
1741 hub: &'a AdSenseHost<C>,
1742 _account_id: String,
1743 _ad_client_id: String,
1744 _delegate: Option<&'a mut dyn common::Delegate>,
1745 _additional_params: HashMap<String, String>,
1746 _scopes: BTreeSet<String>,
1747}
1748
1749impl<'a, C> common::CallBuilder for AccountAdclientGetCall<'a, C> {}
1750
1751impl<'a, C> AccountAdclientGetCall<'a, C>
1752where
1753 C: common::Connector,
1754{
1755 /// Perform the operation you have build so far.
1756 pub async fn doit(mut self) -> common::Result<(common::Response, AdClient)> {
1757 use std::borrow::Cow;
1758 use std::io::{Read, Seek};
1759
1760 use common::{url::Params, ToParts};
1761 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1762
1763 let mut dd = common::DefaultDelegate;
1764 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1765 dlg.begin(common::MethodInfo {
1766 id: "adsensehost.accounts.adclients.get",
1767 http_method: hyper::Method::GET,
1768 });
1769
1770 for &field in ["alt", "accountId", "adClientId"].iter() {
1771 if self._additional_params.contains_key(field) {
1772 dlg.finished(false);
1773 return Err(common::Error::FieldClash(field));
1774 }
1775 }
1776
1777 let mut params = Params::with_capacity(4 + self._additional_params.len());
1778 params.push("accountId", self._account_id);
1779 params.push("adClientId", self._ad_client_id);
1780
1781 params.extend(self._additional_params.iter());
1782
1783 params.push("alt", "json");
1784 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}";
1785 if self._scopes.is_empty() {
1786 self._scopes.insert(Scope::Full.as_ref().to_string());
1787 }
1788
1789 #[allow(clippy::single_element_loop)]
1790 for &(find_this, param_name) in
1791 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
1792 {
1793 url = params.uri_replacement(url, param_name, find_this, false);
1794 }
1795 {
1796 let to_remove = ["adClientId", "accountId"];
1797 params.remove_params(&to_remove);
1798 }
1799
1800 let url = params.parse_with_url(&url);
1801
1802 loop {
1803 let token = match self
1804 .hub
1805 .auth
1806 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1807 .await
1808 {
1809 Ok(token) => token,
1810 Err(e) => match dlg.token(e) {
1811 Ok(token) => token,
1812 Err(e) => {
1813 dlg.finished(false);
1814 return Err(common::Error::MissingToken(e));
1815 }
1816 },
1817 };
1818 let mut req_result = {
1819 let client = &self.hub.client;
1820 dlg.pre_request();
1821 let mut req_builder = hyper::Request::builder()
1822 .method(hyper::Method::GET)
1823 .uri(url.as_str())
1824 .header(USER_AGENT, self.hub._user_agent.clone());
1825
1826 if let Some(token) = token.as_ref() {
1827 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1828 }
1829
1830 let request = req_builder
1831 .header(CONTENT_LENGTH, 0_u64)
1832 .body(common::to_body::<String>(None));
1833
1834 client.request(request.unwrap()).await
1835 };
1836
1837 match req_result {
1838 Err(err) => {
1839 if let common::Retry::After(d) = dlg.http_error(&err) {
1840 sleep(d).await;
1841 continue;
1842 }
1843 dlg.finished(false);
1844 return Err(common::Error::HttpError(err));
1845 }
1846 Ok(res) => {
1847 let (mut parts, body) = res.into_parts();
1848 let mut body = common::Body::new(body);
1849 if !parts.status.is_success() {
1850 let bytes = common::to_bytes(body).await.unwrap_or_default();
1851 let error = serde_json::from_str(&common::to_string(&bytes));
1852 let response = common::to_response(parts, bytes.into());
1853
1854 if let common::Retry::After(d) =
1855 dlg.http_failure(&response, error.as_ref().ok())
1856 {
1857 sleep(d).await;
1858 continue;
1859 }
1860
1861 dlg.finished(false);
1862
1863 return Err(match error {
1864 Ok(value) => common::Error::BadRequest(value),
1865 _ => common::Error::Failure(response),
1866 });
1867 }
1868 let response = {
1869 let bytes = common::to_bytes(body).await.unwrap_or_default();
1870 let encoded = common::to_string(&bytes);
1871 match serde_json::from_str(&encoded) {
1872 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1873 Err(error) => {
1874 dlg.response_json_decode_error(&encoded, &error);
1875 return Err(common::Error::JsonDecodeError(
1876 encoded.to_string(),
1877 error,
1878 ));
1879 }
1880 }
1881 };
1882
1883 dlg.finished(true);
1884 return Ok(response);
1885 }
1886 }
1887 }
1888 }
1889
1890 /// Account which contains the ad client.
1891 ///
1892 /// Sets the *account id* path property to the given value.
1893 ///
1894 /// Even though the property as already been set when instantiating this call,
1895 /// we provide this method for API completeness.
1896 pub fn account_id(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C> {
1897 self._account_id = new_value.to_string();
1898 self
1899 }
1900 /// Ad client to get.
1901 ///
1902 /// Sets the *ad client id* path property to the given value.
1903 ///
1904 /// Even though the property as already been set when instantiating this call,
1905 /// we provide this method for API completeness.
1906 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C> {
1907 self._ad_client_id = new_value.to_string();
1908 self
1909 }
1910 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1911 /// while executing the actual API request.
1912 ///
1913 /// ````text
1914 /// It should be used to handle progress information, and to implement a certain level of resilience.
1915 /// ````
1916 ///
1917 /// Sets the *delegate* property to the given value.
1918 pub fn delegate(
1919 mut self,
1920 new_value: &'a mut dyn common::Delegate,
1921 ) -> AccountAdclientGetCall<'a, C> {
1922 self._delegate = Some(new_value);
1923 self
1924 }
1925
1926 /// Set any additional parameter of the query string used in the request.
1927 /// It should be used to set parameters which are not yet available through their own
1928 /// setters.
1929 ///
1930 /// Please note that this method must not be used to set any of the known parameters
1931 /// which have their own setter method. If done anyway, the request will fail.
1932 ///
1933 /// # Additional Parameters
1934 ///
1935 /// * *alt* (query-string) - Data format for the response.
1936 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1937 /// * *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.
1938 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1939 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1940 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1941 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1942 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetCall<'a, C>
1943 where
1944 T: AsRef<str>,
1945 {
1946 self._additional_params
1947 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1948 self
1949 }
1950
1951 /// Identifies the authorization scope for the method you are building.
1952 ///
1953 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1954 /// [`Scope::Full`].
1955 ///
1956 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1957 /// tokens for more than one scope.
1958 ///
1959 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1960 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1961 /// sufficient, a read-write scope will do as well.
1962 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetCall<'a, C>
1963 where
1964 St: AsRef<str>,
1965 {
1966 self._scopes.insert(String::from(scope.as_ref()));
1967 self
1968 }
1969 /// Identifies the authorization scope(s) for the method you are building.
1970 ///
1971 /// See [`Self::add_scope()`] for details.
1972 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetCall<'a, C>
1973 where
1974 I: IntoIterator<Item = St>,
1975 St: AsRef<str>,
1976 {
1977 self._scopes
1978 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1979 self
1980 }
1981
1982 /// Removes all scopes, and no default scope will be used either.
1983 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1984 /// for details).
1985 pub fn clear_scopes(mut self) -> AccountAdclientGetCall<'a, C> {
1986 self._scopes.clear();
1987 self
1988 }
1989}
1990
1991/// List all hosted ad clients in the specified hosted account.
1992///
1993/// A builder for the *adclients.list* method supported by a *account* resource.
1994/// It is not used directly, but through a [`AccountMethods`] instance.
1995///
1996/// # Example
1997///
1998/// Instantiate a resource method builder
1999///
2000/// ```test_harness,no_run
2001/// # extern crate hyper;
2002/// # extern crate hyper_rustls;
2003/// # extern crate google_adsensehost4d1 as adsensehost4d1;
2004/// # async fn dox() {
2005/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2006///
2007/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2008/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2009/// # .with_native_roots()
2010/// # .unwrap()
2011/// # .https_only()
2012/// # .enable_http2()
2013/// # .build();
2014///
2015/// # let executor = hyper_util::rt::TokioExecutor::new();
2016/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2017/// # secret,
2018/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2019/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2020/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2021/// # ),
2022/// # ).build().await.unwrap();
2023///
2024/// # let client = hyper_util::client::legacy::Client::builder(
2025/// # hyper_util::rt::TokioExecutor::new()
2026/// # )
2027/// # .build(
2028/// # hyper_rustls::HttpsConnectorBuilder::new()
2029/// # .with_native_roots()
2030/// # .unwrap()
2031/// # .https_or_http()
2032/// # .enable_http2()
2033/// # .build()
2034/// # );
2035/// # let mut hub = AdSenseHost::new(client, auth);
2036/// // You can configure optional parameters by calling the respective setters at will, and
2037/// // execute the final call using `doit()`.
2038/// // Values shown here are possibly random and not representative !
2039/// let result = hub.accounts().adclients_list("accountId")
2040/// .page_token("ea")
2041/// .max_results(2)
2042/// .doit().await;
2043/// # }
2044/// ```
2045pub struct AccountAdclientListCall<'a, C>
2046where
2047 C: 'a,
2048{
2049 hub: &'a AdSenseHost<C>,
2050 _account_id: String,
2051 _page_token: Option<String>,
2052 _max_results: Option<u32>,
2053 _delegate: Option<&'a mut dyn common::Delegate>,
2054 _additional_params: HashMap<String, String>,
2055 _scopes: BTreeSet<String>,
2056}
2057
2058impl<'a, C> common::CallBuilder for AccountAdclientListCall<'a, C> {}
2059
2060impl<'a, C> AccountAdclientListCall<'a, C>
2061where
2062 C: common::Connector,
2063{
2064 /// Perform the operation you have build so far.
2065 pub async fn doit(mut self) -> common::Result<(common::Response, AdClients)> {
2066 use std::borrow::Cow;
2067 use std::io::{Read, Seek};
2068
2069 use common::{url::Params, ToParts};
2070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2071
2072 let mut dd = common::DefaultDelegate;
2073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2074 dlg.begin(common::MethodInfo {
2075 id: "adsensehost.accounts.adclients.list",
2076 http_method: hyper::Method::GET,
2077 });
2078
2079 for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
2080 if self._additional_params.contains_key(field) {
2081 dlg.finished(false);
2082 return Err(common::Error::FieldClash(field));
2083 }
2084 }
2085
2086 let mut params = Params::with_capacity(5 + self._additional_params.len());
2087 params.push("accountId", self._account_id);
2088 if let Some(value) = self._page_token.as_ref() {
2089 params.push("pageToken", value);
2090 }
2091 if let Some(value) = self._max_results.as_ref() {
2092 params.push("maxResults", value.to_string());
2093 }
2094
2095 params.extend(self._additional_params.iter());
2096
2097 params.push("alt", "json");
2098 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/adclients";
2099 if self._scopes.is_empty() {
2100 self._scopes.insert(Scope::Full.as_ref().to_string());
2101 }
2102
2103 #[allow(clippy::single_element_loop)]
2104 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
2105 url = params.uri_replacement(url, param_name, find_this, false);
2106 }
2107 {
2108 let to_remove = ["accountId"];
2109 params.remove_params(&to_remove);
2110 }
2111
2112 let url = params.parse_with_url(&url);
2113
2114 loop {
2115 let token = match self
2116 .hub
2117 .auth
2118 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2119 .await
2120 {
2121 Ok(token) => token,
2122 Err(e) => match dlg.token(e) {
2123 Ok(token) => token,
2124 Err(e) => {
2125 dlg.finished(false);
2126 return Err(common::Error::MissingToken(e));
2127 }
2128 },
2129 };
2130 let mut req_result = {
2131 let client = &self.hub.client;
2132 dlg.pre_request();
2133 let mut req_builder = hyper::Request::builder()
2134 .method(hyper::Method::GET)
2135 .uri(url.as_str())
2136 .header(USER_AGENT, self.hub._user_agent.clone());
2137
2138 if let Some(token) = token.as_ref() {
2139 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2140 }
2141
2142 let request = req_builder
2143 .header(CONTENT_LENGTH, 0_u64)
2144 .body(common::to_body::<String>(None));
2145
2146 client.request(request.unwrap()).await
2147 };
2148
2149 match req_result {
2150 Err(err) => {
2151 if let common::Retry::After(d) = dlg.http_error(&err) {
2152 sleep(d).await;
2153 continue;
2154 }
2155 dlg.finished(false);
2156 return Err(common::Error::HttpError(err));
2157 }
2158 Ok(res) => {
2159 let (mut parts, body) = res.into_parts();
2160 let mut body = common::Body::new(body);
2161 if !parts.status.is_success() {
2162 let bytes = common::to_bytes(body).await.unwrap_or_default();
2163 let error = serde_json::from_str(&common::to_string(&bytes));
2164 let response = common::to_response(parts, bytes.into());
2165
2166 if let common::Retry::After(d) =
2167 dlg.http_failure(&response, error.as_ref().ok())
2168 {
2169 sleep(d).await;
2170 continue;
2171 }
2172
2173 dlg.finished(false);
2174
2175 return Err(match error {
2176 Ok(value) => common::Error::BadRequest(value),
2177 _ => common::Error::Failure(response),
2178 });
2179 }
2180 let response = {
2181 let bytes = common::to_bytes(body).await.unwrap_or_default();
2182 let encoded = common::to_string(&bytes);
2183 match serde_json::from_str(&encoded) {
2184 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2185 Err(error) => {
2186 dlg.response_json_decode_error(&encoded, &error);
2187 return Err(common::Error::JsonDecodeError(
2188 encoded.to_string(),
2189 error,
2190 ));
2191 }
2192 }
2193 };
2194
2195 dlg.finished(true);
2196 return Ok(response);
2197 }
2198 }
2199 }
2200 }
2201
2202 /// Account for which to list ad clients.
2203 ///
2204 /// Sets the *account id* path property to the given value.
2205 ///
2206 /// Even though the property as already been set when instantiating this call,
2207 /// we provide this method for API completeness.
2208 pub fn account_id(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
2209 self._account_id = new_value.to_string();
2210 self
2211 }
2212 /// 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.
2213 ///
2214 /// Sets the *page token* query property to the given value.
2215 pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
2216 self._page_token = Some(new_value.to_string());
2217 self
2218 }
2219 /// The maximum number of ad clients to include in the response, used for paging.
2220 ///
2221 /// Sets the *max results* query property to the given value.
2222 pub fn max_results(mut self, new_value: u32) -> AccountAdclientListCall<'a, C> {
2223 self._max_results = Some(new_value);
2224 self
2225 }
2226 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2227 /// while executing the actual API request.
2228 ///
2229 /// ````text
2230 /// It should be used to handle progress information, and to implement a certain level of resilience.
2231 /// ````
2232 ///
2233 /// Sets the *delegate* property to the given value.
2234 pub fn delegate(
2235 mut self,
2236 new_value: &'a mut dyn common::Delegate,
2237 ) -> AccountAdclientListCall<'a, C> {
2238 self._delegate = Some(new_value);
2239 self
2240 }
2241
2242 /// Set any additional parameter of the query string used in the request.
2243 /// It should be used to set parameters which are not yet available through their own
2244 /// setters.
2245 ///
2246 /// Please note that this method must not be used to set any of the known parameters
2247 /// which have their own setter method. If done anyway, the request will fail.
2248 ///
2249 /// # Additional Parameters
2250 ///
2251 /// * *alt* (query-string) - Data format for the response.
2252 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2253 /// * *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.
2254 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2255 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2256 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2257 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2258 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientListCall<'a, C>
2259 where
2260 T: AsRef<str>,
2261 {
2262 self._additional_params
2263 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2264 self
2265 }
2266
2267 /// Identifies the authorization scope for the method you are building.
2268 ///
2269 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2270 /// [`Scope::Full`].
2271 ///
2272 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2273 /// tokens for more than one scope.
2274 ///
2275 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2276 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2277 /// sufficient, a read-write scope will do as well.
2278 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientListCall<'a, C>
2279 where
2280 St: AsRef<str>,
2281 {
2282 self._scopes.insert(String::from(scope.as_ref()));
2283 self
2284 }
2285 /// Identifies the authorization scope(s) for the method you are building.
2286 ///
2287 /// See [`Self::add_scope()`] for details.
2288 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientListCall<'a, C>
2289 where
2290 I: IntoIterator<Item = St>,
2291 St: AsRef<str>,
2292 {
2293 self._scopes
2294 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2295 self
2296 }
2297
2298 /// Removes all scopes, and no default scope will be used either.
2299 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2300 /// for details).
2301 pub fn clear_scopes(mut self) -> AccountAdclientListCall<'a, C> {
2302 self._scopes.clear();
2303 self
2304 }
2305}
2306
2307/// Delete the specified ad unit from the specified publisher AdSense account.
2308///
2309/// A builder for the *adunits.delete* method supported by a *account* resource.
2310/// It is not used directly, but through a [`AccountMethods`] instance.
2311///
2312/// # Example
2313///
2314/// Instantiate a resource method builder
2315///
2316/// ```test_harness,no_run
2317/// # extern crate hyper;
2318/// # extern crate hyper_rustls;
2319/// # extern crate google_adsensehost4d1 as adsensehost4d1;
2320/// # async fn dox() {
2321/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2322///
2323/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2324/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2325/// # .with_native_roots()
2326/// # .unwrap()
2327/// # .https_only()
2328/// # .enable_http2()
2329/// # .build();
2330///
2331/// # let executor = hyper_util::rt::TokioExecutor::new();
2332/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2333/// # secret,
2334/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2335/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2336/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2337/// # ),
2338/// # ).build().await.unwrap();
2339///
2340/// # let client = hyper_util::client::legacy::Client::builder(
2341/// # hyper_util::rt::TokioExecutor::new()
2342/// # )
2343/// # .build(
2344/// # hyper_rustls::HttpsConnectorBuilder::new()
2345/// # .with_native_roots()
2346/// # .unwrap()
2347/// # .https_or_http()
2348/// # .enable_http2()
2349/// # .build()
2350/// # );
2351/// # let mut hub = AdSenseHost::new(client, auth);
2352/// // You can configure optional parameters by calling the respective setters at will, and
2353/// // execute the final call using `doit()`.
2354/// // Values shown here are possibly random and not representative !
2355/// let result = hub.accounts().adunits_delete("accountId", "adClientId", "adUnitId")
2356/// .doit().await;
2357/// # }
2358/// ```
2359pub struct AccountAdunitDeleteCall<'a, C>
2360where
2361 C: 'a,
2362{
2363 hub: &'a AdSenseHost<C>,
2364 _account_id: String,
2365 _ad_client_id: String,
2366 _ad_unit_id: String,
2367 _delegate: Option<&'a mut dyn common::Delegate>,
2368 _additional_params: HashMap<String, String>,
2369 _scopes: BTreeSet<String>,
2370}
2371
2372impl<'a, C> common::CallBuilder for AccountAdunitDeleteCall<'a, C> {}
2373
2374impl<'a, C> AccountAdunitDeleteCall<'a, C>
2375where
2376 C: common::Connector,
2377{
2378 /// Perform the operation you have build so far.
2379 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
2380 use std::borrow::Cow;
2381 use std::io::{Read, Seek};
2382
2383 use common::{url::Params, ToParts};
2384 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2385
2386 let mut dd = common::DefaultDelegate;
2387 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2388 dlg.begin(common::MethodInfo {
2389 id: "adsensehost.accounts.adunits.delete",
2390 http_method: hyper::Method::DELETE,
2391 });
2392
2393 for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
2394 if self._additional_params.contains_key(field) {
2395 dlg.finished(false);
2396 return Err(common::Error::FieldClash(field));
2397 }
2398 }
2399
2400 let mut params = Params::with_capacity(5 + self._additional_params.len());
2401 params.push("accountId", self._account_id);
2402 params.push("adClientId", self._ad_client_id);
2403 params.push("adUnitId", self._ad_unit_id);
2404
2405 params.extend(self._additional_params.iter());
2406
2407 params.push("alt", "json");
2408 let mut url = self.hub._base_url.clone()
2409 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}";
2410 if self._scopes.is_empty() {
2411 self._scopes.insert(Scope::Full.as_ref().to_string());
2412 }
2413
2414 #[allow(clippy::single_element_loop)]
2415 for &(find_this, param_name) in [
2416 ("{accountId}", "accountId"),
2417 ("{adClientId}", "adClientId"),
2418 ("{adUnitId}", "adUnitId"),
2419 ]
2420 .iter()
2421 {
2422 url = params.uri_replacement(url, param_name, find_this, false);
2423 }
2424 {
2425 let to_remove = ["adUnitId", "adClientId", "accountId"];
2426 params.remove_params(&to_remove);
2427 }
2428
2429 let url = params.parse_with_url(&url);
2430
2431 loop {
2432 let token = match self
2433 .hub
2434 .auth
2435 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2436 .await
2437 {
2438 Ok(token) => token,
2439 Err(e) => match dlg.token(e) {
2440 Ok(token) => token,
2441 Err(e) => {
2442 dlg.finished(false);
2443 return Err(common::Error::MissingToken(e));
2444 }
2445 },
2446 };
2447 let mut req_result = {
2448 let client = &self.hub.client;
2449 dlg.pre_request();
2450 let mut req_builder = hyper::Request::builder()
2451 .method(hyper::Method::DELETE)
2452 .uri(url.as_str())
2453 .header(USER_AGENT, self.hub._user_agent.clone());
2454
2455 if let Some(token) = token.as_ref() {
2456 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2457 }
2458
2459 let request = req_builder
2460 .header(CONTENT_LENGTH, 0_u64)
2461 .body(common::to_body::<String>(None));
2462
2463 client.request(request.unwrap()).await
2464 };
2465
2466 match req_result {
2467 Err(err) => {
2468 if let common::Retry::After(d) = dlg.http_error(&err) {
2469 sleep(d).await;
2470 continue;
2471 }
2472 dlg.finished(false);
2473 return Err(common::Error::HttpError(err));
2474 }
2475 Ok(res) => {
2476 let (mut parts, body) = res.into_parts();
2477 let mut body = common::Body::new(body);
2478 if !parts.status.is_success() {
2479 let bytes = common::to_bytes(body).await.unwrap_or_default();
2480 let error = serde_json::from_str(&common::to_string(&bytes));
2481 let response = common::to_response(parts, bytes.into());
2482
2483 if let common::Retry::After(d) =
2484 dlg.http_failure(&response, error.as_ref().ok())
2485 {
2486 sleep(d).await;
2487 continue;
2488 }
2489
2490 dlg.finished(false);
2491
2492 return Err(match error {
2493 Ok(value) => common::Error::BadRequest(value),
2494 _ => common::Error::Failure(response),
2495 });
2496 }
2497 let response = {
2498 let bytes = common::to_bytes(body).await.unwrap_or_default();
2499 let encoded = common::to_string(&bytes);
2500 match serde_json::from_str(&encoded) {
2501 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2502 Err(error) => {
2503 dlg.response_json_decode_error(&encoded, &error);
2504 return Err(common::Error::JsonDecodeError(
2505 encoded.to_string(),
2506 error,
2507 ));
2508 }
2509 }
2510 };
2511
2512 dlg.finished(true);
2513 return Ok(response);
2514 }
2515 }
2516 }
2517 }
2518
2519 /// Account which contains the ad unit.
2520 ///
2521 /// Sets the *account id* path property to the given value.
2522 ///
2523 /// Even though the property as already been set when instantiating this call,
2524 /// we provide this method for API completeness.
2525 pub fn account_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C> {
2526 self._account_id = new_value.to_string();
2527 self
2528 }
2529 /// Ad client for which to get ad unit.
2530 ///
2531 /// Sets the *ad client id* path property to the given value.
2532 ///
2533 /// Even though the property as already been set when instantiating this call,
2534 /// we provide this method for API completeness.
2535 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C> {
2536 self._ad_client_id = new_value.to_string();
2537 self
2538 }
2539 /// Ad unit to delete.
2540 ///
2541 /// Sets the *ad unit id* path property to the given value.
2542 ///
2543 /// Even though the property as already been set when instantiating this call,
2544 /// we provide this method for API completeness.
2545 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C> {
2546 self._ad_unit_id = new_value.to_string();
2547 self
2548 }
2549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2550 /// while executing the actual API request.
2551 ///
2552 /// ````text
2553 /// It should be used to handle progress information, and to implement a certain level of resilience.
2554 /// ````
2555 ///
2556 /// Sets the *delegate* property to the given value.
2557 pub fn delegate(
2558 mut self,
2559 new_value: &'a mut dyn common::Delegate,
2560 ) -> AccountAdunitDeleteCall<'a, C> {
2561 self._delegate = Some(new_value);
2562 self
2563 }
2564
2565 /// Set any additional parameter of the query string used in the request.
2566 /// It should be used to set parameters which are not yet available through their own
2567 /// setters.
2568 ///
2569 /// Please note that this method must not be used to set any of the known parameters
2570 /// which have their own setter method. If done anyway, the request will fail.
2571 ///
2572 /// # Additional Parameters
2573 ///
2574 /// * *alt* (query-string) - Data format for the response.
2575 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2576 /// * *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.
2577 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2578 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2579 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2580 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2581 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitDeleteCall<'a, C>
2582 where
2583 T: AsRef<str>,
2584 {
2585 self._additional_params
2586 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2587 self
2588 }
2589
2590 /// Identifies the authorization scope for the method you are building.
2591 ///
2592 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2593 /// [`Scope::Full`].
2594 ///
2595 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2596 /// tokens for more than one scope.
2597 ///
2598 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2599 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2600 /// sufficient, a read-write scope will do as well.
2601 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitDeleteCall<'a, C>
2602 where
2603 St: AsRef<str>,
2604 {
2605 self._scopes.insert(String::from(scope.as_ref()));
2606 self
2607 }
2608 /// Identifies the authorization scope(s) for the method you are building.
2609 ///
2610 /// See [`Self::add_scope()`] for details.
2611 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitDeleteCall<'a, C>
2612 where
2613 I: IntoIterator<Item = St>,
2614 St: AsRef<str>,
2615 {
2616 self._scopes
2617 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2618 self
2619 }
2620
2621 /// Removes all scopes, and no default scope will be used either.
2622 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2623 /// for details).
2624 pub fn clear_scopes(mut self) -> AccountAdunitDeleteCall<'a, C> {
2625 self._scopes.clear();
2626 self
2627 }
2628}
2629
2630/// Get the specified host ad unit in this AdSense account.
2631///
2632/// A builder for the *adunits.get* method supported by a *account* resource.
2633/// It is not used directly, but through a [`AccountMethods`] instance.
2634///
2635/// # Example
2636///
2637/// Instantiate a resource method builder
2638///
2639/// ```test_harness,no_run
2640/// # extern crate hyper;
2641/// # extern crate hyper_rustls;
2642/// # extern crate google_adsensehost4d1 as adsensehost4d1;
2643/// # async fn dox() {
2644/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2645///
2646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2647/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2648/// # .with_native_roots()
2649/// # .unwrap()
2650/// # .https_only()
2651/// # .enable_http2()
2652/// # .build();
2653///
2654/// # let executor = hyper_util::rt::TokioExecutor::new();
2655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2656/// # secret,
2657/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2658/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2659/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2660/// # ),
2661/// # ).build().await.unwrap();
2662///
2663/// # let client = hyper_util::client::legacy::Client::builder(
2664/// # hyper_util::rt::TokioExecutor::new()
2665/// # )
2666/// # .build(
2667/// # hyper_rustls::HttpsConnectorBuilder::new()
2668/// # .with_native_roots()
2669/// # .unwrap()
2670/// # .https_or_http()
2671/// # .enable_http2()
2672/// # .build()
2673/// # );
2674/// # let mut hub = AdSenseHost::new(client, auth);
2675/// // You can configure optional parameters by calling the respective setters at will, and
2676/// // execute the final call using `doit()`.
2677/// // Values shown here are possibly random and not representative !
2678/// let result = hub.accounts().adunits_get("accountId", "adClientId", "adUnitId")
2679/// .doit().await;
2680/// # }
2681/// ```
2682pub struct AccountAdunitGetCall<'a, C>
2683where
2684 C: 'a,
2685{
2686 hub: &'a AdSenseHost<C>,
2687 _account_id: String,
2688 _ad_client_id: String,
2689 _ad_unit_id: String,
2690 _delegate: Option<&'a mut dyn common::Delegate>,
2691 _additional_params: HashMap<String, String>,
2692 _scopes: BTreeSet<String>,
2693}
2694
2695impl<'a, C> common::CallBuilder for AccountAdunitGetCall<'a, C> {}
2696
2697impl<'a, C> AccountAdunitGetCall<'a, C>
2698where
2699 C: common::Connector,
2700{
2701 /// Perform the operation you have build so far.
2702 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
2703 use std::borrow::Cow;
2704 use std::io::{Read, Seek};
2705
2706 use common::{url::Params, ToParts};
2707 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2708
2709 let mut dd = common::DefaultDelegate;
2710 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2711 dlg.begin(common::MethodInfo {
2712 id: "adsensehost.accounts.adunits.get",
2713 http_method: hyper::Method::GET,
2714 });
2715
2716 for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
2717 if self._additional_params.contains_key(field) {
2718 dlg.finished(false);
2719 return Err(common::Error::FieldClash(field));
2720 }
2721 }
2722
2723 let mut params = Params::with_capacity(5 + self._additional_params.len());
2724 params.push("accountId", self._account_id);
2725 params.push("adClientId", self._ad_client_id);
2726 params.push("adUnitId", self._ad_unit_id);
2727
2728 params.extend(self._additional_params.iter());
2729
2730 params.push("alt", "json");
2731 let mut url = self.hub._base_url.clone()
2732 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}";
2733 if self._scopes.is_empty() {
2734 self._scopes.insert(Scope::Full.as_ref().to_string());
2735 }
2736
2737 #[allow(clippy::single_element_loop)]
2738 for &(find_this, param_name) in [
2739 ("{accountId}", "accountId"),
2740 ("{adClientId}", "adClientId"),
2741 ("{adUnitId}", "adUnitId"),
2742 ]
2743 .iter()
2744 {
2745 url = params.uri_replacement(url, param_name, find_this, false);
2746 }
2747 {
2748 let to_remove = ["adUnitId", "adClientId", "accountId"];
2749 params.remove_params(&to_remove);
2750 }
2751
2752 let url = params.parse_with_url(&url);
2753
2754 loop {
2755 let token = match self
2756 .hub
2757 .auth
2758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2759 .await
2760 {
2761 Ok(token) => token,
2762 Err(e) => match dlg.token(e) {
2763 Ok(token) => token,
2764 Err(e) => {
2765 dlg.finished(false);
2766 return Err(common::Error::MissingToken(e));
2767 }
2768 },
2769 };
2770 let mut req_result = {
2771 let client = &self.hub.client;
2772 dlg.pre_request();
2773 let mut req_builder = hyper::Request::builder()
2774 .method(hyper::Method::GET)
2775 .uri(url.as_str())
2776 .header(USER_AGENT, self.hub._user_agent.clone());
2777
2778 if let Some(token) = token.as_ref() {
2779 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2780 }
2781
2782 let request = req_builder
2783 .header(CONTENT_LENGTH, 0_u64)
2784 .body(common::to_body::<String>(None));
2785
2786 client.request(request.unwrap()).await
2787 };
2788
2789 match req_result {
2790 Err(err) => {
2791 if let common::Retry::After(d) = dlg.http_error(&err) {
2792 sleep(d).await;
2793 continue;
2794 }
2795 dlg.finished(false);
2796 return Err(common::Error::HttpError(err));
2797 }
2798 Ok(res) => {
2799 let (mut parts, body) = res.into_parts();
2800 let mut body = common::Body::new(body);
2801 if !parts.status.is_success() {
2802 let bytes = common::to_bytes(body).await.unwrap_or_default();
2803 let error = serde_json::from_str(&common::to_string(&bytes));
2804 let response = common::to_response(parts, bytes.into());
2805
2806 if let common::Retry::After(d) =
2807 dlg.http_failure(&response, error.as_ref().ok())
2808 {
2809 sleep(d).await;
2810 continue;
2811 }
2812
2813 dlg.finished(false);
2814
2815 return Err(match error {
2816 Ok(value) => common::Error::BadRequest(value),
2817 _ => common::Error::Failure(response),
2818 });
2819 }
2820 let response = {
2821 let bytes = common::to_bytes(body).await.unwrap_or_default();
2822 let encoded = common::to_string(&bytes);
2823 match serde_json::from_str(&encoded) {
2824 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2825 Err(error) => {
2826 dlg.response_json_decode_error(&encoded, &error);
2827 return Err(common::Error::JsonDecodeError(
2828 encoded.to_string(),
2829 error,
2830 ));
2831 }
2832 }
2833 };
2834
2835 dlg.finished(true);
2836 return Ok(response);
2837 }
2838 }
2839 }
2840 }
2841
2842 /// Account which contains the ad unit.
2843 ///
2844 /// Sets the *account id* path property to the given value.
2845 ///
2846 /// Even though the property as already been set when instantiating this call,
2847 /// we provide this method for API completeness.
2848 pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
2849 self._account_id = new_value.to_string();
2850 self
2851 }
2852 /// Ad client for which to get ad unit.
2853 ///
2854 /// Sets the *ad client id* path property to the given value.
2855 ///
2856 /// Even though the property as already been set when instantiating this call,
2857 /// we provide this method for API completeness.
2858 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
2859 self._ad_client_id = new_value.to_string();
2860 self
2861 }
2862 /// Ad unit to get.
2863 ///
2864 /// Sets the *ad unit id* path property to the given value.
2865 ///
2866 /// Even though the property as already been set when instantiating this call,
2867 /// we provide this method for API completeness.
2868 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C> {
2869 self._ad_unit_id = new_value.to_string();
2870 self
2871 }
2872 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2873 /// while executing the actual API request.
2874 ///
2875 /// ````text
2876 /// It should be used to handle progress information, and to implement a certain level of resilience.
2877 /// ````
2878 ///
2879 /// Sets the *delegate* property to the given value.
2880 pub fn delegate(
2881 mut self,
2882 new_value: &'a mut dyn common::Delegate,
2883 ) -> AccountAdunitGetCall<'a, C> {
2884 self._delegate = Some(new_value);
2885 self
2886 }
2887
2888 /// Set any additional parameter of the query string used in the request.
2889 /// It should be used to set parameters which are not yet available through their own
2890 /// setters.
2891 ///
2892 /// Please note that this method must not be used to set any of the known parameters
2893 /// which have their own setter method. If done anyway, the request will fail.
2894 ///
2895 /// # Additional Parameters
2896 ///
2897 /// * *alt* (query-string) - Data format for the response.
2898 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2899 /// * *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.
2900 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2901 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2902 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2903 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2904 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitGetCall<'a, C>
2905 where
2906 T: AsRef<str>,
2907 {
2908 self._additional_params
2909 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2910 self
2911 }
2912
2913 /// Identifies the authorization scope for the method you are building.
2914 ///
2915 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2916 /// [`Scope::Full`].
2917 ///
2918 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2919 /// tokens for more than one scope.
2920 ///
2921 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2922 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2923 /// sufficient, a read-write scope will do as well.
2924 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitGetCall<'a, C>
2925 where
2926 St: AsRef<str>,
2927 {
2928 self._scopes.insert(String::from(scope.as_ref()));
2929 self
2930 }
2931 /// Identifies the authorization scope(s) for the method you are building.
2932 ///
2933 /// See [`Self::add_scope()`] for details.
2934 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitGetCall<'a, C>
2935 where
2936 I: IntoIterator<Item = St>,
2937 St: AsRef<str>,
2938 {
2939 self._scopes
2940 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2941 self
2942 }
2943
2944 /// Removes all scopes, and no default scope will be used either.
2945 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2946 /// for details).
2947 pub fn clear_scopes(mut self) -> AccountAdunitGetCall<'a, C> {
2948 self._scopes.clear();
2949 self
2950 }
2951}
2952
2953/// Get ad code for the specified ad unit, attaching the specified host custom channels.
2954///
2955/// A builder for the *adunits.getAdCode* method supported by a *account* resource.
2956/// It is not used directly, but through a [`AccountMethods`] instance.
2957///
2958/// # Example
2959///
2960/// Instantiate a resource method builder
2961///
2962/// ```test_harness,no_run
2963/// # extern crate hyper;
2964/// # extern crate hyper_rustls;
2965/// # extern crate google_adsensehost4d1 as adsensehost4d1;
2966/// # async fn dox() {
2967/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2968///
2969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2970/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2971/// # .with_native_roots()
2972/// # .unwrap()
2973/// # .https_only()
2974/// # .enable_http2()
2975/// # .build();
2976///
2977/// # let executor = hyper_util::rt::TokioExecutor::new();
2978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2979/// # secret,
2980/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2981/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2982/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2983/// # ),
2984/// # ).build().await.unwrap();
2985///
2986/// # let client = hyper_util::client::legacy::Client::builder(
2987/// # hyper_util::rt::TokioExecutor::new()
2988/// # )
2989/// # .build(
2990/// # hyper_rustls::HttpsConnectorBuilder::new()
2991/// # .with_native_roots()
2992/// # .unwrap()
2993/// # .https_or_http()
2994/// # .enable_http2()
2995/// # .build()
2996/// # );
2997/// # let mut hub = AdSenseHost::new(client, auth);
2998/// // You can configure optional parameters by calling the respective setters at will, and
2999/// // execute the final call using `doit()`.
3000/// // Values shown here are possibly random and not representative !
3001/// let result = hub.accounts().adunits_get_ad_code("accountId", "adClientId", "adUnitId")
3002/// .add_host_custom_channel_id("et")
3003/// .doit().await;
3004/// # }
3005/// ```
3006pub struct AccountAdunitGetAdCodeCall<'a, C>
3007where
3008 C: 'a,
3009{
3010 hub: &'a AdSenseHost<C>,
3011 _account_id: String,
3012 _ad_client_id: String,
3013 _ad_unit_id: String,
3014 _host_custom_channel_id: Vec<String>,
3015 _delegate: Option<&'a mut dyn common::Delegate>,
3016 _additional_params: HashMap<String, String>,
3017 _scopes: BTreeSet<String>,
3018}
3019
3020impl<'a, C> common::CallBuilder for AccountAdunitGetAdCodeCall<'a, C> {}
3021
3022impl<'a, C> AccountAdunitGetAdCodeCall<'a, C>
3023where
3024 C: common::Connector,
3025{
3026 /// Perform the operation you have build so far.
3027 pub async fn doit(mut self) -> common::Result<(common::Response, AdCode)> {
3028 use std::borrow::Cow;
3029 use std::io::{Read, Seek};
3030
3031 use common::{url::Params, ToParts};
3032 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3033
3034 let mut dd = common::DefaultDelegate;
3035 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3036 dlg.begin(common::MethodInfo {
3037 id: "adsensehost.accounts.adunits.getAdCode",
3038 http_method: hyper::Method::GET,
3039 });
3040
3041 for &field in [
3042 "alt",
3043 "accountId",
3044 "adClientId",
3045 "adUnitId",
3046 "hostCustomChannelId",
3047 ]
3048 .iter()
3049 {
3050 if self._additional_params.contains_key(field) {
3051 dlg.finished(false);
3052 return Err(common::Error::FieldClash(field));
3053 }
3054 }
3055
3056 let mut params = Params::with_capacity(6 + self._additional_params.len());
3057 params.push("accountId", self._account_id);
3058 params.push("adClientId", self._ad_client_id);
3059 params.push("adUnitId", self._ad_unit_id);
3060 if !self._host_custom_channel_id.is_empty() {
3061 for f in self._host_custom_channel_id.iter() {
3062 params.push("hostCustomChannelId", f);
3063 }
3064 }
3065
3066 params.extend(self._additional_params.iter());
3067
3068 params.push("alt", "json");
3069 let mut url = self.hub._base_url.clone()
3070 + "accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}/adcode";
3071 if self._scopes.is_empty() {
3072 self._scopes.insert(Scope::Full.as_ref().to_string());
3073 }
3074
3075 #[allow(clippy::single_element_loop)]
3076 for &(find_this, param_name) in [
3077 ("{accountId}", "accountId"),
3078 ("{adClientId}", "adClientId"),
3079 ("{adUnitId}", "adUnitId"),
3080 ]
3081 .iter()
3082 {
3083 url = params.uri_replacement(url, param_name, find_this, false);
3084 }
3085 {
3086 let to_remove = ["adUnitId", "adClientId", "accountId"];
3087 params.remove_params(&to_remove);
3088 }
3089
3090 let url = params.parse_with_url(&url);
3091
3092 loop {
3093 let token = match self
3094 .hub
3095 .auth
3096 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3097 .await
3098 {
3099 Ok(token) => token,
3100 Err(e) => match dlg.token(e) {
3101 Ok(token) => token,
3102 Err(e) => {
3103 dlg.finished(false);
3104 return Err(common::Error::MissingToken(e));
3105 }
3106 },
3107 };
3108 let mut req_result = {
3109 let client = &self.hub.client;
3110 dlg.pre_request();
3111 let mut req_builder = hyper::Request::builder()
3112 .method(hyper::Method::GET)
3113 .uri(url.as_str())
3114 .header(USER_AGENT, self.hub._user_agent.clone());
3115
3116 if let Some(token) = token.as_ref() {
3117 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3118 }
3119
3120 let request = req_builder
3121 .header(CONTENT_LENGTH, 0_u64)
3122 .body(common::to_body::<String>(None));
3123
3124 client.request(request.unwrap()).await
3125 };
3126
3127 match req_result {
3128 Err(err) => {
3129 if let common::Retry::After(d) = dlg.http_error(&err) {
3130 sleep(d).await;
3131 continue;
3132 }
3133 dlg.finished(false);
3134 return Err(common::Error::HttpError(err));
3135 }
3136 Ok(res) => {
3137 let (mut parts, body) = res.into_parts();
3138 let mut body = common::Body::new(body);
3139 if !parts.status.is_success() {
3140 let bytes = common::to_bytes(body).await.unwrap_or_default();
3141 let error = serde_json::from_str(&common::to_string(&bytes));
3142 let response = common::to_response(parts, bytes.into());
3143
3144 if let common::Retry::After(d) =
3145 dlg.http_failure(&response, error.as_ref().ok())
3146 {
3147 sleep(d).await;
3148 continue;
3149 }
3150
3151 dlg.finished(false);
3152
3153 return Err(match error {
3154 Ok(value) => common::Error::BadRequest(value),
3155 _ => common::Error::Failure(response),
3156 });
3157 }
3158 let response = {
3159 let bytes = common::to_bytes(body).await.unwrap_or_default();
3160 let encoded = common::to_string(&bytes);
3161 match serde_json::from_str(&encoded) {
3162 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3163 Err(error) => {
3164 dlg.response_json_decode_error(&encoded, &error);
3165 return Err(common::Error::JsonDecodeError(
3166 encoded.to_string(),
3167 error,
3168 ));
3169 }
3170 }
3171 };
3172
3173 dlg.finished(true);
3174 return Ok(response);
3175 }
3176 }
3177 }
3178 }
3179
3180 /// Account which contains the ad client.
3181 ///
3182 /// Sets the *account id* path property to the given value.
3183 ///
3184 /// Even though the property as already been set when instantiating this call,
3185 /// we provide this method for API completeness.
3186 pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
3187 self._account_id = new_value.to_string();
3188 self
3189 }
3190 /// Ad client with contains the ad unit.
3191 ///
3192 /// Sets the *ad client id* path property to the given value.
3193 ///
3194 /// Even though the property as already been set when instantiating this call,
3195 /// we provide this method for API completeness.
3196 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
3197 self._ad_client_id = new_value.to_string();
3198 self
3199 }
3200 /// Ad unit to get the code for.
3201 ///
3202 /// Sets the *ad unit id* path property to the given value.
3203 ///
3204 /// Even though the property as already been set when instantiating this call,
3205 /// we provide this method for API completeness.
3206 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C> {
3207 self._ad_unit_id = new_value.to_string();
3208 self
3209 }
3210 /// Host custom channel to attach to the ad code.
3211 ///
3212 /// Append the given value to the *host custom channel id* query property.
3213 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
3214 pub fn add_host_custom_channel_id(
3215 mut self,
3216 new_value: &str,
3217 ) -> AccountAdunitGetAdCodeCall<'a, C> {
3218 self._host_custom_channel_id.push(new_value.to_string());
3219 self
3220 }
3221 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3222 /// while executing the actual API request.
3223 ///
3224 /// ````text
3225 /// It should be used to handle progress information, and to implement a certain level of resilience.
3226 /// ````
3227 ///
3228 /// Sets the *delegate* property to the given value.
3229 pub fn delegate(
3230 mut self,
3231 new_value: &'a mut dyn common::Delegate,
3232 ) -> AccountAdunitGetAdCodeCall<'a, C> {
3233 self._delegate = Some(new_value);
3234 self
3235 }
3236
3237 /// Set any additional parameter of the query string used in the request.
3238 /// It should be used to set parameters which are not yet available through their own
3239 /// setters.
3240 ///
3241 /// Please note that this method must not be used to set any of the known parameters
3242 /// which have their own setter method. If done anyway, the request will fail.
3243 ///
3244 /// # Additional Parameters
3245 ///
3246 /// * *alt* (query-string) - Data format for the response.
3247 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3248 /// * *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.
3249 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3250 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3251 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3252 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3253 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitGetAdCodeCall<'a, C>
3254 where
3255 T: AsRef<str>,
3256 {
3257 self._additional_params
3258 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3259 self
3260 }
3261
3262 /// Identifies the authorization scope for the method you are building.
3263 ///
3264 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3265 /// [`Scope::Full`].
3266 ///
3267 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3268 /// tokens for more than one scope.
3269 ///
3270 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3271 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3272 /// sufficient, a read-write scope will do as well.
3273 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitGetAdCodeCall<'a, C>
3274 where
3275 St: AsRef<str>,
3276 {
3277 self._scopes.insert(String::from(scope.as_ref()));
3278 self
3279 }
3280 /// Identifies the authorization scope(s) for the method you are building.
3281 ///
3282 /// See [`Self::add_scope()`] for details.
3283 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitGetAdCodeCall<'a, C>
3284 where
3285 I: IntoIterator<Item = St>,
3286 St: AsRef<str>,
3287 {
3288 self._scopes
3289 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3290 self
3291 }
3292
3293 /// Removes all scopes, and no default scope will be used either.
3294 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3295 /// for details).
3296 pub fn clear_scopes(mut self) -> AccountAdunitGetAdCodeCall<'a, C> {
3297 self._scopes.clear();
3298 self
3299 }
3300}
3301
3302/// Insert the supplied ad unit into the specified publisher AdSense account.
3303///
3304/// A builder for the *adunits.insert* method supported by a *account* resource.
3305/// It is not used directly, but through a [`AccountMethods`] instance.
3306///
3307/// # Example
3308///
3309/// Instantiate a resource method builder
3310///
3311/// ```test_harness,no_run
3312/// # extern crate hyper;
3313/// # extern crate hyper_rustls;
3314/// # extern crate google_adsensehost4d1 as adsensehost4d1;
3315/// use adsensehost4d1::api::AdUnit;
3316/// # async fn dox() {
3317/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3318///
3319/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3320/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3321/// # .with_native_roots()
3322/// # .unwrap()
3323/// # .https_only()
3324/// # .enable_http2()
3325/// # .build();
3326///
3327/// # let executor = hyper_util::rt::TokioExecutor::new();
3328/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3329/// # secret,
3330/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3331/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3332/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3333/// # ),
3334/// # ).build().await.unwrap();
3335///
3336/// # let client = hyper_util::client::legacy::Client::builder(
3337/// # hyper_util::rt::TokioExecutor::new()
3338/// # )
3339/// # .build(
3340/// # hyper_rustls::HttpsConnectorBuilder::new()
3341/// # .with_native_roots()
3342/// # .unwrap()
3343/// # .https_or_http()
3344/// # .enable_http2()
3345/// # .build()
3346/// # );
3347/// # let mut hub = AdSenseHost::new(client, auth);
3348/// // As the method needs a request, you would usually fill it with the desired information
3349/// // into the respective structure. Some of the parts shown here might not be applicable !
3350/// // Values shown here are possibly random and not representative !
3351/// let mut req = AdUnit::default();
3352///
3353/// // You can configure optional parameters by calling the respective setters at will, and
3354/// // execute the final call using `doit()`.
3355/// // Values shown here are possibly random and not representative !
3356/// let result = hub.accounts().adunits_insert(req, "accountId", "adClientId")
3357/// .doit().await;
3358/// # }
3359/// ```
3360pub struct AccountAdunitInsertCall<'a, C>
3361where
3362 C: 'a,
3363{
3364 hub: &'a AdSenseHost<C>,
3365 _request: AdUnit,
3366 _account_id: String,
3367 _ad_client_id: String,
3368 _delegate: Option<&'a mut dyn common::Delegate>,
3369 _additional_params: HashMap<String, String>,
3370 _scopes: BTreeSet<String>,
3371}
3372
3373impl<'a, C> common::CallBuilder for AccountAdunitInsertCall<'a, C> {}
3374
3375impl<'a, C> AccountAdunitInsertCall<'a, C>
3376where
3377 C: common::Connector,
3378{
3379 /// Perform the operation you have build so far.
3380 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
3381 use std::borrow::Cow;
3382 use std::io::{Read, Seek};
3383
3384 use common::{url::Params, ToParts};
3385 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3386
3387 let mut dd = common::DefaultDelegate;
3388 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3389 dlg.begin(common::MethodInfo {
3390 id: "adsensehost.accounts.adunits.insert",
3391 http_method: hyper::Method::POST,
3392 });
3393
3394 for &field in ["alt", "accountId", "adClientId"].iter() {
3395 if self._additional_params.contains_key(field) {
3396 dlg.finished(false);
3397 return Err(common::Error::FieldClash(field));
3398 }
3399 }
3400
3401 let mut params = Params::with_capacity(5 + self._additional_params.len());
3402 params.push("accountId", self._account_id);
3403 params.push("adClientId", self._ad_client_id);
3404
3405 params.extend(self._additional_params.iter());
3406
3407 params.push("alt", "json");
3408 let mut url =
3409 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adunits";
3410 if self._scopes.is_empty() {
3411 self._scopes.insert(Scope::Full.as_ref().to_string());
3412 }
3413
3414 #[allow(clippy::single_element_loop)]
3415 for &(find_this, param_name) in
3416 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
3417 {
3418 url = params.uri_replacement(url, param_name, find_this, false);
3419 }
3420 {
3421 let to_remove = ["adClientId", "accountId"];
3422 params.remove_params(&to_remove);
3423 }
3424
3425 let url = params.parse_with_url(&url);
3426
3427 let mut json_mime_type = mime::APPLICATION_JSON;
3428 let mut request_value_reader = {
3429 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3430 common::remove_json_null_values(&mut value);
3431 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3432 serde_json::to_writer(&mut dst, &value).unwrap();
3433 dst
3434 };
3435 let request_size = request_value_reader
3436 .seek(std::io::SeekFrom::End(0))
3437 .unwrap();
3438 request_value_reader
3439 .seek(std::io::SeekFrom::Start(0))
3440 .unwrap();
3441
3442 loop {
3443 let token = match self
3444 .hub
3445 .auth
3446 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3447 .await
3448 {
3449 Ok(token) => token,
3450 Err(e) => match dlg.token(e) {
3451 Ok(token) => token,
3452 Err(e) => {
3453 dlg.finished(false);
3454 return Err(common::Error::MissingToken(e));
3455 }
3456 },
3457 };
3458 request_value_reader
3459 .seek(std::io::SeekFrom::Start(0))
3460 .unwrap();
3461 let mut req_result = {
3462 let client = &self.hub.client;
3463 dlg.pre_request();
3464 let mut req_builder = hyper::Request::builder()
3465 .method(hyper::Method::POST)
3466 .uri(url.as_str())
3467 .header(USER_AGENT, self.hub._user_agent.clone());
3468
3469 if let Some(token) = token.as_ref() {
3470 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3471 }
3472
3473 let request = req_builder
3474 .header(CONTENT_TYPE, json_mime_type.to_string())
3475 .header(CONTENT_LENGTH, request_size as u64)
3476 .body(common::to_body(
3477 request_value_reader.get_ref().clone().into(),
3478 ));
3479
3480 client.request(request.unwrap()).await
3481 };
3482
3483 match req_result {
3484 Err(err) => {
3485 if let common::Retry::After(d) = dlg.http_error(&err) {
3486 sleep(d).await;
3487 continue;
3488 }
3489 dlg.finished(false);
3490 return Err(common::Error::HttpError(err));
3491 }
3492 Ok(res) => {
3493 let (mut parts, body) = res.into_parts();
3494 let mut body = common::Body::new(body);
3495 if !parts.status.is_success() {
3496 let bytes = common::to_bytes(body).await.unwrap_or_default();
3497 let error = serde_json::from_str(&common::to_string(&bytes));
3498 let response = common::to_response(parts, bytes.into());
3499
3500 if let common::Retry::After(d) =
3501 dlg.http_failure(&response, error.as_ref().ok())
3502 {
3503 sleep(d).await;
3504 continue;
3505 }
3506
3507 dlg.finished(false);
3508
3509 return Err(match error {
3510 Ok(value) => common::Error::BadRequest(value),
3511 _ => common::Error::Failure(response),
3512 });
3513 }
3514 let response = {
3515 let bytes = common::to_bytes(body).await.unwrap_or_default();
3516 let encoded = common::to_string(&bytes);
3517 match serde_json::from_str(&encoded) {
3518 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3519 Err(error) => {
3520 dlg.response_json_decode_error(&encoded, &error);
3521 return Err(common::Error::JsonDecodeError(
3522 encoded.to_string(),
3523 error,
3524 ));
3525 }
3526 }
3527 };
3528
3529 dlg.finished(true);
3530 return Ok(response);
3531 }
3532 }
3533 }
3534 }
3535
3536 ///
3537 /// Sets the *request* property to the given value.
3538 ///
3539 /// Even though the property as already been set when instantiating this call,
3540 /// we provide this method for API completeness.
3541 pub fn request(mut self, new_value: AdUnit) -> AccountAdunitInsertCall<'a, C> {
3542 self._request = new_value;
3543 self
3544 }
3545 /// Account which will contain the ad unit.
3546 ///
3547 /// Sets the *account id* path property to the given value.
3548 ///
3549 /// Even though the property as already been set when instantiating this call,
3550 /// we provide this method for API completeness.
3551 pub fn account_id(mut self, new_value: &str) -> AccountAdunitInsertCall<'a, C> {
3552 self._account_id = new_value.to_string();
3553 self
3554 }
3555 /// Ad client into which to insert the ad unit.
3556 ///
3557 /// Sets the *ad client id* path property to the given value.
3558 ///
3559 /// Even though the property as already been set when instantiating this call,
3560 /// we provide this method for API completeness.
3561 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitInsertCall<'a, C> {
3562 self._ad_client_id = new_value.to_string();
3563 self
3564 }
3565 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3566 /// while executing the actual API request.
3567 ///
3568 /// ````text
3569 /// It should be used to handle progress information, and to implement a certain level of resilience.
3570 /// ````
3571 ///
3572 /// Sets the *delegate* property to the given value.
3573 pub fn delegate(
3574 mut self,
3575 new_value: &'a mut dyn common::Delegate,
3576 ) -> AccountAdunitInsertCall<'a, C> {
3577 self._delegate = Some(new_value);
3578 self
3579 }
3580
3581 /// Set any additional parameter of the query string used in the request.
3582 /// It should be used to set parameters which are not yet available through their own
3583 /// setters.
3584 ///
3585 /// Please note that this method must not be used to set any of the known parameters
3586 /// which have their own setter method. If done anyway, the request will fail.
3587 ///
3588 /// # Additional Parameters
3589 ///
3590 /// * *alt* (query-string) - Data format for the response.
3591 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3592 /// * *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.
3593 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3594 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3595 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3596 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3597 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitInsertCall<'a, C>
3598 where
3599 T: AsRef<str>,
3600 {
3601 self._additional_params
3602 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3603 self
3604 }
3605
3606 /// Identifies the authorization scope for the method you are building.
3607 ///
3608 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3609 /// [`Scope::Full`].
3610 ///
3611 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3612 /// tokens for more than one scope.
3613 ///
3614 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3615 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3616 /// sufficient, a read-write scope will do as well.
3617 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitInsertCall<'a, C>
3618 where
3619 St: AsRef<str>,
3620 {
3621 self._scopes.insert(String::from(scope.as_ref()));
3622 self
3623 }
3624 /// Identifies the authorization scope(s) for the method you are building.
3625 ///
3626 /// See [`Self::add_scope()`] for details.
3627 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitInsertCall<'a, C>
3628 where
3629 I: IntoIterator<Item = St>,
3630 St: AsRef<str>,
3631 {
3632 self._scopes
3633 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3634 self
3635 }
3636
3637 /// Removes all scopes, and no default scope will be used either.
3638 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3639 /// for details).
3640 pub fn clear_scopes(mut self) -> AccountAdunitInsertCall<'a, C> {
3641 self._scopes.clear();
3642 self
3643 }
3644}
3645
3646/// List all ad units in the specified publisher's AdSense account.
3647///
3648/// A builder for the *adunits.list* method supported by a *account* resource.
3649/// It is not used directly, but through a [`AccountMethods`] instance.
3650///
3651/// # Example
3652///
3653/// Instantiate a resource method builder
3654///
3655/// ```test_harness,no_run
3656/// # extern crate hyper;
3657/// # extern crate hyper_rustls;
3658/// # extern crate google_adsensehost4d1 as adsensehost4d1;
3659/// # async fn dox() {
3660/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3661///
3662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3663/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3664/// # .with_native_roots()
3665/// # .unwrap()
3666/// # .https_only()
3667/// # .enable_http2()
3668/// # .build();
3669///
3670/// # let executor = hyper_util::rt::TokioExecutor::new();
3671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3672/// # secret,
3673/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3674/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3675/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3676/// # ),
3677/// # ).build().await.unwrap();
3678///
3679/// # let client = hyper_util::client::legacy::Client::builder(
3680/// # hyper_util::rt::TokioExecutor::new()
3681/// # )
3682/// # .build(
3683/// # hyper_rustls::HttpsConnectorBuilder::new()
3684/// # .with_native_roots()
3685/// # .unwrap()
3686/// # .https_or_http()
3687/// # .enable_http2()
3688/// # .build()
3689/// # );
3690/// # let mut hub = AdSenseHost::new(client, auth);
3691/// // You can configure optional parameters by calling the respective setters at will, and
3692/// // execute the final call using `doit()`.
3693/// // Values shown here are possibly random and not representative !
3694/// let result = hub.accounts().adunits_list("accountId", "adClientId")
3695/// .page_token("erat")
3696/// .max_results(8)
3697/// .include_inactive(false)
3698/// .doit().await;
3699/// # }
3700/// ```
3701pub struct AccountAdunitListCall<'a, C>
3702where
3703 C: 'a,
3704{
3705 hub: &'a AdSenseHost<C>,
3706 _account_id: String,
3707 _ad_client_id: String,
3708 _page_token: Option<String>,
3709 _max_results: Option<u32>,
3710 _include_inactive: Option<bool>,
3711 _delegate: Option<&'a mut dyn common::Delegate>,
3712 _additional_params: HashMap<String, String>,
3713 _scopes: BTreeSet<String>,
3714}
3715
3716impl<'a, C> common::CallBuilder for AccountAdunitListCall<'a, C> {}
3717
3718impl<'a, C> AccountAdunitListCall<'a, C>
3719where
3720 C: common::Connector,
3721{
3722 /// Perform the operation you have build so far.
3723 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnits)> {
3724 use std::borrow::Cow;
3725 use std::io::{Read, Seek};
3726
3727 use common::{url::Params, ToParts};
3728 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3729
3730 let mut dd = common::DefaultDelegate;
3731 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3732 dlg.begin(common::MethodInfo {
3733 id: "adsensehost.accounts.adunits.list",
3734 http_method: hyper::Method::GET,
3735 });
3736
3737 for &field in [
3738 "alt",
3739 "accountId",
3740 "adClientId",
3741 "pageToken",
3742 "maxResults",
3743 "includeInactive",
3744 ]
3745 .iter()
3746 {
3747 if self._additional_params.contains_key(field) {
3748 dlg.finished(false);
3749 return Err(common::Error::FieldClash(field));
3750 }
3751 }
3752
3753 let mut params = Params::with_capacity(7 + self._additional_params.len());
3754 params.push("accountId", self._account_id);
3755 params.push("adClientId", self._ad_client_id);
3756 if let Some(value) = self._page_token.as_ref() {
3757 params.push("pageToken", value);
3758 }
3759 if let Some(value) = self._max_results.as_ref() {
3760 params.push("maxResults", value.to_string());
3761 }
3762 if let Some(value) = self._include_inactive.as_ref() {
3763 params.push("includeInactive", value.to_string());
3764 }
3765
3766 params.extend(self._additional_params.iter());
3767
3768 params.push("alt", "json");
3769 let mut url =
3770 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adunits";
3771 if self._scopes.is_empty() {
3772 self._scopes.insert(Scope::Full.as_ref().to_string());
3773 }
3774
3775 #[allow(clippy::single_element_loop)]
3776 for &(find_this, param_name) in
3777 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
3778 {
3779 url = params.uri_replacement(url, param_name, find_this, false);
3780 }
3781 {
3782 let to_remove = ["adClientId", "accountId"];
3783 params.remove_params(&to_remove);
3784 }
3785
3786 let url = params.parse_with_url(&url);
3787
3788 loop {
3789 let token = match self
3790 .hub
3791 .auth
3792 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3793 .await
3794 {
3795 Ok(token) => token,
3796 Err(e) => match dlg.token(e) {
3797 Ok(token) => token,
3798 Err(e) => {
3799 dlg.finished(false);
3800 return Err(common::Error::MissingToken(e));
3801 }
3802 },
3803 };
3804 let mut req_result = {
3805 let client = &self.hub.client;
3806 dlg.pre_request();
3807 let mut req_builder = hyper::Request::builder()
3808 .method(hyper::Method::GET)
3809 .uri(url.as_str())
3810 .header(USER_AGENT, self.hub._user_agent.clone());
3811
3812 if let Some(token) = token.as_ref() {
3813 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3814 }
3815
3816 let request = req_builder
3817 .header(CONTENT_LENGTH, 0_u64)
3818 .body(common::to_body::<String>(None));
3819
3820 client.request(request.unwrap()).await
3821 };
3822
3823 match req_result {
3824 Err(err) => {
3825 if let common::Retry::After(d) = dlg.http_error(&err) {
3826 sleep(d).await;
3827 continue;
3828 }
3829 dlg.finished(false);
3830 return Err(common::Error::HttpError(err));
3831 }
3832 Ok(res) => {
3833 let (mut parts, body) = res.into_parts();
3834 let mut body = common::Body::new(body);
3835 if !parts.status.is_success() {
3836 let bytes = common::to_bytes(body).await.unwrap_or_default();
3837 let error = serde_json::from_str(&common::to_string(&bytes));
3838 let response = common::to_response(parts, bytes.into());
3839
3840 if let common::Retry::After(d) =
3841 dlg.http_failure(&response, error.as_ref().ok())
3842 {
3843 sleep(d).await;
3844 continue;
3845 }
3846
3847 dlg.finished(false);
3848
3849 return Err(match error {
3850 Ok(value) => common::Error::BadRequest(value),
3851 _ => common::Error::Failure(response),
3852 });
3853 }
3854 let response = {
3855 let bytes = common::to_bytes(body).await.unwrap_or_default();
3856 let encoded = common::to_string(&bytes);
3857 match serde_json::from_str(&encoded) {
3858 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3859 Err(error) => {
3860 dlg.response_json_decode_error(&encoded, &error);
3861 return Err(common::Error::JsonDecodeError(
3862 encoded.to_string(),
3863 error,
3864 ));
3865 }
3866 }
3867 };
3868
3869 dlg.finished(true);
3870 return Ok(response);
3871 }
3872 }
3873 }
3874 }
3875
3876 /// Account which contains the ad client.
3877 ///
3878 /// Sets the *account id* path property to the given value.
3879 ///
3880 /// Even though the property as already been set when instantiating this call,
3881 /// we provide this method for API completeness.
3882 pub fn account_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
3883 self._account_id = new_value.to_string();
3884 self
3885 }
3886 /// Ad client for which to list ad units.
3887 ///
3888 /// Sets the *ad client id* path property to the given value.
3889 ///
3890 /// Even though the property as already been set when instantiating this call,
3891 /// we provide this method for API completeness.
3892 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
3893 self._ad_client_id = new_value.to_string();
3894 self
3895 }
3896 /// 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.
3897 ///
3898 /// Sets the *page token* query property to the given value.
3899 pub fn page_token(mut self, new_value: &str) -> AccountAdunitListCall<'a, C> {
3900 self._page_token = Some(new_value.to_string());
3901 self
3902 }
3903 /// The maximum number of ad units to include in the response, used for paging.
3904 ///
3905 /// Sets the *max results* query property to the given value.
3906 pub fn max_results(mut self, new_value: u32) -> AccountAdunitListCall<'a, C> {
3907 self._max_results = Some(new_value);
3908 self
3909 }
3910 /// Whether to include inactive ad units. Default: true.
3911 ///
3912 /// Sets the *include inactive* query property to the given value.
3913 pub fn include_inactive(mut self, new_value: bool) -> AccountAdunitListCall<'a, C> {
3914 self._include_inactive = Some(new_value);
3915 self
3916 }
3917 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3918 /// while executing the actual API request.
3919 ///
3920 /// ````text
3921 /// It should be used to handle progress information, and to implement a certain level of resilience.
3922 /// ````
3923 ///
3924 /// Sets the *delegate* property to the given value.
3925 pub fn delegate(
3926 mut self,
3927 new_value: &'a mut dyn common::Delegate,
3928 ) -> AccountAdunitListCall<'a, C> {
3929 self._delegate = Some(new_value);
3930 self
3931 }
3932
3933 /// Set any additional parameter of the query string used in the request.
3934 /// It should be used to set parameters which are not yet available through their own
3935 /// setters.
3936 ///
3937 /// Please note that this method must not be used to set any of the known parameters
3938 /// which have their own setter method. If done anyway, the request will fail.
3939 ///
3940 /// # Additional Parameters
3941 ///
3942 /// * *alt* (query-string) - Data format for the response.
3943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3944 /// * *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.
3945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3947 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3948 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3949 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitListCall<'a, C>
3950 where
3951 T: AsRef<str>,
3952 {
3953 self._additional_params
3954 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3955 self
3956 }
3957
3958 /// Identifies the authorization scope for the method you are building.
3959 ///
3960 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3961 /// [`Scope::Full`].
3962 ///
3963 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3964 /// tokens for more than one scope.
3965 ///
3966 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3967 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3968 /// sufficient, a read-write scope will do as well.
3969 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitListCall<'a, C>
3970 where
3971 St: AsRef<str>,
3972 {
3973 self._scopes.insert(String::from(scope.as_ref()));
3974 self
3975 }
3976 /// Identifies the authorization scope(s) for the method you are building.
3977 ///
3978 /// See [`Self::add_scope()`] for details.
3979 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitListCall<'a, C>
3980 where
3981 I: IntoIterator<Item = St>,
3982 St: AsRef<str>,
3983 {
3984 self._scopes
3985 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3986 self
3987 }
3988
3989 /// Removes all scopes, and no default scope will be used either.
3990 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3991 /// for details).
3992 pub fn clear_scopes(mut self) -> AccountAdunitListCall<'a, C> {
3993 self._scopes.clear();
3994 self
3995 }
3996}
3997
3998/// Update the supplied ad unit in the specified publisher AdSense account. This method supports patch semantics.
3999///
4000/// A builder for the *adunits.patch* method supported by a *account* resource.
4001/// It is not used directly, but through a [`AccountMethods`] instance.
4002///
4003/// # Example
4004///
4005/// Instantiate a resource method builder
4006///
4007/// ```test_harness,no_run
4008/// # extern crate hyper;
4009/// # extern crate hyper_rustls;
4010/// # extern crate google_adsensehost4d1 as adsensehost4d1;
4011/// use adsensehost4d1::api::AdUnit;
4012/// # async fn dox() {
4013/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4014///
4015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4016/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4017/// # .with_native_roots()
4018/// # .unwrap()
4019/// # .https_only()
4020/// # .enable_http2()
4021/// # .build();
4022///
4023/// # let executor = hyper_util::rt::TokioExecutor::new();
4024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4025/// # secret,
4026/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4027/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4028/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4029/// # ),
4030/// # ).build().await.unwrap();
4031///
4032/// # let client = hyper_util::client::legacy::Client::builder(
4033/// # hyper_util::rt::TokioExecutor::new()
4034/// # )
4035/// # .build(
4036/// # hyper_rustls::HttpsConnectorBuilder::new()
4037/// # .with_native_roots()
4038/// # .unwrap()
4039/// # .https_or_http()
4040/// # .enable_http2()
4041/// # .build()
4042/// # );
4043/// # let mut hub = AdSenseHost::new(client, auth);
4044/// // As the method needs a request, you would usually fill it with the desired information
4045/// // into the respective structure. Some of the parts shown here might not be applicable !
4046/// // Values shown here are possibly random and not representative !
4047/// let mut req = AdUnit::default();
4048///
4049/// // You can configure optional parameters by calling the respective setters at will, and
4050/// // execute the final call using `doit()`.
4051/// // Values shown here are possibly random and not representative !
4052/// let result = hub.accounts().adunits_patch(req, "accountId", "adClientId", "adUnitId")
4053/// .doit().await;
4054/// # }
4055/// ```
4056pub struct AccountAdunitPatchCall<'a, C>
4057where
4058 C: 'a,
4059{
4060 hub: &'a AdSenseHost<C>,
4061 _request: AdUnit,
4062 _account_id: String,
4063 _ad_client_id: String,
4064 _ad_unit_id: String,
4065 _delegate: Option<&'a mut dyn common::Delegate>,
4066 _additional_params: HashMap<String, String>,
4067 _scopes: BTreeSet<String>,
4068}
4069
4070impl<'a, C> common::CallBuilder for AccountAdunitPatchCall<'a, C> {}
4071
4072impl<'a, C> AccountAdunitPatchCall<'a, C>
4073where
4074 C: common::Connector,
4075{
4076 /// Perform the operation you have build so far.
4077 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
4078 use std::borrow::Cow;
4079 use std::io::{Read, Seek};
4080
4081 use common::{url::Params, ToParts};
4082 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4083
4084 let mut dd = common::DefaultDelegate;
4085 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4086 dlg.begin(common::MethodInfo {
4087 id: "adsensehost.accounts.adunits.patch",
4088 http_method: hyper::Method::PATCH,
4089 });
4090
4091 for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
4092 if self._additional_params.contains_key(field) {
4093 dlg.finished(false);
4094 return Err(common::Error::FieldClash(field));
4095 }
4096 }
4097
4098 let mut params = Params::with_capacity(6 + self._additional_params.len());
4099 params.push("accountId", self._account_id);
4100 params.push("adClientId", self._ad_client_id);
4101 params.push("adUnitId", self._ad_unit_id);
4102
4103 params.extend(self._additional_params.iter());
4104
4105 params.push("alt", "json");
4106 let mut url =
4107 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adunits";
4108 if self._scopes.is_empty() {
4109 self._scopes.insert(Scope::Full.as_ref().to_string());
4110 }
4111
4112 #[allow(clippy::single_element_loop)]
4113 for &(find_this, param_name) in
4114 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
4115 {
4116 url = params.uri_replacement(url, param_name, find_this, false);
4117 }
4118 {
4119 let to_remove = ["adClientId", "accountId"];
4120 params.remove_params(&to_remove);
4121 }
4122
4123 let url = params.parse_with_url(&url);
4124
4125 let mut json_mime_type = mime::APPLICATION_JSON;
4126 let mut request_value_reader = {
4127 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4128 common::remove_json_null_values(&mut value);
4129 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4130 serde_json::to_writer(&mut dst, &value).unwrap();
4131 dst
4132 };
4133 let request_size = request_value_reader
4134 .seek(std::io::SeekFrom::End(0))
4135 .unwrap();
4136 request_value_reader
4137 .seek(std::io::SeekFrom::Start(0))
4138 .unwrap();
4139
4140 loop {
4141 let token = match self
4142 .hub
4143 .auth
4144 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4145 .await
4146 {
4147 Ok(token) => token,
4148 Err(e) => match dlg.token(e) {
4149 Ok(token) => token,
4150 Err(e) => {
4151 dlg.finished(false);
4152 return Err(common::Error::MissingToken(e));
4153 }
4154 },
4155 };
4156 request_value_reader
4157 .seek(std::io::SeekFrom::Start(0))
4158 .unwrap();
4159 let mut req_result = {
4160 let client = &self.hub.client;
4161 dlg.pre_request();
4162 let mut req_builder = hyper::Request::builder()
4163 .method(hyper::Method::PATCH)
4164 .uri(url.as_str())
4165 .header(USER_AGENT, self.hub._user_agent.clone());
4166
4167 if let Some(token) = token.as_ref() {
4168 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4169 }
4170
4171 let request = req_builder
4172 .header(CONTENT_TYPE, json_mime_type.to_string())
4173 .header(CONTENT_LENGTH, request_size as u64)
4174 .body(common::to_body(
4175 request_value_reader.get_ref().clone().into(),
4176 ));
4177
4178 client.request(request.unwrap()).await
4179 };
4180
4181 match req_result {
4182 Err(err) => {
4183 if let common::Retry::After(d) = dlg.http_error(&err) {
4184 sleep(d).await;
4185 continue;
4186 }
4187 dlg.finished(false);
4188 return Err(common::Error::HttpError(err));
4189 }
4190 Ok(res) => {
4191 let (mut parts, body) = res.into_parts();
4192 let mut body = common::Body::new(body);
4193 if !parts.status.is_success() {
4194 let bytes = common::to_bytes(body).await.unwrap_or_default();
4195 let error = serde_json::from_str(&common::to_string(&bytes));
4196 let response = common::to_response(parts, bytes.into());
4197
4198 if let common::Retry::After(d) =
4199 dlg.http_failure(&response, error.as_ref().ok())
4200 {
4201 sleep(d).await;
4202 continue;
4203 }
4204
4205 dlg.finished(false);
4206
4207 return Err(match error {
4208 Ok(value) => common::Error::BadRequest(value),
4209 _ => common::Error::Failure(response),
4210 });
4211 }
4212 let response = {
4213 let bytes = common::to_bytes(body).await.unwrap_or_default();
4214 let encoded = common::to_string(&bytes);
4215 match serde_json::from_str(&encoded) {
4216 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4217 Err(error) => {
4218 dlg.response_json_decode_error(&encoded, &error);
4219 return Err(common::Error::JsonDecodeError(
4220 encoded.to_string(),
4221 error,
4222 ));
4223 }
4224 }
4225 };
4226
4227 dlg.finished(true);
4228 return Ok(response);
4229 }
4230 }
4231 }
4232 }
4233
4234 ///
4235 /// Sets the *request* property to the given value.
4236 ///
4237 /// Even though the property as already been set when instantiating this call,
4238 /// we provide this method for API completeness.
4239 pub fn request(mut self, new_value: AdUnit) -> AccountAdunitPatchCall<'a, C> {
4240 self._request = new_value;
4241 self
4242 }
4243 /// Account which contains the ad client.
4244 ///
4245 /// Sets the *account id* path property to the given value.
4246 ///
4247 /// Even though the property as already been set when instantiating this call,
4248 /// we provide this method for API completeness.
4249 pub fn account_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C> {
4250 self._account_id = new_value.to_string();
4251 self
4252 }
4253 /// Ad client which contains the ad unit.
4254 ///
4255 /// Sets the *ad client id* path property to the given value.
4256 ///
4257 /// Even though the property as already been set when instantiating this call,
4258 /// we provide this method for API completeness.
4259 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C> {
4260 self._ad_client_id = new_value.to_string();
4261 self
4262 }
4263 /// Ad unit to get.
4264 ///
4265 /// Sets the *ad unit id* query property to the given value.
4266 ///
4267 /// Even though the property as already been set when instantiating this call,
4268 /// we provide this method for API completeness.
4269 pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C> {
4270 self._ad_unit_id = new_value.to_string();
4271 self
4272 }
4273 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4274 /// while executing the actual API request.
4275 ///
4276 /// ````text
4277 /// It should be used to handle progress information, and to implement a certain level of resilience.
4278 /// ````
4279 ///
4280 /// Sets the *delegate* property to the given value.
4281 pub fn delegate(
4282 mut self,
4283 new_value: &'a mut dyn common::Delegate,
4284 ) -> AccountAdunitPatchCall<'a, C> {
4285 self._delegate = Some(new_value);
4286 self
4287 }
4288
4289 /// Set any additional parameter of the query string used in the request.
4290 /// It should be used to set parameters which are not yet available through their own
4291 /// setters.
4292 ///
4293 /// Please note that this method must not be used to set any of the known parameters
4294 /// which have their own setter method. If done anyway, the request will fail.
4295 ///
4296 /// # Additional Parameters
4297 ///
4298 /// * *alt* (query-string) - Data format for the response.
4299 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4300 /// * *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.
4301 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4302 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4303 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4304 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4305 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitPatchCall<'a, C>
4306 where
4307 T: AsRef<str>,
4308 {
4309 self._additional_params
4310 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4311 self
4312 }
4313
4314 /// Identifies the authorization scope for the method you are building.
4315 ///
4316 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4317 /// [`Scope::Full`].
4318 ///
4319 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4320 /// tokens for more than one scope.
4321 ///
4322 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4323 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4324 /// sufficient, a read-write scope will do as well.
4325 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitPatchCall<'a, C>
4326 where
4327 St: AsRef<str>,
4328 {
4329 self._scopes.insert(String::from(scope.as_ref()));
4330 self
4331 }
4332 /// Identifies the authorization scope(s) for the method you are building.
4333 ///
4334 /// See [`Self::add_scope()`] for details.
4335 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitPatchCall<'a, C>
4336 where
4337 I: IntoIterator<Item = St>,
4338 St: AsRef<str>,
4339 {
4340 self._scopes
4341 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4342 self
4343 }
4344
4345 /// Removes all scopes, and no default scope will be used either.
4346 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4347 /// for details).
4348 pub fn clear_scopes(mut self) -> AccountAdunitPatchCall<'a, C> {
4349 self._scopes.clear();
4350 self
4351 }
4352}
4353
4354/// Update the supplied ad unit in the specified publisher AdSense account.
4355///
4356/// A builder for the *adunits.update* method supported by a *account* resource.
4357/// It is not used directly, but through a [`AccountMethods`] instance.
4358///
4359/// # Example
4360///
4361/// Instantiate a resource method builder
4362///
4363/// ```test_harness,no_run
4364/// # extern crate hyper;
4365/// # extern crate hyper_rustls;
4366/// # extern crate google_adsensehost4d1 as adsensehost4d1;
4367/// use adsensehost4d1::api::AdUnit;
4368/// # async fn dox() {
4369/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4370///
4371/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4372/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4373/// # .with_native_roots()
4374/// # .unwrap()
4375/// # .https_only()
4376/// # .enable_http2()
4377/// # .build();
4378///
4379/// # let executor = hyper_util::rt::TokioExecutor::new();
4380/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4381/// # secret,
4382/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4383/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4384/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4385/// # ),
4386/// # ).build().await.unwrap();
4387///
4388/// # let client = hyper_util::client::legacy::Client::builder(
4389/// # hyper_util::rt::TokioExecutor::new()
4390/// # )
4391/// # .build(
4392/// # hyper_rustls::HttpsConnectorBuilder::new()
4393/// # .with_native_roots()
4394/// # .unwrap()
4395/// # .https_or_http()
4396/// # .enable_http2()
4397/// # .build()
4398/// # );
4399/// # let mut hub = AdSenseHost::new(client, auth);
4400/// // As the method needs a request, you would usually fill it with the desired information
4401/// // into the respective structure. Some of the parts shown here might not be applicable !
4402/// // Values shown here are possibly random and not representative !
4403/// let mut req = AdUnit::default();
4404///
4405/// // You can configure optional parameters by calling the respective setters at will, and
4406/// // execute the final call using `doit()`.
4407/// // Values shown here are possibly random and not representative !
4408/// let result = hub.accounts().adunits_update(req, "accountId", "adClientId")
4409/// .doit().await;
4410/// # }
4411/// ```
4412pub struct AccountAdunitUpdateCall<'a, C>
4413where
4414 C: 'a,
4415{
4416 hub: &'a AdSenseHost<C>,
4417 _request: AdUnit,
4418 _account_id: String,
4419 _ad_client_id: String,
4420 _delegate: Option<&'a mut dyn common::Delegate>,
4421 _additional_params: HashMap<String, String>,
4422 _scopes: BTreeSet<String>,
4423}
4424
4425impl<'a, C> common::CallBuilder for AccountAdunitUpdateCall<'a, C> {}
4426
4427impl<'a, C> AccountAdunitUpdateCall<'a, C>
4428where
4429 C: common::Connector,
4430{
4431 /// Perform the operation you have build so far.
4432 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
4433 use std::borrow::Cow;
4434 use std::io::{Read, Seek};
4435
4436 use common::{url::Params, ToParts};
4437 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4438
4439 let mut dd = common::DefaultDelegate;
4440 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4441 dlg.begin(common::MethodInfo {
4442 id: "adsensehost.accounts.adunits.update",
4443 http_method: hyper::Method::PUT,
4444 });
4445
4446 for &field in ["alt", "accountId", "adClientId"].iter() {
4447 if self._additional_params.contains_key(field) {
4448 dlg.finished(false);
4449 return Err(common::Error::FieldClash(field));
4450 }
4451 }
4452
4453 let mut params = Params::with_capacity(5 + self._additional_params.len());
4454 params.push("accountId", self._account_id);
4455 params.push("adClientId", self._ad_client_id);
4456
4457 params.extend(self._additional_params.iter());
4458
4459 params.push("alt", "json");
4460 let mut url =
4461 self.hub._base_url.clone() + "accounts/{accountId}/adclients/{adClientId}/adunits";
4462 if self._scopes.is_empty() {
4463 self._scopes.insert(Scope::Full.as_ref().to_string());
4464 }
4465
4466 #[allow(clippy::single_element_loop)]
4467 for &(find_this, param_name) in
4468 [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].iter()
4469 {
4470 url = params.uri_replacement(url, param_name, find_this, false);
4471 }
4472 {
4473 let to_remove = ["adClientId", "accountId"];
4474 params.remove_params(&to_remove);
4475 }
4476
4477 let url = params.parse_with_url(&url);
4478
4479 let mut json_mime_type = mime::APPLICATION_JSON;
4480 let mut request_value_reader = {
4481 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4482 common::remove_json_null_values(&mut value);
4483 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4484 serde_json::to_writer(&mut dst, &value).unwrap();
4485 dst
4486 };
4487 let request_size = request_value_reader
4488 .seek(std::io::SeekFrom::End(0))
4489 .unwrap();
4490 request_value_reader
4491 .seek(std::io::SeekFrom::Start(0))
4492 .unwrap();
4493
4494 loop {
4495 let token = match self
4496 .hub
4497 .auth
4498 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4499 .await
4500 {
4501 Ok(token) => token,
4502 Err(e) => match dlg.token(e) {
4503 Ok(token) => token,
4504 Err(e) => {
4505 dlg.finished(false);
4506 return Err(common::Error::MissingToken(e));
4507 }
4508 },
4509 };
4510 request_value_reader
4511 .seek(std::io::SeekFrom::Start(0))
4512 .unwrap();
4513 let mut req_result = {
4514 let client = &self.hub.client;
4515 dlg.pre_request();
4516 let mut req_builder = hyper::Request::builder()
4517 .method(hyper::Method::PUT)
4518 .uri(url.as_str())
4519 .header(USER_AGENT, self.hub._user_agent.clone());
4520
4521 if let Some(token) = token.as_ref() {
4522 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4523 }
4524
4525 let request = req_builder
4526 .header(CONTENT_TYPE, json_mime_type.to_string())
4527 .header(CONTENT_LENGTH, request_size as u64)
4528 .body(common::to_body(
4529 request_value_reader.get_ref().clone().into(),
4530 ));
4531
4532 client.request(request.unwrap()).await
4533 };
4534
4535 match req_result {
4536 Err(err) => {
4537 if let common::Retry::After(d) = dlg.http_error(&err) {
4538 sleep(d).await;
4539 continue;
4540 }
4541 dlg.finished(false);
4542 return Err(common::Error::HttpError(err));
4543 }
4544 Ok(res) => {
4545 let (mut parts, body) = res.into_parts();
4546 let mut body = common::Body::new(body);
4547 if !parts.status.is_success() {
4548 let bytes = common::to_bytes(body).await.unwrap_or_default();
4549 let error = serde_json::from_str(&common::to_string(&bytes));
4550 let response = common::to_response(parts, bytes.into());
4551
4552 if let common::Retry::After(d) =
4553 dlg.http_failure(&response, error.as_ref().ok())
4554 {
4555 sleep(d).await;
4556 continue;
4557 }
4558
4559 dlg.finished(false);
4560
4561 return Err(match error {
4562 Ok(value) => common::Error::BadRequest(value),
4563 _ => common::Error::Failure(response),
4564 });
4565 }
4566 let response = {
4567 let bytes = common::to_bytes(body).await.unwrap_or_default();
4568 let encoded = common::to_string(&bytes);
4569 match serde_json::from_str(&encoded) {
4570 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4571 Err(error) => {
4572 dlg.response_json_decode_error(&encoded, &error);
4573 return Err(common::Error::JsonDecodeError(
4574 encoded.to_string(),
4575 error,
4576 ));
4577 }
4578 }
4579 };
4580
4581 dlg.finished(true);
4582 return Ok(response);
4583 }
4584 }
4585 }
4586 }
4587
4588 ///
4589 /// Sets the *request* property to the given value.
4590 ///
4591 /// Even though the property as already been set when instantiating this call,
4592 /// we provide this method for API completeness.
4593 pub fn request(mut self, new_value: AdUnit) -> AccountAdunitUpdateCall<'a, C> {
4594 self._request = new_value;
4595 self
4596 }
4597 /// Account which contains the ad client.
4598 ///
4599 /// Sets the *account id* path property to the given value.
4600 ///
4601 /// Even though the property as already been set when instantiating this call,
4602 /// we provide this method for API completeness.
4603 pub fn account_id(mut self, new_value: &str) -> AccountAdunitUpdateCall<'a, C> {
4604 self._account_id = new_value.to_string();
4605 self
4606 }
4607 /// Ad client which contains the ad unit.
4608 ///
4609 /// Sets the *ad client id* path property to the given value.
4610 ///
4611 /// Even though the property as already been set when instantiating this call,
4612 /// we provide this method for API completeness.
4613 pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitUpdateCall<'a, C> {
4614 self._ad_client_id = new_value.to_string();
4615 self
4616 }
4617 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4618 /// while executing the actual API request.
4619 ///
4620 /// ````text
4621 /// It should be used to handle progress information, and to implement a certain level of resilience.
4622 /// ````
4623 ///
4624 /// Sets the *delegate* property to the given value.
4625 pub fn delegate(
4626 mut self,
4627 new_value: &'a mut dyn common::Delegate,
4628 ) -> AccountAdunitUpdateCall<'a, C> {
4629 self._delegate = Some(new_value);
4630 self
4631 }
4632
4633 /// Set any additional parameter of the query string used in the request.
4634 /// It should be used to set parameters which are not yet available through their own
4635 /// setters.
4636 ///
4637 /// Please note that this method must not be used to set any of the known parameters
4638 /// which have their own setter method. If done anyway, the request will fail.
4639 ///
4640 /// # Additional Parameters
4641 ///
4642 /// * *alt* (query-string) - Data format for the response.
4643 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4644 /// * *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.
4645 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4646 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4647 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4648 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4649 pub fn param<T>(mut self, name: T, value: T) -> AccountAdunitUpdateCall<'a, C>
4650 where
4651 T: AsRef<str>,
4652 {
4653 self._additional_params
4654 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4655 self
4656 }
4657
4658 /// Identifies the authorization scope for the method you are building.
4659 ///
4660 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4661 /// [`Scope::Full`].
4662 ///
4663 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4664 /// tokens for more than one scope.
4665 ///
4666 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4667 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4668 /// sufficient, a read-write scope will do as well.
4669 pub fn add_scope<St>(mut self, scope: St) -> AccountAdunitUpdateCall<'a, C>
4670 where
4671 St: AsRef<str>,
4672 {
4673 self._scopes.insert(String::from(scope.as_ref()));
4674 self
4675 }
4676 /// Identifies the authorization scope(s) for the method you are building.
4677 ///
4678 /// See [`Self::add_scope()`] for details.
4679 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdunitUpdateCall<'a, C>
4680 where
4681 I: IntoIterator<Item = St>,
4682 St: AsRef<str>,
4683 {
4684 self._scopes
4685 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4686 self
4687 }
4688
4689 /// Removes all scopes, and no default scope will be used either.
4690 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4691 /// for details).
4692 pub fn clear_scopes(mut self) -> AccountAdunitUpdateCall<'a, C> {
4693 self._scopes.clear();
4694 self
4695 }
4696}
4697
4698/// 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.
4699///
4700/// A builder for the *reports.generate* method supported by a *account* resource.
4701/// It is not used directly, but through a [`AccountMethods`] instance.
4702///
4703/// # Example
4704///
4705/// Instantiate a resource method builder
4706///
4707/// ```test_harness,no_run
4708/// # extern crate hyper;
4709/// # extern crate hyper_rustls;
4710/// # extern crate google_adsensehost4d1 as adsensehost4d1;
4711/// # async fn dox() {
4712/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4713///
4714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4715/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4716/// # .with_native_roots()
4717/// # .unwrap()
4718/// # .https_only()
4719/// # .enable_http2()
4720/// # .build();
4721///
4722/// # let executor = hyper_util::rt::TokioExecutor::new();
4723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4724/// # secret,
4725/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4726/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4727/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4728/// # ),
4729/// # ).build().await.unwrap();
4730///
4731/// # let client = hyper_util::client::legacy::Client::builder(
4732/// # hyper_util::rt::TokioExecutor::new()
4733/// # )
4734/// # .build(
4735/// # hyper_rustls::HttpsConnectorBuilder::new()
4736/// # .with_native_roots()
4737/// # .unwrap()
4738/// # .https_or_http()
4739/// # .enable_http2()
4740/// # .build()
4741/// # );
4742/// # let mut hub = AdSenseHost::new(client, auth);
4743/// // You can configure optional parameters by calling the respective setters at will, and
4744/// // execute the final call using `doit()`.
4745/// // Values shown here are possibly random and not representative !
4746/// let result = hub.accounts().reports_generate("accountId", "startDate", "endDate")
4747/// .start_index(25)
4748/// .add_sort("vero")
4749/// .add_metric("invidunt")
4750/// .max_results(36)
4751/// .locale("vero")
4752/// .add_filter("elitr")
4753/// .add_dimension("Lorem")
4754/// .doit().await;
4755/// # }
4756/// ```
4757pub struct AccountReportGenerateCall<'a, C>
4758where
4759 C: 'a,
4760{
4761 hub: &'a AdSenseHost<C>,
4762 _account_id: String,
4763 _start_date: String,
4764 _end_date: String,
4765 _start_index: Option<u32>,
4766 _sort: Vec<String>,
4767 _metric: Vec<String>,
4768 _max_results: Option<u32>,
4769 _locale: Option<String>,
4770 _filter: Vec<String>,
4771 _dimension: Vec<String>,
4772 _delegate: Option<&'a mut dyn common::Delegate>,
4773 _additional_params: HashMap<String, String>,
4774 _scopes: BTreeSet<String>,
4775}
4776
4777impl<'a, C> common::CallBuilder for AccountReportGenerateCall<'a, C> {}
4778
4779impl<'a, C> AccountReportGenerateCall<'a, C>
4780where
4781 C: common::Connector,
4782{
4783 /// Perform the operation you have build so far.
4784 pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
4785 use std::borrow::Cow;
4786 use std::io::{Read, Seek};
4787
4788 use common::{url::Params, ToParts};
4789 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4790
4791 let mut dd = common::DefaultDelegate;
4792 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4793 dlg.begin(common::MethodInfo {
4794 id: "adsensehost.accounts.reports.generate",
4795 http_method: hyper::Method::GET,
4796 });
4797
4798 for &field in [
4799 "alt",
4800 "accountId",
4801 "startDate",
4802 "endDate",
4803 "startIndex",
4804 "sort",
4805 "metric",
4806 "maxResults",
4807 "locale",
4808 "filter",
4809 "dimension",
4810 ]
4811 .iter()
4812 {
4813 if self._additional_params.contains_key(field) {
4814 dlg.finished(false);
4815 return Err(common::Error::FieldClash(field));
4816 }
4817 }
4818
4819 let mut params = Params::with_capacity(12 + self._additional_params.len());
4820 params.push("accountId", self._account_id);
4821 params.push("startDate", self._start_date);
4822 params.push("endDate", self._end_date);
4823 if let Some(value) = self._start_index.as_ref() {
4824 params.push("startIndex", value.to_string());
4825 }
4826 if !self._sort.is_empty() {
4827 for f in self._sort.iter() {
4828 params.push("sort", f);
4829 }
4830 }
4831 if !self._metric.is_empty() {
4832 for f in self._metric.iter() {
4833 params.push("metric", f);
4834 }
4835 }
4836 if let Some(value) = self._max_results.as_ref() {
4837 params.push("maxResults", value.to_string());
4838 }
4839 if let Some(value) = self._locale.as_ref() {
4840 params.push("locale", value);
4841 }
4842 if !self._filter.is_empty() {
4843 for f in self._filter.iter() {
4844 params.push("filter", f);
4845 }
4846 }
4847 if !self._dimension.is_empty() {
4848 for f in self._dimension.iter() {
4849 params.push("dimension", f);
4850 }
4851 }
4852
4853 params.extend(self._additional_params.iter());
4854
4855 params.push("alt", "json");
4856 let mut url = self.hub._base_url.clone() + "accounts/{accountId}/reports";
4857 if self._scopes.is_empty() {
4858 self._scopes.insert(Scope::Full.as_ref().to_string());
4859 }
4860
4861 #[allow(clippy::single_element_loop)]
4862 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
4863 url = params.uri_replacement(url, param_name, find_this, false);
4864 }
4865 {
4866 let to_remove = ["accountId"];
4867 params.remove_params(&to_remove);
4868 }
4869
4870 let url = params.parse_with_url(&url);
4871
4872 loop {
4873 let token = match self
4874 .hub
4875 .auth
4876 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4877 .await
4878 {
4879 Ok(token) => token,
4880 Err(e) => match dlg.token(e) {
4881 Ok(token) => token,
4882 Err(e) => {
4883 dlg.finished(false);
4884 return Err(common::Error::MissingToken(e));
4885 }
4886 },
4887 };
4888 let mut req_result = {
4889 let client = &self.hub.client;
4890 dlg.pre_request();
4891 let mut req_builder = hyper::Request::builder()
4892 .method(hyper::Method::GET)
4893 .uri(url.as_str())
4894 .header(USER_AGENT, self.hub._user_agent.clone());
4895
4896 if let Some(token) = token.as_ref() {
4897 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4898 }
4899
4900 let request = req_builder
4901 .header(CONTENT_LENGTH, 0_u64)
4902 .body(common::to_body::<String>(None));
4903
4904 client.request(request.unwrap()).await
4905 };
4906
4907 match req_result {
4908 Err(err) => {
4909 if let common::Retry::After(d) = dlg.http_error(&err) {
4910 sleep(d).await;
4911 continue;
4912 }
4913 dlg.finished(false);
4914 return Err(common::Error::HttpError(err));
4915 }
4916 Ok(res) => {
4917 let (mut parts, body) = res.into_parts();
4918 let mut body = common::Body::new(body);
4919 if !parts.status.is_success() {
4920 let bytes = common::to_bytes(body).await.unwrap_or_default();
4921 let error = serde_json::from_str(&common::to_string(&bytes));
4922 let response = common::to_response(parts, bytes.into());
4923
4924 if let common::Retry::After(d) =
4925 dlg.http_failure(&response, error.as_ref().ok())
4926 {
4927 sleep(d).await;
4928 continue;
4929 }
4930
4931 dlg.finished(false);
4932
4933 return Err(match error {
4934 Ok(value) => common::Error::BadRequest(value),
4935 _ => common::Error::Failure(response),
4936 });
4937 }
4938 let response = {
4939 let bytes = common::to_bytes(body).await.unwrap_or_default();
4940 let encoded = common::to_string(&bytes);
4941 match serde_json::from_str(&encoded) {
4942 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4943 Err(error) => {
4944 dlg.response_json_decode_error(&encoded, &error);
4945 return Err(common::Error::JsonDecodeError(
4946 encoded.to_string(),
4947 error,
4948 ));
4949 }
4950 }
4951 };
4952
4953 dlg.finished(true);
4954 return Ok(response);
4955 }
4956 }
4957 }
4958 }
4959
4960 /// Hosted account upon which to report.
4961 ///
4962 /// Sets the *account id* path property to the given value.
4963 ///
4964 /// Even though the property as already been set when instantiating this call,
4965 /// we provide this method for API completeness.
4966 pub fn account_id(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4967 self._account_id = new_value.to_string();
4968 self
4969 }
4970 /// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
4971 ///
4972 /// Sets the *start date* query property to the given value.
4973 ///
4974 /// Even though the property as already been set when instantiating this call,
4975 /// we provide this method for API completeness.
4976 pub fn start_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4977 self._start_date = new_value.to_string();
4978 self
4979 }
4980 /// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
4981 ///
4982 /// Sets the *end date* query property to the given value.
4983 ///
4984 /// Even though the property as already been set when instantiating this call,
4985 /// we provide this method for API completeness.
4986 pub fn end_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
4987 self._end_date = new_value.to_string();
4988 self
4989 }
4990 /// Index of the first row of report data to return.
4991 ///
4992 /// Sets the *start index* query property to the given value.
4993 pub fn start_index(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C> {
4994 self._start_index = Some(new_value);
4995 self
4996 }
4997 /// 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.
4998 ///
4999 /// Append the given value to the *sort* query property.
5000 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5001 pub fn add_sort(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
5002 self._sort.push(new_value.to_string());
5003 self
5004 }
5005 /// Numeric columns to include in the report.
5006 ///
5007 /// Append the given value to the *metric* query property.
5008 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5009 pub fn add_metric(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
5010 self._metric.push(new_value.to_string());
5011 self
5012 }
5013 /// The maximum number of rows of report data to return.
5014 ///
5015 /// Sets the *max results* query property to the given value.
5016 pub fn max_results(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C> {
5017 self._max_results = Some(new_value);
5018 self
5019 }
5020 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
5021 ///
5022 /// Sets the *locale* query property to the given value.
5023 pub fn locale(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
5024 self._locale = Some(new_value.to_string());
5025 self
5026 }
5027 /// Filters to be run on the report.
5028 ///
5029 /// Append the given value to the *filter* query property.
5030 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5031 pub fn add_filter(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
5032 self._filter.push(new_value.to_string());
5033 self
5034 }
5035 /// Dimensions to base the report on.
5036 ///
5037 /// Append the given value to the *dimension* query property.
5038 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5039 pub fn add_dimension(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
5040 self._dimension.push(new_value.to_string());
5041 self
5042 }
5043 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5044 /// while executing the actual API request.
5045 ///
5046 /// ````text
5047 /// It should be used to handle progress information, and to implement a certain level of resilience.
5048 /// ````
5049 ///
5050 /// Sets the *delegate* property to the given value.
5051 pub fn delegate(
5052 mut self,
5053 new_value: &'a mut dyn common::Delegate,
5054 ) -> AccountReportGenerateCall<'a, C> {
5055 self._delegate = Some(new_value);
5056 self
5057 }
5058
5059 /// Set any additional parameter of the query string used in the request.
5060 /// It should be used to set parameters which are not yet available through their own
5061 /// setters.
5062 ///
5063 /// Please note that this method must not be used to set any of the known parameters
5064 /// which have their own setter method. If done anyway, the request will fail.
5065 ///
5066 /// # Additional Parameters
5067 ///
5068 /// * *alt* (query-string) - Data format for the response.
5069 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5070 /// * *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.
5071 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5072 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5073 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5074 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5075 pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCall<'a, C>
5076 where
5077 T: AsRef<str>,
5078 {
5079 self._additional_params
5080 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5081 self
5082 }
5083
5084 /// Identifies the authorization scope for the method you are building.
5085 ///
5086 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5087 /// [`Scope::Full`].
5088 ///
5089 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5090 /// tokens for more than one scope.
5091 ///
5092 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5093 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5094 /// sufficient, a read-write scope will do as well.
5095 pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCall<'a, C>
5096 where
5097 St: AsRef<str>,
5098 {
5099 self._scopes.insert(String::from(scope.as_ref()));
5100 self
5101 }
5102 /// Identifies the authorization scope(s) for the method you are building.
5103 ///
5104 /// See [`Self::add_scope()`] for details.
5105 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCall<'a, C>
5106 where
5107 I: IntoIterator<Item = St>,
5108 St: AsRef<str>,
5109 {
5110 self._scopes
5111 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5112 self
5113 }
5114
5115 /// Removes all scopes, and no default scope will be used either.
5116 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5117 /// for details).
5118 pub fn clear_scopes(mut self) -> AccountReportGenerateCall<'a, C> {
5119 self._scopes.clear();
5120 self
5121 }
5122}
5123
5124/// Get information about the selected associated AdSense account.
5125///
5126/// A builder for the *get* method supported by a *account* resource.
5127/// It is not used directly, but through a [`AccountMethods`] instance.
5128///
5129/// # Example
5130///
5131/// Instantiate a resource method builder
5132///
5133/// ```test_harness,no_run
5134/// # extern crate hyper;
5135/// # extern crate hyper_rustls;
5136/// # extern crate google_adsensehost4d1 as adsensehost4d1;
5137/// # async fn dox() {
5138/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5139///
5140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5141/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5142/// # .with_native_roots()
5143/// # .unwrap()
5144/// # .https_only()
5145/// # .enable_http2()
5146/// # .build();
5147///
5148/// # let executor = hyper_util::rt::TokioExecutor::new();
5149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5150/// # secret,
5151/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5152/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5153/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5154/// # ),
5155/// # ).build().await.unwrap();
5156///
5157/// # let client = hyper_util::client::legacy::Client::builder(
5158/// # hyper_util::rt::TokioExecutor::new()
5159/// # )
5160/// # .build(
5161/// # hyper_rustls::HttpsConnectorBuilder::new()
5162/// # .with_native_roots()
5163/// # .unwrap()
5164/// # .https_or_http()
5165/// # .enable_http2()
5166/// # .build()
5167/// # );
5168/// # let mut hub = AdSenseHost::new(client, auth);
5169/// // You can configure optional parameters by calling the respective setters at will, and
5170/// // execute the final call using `doit()`.
5171/// // Values shown here are possibly random and not representative !
5172/// let result = hub.accounts().get("accountId")
5173/// .doit().await;
5174/// # }
5175/// ```
5176pub struct AccountGetCall<'a, C>
5177where
5178 C: 'a,
5179{
5180 hub: &'a AdSenseHost<C>,
5181 _account_id: String,
5182 _delegate: Option<&'a mut dyn common::Delegate>,
5183 _additional_params: HashMap<String, String>,
5184 _scopes: BTreeSet<String>,
5185}
5186
5187impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
5188
5189impl<'a, C> AccountGetCall<'a, C>
5190where
5191 C: common::Connector,
5192{
5193 /// Perform the operation you have build so far.
5194 pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
5195 use std::borrow::Cow;
5196 use std::io::{Read, Seek};
5197
5198 use common::{url::Params, ToParts};
5199 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5200
5201 let mut dd = common::DefaultDelegate;
5202 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5203 dlg.begin(common::MethodInfo {
5204 id: "adsensehost.accounts.get",
5205 http_method: hyper::Method::GET,
5206 });
5207
5208 for &field in ["alt", "accountId"].iter() {
5209 if self._additional_params.contains_key(field) {
5210 dlg.finished(false);
5211 return Err(common::Error::FieldClash(field));
5212 }
5213 }
5214
5215 let mut params = Params::with_capacity(3 + self._additional_params.len());
5216 params.push("accountId", self._account_id);
5217
5218 params.extend(self._additional_params.iter());
5219
5220 params.push("alt", "json");
5221 let mut url = self.hub._base_url.clone() + "accounts/{accountId}";
5222 if self._scopes.is_empty() {
5223 self._scopes.insert(Scope::Full.as_ref().to_string());
5224 }
5225
5226 #[allow(clippy::single_element_loop)]
5227 for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
5228 url = params.uri_replacement(url, param_name, find_this, false);
5229 }
5230 {
5231 let to_remove = ["accountId"];
5232 params.remove_params(&to_remove);
5233 }
5234
5235 let url = params.parse_with_url(&url);
5236
5237 loop {
5238 let token = match self
5239 .hub
5240 .auth
5241 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5242 .await
5243 {
5244 Ok(token) => token,
5245 Err(e) => match dlg.token(e) {
5246 Ok(token) => token,
5247 Err(e) => {
5248 dlg.finished(false);
5249 return Err(common::Error::MissingToken(e));
5250 }
5251 },
5252 };
5253 let mut req_result = {
5254 let client = &self.hub.client;
5255 dlg.pre_request();
5256 let mut req_builder = hyper::Request::builder()
5257 .method(hyper::Method::GET)
5258 .uri(url.as_str())
5259 .header(USER_AGENT, self.hub._user_agent.clone());
5260
5261 if let Some(token) = token.as_ref() {
5262 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5263 }
5264
5265 let request = req_builder
5266 .header(CONTENT_LENGTH, 0_u64)
5267 .body(common::to_body::<String>(None));
5268
5269 client.request(request.unwrap()).await
5270 };
5271
5272 match req_result {
5273 Err(err) => {
5274 if let common::Retry::After(d) = dlg.http_error(&err) {
5275 sleep(d).await;
5276 continue;
5277 }
5278 dlg.finished(false);
5279 return Err(common::Error::HttpError(err));
5280 }
5281 Ok(res) => {
5282 let (mut parts, body) = res.into_parts();
5283 let mut body = common::Body::new(body);
5284 if !parts.status.is_success() {
5285 let bytes = common::to_bytes(body).await.unwrap_or_default();
5286 let error = serde_json::from_str(&common::to_string(&bytes));
5287 let response = common::to_response(parts, bytes.into());
5288
5289 if let common::Retry::After(d) =
5290 dlg.http_failure(&response, error.as_ref().ok())
5291 {
5292 sleep(d).await;
5293 continue;
5294 }
5295
5296 dlg.finished(false);
5297
5298 return Err(match error {
5299 Ok(value) => common::Error::BadRequest(value),
5300 _ => common::Error::Failure(response),
5301 });
5302 }
5303 let response = {
5304 let bytes = common::to_bytes(body).await.unwrap_or_default();
5305 let encoded = common::to_string(&bytes);
5306 match serde_json::from_str(&encoded) {
5307 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5308 Err(error) => {
5309 dlg.response_json_decode_error(&encoded, &error);
5310 return Err(common::Error::JsonDecodeError(
5311 encoded.to_string(),
5312 error,
5313 ));
5314 }
5315 }
5316 };
5317
5318 dlg.finished(true);
5319 return Ok(response);
5320 }
5321 }
5322 }
5323 }
5324
5325 /// Account to get information about.
5326 ///
5327 /// Sets the *account id* path property to the given value.
5328 ///
5329 /// Even though the property as already been set when instantiating this call,
5330 /// we provide this method for API completeness.
5331 pub fn account_id(mut self, new_value: &str) -> AccountGetCall<'a, C> {
5332 self._account_id = new_value.to_string();
5333 self
5334 }
5335 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5336 /// while executing the actual API request.
5337 ///
5338 /// ````text
5339 /// It should be used to handle progress information, and to implement a certain level of resilience.
5340 /// ````
5341 ///
5342 /// Sets the *delegate* property to the given value.
5343 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
5344 self._delegate = Some(new_value);
5345 self
5346 }
5347
5348 /// Set any additional parameter of the query string used in the request.
5349 /// It should be used to set parameters which are not yet available through their own
5350 /// setters.
5351 ///
5352 /// Please note that this method must not be used to set any of the known parameters
5353 /// which have their own setter method. If done anyway, the request will fail.
5354 ///
5355 /// # Additional Parameters
5356 ///
5357 /// * *alt* (query-string) - Data format for the response.
5358 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5359 /// * *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.
5360 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5361 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5362 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5363 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5364 pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
5365 where
5366 T: AsRef<str>,
5367 {
5368 self._additional_params
5369 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5370 self
5371 }
5372
5373 /// Identifies the authorization scope for the method you are building.
5374 ///
5375 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5376 /// [`Scope::Full`].
5377 ///
5378 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5379 /// tokens for more than one scope.
5380 ///
5381 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5382 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5383 /// sufficient, a read-write scope will do as well.
5384 pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
5385 where
5386 St: AsRef<str>,
5387 {
5388 self._scopes.insert(String::from(scope.as_ref()));
5389 self
5390 }
5391 /// Identifies the authorization scope(s) for the method you are building.
5392 ///
5393 /// See [`Self::add_scope()`] for details.
5394 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
5395 where
5396 I: IntoIterator<Item = St>,
5397 St: AsRef<str>,
5398 {
5399 self._scopes
5400 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5401 self
5402 }
5403
5404 /// Removes all scopes, and no default scope will be used either.
5405 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5406 /// for details).
5407 pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
5408 self._scopes.clear();
5409 self
5410 }
5411}
5412
5413/// List hosted accounts associated with this AdSense account by ad client id.
5414///
5415/// A builder for the *list* method supported by a *account* resource.
5416/// It is not used directly, but through a [`AccountMethods`] instance.
5417///
5418/// # Example
5419///
5420/// Instantiate a resource method builder
5421///
5422/// ```test_harness,no_run
5423/// # extern crate hyper;
5424/// # extern crate hyper_rustls;
5425/// # extern crate google_adsensehost4d1 as adsensehost4d1;
5426/// # async fn dox() {
5427/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5428///
5429/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5430/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5431/// # .with_native_roots()
5432/// # .unwrap()
5433/// # .https_only()
5434/// # .enable_http2()
5435/// # .build();
5436///
5437/// # let executor = hyper_util::rt::TokioExecutor::new();
5438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5439/// # secret,
5440/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5441/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5442/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5443/// # ),
5444/// # ).build().await.unwrap();
5445///
5446/// # let client = hyper_util::client::legacy::Client::builder(
5447/// # hyper_util::rt::TokioExecutor::new()
5448/// # )
5449/// # .build(
5450/// # hyper_rustls::HttpsConnectorBuilder::new()
5451/// # .with_native_roots()
5452/// # .unwrap()
5453/// # .https_or_http()
5454/// # .enable_http2()
5455/// # .build()
5456/// # );
5457/// # let mut hub = AdSenseHost::new(client, auth);
5458/// // You can configure optional parameters by calling the respective setters at will, and
5459/// // execute the final call using `doit()`.
5460/// // Values shown here are possibly random and not representative !
5461/// let result = hub.accounts().list(&vec!["no".into()])
5462/// .doit().await;
5463/// # }
5464/// ```
5465pub struct AccountListCall<'a, C>
5466where
5467 C: 'a,
5468{
5469 hub: &'a AdSenseHost<C>,
5470 _filter_ad_client_id: Vec<String>,
5471 _delegate: Option<&'a mut dyn common::Delegate>,
5472 _additional_params: HashMap<String, String>,
5473 _scopes: BTreeSet<String>,
5474}
5475
5476impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
5477
5478impl<'a, C> AccountListCall<'a, C>
5479where
5480 C: common::Connector,
5481{
5482 /// Perform the operation you have build so far.
5483 pub async fn doit(mut self) -> common::Result<(common::Response, Accounts)> {
5484 use std::borrow::Cow;
5485 use std::io::{Read, Seek};
5486
5487 use common::{url::Params, ToParts};
5488 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5489
5490 let mut dd = common::DefaultDelegate;
5491 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5492 dlg.begin(common::MethodInfo {
5493 id: "adsensehost.accounts.list",
5494 http_method: hyper::Method::GET,
5495 });
5496
5497 for &field in ["alt", "filterAdClientId"].iter() {
5498 if self._additional_params.contains_key(field) {
5499 dlg.finished(false);
5500 return Err(common::Error::FieldClash(field));
5501 }
5502 }
5503
5504 let mut params = Params::with_capacity(3 + self._additional_params.len());
5505 if !self._filter_ad_client_id.is_empty() {
5506 for f in self._filter_ad_client_id.iter() {
5507 params.push("filterAdClientId", f);
5508 }
5509 }
5510
5511 params.extend(self._additional_params.iter());
5512
5513 params.push("alt", "json");
5514 let mut url = self.hub._base_url.clone() + "accounts";
5515 if self._scopes.is_empty() {
5516 self._scopes.insert(Scope::Full.as_ref().to_string());
5517 }
5518
5519 let url = params.parse_with_url(&url);
5520
5521 loop {
5522 let token = match self
5523 .hub
5524 .auth
5525 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5526 .await
5527 {
5528 Ok(token) => token,
5529 Err(e) => match dlg.token(e) {
5530 Ok(token) => token,
5531 Err(e) => {
5532 dlg.finished(false);
5533 return Err(common::Error::MissingToken(e));
5534 }
5535 },
5536 };
5537 let mut req_result = {
5538 let client = &self.hub.client;
5539 dlg.pre_request();
5540 let mut req_builder = hyper::Request::builder()
5541 .method(hyper::Method::GET)
5542 .uri(url.as_str())
5543 .header(USER_AGENT, self.hub._user_agent.clone());
5544
5545 if let Some(token) = token.as_ref() {
5546 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5547 }
5548
5549 let request = req_builder
5550 .header(CONTENT_LENGTH, 0_u64)
5551 .body(common::to_body::<String>(None));
5552
5553 client.request(request.unwrap()).await
5554 };
5555
5556 match req_result {
5557 Err(err) => {
5558 if let common::Retry::After(d) = dlg.http_error(&err) {
5559 sleep(d).await;
5560 continue;
5561 }
5562 dlg.finished(false);
5563 return Err(common::Error::HttpError(err));
5564 }
5565 Ok(res) => {
5566 let (mut parts, body) = res.into_parts();
5567 let mut body = common::Body::new(body);
5568 if !parts.status.is_success() {
5569 let bytes = common::to_bytes(body).await.unwrap_or_default();
5570 let error = serde_json::from_str(&common::to_string(&bytes));
5571 let response = common::to_response(parts, bytes.into());
5572
5573 if let common::Retry::After(d) =
5574 dlg.http_failure(&response, error.as_ref().ok())
5575 {
5576 sleep(d).await;
5577 continue;
5578 }
5579
5580 dlg.finished(false);
5581
5582 return Err(match error {
5583 Ok(value) => common::Error::BadRequest(value),
5584 _ => common::Error::Failure(response),
5585 });
5586 }
5587 let response = {
5588 let bytes = common::to_bytes(body).await.unwrap_or_default();
5589 let encoded = common::to_string(&bytes);
5590 match serde_json::from_str(&encoded) {
5591 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5592 Err(error) => {
5593 dlg.response_json_decode_error(&encoded, &error);
5594 return Err(common::Error::JsonDecodeError(
5595 encoded.to_string(),
5596 error,
5597 ));
5598 }
5599 }
5600 };
5601
5602 dlg.finished(true);
5603 return Ok(response);
5604 }
5605 }
5606 }
5607 }
5608
5609 /// Ad clients to list accounts for.
5610 ///
5611 /// Append the given value to the *filter ad client id* query property.
5612 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5613 ///
5614 /// Even though the property as already been set when instantiating this call,
5615 /// we provide this method for API completeness.
5616 pub fn add_filter_ad_client_id(mut self, new_value: &str) -> AccountListCall<'a, C> {
5617 self._filter_ad_client_id.push(new_value.to_string());
5618 self
5619 }
5620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5621 /// while executing the actual API request.
5622 ///
5623 /// ````text
5624 /// It should be used to handle progress information, and to implement a certain level of resilience.
5625 /// ````
5626 ///
5627 /// Sets the *delegate* property to the given value.
5628 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
5629 self._delegate = Some(new_value);
5630 self
5631 }
5632
5633 /// Set any additional parameter of the query string used in the request.
5634 /// It should be used to set parameters which are not yet available through their own
5635 /// setters.
5636 ///
5637 /// Please note that this method must not be used to set any of the known parameters
5638 /// which have their own setter method. If done anyway, the request will fail.
5639 ///
5640 /// # Additional Parameters
5641 ///
5642 /// * *alt* (query-string) - Data format for the response.
5643 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5644 /// * *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.
5645 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5646 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5647 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5648 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5649 pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
5650 where
5651 T: AsRef<str>,
5652 {
5653 self._additional_params
5654 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5655 self
5656 }
5657
5658 /// Identifies the authorization scope for the method you are building.
5659 ///
5660 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5661 /// [`Scope::Full`].
5662 ///
5663 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5664 /// tokens for more than one scope.
5665 ///
5666 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5667 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5668 /// sufficient, a read-write scope will do as well.
5669 pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
5670 where
5671 St: AsRef<str>,
5672 {
5673 self._scopes.insert(String::from(scope.as_ref()));
5674 self
5675 }
5676 /// Identifies the authorization scope(s) for the method you are building.
5677 ///
5678 /// See [`Self::add_scope()`] for details.
5679 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
5680 where
5681 I: IntoIterator<Item = St>,
5682 St: AsRef<str>,
5683 {
5684 self._scopes
5685 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5686 self
5687 }
5688
5689 /// Removes all scopes, and no default scope will be used either.
5690 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5691 /// for details).
5692 pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
5693 self._scopes.clear();
5694 self
5695 }
5696}
5697
5698/// Get information about one of the ad clients in the Host AdSense account.
5699///
5700/// A builder for the *get* method supported by a *adclient* resource.
5701/// It is not used directly, but through a [`AdclientMethods`] instance.
5702///
5703/// # Example
5704///
5705/// Instantiate a resource method builder
5706///
5707/// ```test_harness,no_run
5708/// # extern crate hyper;
5709/// # extern crate hyper_rustls;
5710/// # extern crate google_adsensehost4d1 as adsensehost4d1;
5711/// # async fn dox() {
5712/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5713///
5714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5715/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5716/// # .with_native_roots()
5717/// # .unwrap()
5718/// # .https_only()
5719/// # .enable_http2()
5720/// # .build();
5721///
5722/// # let executor = hyper_util::rt::TokioExecutor::new();
5723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5724/// # secret,
5725/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5726/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5727/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5728/// # ),
5729/// # ).build().await.unwrap();
5730///
5731/// # let client = hyper_util::client::legacy::Client::builder(
5732/// # hyper_util::rt::TokioExecutor::new()
5733/// # )
5734/// # .build(
5735/// # hyper_rustls::HttpsConnectorBuilder::new()
5736/// # .with_native_roots()
5737/// # .unwrap()
5738/// # .https_or_http()
5739/// # .enable_http2()
5740/// # .build()
5741/// # );
5742/// # let mut hub = AdSenseHost::new(client, auth);
5743/// // You can configure optional parameters by calling the respective setters at will, and
5744/// // execute the final call using `doit()`.
5745/// // Values shown here are possibly random and not representative !
5746/// let result = hub.adclients().get("adClientId")
5747/// .doit().await;
5748/// # }
5749/// ```
5750pub struct AdclientGetCall<'a, C>
5751where
5752 C: 'a,
5753{
5754 hub: &'a AdSenseHost<C>,
5755 _ad_client_id: String,
5756 _delegate: Option<&'a mut dyn common::Delegate>,
5757 _additional_params: HashMap<String, String>,
5758 _scopes: BTreeSet<String>,
5759}
5760
5761impl<'a, C> common::CallBuilder for AdclientGetCall<'a, C> {}
5762
5763impl<'a, C> AdclientGetCall<'a, C>
5764where
5765 C: common::Connector,
5766{
5767 /// Perform the operation you have build so far.
5768 pub async fn doit(mut self) -> common::Result<(common::Response, AdClient)> {
5769 use std::borrow::Cow;
5770 use std::io::{Read, Seek};
5771
5772 use common::{url::Params, ToParts};
5773 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5774
5775 let mut dd = common::DefaultDelegate;
5776 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5777 dlg.begin(common::MethodInfo {
5778 id: "adsensehost.adclients.get",
5779 http_method: hyper::Method::GET,
5780 });
5781
5782 for &field in ["alt", "adClientId"].iter() {
5783 if self._additional_params.contains_key(field) {
5784 dlg.finished(false);
5785 return Err(common::Error::FieldClash(field));
5786 }
5787 }
5788
5789 let mut params = Params::with_capacity(3 + self._additional_params.len());
5790 params.push("adClientId", self._ad_client_id);
5791
5792 params.extend(self._additional_params.iter());
5793
5794 params.push("alt", "json");
5795 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}";
5796 if self._scopes.is_empty() {
5797 self._scopes.insert(Scope::Full.as_ref().to_string());
5798 }
5799
5800 #[allow(clippy::single_element_loop)]
5801 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
5802 url = params.uri_replacement(url, param_name, find_this, false);
5803 }
5804 {
5805 let to_remove = ["adClientId"];
5806 params.remove_params(&to_remove);
5807 }
5808
5809 let url = params.parse_with_url(&url);
5810
5811 loop {
5812 let token = match self
5813 .hub
5814 .auth
5815 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5816 .await
5817 {
5818 Ok(token) => token,
5819 Err(e) => match dlg.token(e) {
5820 Ok(token) => token,
5821 Err(e) => {
5822 dlg.finished(false);
5823 return Err(common::Error::MissingToken(e));
5824 }
5825 },
5826 };
5827 let mut req_result = {
5828 let client = &self.hub.client;
5829 dlg.pre_request();
5830 let mut req_builder = hyper::Request::builder()
5831 .method(hyper::Method::GET)
5832 .uri(url.as_str())
5833 .header(USER_AGENT, self.hub._user_agent.clone());
5834
5835 if let Some(token) = token.as_ref() {
5836 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5837 }
5838
5839 let request = req_builder
5840 .header(CONTENT_LENGTH, 0_u64)
5841 .body(common::to_body::<String>(None));
5842
5843 client.request(request.unwrap()).await
5844 };
5845
5846 match req_result {
5847 Err(err) => {
5848 if let common::Retry::After(d) = dlg.http_error(&err) {
5849 sleep(d).await;
5850 continue;
5851 }
5852 dlg.finished(false);
5853 return Err(common::Error::HttpError(err));
5854 }
5855 Ok(res) => {
5856 let (mut parts, body) = res.into_parts();
5857 let mut body = common::Body::new(body);
5858 if !parts.status.is_success() {
5859 let bytes = common::to_bytes(body).await.unwrap_or_default();
5860 let error = serde_json::from_str(&common::to_string(&bytes));
5861 let response = common::to_response(parts, bytes.into());
5862
5863 if let common::Retry::After(d) =
5864 dlg.http_failure(&response, error.as_ref().ok())
5865 {
5866 sleep(d).await;
5867 continue;
5868 }
5869
5870 dlg.finished(false);
5871
5872 return Err(match error {
5873 Ok(value) => common::Error::BadRequest(value),
5874 _ => common::Error::Failure(response),
5875 });
5876 }
5877 let response = {
5878 let bytes = common::to_bytes(body).await.unwrap_or_default();
5879 let encoded = common::to_string(&bytes);
5880 match serde_json::from_str(&encoded) {
5881 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5882 Err(error) => {
5883 dlg.response_json_decode_error(&encoded, &error);
5884 return Err(common::Error::JsonDecodeError(
5885 encoded.to_string(),
5886 error,
5887 ));
5888 }
5889 }
5890 };
5891
5892 dlg.finished(true);
5893 return Ok(response);
5894 }
5895 }
5896 }
5897 }
5898
5899 /// Ad client to get.
5900 ///
5901 /// Sets the *ad client id* path property to the given value.
5902 ///
5903 /// Even though the property as already been set when instantiating this call,
5904 /// we provide this method for API completeness.
5905 pub fn ad_client_id(mut self, new_value: &str) -> AdclientGetCall<'a, C> {
5906 self._ad_client_id = new_value.to_string();
5907 self
5908 }
5909 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5910 /// while executing the actual API request.
5911 ///
5912 /// ````text
5913 /// It should be used to handle progress information, and to implement a certain level of resilience.
5914 /// ````
5915 ///
5916 /// Sets the *delegate* property to the given value.
5917 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdclientGetCall<'a, C> {
5918 self._delegate = Some(new_value);
5919 self
5920 }
5921
5922 /// Set any additional parameter of the query string used in the request.
5923 /// It should be used to set parameters which are not yet available through their own
5924 /// setters.
5925 ///
5926 /// Please note that this method must not be used to set any of the known parameters
5927 /// which have their own setter method. If done anyway, the request will fail.
5928 ///
5929 /// # Additional Parameters
5930 ///
5931 /// * *alt* (query-string) - Data format for the response.
5932 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5933 /// * *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.
5934 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5935 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5936 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5937 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5938 pub fn param<T>(mut self, name: T, value: T) -> AdclientGetCall<'a, C>
5939 where
5940 T: AsRef<str>,
5941 {
5942 self._additional_params
5943 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5944 self
5945 }
5946
5947 /// Identifies the authorization scope for the method you are building.
5948 ///
5949 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5950 /// [`Scope::Full`].
5951 ///
5952 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5953 /// tokens for more than one scope.
5954 ///
5955 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5956 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5957 /// sufficient, a read-write scope will do as well.
5958 pub fn add_scope<St>(mut self, scope: St) -> AdclientGetCall<'a, C>
5959 where
5960 St: AsRef<str>,
5961 {
5962 self._scopes.insert(String::from(scope.as_ref()));
5963 self
5964 }
5965 /// Identifies the authorization scope(s) for the method you are building.
5966 ///
5967 /// See [`Self::add_scope()`] for details.
5968 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdclientGetCall<'a, C>
5969 where
5970 I: IntoIterator<Item = St>,
5971 St: AsRef<str>,
5972 {
5973 self._scopes
5974 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5975 self
5976 }
5977
5978 /// Removes all scopes, and no default scope will be used either.
5979 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5980 /// for details).
5981 pub fn clear_scopes(mut self) -> AdclientGetCall<'a, C> {
5982 self._scopes.clear();
5983 self
5984 }
5985}
5986
5987/// List all host ad clients in this AdSense account.
5988///
5989/// A builder for the *list* method supported by a *adclient* resource.
5990/// It is not used directly, but through a [`AdclientMethods`] instance.
5991///
5992/// # Example
5993///
5994/// Instantiate a resource method builder
5995///
5996/// ```test_harness,no_run
5997/// # extern crate hyper;
5998/// # extern crate hyper_rustls;
5999/// # extern crate google_adsensehost4d1 as adsensehost4d1;
6000/// # async fn dox() {
6001/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6002///
6003/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6004/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6005/// # .with_native_roots()
6006/// # .unwrap()
6007/// # .https_only()
6008/// # .enable_http2()
6009/// # .build();
6010///
6011/// # let executor = hyper_util::rt::TokioExecutor::new();
6012/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6013/// # secret,
6014/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6015/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6016/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6017/// # ),
6018/// # ).build().await.unwrap();
6019///
6020/// # let client = hyper_util::client::legacy::Client::builder(
6021/// # hyper_util::rt::TokioExecutor::new()
6022/// # )
6023/// # .build(
6024/// # hyper_rustls::HttpsConnectorBuilder::new()
6025/// # .with_native_roots()
6026/// # .unwrap()
6027/// # .https_or_http()
6028/// # .enable_http2()
6029/// # .build()
6030/// # );
6031/// # let mut hub = AdSenseHost::new(client, auth);
6032/// // You can configure optional parameters by calling the respective setters at will, and
6033/// // execute the final call using `doit()`.
6034/// // Values shown here are possibly random and not representative !
6035/// let result = hub.adclients().list()
6036/// .page_token("accusam")
6037/// .max_results(42)
6038/// .doit().await;
6039/// # }
6040/// ```
6041pub struct AdclientListCall<'a, C>
6042where
6043 C: 'a,
6044{
6045 hub: &'a AdSenseHost<C>,
6046 _page_token: Option<String>,
6047 _max_results: Option<u32>,
6048 _delegate: Option<&'a mut dyn common::Delegate>,
6049 _additional_params: HashMap<String, String>,
6050 _scopes: BTreeSet<String>,
6051}
6052
6053impl<'a, C> common::CallBuilder for AdclientListCall<'a, C> {}
6054
6055impl<'a, C> AdclientListCall<'a, C>
6056where
6057 C: common::Connector,
6058{
6059 /// Perform the operation you have build so far.
6060 pub async fn doit(mut self) -> common::Result<(common::Response, AdClients)> {
6061 use std::borrow::Cow;
6062 use std::io::{Read, Seek};
6063
6064 use common::{url::Params, ToParts};
6065 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6066
6067 let mut dd = common::DefaultDelegate;
6068 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6069 dlg.begin(common::MethodInfo {
6070 id: "adsensehost.adclients.list",
6071 http_method: hyper::Method::GET,
6072 });
6073
6074 for &field in ["alt", "pageToken", "maxResults"].iter() {
6075 if self._additional_params.contains_key(field) {
6076 dlg.finished(false);
6077 return Err(common::Error::FieldClash(field));
6078 }
6079 }
6080
6081 let mut params = Params::with_capacity(4 + self._additional_params.len());
6082 if let Some(value) = self._page_token.as_ref() {
6083 params.push("pageToken", value);
6084 }
6085 if let Some(value) = self._max_results.as_ref() {
6086 params.push("maxResults", value.to_string());
6087 }
6088
6089 params.extend(self._additional_params.iter());
6090
6091 params.push("alt", "json");
6092 let mut url = self.hub._base_url.clone() + "adclients";
6093 if self._scopes.is_empty() {
6094 self._scopes.insert(Scope::Full.as_ref().to_string());
6095 }
6096
6097 let url = params.parse_with_url(&url);
6098
6099 loop {
6100 let token = match self
6101 .hub
6102 .auth
6103 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6104 .await
6105 {
6106 Ok(token) => token,
6107 Err(e) => match dlg.token(e) {
6108 Ok(token) => token,
6109 Err(e) => {
6110 dlg.finished(false);
6111 return Err(common::Error::MissingToken(e));
6112 }
6113 },
6114 };
6115 let mut req_result = {
6116 let client = &self.hub.client;
6117 dlg.pre_request();
6118 let mut req_builder = hyper::Request::builder()
6119 .method(hyper::Method::GET)
6120 .uri(url.as_str())
6121 .header(USER_AGENT, self.hub._user_agent.clone());
6122
6123 if let Some(token) = token.as_ref() {
6124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6125 }
6126
6127 let request = req_builder
6128 .header(CONTENT_LENGTH, 0_u64)
6129 .body(common::to_body::<String>(None));
6130
6131 client.request(request.unwrap()).await
6132 };
6133
6134 match req_result {
6135 Err(err) => {
6136 if let common::Retry::After(d) = dlg.http_error(&err) {
6137 sleep(d).await;
6138 continue;
6139 }
6140 dlg.finished(false);
6141 return Err(common::Error::HttpError(err));
6142 }
6143 Ok(res) => {
6144 let (mut parts, body) = res.into_parts();
6145 let mut body = common::Body::new(body);
6146 if !parts.status.is_success() {
6147 let bytes = common::to_bytes(body).await.unwrap_or_default();
6148 let error = serde_json::from_str(&common::to_string(&bytes));
6149 let response = common::to_response(parts, bytes.into());
6150
6151 if let common::Retry::After(d) =
6152 dlg.http_failure(&response, error.as_ref().ok())
6153 {
6154 sleep(d).await;
6155 continue;
6156 }
6157
6158 dlg.finished(false);
6159
6160 return Err(match error {
6161 Ok(value) => common::Error::BadRequest(value),
6162 _ => common::Error::Failure(response),
6163 });
6164 }
6165 let response = {
6166 let bytes = common::to_bytes(body).await.unwrap_or_default();
6167 let encoded = common::to_string(&bytes);
6168 match serde_json::from_str(&encoded) {
6169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6170 Err(error) => {
6171 dlg.response_json_decode_error(&encoded, &error);
6172 return Err(common::Error::JsonDecodeError(
6173 encoded.to_string(),
6174 error,
6175 ));
6176 }
6177 }
6178 };
6179
6180 dlg.finished(true);
6181 return Ok(response);
6182 }
6183 }
6184 }
6185 }
6186
6187 /// 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.
6188 ///
6189 /// Sets the *page token* query property to the given value.
6190 pub fn page_token(mut self, new_value: &str) -> AdclientListCall<'a, C> {
6191 self._page_token = Some(new_value.to_string());
6192 self
6193 }
6194 /// The maximum number of ad clients to include in the response, used for paging.
6195 ///
6196 /// Sets the *max results* query property to the given value.
6197 pub fn max_results(mut self, new_value: u32) -> AdclientListCall<'a, C> {
6198 self._max_results = Some(new_value);
6199 self
6200 }
6201 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6202 /// while executing the actual API request.
6203 ///
6204 /// ````text
6205 /// It should be used to handle progress information, and to implement a certain level of resilience.
6206 /// ````
6207 ///
6208 /// Sets the *delegate* property to the given value.
6209 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdclientListCall<'a, C> {
6210 self._delegate = Some(new_value);
6211 self
6212 }
6213
6214 /// Set any additional parameter of the query string used in the request.
6215 /// It should be used to set parameters which are not yet available through their own
6216 /// setters.
6217 ///
6218 /// Please note that this method must not be used to set any of the known parameters
6219 /// which have their own setter method. If done anyway, the request will fail.
6220 ///
6221 /// # Additional Parameters
6222 ///
6223 /// * *alt* (query-string) - Data format for the response.
6224 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6225 /// * *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.
6226 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6227 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6228 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6229 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6230 pub fn param<T>(mut self, name: T, value: T) -> AdclientListCall<'a, C>
6231 where
6232 T: AsRef<str>,
6233 {
6234 self._additional_params
6235 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6236 self
6237 }
6238
6239 /// Identifies the authorization scope for the method you are building.
6240 ///
6241 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6242 /// [`Scope::Full`].
6243 ///
6244 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6245 /// tokens for more than one scope.
6246 ///
6247 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6248 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6249 /// sufficient, a read-write scope will do as well.
6250 pub fn add_scope<St>(mut self, scope: St) -> AdclientListCall<'a, C>
6251 where
6252 St: AsRef<str>,
6253 {
6254 self._scopes.insert(String::from(scope.as_ref()));
6255 self
6256 }
6257 /// Identifies the authorization scope(s) for the method you are building.
6258 ///
6259 /// See [`Self::add_scope()`] for details.
6260 pub fn add_scopes<I, St>(mut self, scopes: I) -> AdclientListCall<'a, C>
6261 where
6262 I: IntoIterator<Item = St>,
6263 St: AsRef<str>,
6264 {
6265 self._scopes
6266 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6267 self
6268 }
6269
6270 /// Removes all scopes, and no default scope will be used either.
6271 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6272 /// for details).
6273 pub fn clear_scopes(mut self) -> AdclientListCall<'a, C> {
6274 self._scopes.clear();
6275 self
6276 }
6277}
6278
6279/// Create an association session for initiating an association with an AdSense user.
6280///
6281/// A builder for the *start* method supported by a *associationsession* resource.
6282/// It is not used directly, but through a [`AssociationsessionMethods`] instance.
6283///
6284/// # Example
6285///
6286/// Instantiate a resource method builder
6287///
6288/// ```test_harness,no_run
6289/// # extern crate hyper;
6290/// # extern crate hyper_rustls;
6291/// # extern crate google_adsensehost4d1 as adsensehost4d1;
6292/// # async fn dox() {
6293/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6294///
6295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6297/// # .with_native_roots()
6298/// # .unwrap()
6299/// # .https_only()
6300/// # .enable_http2()
6301/// # .build();
6302///
6303/// # let executor = hyper_util::rt::TokioExecutor::new();
6304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6305/// # secret,
6306/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6307/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6308/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6309/// # ),
6310/// # ).build().await.unwrap();
6311///
6312/// # let client = hyper_util::client::legacy::Client::builder(
6313/// # hyper_util::rt::TokioExecutor::new()
6314/// # )
6315/// # .build(
6316/// # hyper_rustls::HttpsConnectorBuilder::new()
6317/// # .with_native_roots()
6318/// # .unwrap()
6319/// # .https_or_http()
6320/// # .enable_http2()
6321/// # .build()
6322/// # );
6323/// # let mut hub = AdSenseHost::new(client, auth);
6324/// // You can configure optional parameters by calling the respective setters at will, and
6325/// // execute the final call using `doit()`.
6326/// // Values shown here are possibly random and not representative !
6327/// let result = hub.associationsessions().start(&vec!["consetetur".into()], "websiteUrl")
6328/// .website_locale("et")
6329/// .user_locale("erat")
6330/// .callback_url("consetetur")
6331/// .doit().await;
6332/// # }
6333/// ```
6334pub struct AssociationsessionStartCall<'a, C>
6335where
6336 C: 'a,
6337{
6338 hub: &'a AdSenseHost<C>,
6339 _product_code: Vec<String>,
6340 _website_url: String,
6341 _website_locale: Option<String>,
6342 _user_locale: Option<String>,
6343 _callback_url: Option<String>,
6344 _delegate: Option<&'a mut dyn common::Delegate>,
6345 _additional_params: HashMap<String, String>,
6346 _scopes: BTreeSet<String>,
6347}
6348
6349impl<'a, C> common::CallBuilder for AssociationsessionStartCall<'a, C> {}
6350
6351impl<'a, C> AssociationsessionStartCall<'a, C>
6352where
6353 C: common::Connector,
6354{
6355 /// Perform the operation you have build so far.
6356 pub async fn doit(mut self) -> common::Result<(common::Response, AssociationSession)> {
6357 use std::borrow::Cow;
6358 use std::io::{Read, Seek};
6359
6360 use common::{url::Params, ToParts};
6361 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6362
6363 let mut dd = common::DefaultDelegate;
6364 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6365 dlg.begin(common::MethodInfo {
6366 id: "adsensehost.associationsessions.start",
6367 http_method: hyper::Method::GET,
6368 });
6369
6370 for &field in [
6371 "alt",
6372 "productCode",
6373 "websiteUrl",
6374 "websiteLocale",
6375 "userLocale",
6376 "callbackUrl",
6377 ]
6378 .iter()
6379 {
6380 if self._additional_params.contains_key(field) {
6381 dlg.finished(false);
6382 return Err(common::Error::FieldClash(field));
6383 }
6384 }
6385
6386 let mut params = Params::with_capacity(7 + self._additional_params.len());
6387 if !self._product_code.is_empty() {
6388 for f in self._product_code.iter() {
6389 params.push("productCode", f);
6390 }
6391 }
6392 params.push("websiteUrl", self._website_url);
6393 if let Some(value) = self._website_locale.as_ref() {
6394 params.push("websiteLocale", value);
6395 }
6396 if let Some(value) = self._user_locale.as_ref() {
6397 params.push("userLocale", value);
6398 }
6399 if let Some(value) = self._callback_url.as_ref() {
6400 params.push("callbackUrl", value);
6401 }
6402
6403 params.extend(self._additional_params.iter());
6404
6405 params.push("alt", "json");
6406 let mut url = self.hub._base_url.clone() + "associationsessions/start";
6407 if self._scopes.is_empty() {
6408 self._scopes.insert(Scope::Full.as_ref().to_string());
6409 }
6410
6411 let url = params.parse_with_url(&url);
6412
6413 loop {
6414 let token = match self
6415 .hub
6416 .auth
6417 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6418 .await
6419 {
6420 Ok(token) => token,
6421 Err(e) => match dlg.token(e) {
6422 Ok(token) => token,
6423 Err(e) => {
6424 dlg.finished(false);
6425 return Err(common::Error::MissingToken(e));
6426 }
6427 },
6428 };
6429 let mut req_result = {
6430 let client = &self.hub.client;
6431 dlg.pre_request();
6432 let mut req_builder = hyper::Request::builder()
6433 .method(hyper::Method::GET)
6434 .uri(url.as_str())
6435 .header(USER_AGENT, self.hub._user_agent.clone());
6436
6437 if let Some(token) = token.as_ref() {
6438 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6439 }
6440
6441 let request = req_builder
6442 .header(CONTENT_LENGTH, 0_u64)
6443 .body(common::to_body::<String>(None));
6444
6445 client.request(request.unwrap()).await
6446 };
6447
6448 match req_result {
6449 Err(err) => {
6450 if let common::Retry::After(d) = dlg.http_error(&err) {
6451 sleep(d).await;
6452 continue;
6453 }
6454 dlg.finished(false);
6455 return Err(common::Error::HttpError(err));
6456 }
6457 Ok(res) => {
6458 let (mut parts, body) = res.into_parts();
6459 let mut body = common::Body::new(body);
6460 if !parts.status.is_success() {
6461 let bytes = common::to_bytes(body).await.unwrap_or_default();
6462 let error = serde_json::from_str(&common::to_string(&bytes));
6463 let response = common::to_response(parts, bytes.into());
6464
6465 if let common::Retry::After(d) =
6466 dlg.http_failure(&response, error.as_ref().ok())
6467 {
6468 sleep(d).await;
6469 continue;
6470 }
6471
6472 dlg.finished(false);
6473
6474 return Err(match error {
6475 Ok(value) => common::Error::BadRequest(value),
6476 _ => common::Error::Failure(response),
6477 });
6478 }
6479 let response = {
6480 let bytes = common::to_bytes(body).await.unwrap_or_default();
6481 let encoded = common::to_string(&bytes);
6482 match serde_json::from_str(&encoded) {
6483 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6484 Err(error) => {
6485 dlg.response_json_decode_error(&encoded, &error);
6486 return Err(common::Error::JsonDecodeError(
6487 encoded.to_string(),
6488 error,
6489 ));
6490 }
6491 }
6492 };
6493
6494 dlg.finished(true);
6495 return Ok(response);
6496 }
6497 }
6498 }
6499 }
6500
6501 /// Products to associate with the user.
6502 ///
6503 /// Append the given value to the *product code* query property.
6504 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6505 ///
6506 /// Even though the property as already been set when instantiating this call,
6507 /// we provide this method for API completeness.
6508 pub fn add_product_code(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C> {
6509 self._product_code.push(new_value.to_string());
6510 self
6511 }
6512 /// The URL of the user's hosted website.
6513 ///
6514 /// Sets the *website url* query property to the given value.
6515 ///
6516 /// Even though the property as already been set when instantiating this call,
6517 /// we provide this method for API completeness.
6518 pub fn website_url(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C> {
6519 self._website_url = new_value.to_string();
6520 self
6521 }
6522 /// The locale of the user's hosted website.
6523 ///
6524 /// Sets the *website locale* query property to the given value.
6525 pub fn website_locale(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C> {
6526 self._website_locale = Some(new_value.to_string());
6527 self
6528 }
6529 /// The preferred locale of the user.
6530 ///
6531 /// Sets the *user locale* query property to the given value.
6532 pub fn user_locale(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C> {
6533 self._user_locale = Some(new_value.to_string());
6534 self
6535 }
6536 /// The URL to redirect the user to once association is completed. It receives a token parameter that can then be used to retrieve the associated account.
6537 ///
6538 /// Sets the *callback url* query property to the given value.
6539 pub fn callback_url(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C> {
6540 self._callback_url = Some(new_value.to_string());
6541 self
6542 }
6543 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6544 /// while executing the actual API request.
6545 ///
6546 /// ````text
6547 /// It should be used to handle progress information, and to implement a certain level of resilience.
6548 /// ````
6549 ///
6550 /// Sets the *delegate* property to the given value.
6551 pub fn delegate(
6552 mut self,
6553 new_value: &'a mut dyn common::Delegate,
6554 ) -> AssociationsessionStartCall<'a, C> {
6555 self._delegate = Some(new_value);
6556 self
6557 }
6558
6559 /// Set any additional parameter of the query string used in the request.
6560 /// It should be used to set parameters which are not yet available through their own
6561 /// setters.
6562 ///
6563 /// Please note that this method must not be used to set any of the known parameters
6564 /// which have their own setter method. If done anyway, the request will fail.
6565 ///
6566 /// # Additional Parameters
6567 ///
6568 /// * *alt* (query-string) - Data format for the response.
6569 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6570 /// * *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.
6571 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6572 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6573 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6574 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6575 pub fn param<T>(mut self, name: T, value: T) -> AssociationsessionStartCall<'a, C>
6576 where
6577 T: AsRef<str>,
6578 {
6579 self._additional_params
6580 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6581 self
6582 }
6583
6584 /// Identifies the authorization scope for the method you are building.
6585 ///
6586 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6587 /// [`Scope::Full`].
6588 ///
6589 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6590 /// tokens for more than one scope.
6591 ///
6592 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6593 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6594 /// sufficient, a read-write scope will do as well.
6595 pub fn add_scope<St>(mut self, scope: St) -> AssociationsessionStartCall<'a, C>
6596 where
6597 St: AsRef<str>,
6598 {
6599 self._scopes.insert(String::from(scope.as_ref()));
6600 self
6601 }
6602 /// Identifies the authorization scope(s) for the method you are building.
6603 ///
6604 /// See [`Self::add_scope()`] for details.
6605 pub fn add_scopes<I, St>(mut self, scopes: I) -> AssociationsessionStartCall<'a, C>
6606 where
6607 I: IntoIterator<Item = St>,
6608 St: AsRef<str>,
6609 {
6610 self._scopes
6611 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6612 self
6613 }
6614
6615 /// Removes all scopes, and no default scope will be used either.
6616 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6617 /// for details).
6618 pub fn clear_scopes(mut self) -> AssociationsessionStartCall<'a, C> {
6619 self._scopes.clear();
6620 self
6621 }
6622}
6623
6624/// Verify an association session after the association callback returns from AdSense signup.
6625///
6626/// A builder for the *verify* method supported by a *associationsession* resource.
6627/// It is not used directly, but through a [`AssociationsessionMethods`] instance.
6628///
6629/// # Example
6630///
6631/// Instantiate a resource method builder
6632///
6633/// ```test_harness,no_run
6634/// # extern crate hyper;
6635/// # extern crate hyper_rustls;
6636/// # extern crate google_adsensehost4d1 as adsensehost4d1;
6637/// # async fn dox() {
6638/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6639///
6640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6642/// # .with_native_roots()
6643/// # .unwrap()
6644/// # .https_only()
6645/// # .enable_http2()
6646/// # .build();
6647///
6648/// # let executor = hyper_util::rt::TokioExecutor::new();
6649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6650/// # secret,
6651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6652/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6653/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6654/// # ),
6655/// # ).build().await.unwrap();
6656///
6657/// # let client = hyper_util::client::legacy::Client::builder(
6658/// # hyper_util::rt::TokioExecutor::new()
6659/// # )
6660/// # .build(
6661/// # hyper_rustls::HttpsConnectorBuilder::new()
6662/// # .with_native_roots()
6663/// # .unwrap()
6664/// # .https_or_http()
6665/// # .enable_http2()
6666/// # .build()
6667/// # );
6668/// # let mut hub = AdSenseHost::new(client, auth);
6669/// // You can configure optional parameters by calling the respective setters at will, and
6670/// // execute the final call using `doit()`.
6671/// // Values shown here are possibly random and not representative !
6672/// let result = hub.associationsessions().verify("token")
6673/// .doit().await;
6674/// # }
6675/// ```
6676pub struct AssociationsessionVerifyCall<'a, C>
6677where
6678 C: 'a,
6679{
6680 hub: &'a AdSenseHost<C>,
6681 _token: String,
6682 _delegate: Option<&'a mut dyn common::Delegate>,
6683 _additional_params: HashMap<String, String>,
6684 _scopes: BTreeSet<String>,
6685}
6686
6687impl<'a, C> common::CallBuilder for AssociationsessionVerifyCall<'a, C> {}
6688
6689impl<'a, C> AssociationsessionVerifyCall<'a, C>
6690where
6691 C: common::Connector,
6692{
6693 /// Perform the operation you have build so far.
6694 pub async fn doit(mut self) -> common::Result<(common::Response, AssociationSession)> {
6695 use std::borrow::Cow;
6696 use std::io::{Read, Seek};
6697
6698 use common::{url::Params, ToParts};
6699 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6700
6701 let mut dd = common::DefaultDelegate;
6702 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6703 dlg.begin(common::MethodInfo {
6704 id: "adsensehost.associationsessions.verify",
6705 http_method: hyper::Method::GET,
6706 });
6707
6708 for &field in ["alt", "token"].iter() {
6709 if self._additional_params.contains_key(field) {
6710 dlg.finished(false);
6711 return Err(common::Error::FieldClash(field));
6712 }
6713 }
6714
6715 let mut params = Params::with_capacity(3 + self._additional_params.len());
6716 params.push("token", self._token);
6717
6718 params.extend(self._additional_params.iter());
6719
6720 params.push("alt", "json");
6721 let mut url = self.hub._base_url.clone() + "associationsessions/verify";
6722 if self._scopes.is_empty() {
6723 self._scopes.insert(Scope::Full.as_ref().to_string());
6724 }
6725
6726 let url = params.parse_with_url(&url);
6727
6728 loop {
6729 let token = match self
6730 .hub
6731 .auth
6732 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6733 .await
6734 {
6735 Ok(token) => token,
6736 Err(e) => match dlg.token(e) {
6737 Ok(token) => token,
6738 Err(e) => {
6739 dlg.finished(false);
6740 return Err(common::Error::MissingToken(e));
6741 }
6742 },
6743 };
6744 let mut req_result = {
6745 let client = &self.hub.client;
6746 dlg.pre_request();
6747 let mut req_builder = hyper::Request::builder()
6748 .method(hyper::Method::GET)
6749 .uri(url.as_str())
6750 .header(USER_AGENT, self.hub._user_agent.clone());
6751
6752 if let Some(token) = token.as_ref() {
6753 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6754 }
6755
6756 let request = req_builder
6757 .header(CONTENT_LENGTH, 0_u64)
6758 .body(common::to_body::<String>(None));
6759
6760 client.request(request.unwrap()).await
6761 };
6762
6763 match req_result {
6764 Err(err) => {
6765 if let common::Retry::After(d) = dlg.http_error(&err) {
6766 sleep(d).await;
6767 continue;
6768 }
6769 dlg.finished(false);
6770 return Err(common::Error::HttpError(err));
6771 }
6772 Ok(res) => {
6773 let (mut parts, body) = res.into_parts();
6774 let mut body = common::Body::new(body);
6775 if !parts.status.is_success() {
6776 let bytes = common::to_bytes(body).await.unwrap_or_default();
6777 let error = serde_json::from_str(&common::to_string(&bytes));
6778 let response = common::to_response(parts, bytes.into());
6779
6780 if let common::Retry::After(d) =
6781 dlg.http_failure(&response, error.as_ref().ok())
6782 {
6783 sleep(d).await;
6784 continue;
6785 }
6786
6787 dlg.finished(false);
6788
6789 return Err(match error {
6790 Ok(value) => common::Error::BadRequest(value),
6791 _ => common::Error::Failure(response),
6792 });
6793 }
6794 let response = {
6795 let bytes = common::to_bytes(body).await.unwrap_or_default();
6796 let encoded = common::to_string(&bytes);
6797 match serde_json::from_str(&encoded) {
6798 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6799 Err(error) => {
6800 dlg.response_json_decode_error(&encoded, &error);
6801 return Err(common::Error::JsonDecodeError(
6802 encoded.to_string(),
6803 error,
6804 ));
6805 }
6806 }
6807 };
6808
6809 dlg.finished(true);
6810 return Ok(response);
6811 }
6812 }
6813 }
6814 }
6815
6816 /// The token returned to the association callback URL.
6817 ///
6818 /// Sets the *token* query property to the given value.
6819 ///
6820 /// Even though the property as already been set when instantiating this call,
6821 /// we provide this method for API completeness.
6822 pub fn token(mut self, new_value: &str) -> AssociationsessionVerifyCall<'a, C> {
6823 self._token = new_value.to_string();
6824 self
6825 }
6826 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6827 /// while executing the actual API request.
6828 ///
6829 /// ````text
6830 /// It should be used to handle progress information, and to implement a certain level of resilience.
6831 /// ````
6832 ///
6833 /// Sets the *delegate* property to the given value.
6834 pub fn delegate(
6835 mut self,
6836 new_value: &'a mut dyn common::Delegate,
6837 ) -> AssociationsessionVerifyCall<'a, C> {
6838 self._delegate = Some(new_value);
6839 self
6840 }
6841
6842 /// Set any additional parameter of the query string used in the request.
6843 /// It should be used to set parameters which are not yet available through their own
6844 /// setters.
6845 ///
6846 /// Please note that this method must not be used to set any of the known parameters
6847 /// which have their own setter method. If done anyway, the request will fail.
6848 ///
6849 /// # Additional Parameters
6850 ///
6851 /// * *alt* (query-string) - Data format for the response.
6852 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6853 /// * *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.
6854 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6855 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6856 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6857 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6858 pub fn param<T>(mut self, name: T, value: T) -> AssociationsessionVerifyCall<'a, C>
6859 where
6860 T: AsRef<str>,
6861 {
6862 self._additional_params
6863 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6864 self
6865 }
6866
6867 /// Identifies the authorization scope for the method you are building.
6868 ///
6869 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6870 /// [`Scope::Full`].
6871 ///
6872 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6873 /// tokens for more than one scope.
6874 ///
6875 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6876 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6877 /// sufficient, a read-write scope will do as well.
6878 pub fn add_scope<St>(mut self, scope: St) -> AssociationsessionVerifyCall<'a, C>
6879 where
6880 St: AsRef<str>,
6881 {
6882 self._scopes.insert(String::from(scope.as_ref()));
6883 self
6884 }
6885 /// Identifies the authorization scope(s) for the method you are building.
6886 ///
6887 /// See [`Self::add_scope()`] for details.
6888 pub fn add_scopes<I, St>(mut self, scopes: I) -> AssociationsessionVerifyCall<'a, C>
6889 where
6890 I: IntoIterator<Item = St>,
6891 St: AsRef<str>,
6892 {
6893 self._scopes
6894 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6895 self
6896 }
6897
6898 /// Removes all scopes, and no default scope will be used either.
6899 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6900 /// for details).
6901 pub fn clear_scopes(mut self) -> AssociationsessionVerifyCall<'a, C> {
6902 self._scopes.clear();
6903 self
6904 }
6905}
6906
6907/// Delete a specific custom channel from the host AdSense account.
6908///
6909/// A builder for the *delete* method supported by a *customchannel* resource.
6910/// It is not used directly, but through a [`CustomchannelMethods`] instance.
6911///
6912/// # Example
6913///
6914/// Instantiate a resource method builder
6915///
6916/// ```test_harness,no_run
6917/// # extern crate hyper;
6918/// # extern crate hyper_rustls;
6919/// # extern crate google_adsensehost4d1 as adsensehost4d1;
6920/// # async fn dox() {
6921/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6922///
6923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6924/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6925/// # .with_native_roots()
6926/// # .unwrap()
6927/// # .https_only()
6928/// # .enable_http2()
6929/// # .build();
6930///
6931/// # let executor = hyper_util::rt::TokioExecutor::new();
6932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6933/// # secret,
6934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6935/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6936/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6937/// # ),
6938/// # ).build().await.unwrap();
6939///
6940/// # let client = hyper_util::client::legacy::Client::builder(
6941/// # hyper_util::rt::TokioExecutor::new()
6942/// # )
6943/// # .build(
6944/// # hyper_rustls::HttpsConnectorBuilder::new()
6945/// # .with_native_roots()
6946/// # .unwrap()
6947/// # .https_or_http()
6948/// # .enable_http2()
6949/// # .build()
6950/// # );
6951/// # let mut hub = AdSenseHost::new(client, auth);
6952/// // You can configure optional parameters by calling the respective setters at will, and
6953/// // execute the final call using `doit()`.
6954/// // Values shown here are possibly random and not representative !
6955/// let result = hub.customchannels().delete("adClientId", "customChannelId")
6956/// .doit().await;
6957/// # }
6958/// ```
6959pub struct CustomchannelDeleteCall<'a, C>
6960where
6961 C: 'a,
6962{
6963 hub: &'a AdSenseHost<C>,
6964 _ad_client_id: String,
6965 _custom_channel_id: String,
6966 _delegate: Option<&'a mut dyn common::Delegate>,
6967 _additional_params: HashMap<String, String>,
6968 _scopes: BTreeSet<String>,
6969}
6970
6971impl<'a, C> common::CallBuilder for CustomchannelDeleteCall<'a, C> {}
6972
6973impl<'a, C> CustomchannelDeleteCall<'a, C>
6974where
6975 C: common::Connector,
6976{
6977 /// Perform the operation you have build so far.
6978 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
6979 use std::borrow::Cow;
6980 use std::io::{Read, Seek};
6981
6982 use common::{url::Params, ToParts};
6983 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6984
6985 let mut dd = common::DefaultDelegate;
6986 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6987 dlg.begin(common::MethodInfo {
6988 id: "adsensehost.customchannels.delete",
6989 http_method: hyper::Method::DELETE,
6990 });
6991
6992 for &field in ["alt", "adClientId", "customChannelId"].iter() {
6993 if self._additional_params.contains_key(field) {
6994 dlg.finished(false);
6995 return Err(common::Error::FieldClash(field));
6996 }
6997 }
6998
6999 let mut params = Params::with_capacity(4 + self._additional_params.len());
7000 params.push("adClientId", self._ad_client_id);
7001 params.push("customChannelId", self._custom_channel_id);
7002
7003 params.extend(self._additional_params.iter());
7004
7005 params.push("alt", "json");
7006 let mut url =
7007 self.hub._base_url.clone() + "adclients/{adClientId}/customchannels/{customChannelId}";
7008 if self._scopes.is_empty() {
7009 self._scopes.insert(Scope::Full.as_ref().to_string());
7010 }
7011
7012 #[allow(clippy::single_element_loop)]
7013 for &(find_this, param_name) in [
7014 ("{adClientId}", "adClientId"),
7015 ("{customChannelId}", "customChannelId"),
7016 ]
7017 .iter()
7018 {
7019 url = params.uri_replacement(url, param_name, find_this, false);
7020 }
7021 {
7022 let to_remove = ["customChannelId", "adClientId"];
7023 params.remove_params(&to_remove);
7024 }
7025
7026 let url = params.parse_with_url(&url);
7027
7028 loop {
7029 let token = match self
7030 .hub
7031 .auth
7032 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7033 .await
7034 {
7035 Ok(token) => token,
7036 Err(e) => match dlg.token(e) {
7037 Ok(token) => token,
7038 Err(e) => {
7039 dlg.finished(false);
7040 return Err(common::Error::MissingToken(e));
7041 }
7042 },
7043 };
7044 let mut req_result = {
7045 let client = &self.hub.client;
7046 dlg.pre_request();
7047 let mut req_builder = hyper::Request::builder()
7048 .method(hyper::Method::DELETE)
7049 .uri(url.as_str())
7050 .header(USER_AGENT, self.hub._user_agent.clone());
7051
7052 if let Some(token) = token.as_ref() {
7053 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7054 }
7055
7056 let request = req_builder
7057 .header(CONTENT_LENGTH, 0_u64)
7058 .body(common::to_body::<String>(None));
7059
7060 client.request(request.unwrap()).await
7061 };
7062
7063 match req_result {
7064 Err(err) => {
7065 if let common::Retry::After(d) = dlg.http_error(&err) {
7066 sleep(d).await;
7067 continue;
7068 }
7069 dlg.finished(false);
7070 return Err(common::Error::HttpError(err));
7071 }
7072 Ok(res) => {
7073 let (mut parts, body) = res.into_parts();
7074 let mut body = common::Body::new(body);
7075 if !parts.status.is_success() {
7076 let bytes = common::to_bytes(body).await.unwrap_or_default();
7077 let error = serde_json::from_str(&common::to_string(&bytes));
7078 let response = common::to_response(parts, bytes.into());
7079
7080 if let common::Retry::After(d) =
7081 dlg.http_failure(&response, error.as_ref().ok())
7082 {
7083 sleep(d).await;
7084 continue;
7085 }
7086
7087 dlg.finished(false);
7088
7089 return Err(match error {
7090 Ok(value) => common::Error::BadRequest(value),
7091 _ => common::Error::Failure(response),
7092 });
7093 }
7094 let response = {
7095 let bytes = common::to_bytes(body).await.unwrap_or_default();
7096 let encoded = common::to_string(&bytes);
7097 match serde_json::from_str(&encoded) {
7098 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7099 Err(error) => {
7100 dlg.response_json_decode_error(&encoded, &error);
7101 return Err(common::Error::JsonDecodeError(
7102 encoded.to_string(),
7103 error,
7104 ));
7105 }
7106 }
7107 };
7108
7109 dlg.finished(true);
7110 return Ok(response);
7111 }
7112 }
7113 }
7114 }
7115
7116 /// Ad client from which to delete the custom channel.
7117 ///
7118 /// Sets the *ad client id* path property to the given value.
7119 ///
7120 /// Even though the property as already been set when instantiating this call,
7121 /// we provide this method for API completeness.
7122 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelDeleteCall<'a, C> {
7123 self._ad_client_id = new_value.to_string();
7124 self
7125 }
7126 /// Custom channel to delete.
7127 ///
7128 /// Sets the *custom channel id* path property to the given value.
7129 ///
7130 /// Even though the property as already been set when instantiating this call,
7131 /// we provide this method for API completeness.
7132 pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelDeleteCall<'a, C> {
7133 self._custom_channel_id = new_value.to_string();
7134 self
7135 }
7136 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7137 /// while executing the actual API request.
7138 ///
7139 /// ````text
7140 /// It should be used to handle progress information, and to implement a certain level of resilience.
7141 /// ````
7142 ///
7143 /// Sets the *delegate* property to the given value.
7144 pub fn delegate(
7145 mut self,
7146 new_value: &'a mut dyn common::Delegate,
7147 ) -> CustomchannelDeleteCall<'a, C> {
7148 self._delegate = Some(new_value);
7149 self
7150 }
7151
7152 /// Set any additional parameter of the query string used in the request.
7153 /// It should be used to set parameters which are not yet available through their own
7154 /// setters.
7155 ///
7156 /// Please note that this method must not be used to set any of the known parameters
7157 /// which have their own setter method. If done anyway, the request will fail.
7158 ///
7159 /// # Additional Parameters
7160 ///
7161 /// * *alt* (query-string) - Data format for the response.
7162 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7163 /// * *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.
7164 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7165 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7166 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7167 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7168 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelDeleteCall<'a, C>
7169 where
7170 T: AsRef<str>,
7171 {
7172 self._additional_params
7173 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7174 self
7175 }
7176
7177 /// Identifies the authorization scope for the method you are building.
7178 ///
7179 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7180 /// [`Scope::Full`].
7181 ///
7182 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7183 /// tokens for more than one scope.
7184 ///
7185 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7186 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7187 /// sufficient, a read-write scope will do as well.
7188 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelDeleteCall<'a, C>
7189 where
7190 St: AsRef<str>,
7191 {
7192 self._scopes.insert(String::from(scope.as_ref()));
7193 self
7194 }
7195 /// Identifies the authorization scope(s) for the method you are building.
7196 ///
7197 /// See [`Self::add_scope()`] for details.
7198 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelDeleteCall<'a, C>
7199 where
7200 I: IntoIterator<Item = St>,
7201 St: AsRef<str>,
7202 {
7203 self._scopes
7204 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7205 self
7206 }
7207
7208 /// Removes all scopes, and no default scope will be used either.
7209 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7210 /// for details).
7211 pub fn clear_scopes(mut self) -> CustomchannelDeleteCall<'a, C> {
7212 self._scopes.clear();
7213 self
7214 }
7215}
7216
7217/// Get a specific custom channel from the host AdSense account.
7218///
7219/// A builder for the *get* method supported by a *customchannel* resource.
7220/// It is not used directly, but through a [`CustomchannelMethods`] instance.
7221///
7222/// # Example
7223///
7224/// Instantiate a resource method builder
7225///
7226/// ```test_harness,no_run
7227/// # extern crate hyper;
7228/// # extern crate hyper_rustls;
7229/// # extern crate google_adsensehost4d1 as adsensehost4d1;
7230/// # async fn dox() {
7231/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7232///
7233/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7234/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7235/// # .with_native_roots()
7236/// # .unwrap()
7237/// # .https_only()
7238/// # .enable_http2()
7239/// # .build();
7240///
7241/// # let executor = hyper_util::rt::TokioExecutor::new();
7242/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7243/// # secret,
7244/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7245/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7246/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7247/// # ),
7248/// # ).build().await.unwrap();
7249///
7250/// # let client = hyper_util::client::legacy::Client::builder(
7251/// # hyper_util::rt::TokioExecutor::new()
7252/// # )
7253/// # .build(
7254/// # hyper_rustls::HttpsConnectorBuilder::new()
7255/// # .with_native_roots()
7256/// # .unwrap()
7257/// # .https_or_http()
7258/// # .enable_http2()
7259/// # .build()
7260/// # );
7261/// # let mut hub = AdSenseHost::new(client, auth);
7262/// // You can configure optional parameters by calling the respective setters at will, and
7263/// // execute the final call using `doit()`.
7264/// // Values shown here are possibly random and not representative !
7265/// let result = hub.customchannels().get("adClientId", "customChannelId")
7266/// .doit().await;
7267/// # }
7268/// ```
7269pub struct CustomchannelGetCall<'a, C>
7270where
7271 C: 'a,
7272{
7273 hub: &'a AdSenseHost<C>,
7274 _ad_client_id: String,
7275 _custom_channel_id: String,
7276 _delegate: Option<&'a mut dyn common::Delegate>,
7277 _additional_params: HashMap<String, String>,
7278 _scopes: BTreeSet<String>,
7279}
7280
7281impl<'a, C> common::CallBuilder for CustomchannelGetCall<'a, C> {}
7282
7283impl<'a, C> CustomchannelGetCall<'a, C>
7284where
7285 C: common::Connector,
7286{
7287 /// Perform the operation you have build so far.
7288 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
7289 use std::borrow::Cow;
7290 use std::io::{Read, Seek};
7291
7292 use common::{url::Params, ToParts};
7293 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7294
7295 let mut dd = common::DefaultDelegate;
7296 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7297 dlg.begin(common::MethodInfo {
7298 id: "adsensehost.customchannels.get",
7299 http_method: hyper::Method::GET,
7300 });
7301
7302 for &field in ["alt", "adClientId", "customChannelId"].iter() {
7303 if self._additional_params.contains_key(field) {
7304 dlg.finished(false);
7305 return Err(common::Error::FieldClash(field));
7306 }
7307 }
7308
7309 let mut params = Params::with_capacity(4 + self._additional_params.len());
7310 params.push("adClientId", self._ad_client_id);
7311 params.push("customChannelId", self._custom_channel_id);
7312
7313 params.extend(self._additional_params.iter());
7314
7315 params.push("alt", "json");
7316 let mut url =
7317 self.hub._base_url.clone() + "adclients/{adClientId}/customchannels/{customChannelId}";
7318 if self._scopes.is_empty() {
7319 self._scopes.insert(Scope::Full.as_ref().to_string());
7320 }
7321
7322 #[allow(clippy::single_element_loop)]
7323 for &(find_this, param_name) in [
7324 ("{adClientId}", "adClientId"),
7325 ("{customChannelId}", "customChannelId"),
7326 ]
7327 .iter()
7328 {
7329 url = params.uri_replacement(url, param_name, find_this, false);
7330 }
7331 {
7332 let to_remove = ["customChannelId", "adClientId"];
7333 params.remove_params(&to_remove);
7334 }
7335
7336 let url = params.parse_with_url(&url);
7337
7338 loop {
7339 let token = match self
7340 .hub
7341 .auth
7342 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7343 .await
7344 {
7345 Ok(token) => token,
7346 Err(e) => match dlg.token(e) {
7347 Ok(token) => token,
7348 Err(e) => {
7349 dlg.finished(false);
7350 return Err(common::Error::MissingToken(e));
7351 }
7352 },
7353 };
7354 let mut req_result = {
7355 let client = &self.hub.client;
7356 dlg.pre_request();
7357 let mut req_builder = hyper::Request::builder()
7358 .method(hyper::Method::GET)
7359 .uri(url.as_str())
7360 .header(USER_AGENT, self.hub._user_agent.clone());
7361
7362 if let Some(token) = token.as_ref() {
7363 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7364 }
7365
7366 let request = req_builder
7367 .header(CONTENT_LENGTH, 0_u64)
7368 .body(common::to_body::<String>(None));
7369
7370 client.request(request.unwrap()).await
7371 };
7372
7373 match req_result {
7374 Err(err) => {
7375 if let common::Retry::After(d) = dlg.http_error(&err) {
7376 sleep(d).await;
7377 continue;
7378 }
7379 dlg.finished(false);
7380 return Err(common::Error::HttpError(err));
7381 }
7382 Ok(res) => {
7383 let (mut parts, body) = res.into_parts();
7384 let mut body = common::Body::new(body);
7385 if !parts.status.is_success() {
7386 let bytes = common::to_bytes(body).await.unwrap_or_default();
7387 let error = serde_json::from_str(&common::to_string(&bytes));
7388 let response = common::to_response(parts, bytes.into());
7389
7390 if let common::Retry::After(d) =
7391 dlg.http_failure(&response, error.as_ref().ok())
7392 {
7393 sleep(d).await;
7394 continue;
7395 }
7396
7397 dlg.finished(false);
7398
7399 return Err(match error {
7400 Ok(value) => common::Error::BadRequest(value),
7401 _ => common::Error::Failure(response),
7402 });
7403 }
7404 let response = {
7405 let bytes = common::to_bytes(body).await.unwrap_or_default();
7406 let encoded = common::to_string(&bytes);
7407 match serde_json::from_str(&encoded) {
7408 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7409 Err(error) => {
7410 dlg.response_json_decode_error(&encoded, &error);
7411 return Err(common::Error::JsonDecodeError(
7412 encoded.to_string(),
7413 error,
7414 ));
7415 }
7416 }
7417 };
7418
7419 dlg.finished(true);
7420 return Ok(response);
7421 }
7422 }
7423 }
7424 }
7425
7426 /// Ad client from which to get the custom channel.
7427 ///
7428 /// Sets the *ad client id* path property to the given value.
7429 ///
7430 /// Even though the property as already been set when instantiating this call,
7431 /// we provide this method for API completeness.
7432 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C> {
7433 self._ad_client_id = new_value.to_string();
7434 self
7435 }
7436 /// Custom channel to get.
7437 ///
7438 /// Sets the *custom channel id* path property to the given value.
7439 ///
7440 /// Even though the property as already been set when instantiating this call,
7441 /// we provide this method for API completeness.
7442 pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C> {
7443 self._custom_channel_id = new_value.to_string();
7444 self
7445 }
7446 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7447 /// while executing the actual API request.
7448 ///
7449 /// ````text
7450 /// It should be used to handle progress information, and to implement a certain level of resilience.
7451 /// ````
7452 ///
7453 /// Sets the *delegate* property to the given value.
7454 pub fn delegate(
7455 mut self,
7456 new_value: &'a mut dyn common::Delegate,
7457 ) -> CustomchannelGetCall<'a, C> {
7458 self._delegate = Some(new_value);
7459 self
7460 }
7461
7462 /// Set any additional parameter of the query string used in the request.
7463 /// It should be used to set parameters which are not yet available through their own
7464 /// setters.
7465 ///
7466 /// Please note that this method must not be used to set any of the known parameters
7467 /// which have their own setter method. If done anyway, the request will fail.
7468 ///
7469 /// # Additional Parameters
7470 ///
7471 /// * *alt* (query-string) - Data format for the response.
7472 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7473 /// * *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.
7474 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7475 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7476 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7477 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7478 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelGetCall<'a, C>
7479 where
7480 T: AsRef<str>,
7481 {
7482 self._additional_params
7483 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7484 self
7485 }
7486
7487 /// Identifies the authorization scope for the method you are building.
7488 ///
7489 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7490 /// [`Scope::Full`].
7491 ///
7492 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7493 /// tokens for more than one scope.
7494 ///
7495 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7496 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7497 /// sufficient, a read-write scope will do as well.
7498 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelGetCall<'a, C>
7499 where
7500 St: AsRef<str>,
7501 {
7502 self._scopes.insert(String::from(scope.as_ref()));
7503 self
7504 }
7505 /// Identifies the authorization scope(s) for the method you are building.
7506 ///
7507 /// See [`Self::add_scope()`] for details.
7508 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelGetCall<'a, C>
7509 where
7510 I: IntoIterator<Item = St>,
7511 St: AsRef<str>,
7512 {
7513 self._scopes
7514 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7515 self
7516 }
7517
7518 /// Removes all scopes, and no default scope will be used either.
7519 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7520 /// for details).
7521 pub fn clear_scopes(mut self) -> CustomchannelGetCall<'a, C> {
7522 self._scopes.clear();
7523 self
7524 }
7525}
7526
7527/// Add a new custom channel to the host AdSense account.
7528///
7529/// A builder for the *insert* method supported by a *customchannel* resource.
7530/// It is not used directly, but through a [`CustomchannelMethods`] instance.
7531///
7532/// # Example
7533///
7534/// Instantiate a resource method builder
7535///
7536/// ```test_harness,no_run
7537/// # extern crate hyper;
7538/// # extern crate hyper_rustls;
7539/// # extern crate google_adsensehost4d1 as adsensehost4d1;
7540/// use adsensehost4d1::api::CustomChannel;
7541/// # async fn dox() {
7542/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7543///
7544/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7545/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7546/// # .with_native_roots()
7547/// # .unwrap()
7548/// # .https_only()
7549/// # .enable_http2()
7550/// # .build();
7551///
7552/// # let executor = hyper_util::rt::TokioExecutor::new();
7553/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7554/// # secret,
7555/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7556/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7557/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7558/// # ),
7559/// # ).build().await.unwrap();
7560///
7561/// # let client = hyper_util::client::legacy::Client::builder(
7562/// # hyper_util::rt::TokioExecutor::new()
7563/// # )
7564/// # .build(
7565/// # hyper_rustls::HttpsConnectorBuilder::new()
7566/// # .with_native_roots()
7567/// # .unwrap()
7568/// # .https_or_http()
7569/// # .enable_http2()
7570/// # .build()
7571/// # );
7572/// # let mut hub = AdSenseHost::new(client, auth);
7573/// // As the method needs a request, you would usually fill it with the desired information
7574/// // into the respective structure. Some of the parts shown here might not be applicable !
7575/// // Values shown here are possibly random and not representative !
7576/// let mut req = CustomChannel::default();
7577///
7578/// // You can configure optional parameters by calling the respective setters at will, and
7579/// // execute the final call using `doit()`.
7580/// // Values shown here are possibly random and not representative !
7581/// let result = hub.customchannels().insert(req, "adClientId")
7582/// .doit().await;
7583/// # }
7584/// ```
7585pub struct CustomchannelInsertCall<'a, C>
7586where
7587 C: 'a,
7588{
7589 hub: &'a AdSenseHost<C>,
7590 _request: CustomChannel,
7591 _ad_client_id: String,
7592 _delegate: Option<&'a mut dyn common::Delegate>,
7593 _additional_params: HashMap<String, String>,
7594 _scopes: BTreeSet<String>,
7595}
7596
7597impl<'a, C> common::CallBuilder for CustomchannelInsertCall<'a, C> {}
7598
7599impl<'a, C> CustomchannelInsertCall<'a, C>
7600where
7601 C: common::Connector,
7602{
7603 /// Perform the operation you have build so far.
7604 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
7605 use std::borrow::Cow;
7606 use std::io::{Read, Seek};
7607
7608 use common::{url::Params, ToParts};
7609 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7610
7611 let mut dd = common::DefaultDelegate;
7612 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7613 dlg.begin(common::MethodInfo {
7614 id: "adsensehost.customchannels.insert",
7615 http_method: hyper::Method::POST,
7616 });
7617
7618 for &field in ["alt", "adClientId"].iter() {
7619 if self._additional_params.contains_key(field) {
7620 dlg.finished(false);
7621 return Err(common::Error::FieldClash(field));
7622 }
7623 }
7624
7625 let mut params = Params::with_capacity(4 + self._additional_params.len());
7626 params.push("adClientId", self._ad_client_id);
7627
7628 params.extend(self._additional_params.iter());
7629
7630 params.push("alt", "json");
7631 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/customchannels";
7632 if self._scopes.is_empty() {
7633 self._scopes.insert(Scope::Full.as_ref().to_string());
7634 }
7635
7636 #[allow(clippy::single_element_loop)]
7637 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
7638 url = params.uri_replacement(url, param_name, find_this, false);
7639 }
7640 {
7641 let to_remove = ["adClientId"];
7642 params.remove_params(&to_remove);
7643 }
7644
7645 let url = params.parse_with_url(&url);
7646
7647 let mut json_mime_type = mime::APPLICATION_JSON;
7648 let mut request_value_reader = {
7649 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7650 common::remove_json_null_values(&mut value);
7651 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7652 serde_json::to_writer(&mut dst, &value).unwrap();
7653 dst
7654 };
7655 let request_size = request_value_reader
7656 .seek(std::io::SeekFrom::End(0))
7657 .unwrap();
7658 request_value_reader
7659 .seek(std::io::SeekFrom::Start(0))
7660 .unwrap();
7661
7662 loop {
7663 let token = match self
7664 .hub
7665 .auth
7666 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7667 .await
7668 {
7669 Ok(token) => token,
7670 Err(e) => match dlg.token(e) {
7671 Ok(token) => token,
7672 Err(e) => {
7673 dlg.finished(false);
7674 return Err(common::Error::MissingToken(e));
7675 }
7676 },
7677 };
7678 request_value_reader
7679 .seek(std::io::SeekFrom::Start(0))
7680 .unwrap();
7681 let mut req_result = {
7682 let client = &self.hub.client;
7683 dlg.pre_request();
7684 let mut req_builder = hyper::Request::builder()
7685 .method(hyper::Method::POST)
7686 .uri(url.as_str())
7687 .header(USER_AGENT, self.hub._user_agent.clone());
7688
7689 if let Some(token) = token.as_ref() {
7690 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7691 }
7692
7693 let request = req_builder
7694 .header(CONTENT_TYPE, json_mime_type.to_string())
7695 .header(CONTENT_LENGTH, request_size as u64)
7696 .body(common::to_body(
7697 request_value_reader.get_ref().clone().into(),
7698 ));
7699
7700 client.request(request.unwrap()).await
7701 };
7702
7703 match req_result {
7704 Err(err) => {
7705 if let common::Retry::After(d) = dlg.http_error(&err) {
7706 sleep(d).await;
7707 continue;
7708 }
7709 dlg.finished(false);
7710 return Err(common::Error::HttpError(err));
7711 }
7712 Ok(res) => {
7713 let (mut parts, body) = res.into_parts();
7714 let mut body = common::Body::new(body);
7715 if !parts.status.is_success() {
7716 let bytes = common::to_bytes(body).await.unwrap_or_default();
7717 let error = serde_json::from_str(&common::to_string(&bytes));
7718 let response = common::to_response(parts, bytes.into());
7719
7720 if let common::Retry::After(d) =
7721 dlg.http_failure(&response, error.as_ref().ok())
7722 {
7723 sleep(d).await;
7724 continue;
7725 }
7726
7727 dlg.finished(false);
7728
7729 return Err(match error {
7730 Ok(value) => common::Error::BadRequest(value),
7731 _ => common::Error::Failure(response),
7732 });
7733 }
7734 let response = {
7735 let bytes = common::to_bytes(body).await.unwrap_or_default();
7736 let encoded = common::to_string(&bytes);
7737 match serde_json::from_str(&encoded) {
7738 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7739 Err(error) => {
7740 dlg.response_json_decode_error(&encoded, &error);
7741 return Err(common::Error::JsonDecodeError(
7742 encoded.to_string(),
7743 error,
7744 ));
7745 }
7746 }
7747 };
7748
7749 dlg.finished(true);
7750 return Ok(response);
7751 }
7752 }
7753 }
7754 }
7755
7756 ///
7757 /// Sets the *request* property to the given value.
7758 ///
7759 /// Even though the property as already been set when instantiating this call,
7760 /// we provide this method for API completeness.
7761 pub fn request(mut self, new_value: CustomChannel) -> CustomchannelInsertCall<'a, C> {
7762 self._request = new_value;
7763 self
7764 }
7765 /// Ad client to which the new custom channel will be added.
7766 ///
7767 /// Sets the *ad client id* path property to the given value.
7768 ///
7769 /// Even though the property as already been set when instantiating this call,
7770 /// we provide this method for API completeness.
7771 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelInsertCall<'a, C> {
7772 self._ad_client_id = new_value.to_string();
7773 self
7774 }
7775 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7776 /// while executing the actual API request.
7777 ///
7778 /// ````text
7779 /// It should be used to handle progress information, and to implement a certain level of resilience.
7780 /// ````
7781 ///
7782 /// Sets the *delegate* property to the given value.
7783 pub fn delegate(
7784 mut self,
7785 new_value: &'a mut dyn common::Delegate,
7786 ) -> CustomchannelInsertCall<'a, C> {
7787 self._delegate = Some(new_value);
7788 self
7789 }
7790
7791 /// Set any additional parameter of the query string used in the request.
7792 /// It should be used to set parameters which are not yet available through their own
7793 /// setters.
7794 ///
7795 /// Please note that this method must not be used to set any of the known parameters
7796 /// which have their own setter method. If done anyway, the request will fail.
7797 ///
7798 /// # Additional Parameters
7799 ///
7800 /// * *alt* (query-string) - Data format for the response.
7801 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7802 /// * *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.
7803 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7804 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7805 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7806 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7807 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelInsertCall<'a, C>
7808 where
7809 T: AsRef<str>,
7810 {
7811 self._additional_params
7812 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7813 self
7814 }
7815
7816 /// Identifies the authorization scope for the method you are building.
7817 ///
7818 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7819 /// [`Scope::Full`].
7820 ///
7821 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7822 /// tokens for more than one scope.
7823 ///
7824 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7825 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7826 /// sufficient, a read-write scope will do as well.
7827 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelInsertCall<'a, C>
7828 where
7829 St: AsRef<str>,
7830 {
7831 self._scopes.insert(String::from(scope.as_ref()));
7832 self
7833 }
7834 /// Identifies the authorization scope(s) for the method you are building.
7835 ///
7836 /// See [`Self::add_scope()`] for details.
7837 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelInsertCall<'a, C>
7838 where
7839 I: IntoIterator<Item = St>,
7840 St: AsRef<str>,
7841 {
7842 self._scopes
7843 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7844 self
7845 }
7846
7847 /// Removes all scopes, and no default scope will be used either.
7848 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7849 /// for details).
7850 pub fn clear_scopes(mut self) -> CustomchannelInsertCall<'a, C> {
7851 self._scopes.clear();
7852 self
7853 }
7854}
7855
7856/// List all host custom channels in this AdSense account.
7857///
7858/// A builder for the *list* method supported by a *customchannel* resource.
7859/// It is not used directly, but through a [`CustomchannelMethods`] instance.
7860///
7861/// # Example
7862///
7863/// Instantiate a resource method builder
7864///
7865/// ```test_harness,no_run
7866/// # extern crate hyper;
7867/// # extern crate hyper_rustls;
7868/// # extern crate google_adsensehost4d1 as adsensehost4d1;
7869/// # async fn dox() {
7870/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7871///
7872/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7873/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7874/// # .with_native_roots()
7875/// # .unwrap()
7876/// # .https_only()
7877/// # .enable_http2()
7878/// # .build();
7879///
7880/// # let executor = hyper_util::rt::TokioExecutor::new();
7881/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7882/// # secret,
7883/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7884/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7885/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7886/// # ),
7887/// # ).build().await.unwrap();
7888///
7889/// # let client = hyper_util::client::legacy::Client::builder(
7890/// # hyper_util::rt::TokioExecutor::new()
7891/// # )
7892/// # .build(
7893/// # hyper_rustls::HttpsConnectorBuilder::new()
7894/// # .with_native_roots()
7895/// # .unwrap()
7896/// # .https_or_http()
7897/// # .enable_http2()
7898/// # .build()
7899/// # );
7900/// # let mut hub = AdSenseHost::new(client, auth);
7901/// // You can configure optional parameters by calling the respective setters at will, and
7902/// // execute the final call using `doit()`.
7903/// // Values shown here are possibly random and not representative !
7904/// let result = hub.customchannels().list("adClientId")
7905/// .page_token("voluptua.")
7906/// .max_results(67)
7907/// .doit().await;
7908/// # }
7909/// ```
7910pub struct CustomchannelListCall<'a, C>
7911where
7912 C: 'a,
7913{
7914 hub: &'a AdSenseHost<C>,
7915 _ad_client_id: String,
7916 _page_token: Option<String>,
7917 _max_results: Option<u32>,
7918 _delegate: Option<&'a mut dyn common::Delegate>,
7919 _additional_params: HashMap<String, String>,
7920 _scopes: BTreeSet<String>,
7921}
7922
7923impl<'a, C> common::CallBuilder for CustomchannelListCall<'a, C> {}
7924
7925impl<'a, C> CustomchannelListCall<'a, C>
7926where
7927 C: common::Connector,
7928{
7929 /// Perform the operation you have build so far.
7930 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannels)> {
7931 use std::borrow::Cow;
7932 use std::io::{Read, Seek};
7933
7934 use common::{url::Params, ToParts};
7935 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7936
7937 let mut dd = common::DefaultDelegate;
7938 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7939 dlg.begin(common::MethodInfo {
7940 id: "adsensehost.customchannels.list",
7941 http_method: hyper::Method::GET,
7942 });
7943
7944 for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
7945 if self._additional_params.contains_key(field) {
7946 dlg.finished(false);
7947 return Err(common::Error::FieldClash(field));
7948 }
7949 }
7950
7951 let mut params = Params::with_capacity(5 + self._additional_params.len());
7952 params.push("adClientId", self._ad_client_id);
7953 if let Some(value) = self._page_token.as_ref() {
7954 params.push("pageToken", value);
7955 }
7956 if let Some(value) = self._max_results.as_ref() {
7957 params.push("maxResults", value.to_string());
7958 }
7959
7960 params.extend(self._additional_params.iter());
7961
7962 params.push("alt", "json");
7963 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/customchannels";
7964 if self._scopes.is_empty() {
7965 self._scopes.insert(Scope::Full.as_ref().to_string());
7966 }
7967
7968 #[allow(clippy::single_element_loop)]
7969 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
7970 url = params.uri_replacement(url, param_name, find_this, false);
7971 }
7972 {
7973 let to_remove = ["adClientId"];
7974 params.remove_params(&to_remove);
7975 }
7976
7977 let url = params.parse_with_url(&url);
7978
7979 loop {
7980 let token = match self
7981 .hub
7982 .auth
7983 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7984 .await
7985 {
7986 Ok(token) => token,
7987 Err(e) => match dlg.token(e) {
7988 Ok(token) => token,
7989 Err(e) => {
7990 dlg.finished(false);
7991 return Err(common::Error::MissingToken(e));
7992 }
7993 },
7994 };
7995 let mut req_result = {
7996 let client = &self.hub.client;
7997 dlg.pre_request();
7998 let mut req_builder = hyper::Request::builder()
7999 .method(hyper::Method::GET)
8000 .uri(url.as_str())
8001 .header(USER_AGENT, self.hub._user_agent.clone());
8002
8003 if let Some(token) = token.as_ref() {
8004 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8005 }
8006
8007 let request = req_builder
8008 .header(CONTENT_LENGTH, 0_u64)
8009 .body(common::to_body::<String>(None));
8010
8011 client.request(request.unwrap()).await
8012 };
8013
8014 match req_result {
8015 Err(err) => {
8016 if let common::Retry::After(d) = dlg.http_error(&err) {
8017 sleep(d).await;
8018 continue;
8019 }
8020 dlg.finished(false);
8021 return Err(common::Error::HttpError(err));
8022 }
8023 Ok(res) => {
8024 let (mut parts, body) = res.into_parts();
8025 let mut body = common::Body::new(body);
8026 if !parts.status.is_success() {
8027 let bytes = common::to_bytes(body).await.unwrap_or_default();
8028 let error = serde_json::from_str(&common::to_string(&bytes));
8029 let response = common::to_response(parts, bytes.into());
8030
8031 if let common::Retry::After(d) =
8032 dlg.http_failure(&response, error.as_ref().ok())
8033 {
8034 sleep(d).await;
8035 continue;
8036 }
8037
8038 dlg.finished(false);
8039
8040 return Err(match error {
8041 Ok(value) => common::Error::BadRequest(value),
8042 _ => common::Error::Failure(response),
8043 });
8044 }
8045 let response = {
8046 let bytes = common::to_bytes(body).await.unwrap_or_default();
8047 let encoded = common::to_string(&bytes);
8048 match serde_json::from_str(&encoded) {
8049 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8050 Err(error) => {
8051 dlg.response_json_decode_error(&encoded, &error);
8052 return Err(common::Error::JsonDecodeError(
8053 encoded.to_string(),
8054 error,
8055 ));
8056 }
8057 }
8058 };
8059
8060 dlg.finished(true);
8061 return Ok(response);
8062 }
8063 }
8064 }
8065 }
8066
8067 /// Ad client for which to list custom channels.
8068 ///
8069 /// Sets the *ad client id* path property to the given value.
8070 ///
8071 /// Even though the property as already been set when instantiating this call,
8072 /// we provide this method for API completeness.
8073 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelListCall<'a, C> {
8074 self._ad_client_id = new_value.to_string();
8075 self
8076 }
8077 /// 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.
8078 ///
8079 /// Sets the *page token* query property to the given value.
8080 pub fn page_token(mut self, new_value: &str) -> CustomchannelListCall<'a, C> {
8081 self._page_token = Some(new_value.to_string());
8082 self
8083 }
8084 /// The maximum number of custom channels to include in the response, used for paging.
8085 ///
8086 /// Sets the *max results* query property to the given value.
8087 pub fn max_results(mut self, new_value: u32) -> CustomchannelListCall<'a, C> {
8088 self._max_results = Some(new_value);
8089 self
8090 }
8091 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8092 /// while executing the actual API request.
8093 ///
8094 /// ````text
8095 /// It should be used to handle progress information, and to implement a certain level of resilience.
8096 /// ````
8097 ///
8098 /// Sets the *delegate* property to the given value.
8099 pub fn delegate(
8100 mut self,
8101 new_value: &'a mut dyn common::Delegate,
8102 ) -> CustomchannelListCall<'a, C> {
8103 self._delegate = Some(new_value);
8104 self
8105 }
8106
8107 /// Set any additional parameter of the query string used in the request.
8108 /// It should be used to set parameters which are not yet available through their own
8109 /// setters.
8110 ///
8111 /// Please note that this method must not be used to set any of the known parameters
8112 /// which have their own setter method. If done anyway, the request will fail.
8113 ///
8114 /// # Additional Parameters
8115 ///
8116 /// * *alt* (query-string) - Data format for the response.
8117 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8118 /// * *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.
8119 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8120 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8121 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8122 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8123 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelListCall<'a, C>
8124 where
8125 T: AsRef<str>,
8126 {
8127 self._additional_params
8128 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8129 self
8130 }
8131
8132 /// Identifies the authorization scope for the method you are building.
8133 ///
8134 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8135 /// [`Scope::Full`].
8136 ///
8137 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8138 /// tokens for more than one scope.
8139 ///
8140 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8141 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8142 /// sufficient, a read-write scope will do as well.
8143 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelListCall<'a, C>
8144 where
8145 St: AsRef<str>,
8146 {
8147 self._scopes.insert(String::from(scope.as_ref()));
8148 self
8149 }
8150 /// Identifies the authorization scope(s) for the method you are building.
8151 ///
8152 /// See [`Self::add_scope()`] for details.
8153 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelListCall<'a, C>
8154 where
8155 I: IntoIterator<Item = St>,
8156 St: AsRef<str>,
8157 {
8158 self._scopes
8159 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8160 self
8161 }
8162
8163 /// Removes all scopes, and no default scope will be used either.
8164 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8165 /// for details).
8166 pub fn clear_scopes(mut self) -> CustomchannelListCall<'a, C> {
8167 self._scopes.clear();
8168 self
8169 }
8170}
8171
8172/// Update a custom channel in the host AdSense account. This method supports patch semantics.
8173///
8174/// A builder for the *patch* method supported by a *customchannel* resource.
8175/// It is not used directly, but through a [`CustomchannelMethods`] instance.
8176///
8177/// # Example
8178///
8179/// Instantiate a resource method builder
8180///
8181/// ```test_harness,no_run
8182/// # extern crate hyper;
8183/// # extern crate hyper_rustls;
8184/// # extern crate google_adsensehost4d1 as adsensehost4d1;
8185/// use adsensehost4d1::api::CustomChannel;
8186/// # async fn dox() {
8187/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8188///
8189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8191/// # .with_native_roots()
8192/// # .unwrap()
8193/// # .https_only()
8194/// # .enable_http2()
8195/// # .build();
8196///
8197/// # let executor = hyper_util::rt::TokioExecutor::new();
8198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8199/// # secret,
8200/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8201/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8202/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8203/// # ),
8204/// # ).build().await.unwrap();
8205///
8206/// # let client = hyper_util::client::legacy::Client::builder(
8207/// # hyper_util::rt::TokioExecutor::new()
8208/// # )
8209/// # .build(
8210/// # hyper_rustls::HttpsConnectorBuilder::new()
8211/// # .with_native_roots()
8212/// # .unwrap()
8213/// # .https_or_http()
8214/// # .enable_http2()
8215/// # .build()
8216/// # );
8217/// # let mut hub = AdSenseHost::new(client, auth);
8218/// // As the method needs a request, you would usually fill it with the desired information
8219/// // into the respective structure. Some of the parts shown here might not be applicable !
8220/// // Values shown here are possibly random and not representative !
8221/// let mut req = CustomChannel::default();
8222///
8223/// // You can configure optional parameters by calling the respective setters at will, and
8224/// // execute the final call using `doit()`.
8225/// // Values shown here are possibly random and not representative !
8226/// let result = hub.customchannels().patch(req, "adClientId", "customChannelId")
8227/// .doit().await;
8228/// # }
8229/// ```
8230pub struct CustomchannelPatchCall<'a, C>
8231where
8232 C: 'a,
8233{
8234 hub: &'a AdSenseHost<C>,
8235 _request: CustomChannel,
8236 _ad_client_id: String,
8237 _custom_channel_id: String,
8238 _delegate: Option<&'a mut dyn common::Delegate>,
8239 _additional_params: HashMap<String, String>,
8240 _scopes: BTreeSet<String>,
8241}
8242
8243impl<'a, C> common::CallBuilder for CustomchannelPatchCall<'a, C> {}
8244
8245impl<'a, C> CustomchannelPatchCall<'a, C>
8246where
8247 C: common::Connector,
8248{
8249 /// Perform the operation you have build so far.
8250 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
8251 use std::borrow::Cow;
8252 use std::io::{Read, Seek};
8253
8254 use common::{url::Params, ToParts};
8255 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8256
8257 let mut dd = common::DefaultDelegate;
8258 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8259 dlg.begin(common::MethodInfo {
8260 id: "adsensehost.customchannels.patch",
8261 http_method: hyper::Method::PATCH,
8262 });
8263
8264 for &field in ["alt", "adClientId", "customChannelId"].iter() {
8265 if self._additional_params.contains_key(field) {
8266 dlg.finished(false);
8267 return Err(common::Error::FieldClash(field));
8268 }
8269 }
8270
8271 let mut params = Params::with_capacity(5 + self._additional_params.len());
8272 params.push("adClientId", self._ad_client_id);
8273 params.push("customChannelId", self._custom_channel_id);
8274
8275 params.extend(self._additional_params.iter());
8276
8277 params.push("alt", "json");
8278 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/customchannels";
8279 if self._scopes.is_empty() {
8280 self._scopes.insert(Scope::Full.as_ref().to_string());
8281 }
8282
8283 #[allow(clippy::single_element_loop)]
8284 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
8285 url = params.uri_replacement(url, param_name, find_this, false);
8286 }
8287 {
8288 let to_remove = ["adClientId"];
8289 params.remove_params(&to_remove);
8290 }
8291
8292 let url = params.parse_with_url(&url);
8293
8294 let mut json_mime_type = mime::APPLICATION_JSON;
8295 let mut request_value_reader = {
8296 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8297 common::remove_json_null_values(&mut value);
8298 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8299 serde_json::to_writer(&mut dst, &value).unwrap();
8300 dst
8301 };
8302 let request_size = request_value_reader
8303 .seek(std::io::SeekFrom::End(0))
8304 .unwrap();
8305 request_value_reader
8306 .seek(std::io::SeekFrom::Start(0))
8307 .unwrap();
8308
8309 loop {
8310 let token = match self
8311 .hub
8312 .auth
8313 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8314 .await
8315 {
8316 Ok(token) => token,
8317 Err(e) => match dlg.token(e) {
8318 Ok(token) => token,
8319 Err(e) => {
8320 dlg.finished(false);
8321 return Err(common::Error::MissingToken(e));
8322 }
8323 },
8324 };
8325 request_value_reader
8326 .seek(std::io::SeekFrom::Start(0))
8327 .unwrap();
8328 let mut req_result = {
8329 let client = &self.hub.client;
8330 dlg.pre_request();
8331 let mut req_builder = hyper::Request::builder()
8332 .method(hyper::Method::PATCH)
8333 .uri(url.as_str())
8334 .header(USER_AGENT, self.hub._user_agent.clone());
8335
8336 if let Some(token) = token.as_ref() {
8337 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8338 }
8339
8340 let request = req_builder
8341 .header(CONTENT_TYPE, json_mime_type.to_string())
8342 .header(CONTENT_LENGTH, request_size as u64)
8343 .body(common::to_body(
8344 request_value_reader.get_ref().clone().into(),
8345 ));
8346
8347 client.request(request.unwrap()).await
8348 };
8349
8350 match req_result {
8351 Err(err) => {
8352 if let common::Retry::After(d) = dlg.http_error(&err) {
8353 sleep(d).await;
8354 continue;
8355 }
8356 dlg.finished(false);
8357 return Err(common::Error::HttpError(err));
8358 }
8359 Ok(res) => {
8360 let (mut parts, body) = res.into_parts();
8361 let mut body = common::Body::new(body);
8362 if !parts.status.is_success() {
8363 let bytes = common::to_bytes(body).await.unwrap_or_default();
8364 let error = serde_json::from_str(&common::to_string(&bytes));
8365 let response = common::to_response(parts, bytes.into());
8366
8367 if let common::Retry::After(d) =
8368 dlg.http_failure(&response, error.as_ref().ok())
8369 {
8370 sleep(d).await;
8371 continue;
8372 }
8373
8374 dlg.finished(false);
8375
8376 return Err(match error {
8377 Ok(value) => common::Error::BadRequest(value),
8378 _ => common::Error::Failure(response),
8379 });
8380 }
8381 let response = {
8382 let bytes = common::to_bytes(body).await.unwrap_or_default();
8383 let encoded = common::to_string(&bytes);
8384 match serde_json::from_str(&encoded) {
8385 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8386 Err(error) => {
8387 dlg.response_json_decode_error(&encoded, &error);
8388 return Err(common::Error::JsonDecodeError(
8389 encoded.to_string(),
8390 error,
8391 ));
8392 }
8393 }
8394 };
8395
8396 dlg.finished(true);
8397 return Ok(response);
8398 }
8399 }
8400 }
8401 }
8402
8403 ///
8404 /// Sets the *request* property to the given value.
8405 ///
8406 /// Even though the property as already been set when instantiating this call,
8407 /// we provide this method for API completeness.
8408 pub fn request(mut self, new_value: CustomChannel) -> CustomchannelPatchCall<'a, C> {
8409 self._request = new_value;
8410 self
8411 }
8412 /// Ad client in which the custom channel will be updated.
8413 ///
8414 /// Sets the *ad client id* path property to the given value.
8415 ///
8416 /// Even though the property as already been set when instantiating this call,
8417 /// we provide this method for API completeness.
8418 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelPatchCall<'a, C> {
8419 self._ad_client_id = new_value.to_string();
8420 self
8421 }
8422 /// Custom channel to get.
8423 ///
8424 /// Sets the *custom channel id* query property to the given value.
8425 ///
8426 /// Even though the property as already been set when instantiating this call,
8427 /// we provide this method for API completeness.
8428 pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelPatchCall<'a, C> {
8429 self._custom_channel_id = new_value.to_string();
8430 self
8431 }
8432 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8433 /// while executing the actual API request.
8434 ///
8435 /// ````text
8436 /// It should be used to handle progress information, and to implement a certain level of resilience.
8437 /// ````
8438 ///
8439 /// Sets the *delegate* property to the given value.
8440 pub fn delegate(
8441 mut self,
8442 new_value: &'a mut dyn common::Delegate,
8443 ) -> CustomchannelPatchCall<'a, C> {
8444 self._delegate = Some(new_value);
8445 self
8446 }
8447
8448 /// Set any additional parameter of the query string used in the request.
8449 /// It should be used to set parameters which are not yet available through their own
8450 /// setters.
8451 ///
8452 /// Please note that this method must not be used to set any of the known parameters
8453 /// which have their own setter method. If done anyway, the request will fail.
8454 ///
8455 /// # Additional Parameters
8456 ///
8457 /// * *alt* (query-string) - Data format for the response.
8458 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8459 /// * *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.
8460 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8461 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8462 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8463 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8464 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelPatchCall<'a, C>
8465 where
8466 T: AsRef<str>,
8467 {
8468 self._additional_params
8469 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8470 self
8471 }
8472
8473 /// Identifies the authorization scope for the method you are building.
8474 ///
8475 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8476 /// [`Scope::Full`].
8477 ///
8478 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8479 /// tokens for more than one scope.
8480 ///
8481 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8482 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8483 /// sufficient, a read-write scope will do as well.
8484 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelPatchCall<'a, C>
8485 where
8486 St: AsRef<str>,
8487 {
8488 self._scopes.insert(String::from(scope.as_ref()));
8489 self
8490 }
8491 /// Identifies the authorization scope(s) for the method you are building.
8492 ///
8493 /// See [`Self::add_scope()`] for details.
8494 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelPatchCall<'a, C>
8495 where
8496 I: IntoIterator<Item = St>,
8497 St: AsRef<str>,
8498 {
8499 self._scopes
8500 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8501 self
8502 }
8503
8504 /// Removes all scopes, and no default scope will be used either.
8505 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8506 /// for details).
8507 pub fn clear_scopes(mut self) -> CustomchannelPatchCall<'a, C> {
8508 self._scopes.clear();
8509 self
8510 }
8511}
8512
8513/// Update a custom channel in the host AdSense account.
8514///
8515/// A builder for the *update* method supported by a *customchannel* resource.
8516/// It is not used directly, but through a [`CustomchannelMethods`] instance.
8517///
8518/// # Example
8519///
8520/// Instantiate a resource method builder
8521///
8522/// ```test_harness,no_run
8523/// # extern crate hyper;
8524/// # extern crate hyper_rustls;
8525/// # extern crate google_adsensehost4d1 as adsensehost4d1;
8526/// use adsensehost4d1::api::CustomChannel;
8527/// # async fn dox() {
8528/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8529///
8530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8531/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8532/// # .with_native_roots()
8533/// # .unwrap()
8534/// # .https_only()
8535/// # .enable_http2()
8536/// # .build();
8537///
8538/// # let executor = hyper_util::rt::TokioExecutor::new();
8539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8540/// # secret,
8541/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8542/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8543/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8544/// # ),
8545/// # ).build().await.unwrap();
8546///
8547/// # let client = hyper_util::client::legacy::Client::builder(
8548/// # hyper_util::rt::TokioExecutor::new()
8549/// # )
8550/// # .build(
8551/// # hyper_rustls::HttpsConnectorBuilder::new()
8552/// # .with_native_roots()
8553/// # .unwrap()
8554/// # .https_or_http()
8555/// # .enable_http2()
8556/// # .build()
8557/// # );
8558/// # let mut hub = AdSenseHost::new(client, auth);
8559/// // As the method needs a request, you would usually fill it with the desired information
8560/// // into the respective structure. Some of the parts shown here might not be applicable !
8561/// // Values shown here are possibly random and not representative !
8562/// let mut req = CustomChannel::default();
8563///
8564/// // You can configure optional parameters by calling the respective setters at will, and
8565/// // execute the final call using `doit()`.
8566/// // Values shown here are possibly random and not representative !
8567/// let result = hub.customchannels().update(req, "adClientId")
8568/// .doit().await;
8569/// # }
8570/// ```
8571pub struct CustomchannelUpdateCall<'a, C>
8572where
8573 C: 'a,
8574{
8575 hub: &'a AdSenseHost<C>,
8576 _request: CustomChannel,
8577 _ad_client_id: String,
8578 _delegate: Option<&'a mut dyn common::Delegate>,
8579 _additional_params: HashMap<String, String>,
8580 _scopes: BTreeSet<String>,
8581}
8582
8583impl<'a, C> common::CallBuilder for CustomchannelUpdateCall<'a, C> {}
8584
8585impl<'a, C> CustomchannelUpdateCall<'a, C>
8586where
8587 C: common::Connector,
8588{
8589 /// Perform the operation you have build so far.
8590 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
8591 use std::borrow::Cow;
8592 use std::io::{Read, Seek};
8593
8594 use common::{url::Params, ToParts};
8595 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8596
8597 let mut dd = common::DefaultDelegate;
8598 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8599 dlg.begin(common::MethodInfo {
8600 id: "adsensehost.customchannels.update",
8601 http_method: hyper::Method::PUT,
8602 });
8603
8604 for &field in ["alt", "adClientId"].iter() {
8605 if self._additional_params.contains_key(field) {
8606 dlg.finished(false);
8607 return Err(common::Error::FieldClash(field));
8608 }
8609 }
8610
8611 let mut params = Params::with_capacity(4 + self._additional_params.len());
8612 params.push("adClientId", self._ad_client_id);
8613
8614 params.extend(self._additional_params.iter());
8615
8616 params.push("alt", "json");
8617 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/customchannels";
8618 if self._scopes.is_empty() {
8619 self._scopes.insert(Scope::Full.as_ref().to_string());
8620 }
8621
8622 #[allow(clippy::single_element_loop)]
8623 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
8624 url = params.uri_replacement(url, param_name, find_this, false);
8625 }
8626 {
8627 let to_remove = ["adClientId"];
8628 params.remove_params(&to_remove);
8629 }
8630
8631 let url = params.parse_with_url(&url);
8632
8633 let mut json_mime_type = mime::APPLICATION_JSON;
8634 let mut request_value_reader = {
8635 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8636 common::remove_json_null_values(&mut value);
8637 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8638 serde_json::to_writer(&mut dst, &value).unwrap();
8639 dst
8640 };
8641 let request_size = request_value_reader
8642 .seek(std::io::SeekFrom::End(0))
8643 .unwrap();
8644 request_value_reader
8645 .seek(std::io::SeekFrom::Start(0))
8646 .unwrap();
8647
8648 loop {
8649 let token = match self
8650 .hub
8651 .auth
8652 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8653 .await
8654 {
8655 Ok(token) => token,
8656 Err(e) => match dlg.token(e) {
8657 Ok(token) => token,
8658 Err(e) => {
8659 dlg.finished(false);
8660 return Err(common::Error::MissingToken(e));
8661 }
8662 },
8663 };
8664 request_value_reader
8665 .seek(std::io::SeekFrom::Start(0))
8666 .unwrap();
8667 let mut req_result = {
8668 let client = &self.hub.client;
8669 dlg.pre_request();
8670 let mut req_builder = hyper::Request::builder()
8671 .method(hyper::Method::PUT)
8672 .uri(url.as_str())
8673 .header(USER_AGENT, self.hub._user_agent.clone());
8674
8675 if let Some(token) = token.as_ref() {
8676 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8677 }
8678
8679 let request = req_builder
8680 .header(CONTENT_TYPE, json_mime_type.to_string())
8681 .header(CONTENT_LENGTH, request_size as u64)
8682 .body(common::to_body(
8683 request_value_reader.get_ref().clone().into(),
8684 ));
8685
8686 client.request(request.unwrap()).await
8687 };
8688
8689 match req_result {
8690 Err(err) => {
8691 if let common::Retry::After(d) = dlg.http_error(&err) {
8692 sleep(d).await;
8693 continue;
8694 }
8695 dlg.finished(false);
8696 return Err(common::Error::HttpError(err));
8697 }
8698 Ok(res) => {
8699 let (mut parts, body) = res.into_parts();
8700 let mut body = common::Body::new(body);
8701 if !parts.status.is_success() {
8702 let bytes = common::to_bytes(body).await.unwrap_or_default();
8703 let error = serde_json::from_str(&common::to_string(&bytes));
8704 let response = common::to_response(parts, bytes.into());
8705
8706 if let common::Retry::After(d) =
8707 dlg.http_failure(&response, error.as_ref().ok())
8708 {
8709 sleep(d).await;
8710 continue;
8711 }
8712
8713 dlg.finished(false);
8714
8715 return Err(match error {
8716 Ok(value) => common::Error::BadRequest(value),
8717 _ => common::Error::Failure(response),
8718 });
8719 }
8720 let response = {
8721 let bytes = common::to_bytes(body).await.unwrap_or_default();
8722 let encoded = common::to_string(&bytes);
8723 match serde_json::from_str(&encoded) {
8724 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8725 Err(error) => {
8726 dlg.response_json_decode_error(&encoded, &error);
8727 return Err(common::Error::JsonDecodeError(
8728 encoded.to_string(),
8729 error,
8730 ));
8731 }
8732 }
8733 };
8734
8735 dlg.finished(true);
8736 return Ok(response);
8737 }
8738 }
8739 }
8740 }
8741
8742 ///
8743 /// Sets the *request* property to the given value.
8744 ///
8745 /// Even though the property as already been set when instantiating this call,
8746 /// we provide this method for API completeness.
8747 pub fn request(mut self, new_value: CustomChannel) -> CustomchannelUpdateCall<'a, C> {
8748 self._request = new_value;
8749 self
8750 }
8751 /// Ad client in which the custom channel will be updated.
8752 ///
8753 /// Sets the *ad client id* path property to the given value.
8754 ///
8755 /// Even though the property as already been set when instantiating this call,
8756 /// we provide this method for API completeness.
8757 pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelUpdateCall<'a, C> {
8758 self._ad_client_id = new_value.to_string();
8759 self
8760 }
8761 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8762 /// while executing the actual API request.
8763 ///
8764 /// ````text
8765 /// It should be used to handle progress information, and to implement a certain level of resilience.
8766 /// ````
8767 ///
8768 /// Sets the *delegate* property to the given value.
8769 pub fn delegate(
8770 mut self,
8771 new_value: &'a mut dyn common::Delegate,
8772 ) -> CustomchannelUpdateCall<'a, C> {
8773 self._delegate = Some(new_value);
8774 self
8775 }
8776
8777 /// Set any additional parameter of the query string used in the request.
8778 /// It should be used to set parameters which are not yet available through their own
8779 /// setters.
8780 ///
8781 /// Please note that this method must not be used to set any of the known parameters
8782 /// which have their own setter method. If done anyway, the request will fail.
8783 ///
8784 /// # Additional Parameters
8785 ///
8786 /// * *alt* (query-string) - Data format for the response.
8787 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8788 /// * *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.
8789 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8790 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8791 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8792 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8793 pub fn param<T>(mut self, name: T, value: T) -> CustomchannelUpdateCall<'a, C>
8794 where
8795 T: AsRef<str>,
8796 {
8797 self._additional_params
8798 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8799 self
8800 }
8801
8802 /// Identifies the authorization scope for the method you are building.
8803 ///
8804 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8805 /// [`Scope::Full`].
8806 ///
8807 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8808 /// tokens for more than one scope.
8809 ///
8810 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8811 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8812 /// sufficient, a read-write scope will do as well.
8813 pub fn add_scope<St>(mut self, scope: St) -> CustomchannelUpdateCall<'a, C>
8814 where
8815 St: AsRef<str>,
8816 {
8817 self._scopes.insert(String::from(scope.as_ref()));
8818 self
8819 }
8820 /// Identifies the authorization scope(s) for the method you are building.
8821 ///
8822 /// See [`Self::add_scope()`] for details.
8823 pub fn add_scopes<I, St>(mut self, scopes: I) -> CustomchannelUpdateCall<'a, C>
8824 where
8825 I: IntoIterator<Item = St>,
8826 St: AsRef<str>,
8827 {
8828 self._scopes
8829 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8830 self
8831 }
8832
8833 /// Removes all scopes, and no default scope will be used either.
8834 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8835 /// for details).
8836 pub fn clear_scopes(mut self) -> CustomchannelUpdateCall<'a, C> {
8837 self._scopes.clear();
8838 self
8839 }
8840}
8841
8842/// 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.
8843///
8844/// A builder for the *generate* method supported by a *report* resource.
8845/// It is not used directly, but through a [`ReportMethods`] instance.
8846///
8847/// # Example
8848///
8849/// Instantiate a resource method builder
8850///
8851/// ```test_harness,no_run
8852/// # extern crate hyper;
8853/// # extern crate hyper_rustls;
8854/// # extern crate google_adsensehost4d1 as adsensehost4d1;
8855/// # async fn dox() {
8856/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8857///
8858/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8859/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8860/// # .with_native_roots()
8861/// # .unwrap()
8862/// # .https_only()
8863/// # .enable_http2()
8864/// # .build();
8865///
8866/// # let executor = hyper_util::rt::TokioExecutor::new();
8867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8868/// # secret,
8869/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8870/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8871/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8872/// # ),
8873/// # ).build().await.unwrap();
8874///
8875/// # let client = hyper_util::client::legacy::Client::builder(
8876/// # hyper_util::rt::TokioExecutor::new()
8877/// # )
8878/// # .build(
8879/// # hyper_rustls::HttpsConnectorBuilder::new()
8880/// # .with_native_roots()
8881/// # .unwrap()
8882/// # .https_or_http()
8883/// # .enable_http2()
8884/// # .build()
8885/// # );
8886/// # let mut hub = AdSenseHost::new(client, auth);
8887/// // You can configure optional parameters by calling the respective setters at will, and
8888/// // execute the final call using `doit()`.
8889/// // Values shown here are possibly random and not representative !
8890/// let result = hub.reports().generate("startDate", "endDate")
8891/// .start_index(6)
8892/// .add_sort("Lorem")
8893/// .add_metric("invidunt")
8894/// .max_results(90)
8895/// .locale("est")
8896/// .add_filter("At")
8897/// .add_dimension("sed")
8898/// .doit().await;
8899/// # }
8900/// ```
8901pub struct ReportGenerateCall<'a, C>
8902where
8903 C: 'a,
8904{
8905 hub: &'a AdSenseHost<C>,
8906 _start_date: String,
8907 _end_date: String,
8908 _start_index: Option<u32>,
8909 _sort: Vec<String>,
8910 _metric: Vec<String>,
8911 _max_results: Option<u32>,
8912 _locale: Option<String>,
8913 _filter: Vec<String>,
8914 _dimension: Vec<String>,
8915 _delegate: Option<&'a mut dyn common::Delegate>,
8916 _additional_params: HashMap<String, String>,
8917 _scopes: BTreeSet<String>,
8918}
8919
8920impl<'a, C> common::CallBuilder for ReportGenerateCall<'a, C> {}
8921
8922impl<'a, C> ReportGenerateCall<'a, C>
8923where
8924 C: common::Connector,
8925{
8926 /// Perform the operation you have build so far.
8927 pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
8928 use std::borrow::Cow;
8929 use std::io::{Read, Seek};
8930
8931 use common::{url::Params, ToParts};
8932 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8933
8934 let mut dd = common::DefaultDelegate;
8935 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8936 dlg.begin(common::MethodInfo {
8937 id: "adsensehost.reports.generate",
8938 http_method: hyper::Method::GET,
8939 });
8940
8941 for &field in [
8942 "alt",
8943 "startDate",
8944 "endDate",
8945 "startIndex",
8946 "sort",
8947 "metric",
8948 "maxResults",
8949 "locale",
8950 "filter",
8951 "dimension",
8952 ]
8953 .iter()
8954 {
8955 if self._additional_params.contains_key(field) {
8956 dlg.finished(false);
8957 return Err(common::Error::FieldClash(field));
8958 }
8959 }
8960
8961 let mut params = Params::with_capacity(11 + self._additional_params.len());
8962 params.push("startDate", self._start_date);
8963 params.push("endDate", self._end_date);
8964 if let Some(value) = self._start_index.as_ref() {
8965 params.push("startIndex", value.to_string());
8966 }
8967 if !self._sort.is_empty() {
8968 for f in self._sort.iter() {
8969 params.push("sort", f);
8970 }
8971 }
8972 if !self._metric.is_empty() {
8973 for f in self._metric.iter() {
8974 params.push("metric", f);
8975 }
8976 }
8977 if let Some(value) = self._max_results.as_ref() {
8978 params.push("maxResults", value.to_string());
8979 }
8980 if let Some(value) = self._locale.as_ref() {
8981 params.push("locale", value);
8982 }
8983 if !self._filter.is_empty() {
8984 for f in self._filter.iter() {
8985 params.push("filter", f);
8986 }
8987 }
8988 if !self._dimension.is_empty() {
8989 for f in self._dimension.iter() {
8990 params.push("dimension", f);
8991 }
8992 }
8993
8994 params.extend(self._additional_params.iter());
8995
8996 params.push("alt", "json");
8997 let mut url = self.hub._base_url.clone() + "reports";
8998 if self._scopes.is_empty() {
8999 self._scopes.insert(Scope::Full.as_ref().to_string());
9000 }
9001
9002 let url = params.parse_with_url(&url);
9003
9004 loop {
9005 let token = match self
9006 .hub
9007 .auth
9008 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9009 .await
9010 {
9011 Ok(token) => token,
9012 Err(e) => match dlg.token(e) {
9013 Ok(token) => token,
9014 Err(e) => {
9015 dlg.finished(false);
9016 return Err(common::Error::MissingToken(e));
9017 }
9018 },
9019 };
9020 let mut req_result = {
9021 let client = &self.hub.client;
9022 dlg.pre_request();
9023 let mut req_builder = hyper::Request::builder()
9024 .method(hyper::Method::GET)
9025 .uri(url.as_str())
9026 .header(USER_AGENT, self.hub._user_agent.clone());
9027
9028 if let Some(token) = token.as_ref() {
9029 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9030 }
9031
9032 let request = req_builder
9033 .header(CONTENT_LENGTH, 0_u64)
9034 .body(common::to_body::<String>(None));
9035
9036 client.request(request.unwrap()).await
9037 };
9038
9039 match req_result {
9040 Err(err) => {
9041 if let common::Retry::After(d) = dlg.http_error(&err) {
9042 sleep(d).await;
9043 continue;
9044 }
9045 dlg.finished(false);
9046 return Err(common::Error::HttpError(err));
9047 }
9048 Ok(res) => {
9049 let (mut parts, body) = res.into_parts();
9050 let mut body = common::Body::new(body);
9051 if !parts.status.is_success() {
9052 let bytes = common::to_bytes(body).await.unwrap_or_default();
9053 let error = serde_json::from_str(&common::to_string(&bytes));
9054 let response = common::to_response(parts, bytes.into());
9055
9056 if let common::Retry::After(d) =
9057 dlg.http_failure(&response, error.as_ref().ok())
9058 {
9059 sleep(d).await;
9060 continue;
9061 }
9062
9063 dlg.finished(false);
9064
9065 return Err(match error {
9066 Ok(value) => common::Error::BadRequest(value),
9067 _ => common::Error::Failure(response),
9068 });
9069 }
9070 let response = {
9071 let bytes = common::to_bytes(body).await.unwrap_or_default();
9072 let encoded = common::to_string(&bytes);
9073 match serde_json::from_str(&encoded) {
9074 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9075 Err(error) => {
9076 dlg.response_json_decode_error(&encoded, &error);
9077 return Err(common::Error::JsonDecodeError(
9078 encoded.to_string(),
9079 error,
9080 ));
9081 }
9082 }
9083 };
9084
9085 dlg.finished(true);
9086 return Ok(response);
9087 }
9088 }
9089 }
9090 }
9091
9092 /// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
9093 ///
9094 /// Sets the *start date* query property to the given value.
9095 ///
9096 /// Even though the property as already been set when instantiating this call,
9097 /// we provide this method for API completeness.
9098 pub fn start_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9099 self._start_date = new_value.to_string();
9100 self
9101 }
9102 /// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
9103 ///
9104 /// Sets the *end date* query property to the given value.
9105 ///
9106 /// Even though the property as already been set when instantiating this call,
9107 /// we provide this method for API completeness.
9108 pub fn end_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9109 self._end_date = new_value.to_string();
9110 self
9111 }
9112 /// Index of the first row of report data to return.
9113 ///
9114 /// Sets the *start index* query property to the given value.
9115 pub fn start_index(mut self, new_value: u32) -> ReportGenerateCall<'a, C> {
9116 self._start_index = Some(new_value);
9117 self
9118 }
9119 /// 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.
9120 ///
9121 /// Append the given value to the *sort* query property.
9122 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9123 pub fn add_sort(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9124 self._sort.push(new_value.to_string());
9125 self
9126 }
9127 /// Numeric columns to include in the report.
9128 ///
9129 /// Append the given value to the *metric* query property.
9130 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9131 pub fn add_metric(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9132 self._metric.push(new_value.to_string());
9133 self
9134 }
9135 /// The maximum number of rows of report data to return.
9136 ///
9137 /// Sets the *max results* query property to the given value.
9138 pub fn max_results(mut self, new_value: u32) -> ReportGenerateCall<'a, C> {
9139 self._max_results = Some(new_value);
9140 self
9141 }
9142 /// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
9143 ///
9144 /// Sets the *locale* query property to the given value.
9145 pub fn locale(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9146 self._locale = Some(new_value.to_string());
9147 self
9148 }
9149 /// Filters to be run on the report.
9150 ///
9151 /// Append the given value to the *filter* query property.
9152 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9153 pub fn add_filter(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9154 self._filter.push(new_value.to_string());
9155 self
9156 }
9157 /// Dimensions to base the report on.
9158 ///
9159 /// Append the given value to the *dimension* query property.
9160 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9161 pub fn add_dimension(mut self, new_value: &str) -> ReportGenerateCall<'a, C> {
9162 self._dimension.push(new_value.to_string());
9163 self
9164 }
9165 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9166 /// while executing the actual API request.
9167 ///
9168 /// ````text
9169 /// It should be used to handle progress information, and to implement a certain level of resilience.
9170 /// ````
9171 ///
9172 /// Sets the *delegate* property to the given value.
9173 pub fn delegate(
9174 mut self,
9175 new_value: &'a mut dyn common::Delegate,
9176 ) -> ReportGenerateCall<'a, C> {
9177 self._delegate = Some(new_value);
9178 self
9179 }
9180
9181 /// Set any additional parameter of the query string used in the request.
9182 /// It should be used to set parameters which are not yet available through their own
9183 /// setters.
9184 ///
9185 /// Please note that this method must not be used to set any of the known parameters
9186 /// which have their own setter method. If done anyway, the request will fail.
9187 ///
9188 /// # Additional Parameters
9189 ///
9190 /// * *alt* (query-string) - Data format for the response.
9191 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9192 /// * *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.
9193 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9194 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9195 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9196 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9197 pub fn param<T>(mut self, name: T, value: T) -> ReportGenerateCall<'a, C>
9198 where
9199 T: AsRef<str>,
9200 {
9201 self._additional_params
9202 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9203 self
9204 }
9205
9206 /// Identifies the authorization scope for the method you are building.
9207 ///
9208 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9209 /// [`Scope::Full`].
9210 ///
9211 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9212 /// tokens for more than one scope.
9213 ///
9214 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9215 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9216 /// sufficient, a read-write scope will do as well.
9217 pub fn add_scope<St>(mut self, scope: St) -> ReportGenerateCall<'a, C>
9218 where
9219 St: AsRef<str>,
9220 {
9221 self._scopes.insert(String::from(scope.as_ref()));
9222 self
9223 }
9224 /// Identifies the authorization scope(s) for the method you are building.
9225 ///
9226 /// See [`Self::add_scope()`] for details.
9227 pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportGenerateCall<'a, C>
9228 where
9229 I: IntoIterator<Item = St>,
9230 St: AsRef<str>,
9231 {
9232 self._scopes
9233 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9234 self
9235 }
9236
9237 /// Removes all scopes, and no default scope will be used either.
9238 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9239 /// for details).
9240 pub fn clear_scopes(mut self) -> ReportGenerateCall<'a, C> {
9241 self._scopes.clear();
9242 self
9243 }
9244}
9245
9246/// Delete a URL channel from the host AdSense account.
9247///
9248/// A builder for the *delete* method supported by a *urlchannel* resource.
9249/// It is not used directly, but through a [`UrlchannelMethods`] instance.
9250///
9251/// # Example
9252///
9253/// Instantiate a resource method builder
9254///
9255/// ```test_harness,no_run
9256/// # extern crate hyper;
9257/// # extern crate hyper_rustls;
9258/// # extern crate google_adsensehost4d1 as adsensehost4d1;
9259/// # async fn dox() {
9260/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9261///
9262/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9263/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9264/// # .with_native_roots()
9265/// # .unwrap()
9266/// # .https_only()
9267/// # .enable_http2()
9268/// # .build();
9269///
9270/// # let executor = hyper_util::rt::TokioExecutor::new();
9271/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9272/// # secret,
9273/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9274/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9275/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9276/// # ),
9277/// # ).build().await.unwrap();
9278///
9279/// # let client = hyper_util::client::legacy::Client::builder(
9280/// # hyper_util::rt::TokioExecutor::new()
9281/// # )
9282/// # .build(
9283/// # hyper_rustls::HttpsConnectorBuilder::new()
9284/// # .with_native_roots()
9285/// # .unwrap()
9286/// # .https_or_http()
9287/// # .enable_http2()
9288/// # .build()
9289/// # );
9290/// # let mut hub = AdSenseHost::new(client, auth);
9291/// // You can configure optional parameters by calling the respective setters at will, and
9292/// // execute the final call using `doit()`.
9293/// // Values shown here are possibly random and not representative !
9294/// let result = hub.urlchannels().delete("adClientId", "urlChannelId")
9295/// .doit().await;
9296/// # }
9297/// ```
9298pub struct UrlchannelDeleteCall<'a, C>
9299where
9300 C: 'a,
9301{
9302 hub: &'a AdSenseHost<C>,
9303 _ad_client_id: String,
9304 _url_channel_id: String,
9305 _delegate: Option<&'a mut dyn common::Delegate>,
9306 _additional_params: HashMap<String, String>,
9307 _scopes: BTreeSet<String>,
9308}
9309
9310impl<'a, C> common::CallBuilder for UrlchannelDeleteCall<'a, C> {}
9311
9312impl<'a, C> UrlchannelDeleteCall<'a, C>
9313where
9314 C: common::Connector,
9315{
9316 /// Perform the operation you have build so far.
9317 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannel)> {
9318 use std::borrow::Cow;
9319 use std::io::{Read, Seek};
9320
9321 use common::{url::Params, ToParts};
9322 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9323
9324 let mut dd = common::DefaultDelegate;
9325 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9326 dlg.begin(common::MethodInfo {
9327 id: "adsensehost.urlchannels.delete",
9328 http_method: hyper::Method::DELETE,
9329 });
9330
9331 for &field in ["alt", "adClientId", "urlChannelId"].iter() {
9332 if self._additional_params.contains_key(field) {
9333 dlg.finished(false);
9334 return Err(common::Error::FieldClash(field));
9335 }
9336 }
9337
9338 let mut params = Params::with_capacity(4 + self._additional_params.len());
9339 params.push("adClientId", self._ad_client_id);
9340 params.push("urlChannelId", self._url_channel_id);
9341
9342 params.extend(self._additional_params.iter());
9343
9344 params.push("alt", "json");
9345 let mut url =
9346 self.hub._base_url.clone() + "adclients/{adClientId}/urlchannels/{urlChannelId}";
9347 if self._scopes.is_empty() {
9348 self._scopes.insert(Scope::Full.as_ref().to_string());
9349 }
9350
9351 #[allow(clippy::single_element_loop)]
9352 for &(find_this, param_name) in [
9353 ("{adClientId}", "adClientId"),
9354 ("{urlChannelId}", "urlChannelId"),
9355 ]
9356 .iter()
9357 {
9358 url = params.uri_replacement(url, param_name, find_this, false);
9359 }
9360 {
9361 let to_remove = ["urlChannelId", "adClientId"];
9362 params.remove_params(&to_remove);
9363 }
9364
9365 let url = params.parse_with_url(&url);
9366
9367 loop {
9368 let token = match self
9369 .hub
9370 .auth
9371 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9372 .await
9373 {
9374 Ok(token) => token,
9375 Err(e) => match dlg.token(e) {
9376 Ok(token) => token,
9377 Err(e) => {
9378 dlg.finished(false);
9379 return Err(common::Error::MissingToken(e));
9380 }
9381 },
9382 };
9383 let mut req_result = {
9384 let client = &self.hub.client;
9385 dlg.pre_request();
9386 let mut req_builder = hyper::Request::builder()
9387 .method(hyper::Method::DELETE)
9388 .uri(url.as_str())
9389 .header(USER_AGENT, self.hub._user_agent.clone());
9390
9391 if let Some(token) = token.as_ref() {
9392 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9393 }
9394
9395 let request = req_builder
9396 .header(CONTENT_LENGTH, 0_u64)
9397 .body(common::to_body::<String>(None));
9398
9399 client.request(request.unwrap()).await
9400 };
9401
9402 match req_result {
9403 Err(err) => {
9404 if let common::Retry::After(d) = dlg.http_error(&err) {
9405 sleep(d).await;
9406 continue;
9407 }
9408 dlg.finished(false);
9409 return Err(common::Error::HttpError(err));
9410 }
9411 Ok(res) => {
9412 let (mut parts, body) = res.into_parts();
9413 let mut body = common::Body::new(body);
9414 if !parts.status.is_success() {
9415 let bytes = common::to_bytes(body).await.unwrap_or_default();
9416 let error = serde_json::from_str(&common::to_string(&bytes));
9417 let response = common::to_response(parts, bytes.into());
9418
9419 if let common::Retry::After(d) =
9420 dlg.http_failure(&response, error.as_ref().ok())
9421 {
9422 sleep(d).await;
9423 continue;
9424 }
9425
9426 dlg.finished(false);
9427
9428 return Err(match error {
9429 Ok(value) => common::Error::BadRequest(value),
9430 _ => common::Error::Failure(response),
9431 });
9432 }
9433 let response = {
9434 let bytes = common::to_bytes(body).await.unwrap_or_default();
9435 let encoded = common::to_string(&bytes);
9436 match serde_json::from_str(&encoded) {
9437 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9438 Err(error) => {
9439 dlg.response_json_decode_error(&encoded, &error);
9440 return Err(common::Error::JsonDecodeError(
9441 encoded.to_string(),
9442 error,
9443 ));
9444 }
9445 }
9446 };
9447
9448 dlg.finished(true);
9449 return Ok(response);
9450 }
9451 }
9452 }
9453 }
9454
9455 /// Ad client from which to delete the URL channel.
9456 ///
9457 /// Sets the *ad client id* path property to the given value.
9458 ///
9459 /// Even though the property as already been set when instantiating this call,
9460 /// we provide this method for API completeness.
9461 pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelDeleteCall<'a, C> {
9462 self._ad_client_id = new_value.to_string();
9463 self
9464 }
9465 /// URL channel to delete.
9466 ///
9467 /// Sets the *url channel id* path property to the given value.
9468 ///
9469 /// Even though the property as already been set when instantiating this call,
9470 /// we provide this method for API completeness.
9471 pub fn url_channel_id(mut self, new_value: &str) -> UrlchannelDeleteCall<'a, C> {
9472 self._url_channel_id = new_value.to_string();
9473 self
9474 }
9475 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9476 /// while executing the actual API request.
9477 ///
9478 /// ````text
9479 /// It should be used to handle progress information, and to implement a certain level of resilience.
9480 /// ````
9481 ///
9482 /// Sets the *delegate* property to the given value.
9483 pub fn delegate(
9484 mut self,
9485 new_value: &'a mut dyn common::Delegate,
9486 ) -> UrlchannelDeleteCall<'a, C> {
9487 self._delegate = Some(new_value);
9488 self
9489 }
9490
9491 /// Set any additional parameter of the query string used in the request.
9492 /// It should be used to set parameters which are not yet available through their own
9493 /// setters.
9494 ///
9495 /// Please note that this method must not be used to set any of the known parameters
9496 /// which have their own setter method. If done anyway, the request will fail.
9497 ///
9498 /// # Additional Parameters
9499 ///
9500 /// * *alt* (query-string) - Data format for the response.
9501 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9502 /// * *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.
9503 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9504 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9505 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9506 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9507 pub fn param<T>(mut self, name: T, value: T) -> UrlchannelDeleteCall<'a, C>
9508 where
9509 T: AsRef<str>,
9510 {
9511 self._additional_params
9512 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9513 self
9514 }
9515
9516 /// Identifies the authorization scope for the method you are building.
9517 ///
9518 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9519 /// [`Scope::Full`].
9520 ///
9521 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9522 /// tokens for more than one scope.
9523 ///
9524 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9525 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9526 /// sufficient, a read-write scope will do as well.
9527 pub fn add_scope<St>(mut self, scope: St) -> UrlchannelDeleteCall<'a, C>
9528 where
9529 St: AsRef<str>,
9530 {
9531 self._scopes.insert(String::from(scope.as_ref()));
9532 self
9533 }
9534 /// Identifies the authorization scope(s) for the method you are building.
9535 ///
9536 /// See [`Self::add_scope()`] for details.
9537 pub fn add_scopes<I, St>(mut self, scopes: I) -> UrlchannelDeleteCall<'a, C>
9538 where
9539 I: IntoIterator<Item = St>,
9540 St: AsRef<str>,
9541 {
9542 self._scopes
9543 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9544 self
9545 }
9546
9547 /// Removes all scopes, and no default scope will be used either.
9548 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9549 /// for details).
9550 pub fn clear_scopes(mut self) -> UrlchannelDeleteCall<'a, C> {
9551 self._scopes.clear();
9552 self
9553 }
9554}
9555
9556/// Add a new URL channel to the host AdSense account.
9557///
9558/// A builder for the *insert* method supported by a *urlchannel* resource.
9559/// It is not used directly, but through a [`UrlchannelMethods`] instance.
9560///
9561/// # Example
9562///
9563/// Instantiate a resource method builder
9564///
9565/// ```test_harness,no_run
9566/// # extern crate hyper;
9567/// # extern crate hyper_rustls;
9568/// # extern crate google_adsensehost4d1 as adsensehost4d1;
9569/// use adsensehost4d1::api::UrlChannel;
9570/// # async fn dox() {
9571/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9572///
9573/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9574/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9575/// # .with_native_roots()
9576/// # .unwrap()
9577/// # .https_only()
9578/// # .enable_http2()
9579/// # .build();
9580///
9581/// # let executor = hyper_util::rt::TokioExecutor::new();
9582/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9583/// # secret,
9584/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9585/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9586/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9587/// # ),
9588/// # ).build().await.unwrap();
9589///
9590/// # let client = hyper_util::client::legacy::Client::builder(
9591/// # hyper_util::rt::TokioExecutor::new()
9592/// # )
9593/// # .build(
9594/// # hyper_rustls::HttpsConnectorBuilder::new()
9595/// # .with_native_roots()
9596/// # .unwrap()
9597/// # .https_or_http()
9598/// # .enable_http2()
9599/// # .build()
9600/// # );
9601/// # let mut hub = AdSenseHost::new(client, auth);
9602/// // As the method needs a request, you would usually fill it with the desired information
9603/// // into the respective structure. Some of the parts shown here might not be applicable !
9604/// // Values shown here are possibly random and not representative !
9605/// let mut req = UrlChannel::default();
9606///
9607/// // You can configure optional parameters by calling the respective setters at will, and
9608/// // execute the final call using `doit()`.
9609/// // Values shown here are possibly random and not representative !
9610/// let result = hub.urlchannels().insert(req, "adClientId")
9611/// .doit().await;
9612/// # }
9613/// ```
9614pub struct UrlchannelInsertCall<'a, C>
9615where
9616 C: 'a,
9617{
9618 hub: &'a AdSenseHost<C>,
9619 _request: UrlChannel,
9620 _ad_client_id: String,
9621 _delegate: Option<&'a mut dyn common::Delegate>,
9622 _additional_params: HashMap<String, String>,
9623 _scopes: BTreeSet<String>,
9624}
9625
9626impl<'a, C> common::CallBuilder for UrlchannelInsertCall<'a, C> {}
9627
9628impl<'a, C> UrlchannelInsertCall<'a, C>
9629where
9630 C: common::Connector,
9631{
9632 /// Perform the operation you have build so far.
9633 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannel)> {
9634 use std::borrow::Cow;
9635 use std::io::{Read, Seek};
9636
9637 use common::{url::Params, ToParts};
9638 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9639
9640 let mut dd = common::DefaultDelegate;
9641 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9642 dlg.begin(common::MethodInfo {
9643 id: "adsensehost.urlchannels.insert",
9644 http_method: hyper::Method::POST,
9645 });
9646
9647 for &field in ["alt", "adClientId"].iter() {
9648 if self._additional_params.contains_key(field) {
9649 dlg.finished(false);
9650 return Err(common::Error::FieldClash(field));
9651 }
9652 }
9653
9654 let mut params = Params::with_capacity(4 + self._additional_params.len());
9655 params.push("adClientId", self._ad_client_id);
9656
9657 params.extend(self._additional_params.iter());
9658
9659 params.push("alt", "json");
9660 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/urlchannels";
9661 if self._scopes.is_empty() {
9662 self._scopes.insert(Scope::Full.as_ref().to_string());
9663 }
9664
9665 #[allow(clippy::single_element_loop)]
9666 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
9667 url = params.uri_replacement(url, param_name, find_this, false);
9668 }
9669 {
9670 let to_remove = ["adClientId"];
9671 params.remove_params(&to_remove);
9672 }
9673
9674 let url = params.parse_with_url(&url);
9675
9676 let mut json_mime_type = mime::APPLICATION_JSON;
9677 let mut request_value_reader = {
9678 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9679 common::remove_json_null_values(&mut value);
9680 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9681 serde_json::to_writer(&mut dst, &value).unwrap();
9682 dst
9683 };
9684 let request_size = request_value_reader
9685 .seek(std::io::SeekFrom::End(0))
9686 .unwrap();
9687 request_value_reader
9688 .seek(std::io::SeekFrom::Start(0))
9689 .unwrap();
9690
9691 loop {
9692 let token = match self
9693 .hub
9694 .auth
9695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9696 .await
9697 {
9698 Ok(token) => token,
9699 Err(e) => match dlg.token(e) {
9700 Ok(token) => token,
9701 Err(e) => {
9702 dlg.finished(false);
9703 return Err(common::Error::MissingToken(e));
9704 }
9705 },
9706 };
9707 request_value_reader
9708 .seek(std::io::SeekFrom::Start(0))
9709 .unwrap();
9710 let mut req_result = {
9711 let client = &self.hub.client;
9712 dlg.pre_request();
9713 let mut req_builder = hyper::Request::builder()
9714 .method(hyper::Method::POST)
9715 .uri(url.as_str())
9716 .header(USER_AGENT, self.hub._user_agent.clone());
9717
9718 if let Some(token) = token.as_ref() {
9719 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9720 }
9721
9722 let request = req_builder
9723 .header(CONTENT_TYPE, json_mime_type.to_string())
9724 .header(CONTENT_LENGTH, request_size as u64)
9725 .body(common::to_body(
9726 request_value_reader.get_ref().clone().into(),
9727 ));
9728
9729 client.request(request.unwrap()).await
9730 };
9731
9732 match req_result {
9733 Err(err) => {
9734 if let common::Retry::After(d) = dlg.http_error(&err) {
9735 sleep(d).await;
9736 continue;
9737 }
9738 dlg.finished(false);
9739 return Err(common::Error::HttpError(err));
9740 }
9741 Ok(res) => {
9742 let (mut parts, body) = res.into_parts();
9743 let mut body = common::Body::new(body);
9744 if !parts.status.is_success() {
9745 let bytes = common::to_bytes(body).await.unwrap_or_default();
9746 let error = serde_json::from_str(&common::to_string(&bytes));
9747 let response = common::to_response(parts, bytes.into());
9748
9749 if let common::Retry::After(d) =
9750 dlg.http_failure(&response, error.as_ref().ok())
9751 {
9752 sleep(d).await;
9753 continue;
9754 }
9755
9756 dlg.finished(false);
9757
9758 return Err(match error {
9759 Ok(value) => common::Error::BadRequest(value),
9760 _ => common::Error::Failure(response),
9761 });
9762 }
9763 let response = {
9764 let bytes = common::to_bytes(body).await.unwrap_or_default();
9765 let encoded = common::to_string(&bytes);
9766 match serde_json::from_str(&encoded) {
9767 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9768 Err(error) => {
9769 dlg.response_json_decode_error(&encoded, &error);
9770 return Err(common::Error::JsonDecodeError(
9771 encoded.to_string(),
9772 error,
9773 ));
9774 }
9775 }
9776 };
9777
9778 dlg.finished(true);
9779 return Ok(response);
9780 }
9781 }
9782 }
9783 }
9784
9785 ///
9786 /// Sets the *request* property to the given value.
9787 ///
9788 /// Even though the property as already been set when instantiating this call,
9789 /// we provide this method for API completeness.
9790 pub fn request(mut self, new_value: UrlChannel) -> UrlchannelInsertCall<'a, C> {
9791 self._request = new_value;
9792 self
9793 }
9794 /// Ad client to which the new URL channel will be added.
9795 ///
9796 /// Sets the *ad client id* path property to the given value.
9797 ///
9798 /// Even though the property as already been set when instantiating this call,
9799 /// we provide this method for API completeness.
9800 pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelInsertCall<'a, C> {
9801 self._ad_client_id = new_value.to_string();
9802 self
9803 }
9804 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9805 /// while executing the actual API request.
9806 ///
9807 /// ````text
9808 /// It should be used to handle progress information, and to implement a certain level of resilience.
9809 /// ````
9810 ///
9811 /// Sets the *delegate* property to the given value.
9812 pub fn delegate(
9813 mut self,
9814 new_value: &'a mut dyn common::Delegate,
9815 ) -> UrlchannelInsertCall<'a, C> {
9816 self._delegate = Some(new_value);
9817 self
9818 }
9819
9820 /// Set any additional parameter of the query string used in the request.
9821 /// It should be used to set parameters which are not yet available through their own
9822 /// setters.
9823 ///
9824 /// Please note that this method must not be used to set any of the known parameters
9825 /// which have their own setter method. If done anyway, the request will fail.
9826 ///
9827 /// # Additional Parameters
9828 ///
9829 /// * *alt* (query-string) - Data format for the response.
9830 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9831 /// * *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.
9832 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9833 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9834 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9835 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9836 pub fn param<T>(mut self, name: T, value: T) -> UrlchannelInsertCall<'a, C>
9837 where
9838 T: AsRef<str>,
9839 {
9840 self._additional_params
9841 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9842 self
9843 }
9844
9845 /// Identifies the authorization scope for the method you are building.
9846 ///
9847 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9848 /// [`Scope::Full`].
9849 ///
9850 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9851 /// tokens for more than one scope.
9852 ///
9853 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9854 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9855 /// sufficient, a read-write scope will do as well.
9856 pub fn add_scope<St>(mut self, scope: St) -> UrlchannelInsertCall<'a, C>
9857 where
9858 St: AsRef<str>,
9859 {
9860 self._scopes.insert(String::from(scope.as_ref()));
9861 self
9862 }
9863 /// Identifies the authorization scope(s) for the method you are building.
9864 ///
9865 /// See [`Self::add_scope()`] for details.
9866 pub fn add_scopes<I, St>(mut self, scopes: I) -> UrlchannelInsertCall<'a, C>
9867 where
9868 I: IntoIterator<Item = St>,
9869 St: AsRef<str>,
9870 {
9871 self._scopes
9872 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9873 self
9874 }
9875
9876 /// Removes all scopes, and no default scope will be used either.
9877 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9878 /// for details).
9879 pub fn clear_scopes(mut self) -> UrlchannelInsertCall<'a, C> {
9880 self._scopes.clear();
9881 self
9882 }
9883}
9884
9885/// List all host URL channels in the host AdSense account.
9886///
9887/// A builder for the *list* method supported by a *urlchannel* resource.
9888/// It is not used directly, but through a [`UrlchannelMethods`] instance.
9889///
9890/// # Example
9891///
9892/// Instantiate a resource method builder
9893///
9894/// ```test_harness,no_run
9895/// # extern crate hyper;
9896/// # extern crate hyper_rustls;
9897/// # extern crate google_adsensehost4d1 as adsensehost4d1;
9898/// # async fn dox() {
9899/// # use adsensehost4d1::{AdSenseHost, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9900///
9901/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9902/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9903/// # .with_native_roots()
9904/// # .unwrap()
9905/// # .https_only()
9906/// # .enable_http2()
9907/// # .build();
9908///
9909/// # let executor = hyper_util::rt::TokioExecutor::new();
9910/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9911/// # secret,
9912/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9913/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9914/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9915/// # ),
9916/// # ).build().await.unwrap();
9917///
9918/// # let client = hyper_util::client::legacy::Client::builder(
9919/// # hyper_util::rt::TokioExecutor::new()
9920/// # )
9921/// # .build(
9922/// # hyper_rustls::HttpsConnectorBuilder::new()
9923/// # .with_native_roots()
9924/// # .unwrap()
9925/// # .https_or_http()
9926/// # .enable_http2()
9927/// # .build()
9928/// # );
9929/// # let mut hub = AdSenseHost::new(client, auth);
9930/// // You can configure optional parameters by calling the respective setters at will, and
9931/// // execute the final call using `doit()`.
9932/// // Values shown here are possibly random and not representative !
9933/// let result = hub.urlchannels().list("adClientId")
9934/// .page_token("ipsum")
9935/// .max_results(83)
9936/// .doit().await;
9937/// # }
9938/// ```
9939pub struct UrlchannelListCall<'a, C>
9940where
9941 C: 'a,
9942{
9943 hub: &'a AdSenseHost<C>,
9944 _ad_client_id: String,
9945 _page_token: Option<String>,
9946 _max_results: Option<u32>,
9947 _delegate: Option<&'a mut dyn common::Delegate>,
9948 _additional_params: HashMap<String, String>,
9949 _scopes: BTreeSet<String>,
9950}
9951
9952impl<'a, C> common::CallBuilder for UrlchannelListCall<'a, C> {}
9953
9954impl<'a, C> UrlchannelListCall<'a, C>
9955where
9956 C: common::Connector,
9957{
9958 /// Perform the operation you have build so far.
9959 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannels)> {
9960 use std::borrow::Cow;
9961 use std::io::{Read, Seek};
9962
9963 use common::{url::Params, ToParts};
9964 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9965
9966 let mut dd = common::DefaultDelegate;
9967 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9968 dlg.begin(common::MethodInfo {
9969 id: "adsensehost.urlchannels.list",
9970 http_method: hyper::Method::GET,
9971 });
9972
9973 for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
9974 if self._additional_params.contains_key(field) {
9975 dlg.finished(false);
9976 return Err(common::Error::FieldClash(field));
9977 }
9978 }
9979
9980 let mut params = Params::with_capacity(5 + self._additional_params.len());
9981 params.push("adClientId", self._ad_client_id);
9982 if let Some(value) = self._page_token.as_ref() {
9983 params.push("pageToken", value);
9984 }
9985 if let Some(value) = self._max_results.as_ref() {
9986 params.push("maxResults", value.to_string());
9987 }
9988
9989 params.extend(self._additional_params.iter());
9990
9991 params.push("alt", "json");
9992 let mut url = self.hub._base_url.clone() + "adclients/{adClientId}/urlchannels";
9993 if self._scopes.is_empty() {
9994 self._scopes.insert(Scope::Full.as_ref().to_string());
9995 }
9996
9997 #[allow(clippy::single_element_loop)]
9998 for &(find_this, param_name) in [("{adClientId}", "adClientId")].iter() {
9999 url = params.uri_replacement(url, param_name, find_this, false);
10000 }
10001 {
10002 let to_remove = ["adClientId"];
10003 params.remove_params(&to_remove);
10004 }
10005
10006 let url = params.parse_with_url(&url);
10007
10008 loop {
10009 let token = match self
10010 .hub
10011 .auth
10012 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10013 .await
10014 {
10015 Ok(token) => token,
10016 Err(e) => match dlg.token(e) {
10017 Ok(token) => token,
10018 Err(e) => {
10019 dlg.finished(false);
10020 return Err(common::Error::MissingToken(e));
10021 }
10022 },
10023 };
10024 let mut req_result = {
10025 let client = &self.hub.client;
10026 dlg.pre_request();
10027 let mut req_builder = hyper::Request::builder()
10028 .method(hyper::Method::GET)
10029 .uri(url.as_str())
10030 .header(USER_AGENT, self.hub._user_agent.clone());
10031
10032 if let Some(token) = token.as_ref() {
10033 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10034 }
10035
10036 let request = req_builder
10037 .header(CONTENT_LENGTH, 0_u64)
10038 .body(common::to_body::<String>(None));
10039
10040 client.request(request.unwrap()).await
10041 };
10042
10043 match req_result {
10044 Err(err) => {
10045 if let common::Retry::After(d) = dlg.http_error(&err) {
10046 sleep(d).await;
10047 continue;
10048 }
10049 dlg.finished(false);
10050 return Err(common::Error::HttpError(err));
10051 }
10052 Ok(res) => {
10053 let (mut parts, body) = res.into_parts();
10054 let mut body = common::Body::new(body);
10055 if !parts.status.is_success() {
10056 let bytes = common::to_bytes(body).await.unwrap_or_default();
10057 let error = serde_json::from_str(&common::to_string(&bytes));
10058 let response = common::to_response(parts, bytes.into());
10059
10060 if let common::Retry::After(d) =
10061 dlg.http_failure(&response, error.as_ref().ok())
10062 {
10063 sleep(d).await;
10064 continue;
10065 }
10066
10067 dlg.finished(false);
10068
10069 return Err(match error {
10070 Ok(value) => common::Error::BadRequest(value),
10071 _ => common::Error::Failure(response),
10072 });
10073 }
10074 let response = {
10075 let bytes = common::to_bytes(body).await.unwrap_or_default();
10076 let encoded = common::to_string(&bytes);
10077 match serde_json::from_str(&encoded) {
10078 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10079 Err(error) => {
10080 dlg.response_json_decode_error(&encoded, &error);
10081 return Err(common::Error::JsonDecodeError(
10082 encoded.to_string(),
10083 error,
10084 ));
10085 }
10086 }
10087 };
10088
10089 dlg.finished(true);
10090 return Ok(response);
10091 }
10092 }
10093 }
10094 }
10095
10096 /// Ad client for which to list URL channels.
10097 ///
10098 /// Sets the *ad client id* path property to the given value.
10099 ///
10100 /// Even though the property as already been set when instantiating this call,
10101 /// we provide this method for API completeness.
10102 pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelListCall<'a, C> {
10103 self._ad_client_id = new_value.to_string();
10104 self
10105 }
10106 /// 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.
10107 ///
10108 /// Sets the *page token* query property to the given value.
10109 pub fn page_token(mut self, new_value: &str) -> UrlchannelListCall<'a, C> {
10110 self._page_token = Some(new_value.to_string());
10111 self
10112 }
10113 /// The maximum number of URL channels to include in the response, used for paging.
10114 ///
10115 /// Sets the *max results* query property to the given value.
10116 pub fn max_results(mut self, new_value: u32) -> UrlchannelListCall<'a, C> {
10117 self._max_results = Some(new_value);
10118 self
10119 }
10120 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10121 /// while executing the actual API request.
10122 ///
10123 /// ````text
10124 /// It should be used to handle progress information, and to implement a certain level of resilience.
10125 /// ````
10126 ///
10127 /// Sets the *delegate* property to the given value.
10128 pub fn delegate(
10129 mut self,
10130 new_value: &'a mut dyn common::Delegate,
10131 ) -> UrlchannelListCall<'a, C> {
10132 self._delegate = Some(new_value);
10133 self
10134 }
10135
10136 /// Set any additional parameter of the query string used in the request.
10137 /// It should be used to set parameters which are not yet available through their own
10138 /// setters.
10139 ///
10140 /// Please note that this method must not be used to set any of the known parameters
10141 /// which have their own setter method. If done anyway, the request will fail.
10142 ///
10143 /// # Additional Parameters
10144 ///
10145 /// * *alt* (query-string) - Data format for the response.
10146 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10147 /// * *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.
10148 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10149 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10150 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10151 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10152 pub fn param<T>(mut self, name: T, value: T) -> UrlchannelListCall<'a, C>
10153 where
10154 T: AsRef<str>,
10155 {
10156 self._additional_params
10157 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10158 self
10159 }
10160
10161 /// Identifies the authorization scope for the method you are building.
10162 ///
10163 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10164 /// [`Scope::Full`].
10165 ///
10166 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10167 /// tokens for more than one scope.
10168 ///
10169 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10170 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10171 /// sufficient, a read-write scope will do as well.
10172 pub fn add_scope<St>(mut self, scope: St) -> UrlchannelListCall<'a, C>
10173 where
10174 St: AsRef<str>,
10175 {
10176 self._scopes.insert(String::from(scope.as_ref()));
10177 self
10178 }
10179 /// Identifies the authorization scope(s) for the method you are building.
10180 ///
10181 /// See [`Self::add_scope()`] for details.
10182 pub fn add_scopes<I, St>(mut self, scopes: I) -> UrlchannelListCall<'a, C>
10183 where
10184 I: IntoIterator<Item = St>,
10185 St: AsRef<str>,
10186 {
10187 self._scopes
10188 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10189 self
10190 }
10191
10192 /// Removes all scopes, and no default scope will be used either.
10193 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10194 /// for details).
10195 pub fn clear_scopes(mut self) -> UrlchannelListCall<'a, C> {
10196 self._scopes.clear();
10197 self
10198 }
10199}