google_adsense2/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// View and manage your AdSense data
17 Full,
18
19 /// View your AdSense data
20 Readonly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/adsense",
27 Scope::Readonly => "https://www.googleapis.com/auth/adsense.readonly",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Readonly
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Adsense related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_adsense2 as adsense2;
53/// use adsense2::{Result, Error};
54/// # async fn dox() {
55/// use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = Adsense::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.accounts().reports_generate("account")
97/// .start_date_year(-17)
98/// .start_date_month(-99)
99/// .start_date_day(-56)
100/// .reporting_time_zone("eos")
101/// .add_order_by("labore")
102/// .add_metrics("sed")
103/// .limit(-70)
104/// .language_code("sed")
105/// .add_filters("no")
106/// .end_date_year(-15)
107/// .end_date_month(-13)
108/// .end_date_day(-24)
109/// .add_dimensions("sed")
110/// .date_range("et")
111/// .currency_code("et")
112/// .doit().await;
113///
114/// match result {
115/// Err(e) => match e {
116/// // The Error enum provides details about what exactly happened.
117/// // You can also just use its `Debug`, `Display` or `Error` traits
118/// Error::HttpError(_)
119/// |Error::Io(_)
120/// |Error::MissingAPIKey
121/// |Error::MissingToken(_)
122/// |Error::Cancelled
123/// |Error::UploadSizeLimitExceeded(_, _)
124/// |Error::Failure(_)
125/// |Error::BadRequest(_)
126/// |Error::FieldClash(_)
127/// |Error::JsonDecodeError(_, _) => println!("{}", e),
128/// },
129/// Ok(res) => println!("Success: {:?}", res),
130/// }
131/// # }
132/// ```
133#[derive(Clone)]
134pub struct Adsense<C> {
135 pub client: common::Client<C>,
136 pub auth: Box<dyn common::GetToken>,
137 _user_agent: String,
138 _base_url: String,
139 _root_url: String,
140}
141
142impl<C> common::Hub for Adsense<C> {}
143
144impl<'a, C> Adsense<C> {
145 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Adsense<C> {
146 Adsense {
147 client,
148 auth: Box::new(auth),
149 _user_agent: "google-api-rust-client/7.0.0".to_string(),
150 _base_url: "https://adsense.googleapis.com/".to_string(),
151 _root_url: "https://adsense.googleapis.com/".to_string(),
152 }
153 }
154
155 pub fn accounts(&'a self) -> AccountMethods<'a, C> {
156 AccountMethods { hub: self }
157 }
158
159 /// Set the user-agent header field to use in all requests to the server.
160 /// It defaults to `google-api-rust-client/7.0.0`.
161 ///
162 /// Returns the previously set user-agent.
163 pub fn user_agent(&mut self, agent_name: String) -> String {
164 std::mem::replace(&mut self._user_agent, agent_name)
165 }
166
167 /// Set the base url to use in all requests to the server.
168 /// It defaults to `https://adsense.googleapis.com/`.
169 ///
170 /// Returns the previously set base url.
171 pub fn base_url(&mut self, new_base_url: String) -> String {
172 std::mem::replace(&mut self._base_url, new_base_url)
173 }
174
175 /// Set the root url to use in all requests to the server.
176 /// It defaults to `https://adsense.googleapis.com/`.
177 ///
178 /// Returns the previously set root url.
179 pub fn root_url(&mut self, new_root_url: String) -> String {
180 std::mem::replace(&mut self._root_url, new_root_url)
181 }
182}
183
184// ############
185// SCHEMAS ###
186// ##########
187/// Representation of an account.
188///
189/// # Activities
190///
191/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
192/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
193///
194/// * [adclients adunits create accounts](AccountAdclientAdunitCreateCall) (none)
195/// * [adclients adunits get accounts](AccountAdclientAdunitGetCall) (none)
196/// * [adclients adunits get adcode accounts](AccountAdclientAdunitGetAdcodeCall) (none)
197/// * [adclients adunits list accounts](AccountAdclientAdunitListCall) (none)
198/// * [adclients adunits list linked custom channels accounts](AccountAdclientAdunitListLinkedCustomChannelCall) (none)
199/// * [adclients adunits patch accounts](AccountAdclientAdunitPatchCall) (none)
200/// * [adclients customchannels create accounts](AccountAdclientCustomchannelCreateCall) (none)
201/// * [adclients customchannels delete accounts](AccountAdclientCustomchannelDeleteCall) (none)
202/// * [adclients customchannels get accounts](AccountAdclientCustomchannelGetCall) (none)
203/// * [adclients customchannels list accounts](AccountAdclientCustomchannelListCall) (none)
204/// * [adclients customchannels list linked ad units accounts](AccountAdclientCustomchannelListLinkedAdUnitCall) (none)
205/// * [adclients customchannels patch accounts](AccountAdclientCustomchannelPatchCall) (none)
206/// * [adclients urlchannels get accounts](AccountAdclientUrlchannelGetCall) (none)
207/// * [adclients urlchannels list accounts](AccountAdclientUrlchannelListCall) (none)
208/// * [adclients get accounts](AccountAdclientGetCall) (none)
209/// * [adclients get adcode accounts](AccountAdclientGetAdcodeCall) (none)
210/// * [adclients list accounts](AccountAdclientListCall) (none)
211/// * [alerts list accounts](AccountAlertListCall) (none)
212/// * [payments list accounts](AccountPaymentListCall) (none)
213/// * [policy issues get accounts](AccountPolicyIssueGetCall) (none)
214/// * [policy issues list accounts](AccountPolicyIssueListCall) (none)
215/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (none)
216/// * [reports saved generate csv accounts](AccountReportSavedGenerateCsvCall) (none)
217/// * [reports saved list accounts](AccountReportSavedListCall) (none)
218/// * [reports generate accounts](AccountReportGenerateCall) (none)
219/// * [reports generate csv accounts](AccountReportGenerateCsvCall) (none)
220/// * [reports get saved accounts](AccountReportGetSavedCall) (none)
221/// * [sites get accounts](AccountSiteGetCall) (none)
222/// * [sites list accounts](AccountSiteListCall) (none)
223/// * [get accounts](AccountGetCall) (response)
224/// * [get ad blocking recovery tag accounts](AccountGetAdBlockingRecoveryTagCall) (none)
225/// * [list accounts](AccountListCall) (none)
226/// * [list child accounts accounts](AccountListChildAccountCall) (none)
227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
228#[serde_with::serde_as]
229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
230pub struct Account {
231 /// Output only. Creation time of the account.
232 #[serde(rename = "createTime")]
233 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
234 /// Output only. Display name of this account.
235 #[serde(rename = "displayName")]
236 pub display_name: Option<String>,
237 /// Output only. Resource name of the account. Format: accounts/pub-[0-9]+
238 pub name: Option<String>,
239 /// Output only. Outstanding tasks that need to be completed as part of the sign-up process for a new account. e.g. "billing-profile-creation", "phone-pin-verification".
240 #[serde(rename = "pendingTasks")]
241 pub pending_tasks: Option<Vec<String>>,
242 /// Output only. Whether this account is premium. Premium accounts have access to additional spam-related metrics.
243 pub premium: Option<bool>,
244 /// Output only. State of the account.
245 pub state: Option<String>,
246 /// The account time zone, as used by reporting. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
247 #[serde(rename = "timeZone")]
248 pub time_zone: Option<TimeZone>,
249}
250
251impl common::Resource for Account {}
252impl common::ResponseResult for Account {}
253
254/// Representation of an ad blocking recovery tag. See https://support.google.com/adsense/answer/11575177.
255///
256/// # Activities
257///
258/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
259/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
260///
261/// * [get ad blocking recovery tag accounts](AccountGetAdBlockingRecoveryTagCall) (response)
262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
263#[serde_with::serde_as]
264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
265pub struct AdBlockingRecoveryTag {
266 /// Error protection code that can be used in conjunction with the tag. It'll display a message to users if an [ad blocking extension blocks their access to your site](https://support.google.com/adsense/answer/11575480).
267 #[serde(rename = "errorProtectionCode")]
268 pub error_protection_code: Option<String>,
269 /// The ad blocking recovery tag. Note that the message generated by the tag can be blocked by an ad blocking extension. If this is not your desired outcome, then you'll need to use it in conjunction with the error protection code.
270 pub tag: Option<String>,
271}
272
273impl common::ResponseResult for AdBlockingRecoveryTag {}
274
275/// Representation of an ad client. An ad client represents a user’s subscription with a specific AdSense product.
276///
277/// # Activities
278///
279/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
280/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
281///
282/// * [adclients get accounts](AccountAdclientGetCall) (response)
283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
284#[serde_with::serde_as]
285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
286pub struct AdClient {
287 /// Output only. Resource name of the ad client. Format: accounts/{account}/adclients/{adclient}
288 pub name: Option<String>,
289 /// Output only. Reporting product code of the ad client. For example, "AFC" for AdSense for Content. Corresponds to the `PRODUCT_CODE` dimension, and present only if the ad client supports reporting.
290 #[serde(rename = "productCode")]
291 pub product_code: Option<String>,
292 /// Output only. Unique ID of the ad client as used in the `AD_CLIENT_ID` reporting dimension. Present only if the ad client supports reporting.
293 #[serde(rename = "reportingDimensionId")]
294 pub reporting_dimension_id: Option<String>,
295 /// Output only. State of the ad client.
296 pub state: Option<String>,
297}
298
299impl common::ResponseResult for AdClient {}
300
301/// Representation of the AdSense code for a given ad client. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
302///
303/// # Activities
304///
305/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
306/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
307///
308/// * [adclients get adcode accounts](AccountAdclientGetAdcodeCall) (response)
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct AdClientAdCode {
313 /// Output only. The AdSense code snippet to add to the head of an HTML page.
314 #[serde(rename = "adCode")]
315 pub ad_code: Option<String>,
316 /// Output only. The AdSense code snippet to add to the body of an AMP page.
317 #[serde(rename = "ampBody")]
318 pub amp_body: Option<String>,
319 /// Output only. The AdSense code snippet to add to the head of an AMP page.
320 #[serde(rename = "ampHead")]
321 pub amp_head: Option<String>,
322}
323
324impl common::ResponseResult for AdClientAdCode {}
325
326/// Representation of an ad unit. An ad unit represents a saved ad unit with a specific set of ad settings that have been customized within an account.
327///
328/// # Activities
329///
330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
332///
333/// * [adclients adunits create accounts](AccountAdclientAdunitCreateCall) (request|response)
334/// * [adclients adunits get accounts](AccountAdclientAdunitGetCall) (response)
335/// * [adclients adunits patch accounts](AccountAdclientAdunitPatchCall) (request|response)
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as]
338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
339pub struct AdUnit {
340 /// Required. Settings specific to content ads (AFC).
341 #[serde(rename = "contentAdsSettings")]
342 pub content_ads_settings: Option<ContentAdsSettings>,
343 /// Required. Display name of the ad unit, as provided when the ad unit was created.
344 #[serde(rename = "displayName")]
345 pub display_name: Option<String>,
346 /// Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
347 pub name: Option<String>,
348 /// Output only. Unique ID of the ad unit as used in the `AD_UNIT_ID` reporting dimension.
349 #[serde(rename = "reportingDimensionId")]
350 pub reporting_dimension_id: Option<String>,
351 /// Required. State of the ad unit.
352 pub state: Option<String>,
353}
354
355impl common::RequestValue for AdUnit {}
356impl common::ResponseResult for AdUnit {}
357
358/// Representation of the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
359///
360/// # Activities
361///
362/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
363/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
364///
365/// * [adclients adunits get adcode accounts](AccountAdclientAdunitGetAdcodeCall) (response)
366#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
367#[serde_with::serde_as]
368#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
369pub struct AdUnitAdCode {
370 /// Output only. The code snippet to add to the body of an HTML page.
371 #[serde(rename = "adCode")]
372 pub ad_code: Option<String>,
373}
374
375impl common::ResponseResult for AdUnitAdCode {}
376
377/// Representation of an alert.
378///
379/// This type is not used in any activity, and only used as *part* of another schema.
380///
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct Alert {
385 /// Output only. The localized alert message. This may contain HTML markup, such as phrase elements or links.
386 pub message: Option<String>,
387 /// Output only. Resource name of the alert. Format: accounts/{account}/alerts/{alert}
388 pub name: Option<String>,
389 /// Output only. Severity of this alert.
390 pub severity: Option<String>,
391 /// Output only. Type of alert. This identifies the broad type of this alert, and provides a stable machine-readable identifier that will not be translated. For example, "payment-hold".
392 #[serde(rename = "type")]
393 pub type_: Option<String>,
394}
395
396impl common::Part for Alert {}
397
398/// Cell representation.
399///
400/// This type is not used in any activity, and only used as *part* of another schema.
401///
402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
403#[serde_with::serde_as]
404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
405pub struct Cell {
406 /// Value in the cell. The dimension cells contain strings, and the metric cells contain numbers.
407 pub value: Option<String>,
408}
409
410impl common::Part for Cell {}
411
412/// Settings specific to content ads (AFC).
413///
414/// This type is not used in any activity, and only used as *part* of another schema.
415///
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct ContentAdsSettings {
420 /// Required. Size of the ad unit. e.g. "728x90", "1x3" (for responsive ad units).
421 pub size: Option<String>,
422 /// Required. Type of the ad unit.
423 #[serde(rename = "type")]
424 pub type_: Option<String>,
425}
426
427impl common::Part for ContentAdsSettings {}
428
429/// Representation of a custom channel.
430///
431/// # Activities
432///
433/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
434/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
435///
436/// * [adclients customchannels create accounts](AccountAdclientCustomchannelCreateCall) (request|response)
437/// * [adclients customchannels get accounts](AccountAdclientCustomchannelGetCall) (response)
438/// * [adclients customchannels patch accounts](AccountAdclientCustomchannelPatchCall) (request|response)
439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
440#[serde_with::serde_as]
441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
442pub struct CustomChannel {
443 /// Whether the custom channel is active and collecting data. See https://support.google.com/adsense/answer/10077192.
444 pub active: Option<bool>,
445 /// Required. Display name of the custom channel.
446 #[serde(rename = "displayName")]
447 pub display_name: Option<String>,
448 /// Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
449 pub name: Option<String>,
450 /// Output only. Unique ID of the custom channel as used in the `CUSTOM_CHANNEL_ID` reporting dimension.
451 #[serde(rename = "reportingDimensionId")]
452 pub reporting_dimension_id: Option<String>,
453}
454
455impl common::RequestValue for CustomChannel {}
456impl common::ResponseResult for CustomChannel {}
457
458/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
459///
460/// This type is not used in any activity, and only used as *part* of another schema.
461///
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct Date {
466 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
467 pub day: Option<i32>,
468 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
469 pub month: Option<i32>,
470 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
471 pub year: Option<i32>,
472}
473
474impl common::Part for Date {}
475
476/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
477///
478/// # Activities
479///
480/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
481/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
482///
483/// * [adclients customchannels delete accounts](AccountAdclientCustomchannelDeleteCall) (response)
484#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
485#[serde_with::serde_as]
486#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
487pub struct Empty {
488 _never_set: Option<bool>,
489}
490
491impl common::ResponseResult for Empty {}
492
493/// The header information of the columns requested in the report.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct Header {
501 /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) of this column. Only present if the header type is METRIC_CURRENCY.
502 #[serde(rename = "currencyCode")]
503 pub currency_code: Option<String>,
504 /// Required. Name of the header.
505 pub name: Option<String>,
506 /// Required. Type of the header.
507 #[serde(rename = "type")]
508 pub type_: Option<String>,
509}
510
511impl common::Part for Header {}
512
513/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
514///
515/// # Activities
516///
517/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
518/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
519///
520/// * [reports saved generate csv accounts](AccountReportSavedGenerateCsvCall) (response)
521/// * [reports generate csv accounts](AccountReportGenerateCsvCall) (response)
522#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
523#[serde_with::serde_as]
524#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
525pub struct HttpBody {
526 /// The HTTP Content-Type header value specifying the content type of the body.
527 #[serde(rename = "contentType")]
528 pub content_type: Option<String>,
529 /// The HTTP request/response body as raw binary.
530 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
531 pub data: Option<Vec<u8>>,
532 /// Application specific response metadata. Must be set in the first response for streaming APIs.
533 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
534}
535
536impl common::ResponseResult for HttpBody {}
537
538/// Response definition for the account list rpc.
539///
540/// # Activities
541///
542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
544///
545/// * [list accounts](AccountListCall) (response)
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct ListAccountsResponse {
550 /// The accounts returned in this list response.
551 pub accounts: Option<Vec<Account>>,
552 /// Continuation token used to page through accounts. To retrieve the next page of the results, set the next request's "page_token" value to this.
553 #[serde(rename = "nextPageToken")]
554 pub next_page_token: Option<String>,
555}
556
557impl common::ResponseResult for ListAccountsResponse {}
558
559/// Response definition for the ad client list rpc.
560///
561/// # Activities
562///
563/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
564/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
565///
566/// * [adclients list accounts](AccountAdclientListCall) (response)
567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
568#[serde_with::serde_as]
569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
570pub struct ListAdClientsResponse {
571 /// The ad clients returned in this list response.
572 #[serde(rename = "adClients")]
573 pub ad_clients: Option<Vec<AdClient>>,
574 /// Continuation token used to page through ad clients. To retrieve the next page of the results, set the next request's "page_token" value to this.
575 #[serde(rename = "nextPageToken")]
576 pub next_page_token: Option<String>,
577}
578
579impl common::ResponseResult for ListAdClientsResponse {}
580
581/// Response definition for the adunit list rpc.
582///
583/// # Activities
584///
585/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
586/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
587///
588/// * [adclients adunits list accounts](AccountAdclientAdunitListCall) (response)
589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
590#[serde_with::serde_as]
591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
592pub struct ListAdUnitsResponse {
593 /// The ad units returned in the list response.
594 #[serde(rename = "adUnits")]
595 pub ad_units: Option<Vec<AdUnit>>,
596 /// Continuation token used to page through ad units. To retrieve the next page of the results, set the next request's "page_token" value to this.
597 #[serde(rename = "nextPageToken")]
598 pub next_page_token: Option<String>,
599}
600
601impl common::ResponseResult for ListAdUnitsResponse {}
602
603/// Response definition for the alerts list rpc.
604///
605/// # Activities
606///
607/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
608/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
609///
610/// * [alerts list accounts](AccountAlertListCall) (response)
611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
612#[serde_with::serde_as]
613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
614pub struct ListAlertsResponse {
615 /// The alerts returned in this list response.
616 pub alerts: Option<Vec<Alert>>,
617}
618
619impl common::ResponseResult for ListAlertsResponse {}
620
621/// Response definition for the child account list rpc.
622///
623/// # Activities
624///
625/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
627///
628/// * [list child accounts accounts](AccountListChildAccountCall) (response)
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as]
631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
632pub struct ListChildAccountsResponse {
633 /// The accounts returned in this list response.
634 pub accounts: Option<Vec<Account>>,
635 /// Continuation token used to page through accounts. To retrieve the next page of the results, set the next request's "page_token" value to this.
636 #[serde(rename = "nextPageToken")]
637 pub next_page_token: Option<String>,
638}
639
640impl common::ResponseResult for ListChildAccountsResponse {}
641
642/// Response definition for the custom channel list rpc.
643///
644/// # Activities
645///
646/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
647/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
648///
649/// * [adclients customchannels list accounts](AccountAdclientCustomchannelListCall) (response)
650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
651#[serde_with::serde_as]
652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
653pub struct ListCustomChannelsResponse {
654 /// The custom channels returned in this list response.
655 #[serde(rename = "customChannels")]
656 pub custom_channels: Option<Vec<CustomChannel>>,
657 /// Continuation token used to page through alerts. To retrieve the next page of the results, set the next request's "page_token" value to this.
658 #[serde(rename = "nextPageToken")]
659 pub next_page_token: Option<String>,
660}
661
662impl common::ResponseResult for ListCustomChannelsResponse {}
663
664/// Response definition for the ad units linked to a custom channel list rpc.
665///
666/// # Activities
667///
668/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
669/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
670///
671/// * [adclients customchannels list linked ad units accounts](AccountAdclientCustomchannelListLinkedAdUnitCall) (response)
672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
673#[serde_with::serde_as]
674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
675pub struct ListLinkedAdUnitsResponse {
676 /// The ad units returned in the list response.
677 #[serde(rename = "adUnits")]
678 pub ad_units: Option<Vec<AdUnit>>,
679 /// Continuation token used to page through ad units. To retrieve the next page of the results, set the next request's "page_token" value to this.
680 #[serde(rename = "nextPageToken")]
681 pub next_page_token: Option<String>,
682}
683
684impl common::ResponseResult for ListLinkedAdUnitsResponse {}
685
686/// Response definition for the custom channels linked to an adunit list rpc.
687///
688/// # Activities
689///
690/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
692///
693/// * [adclients adunits list linked custom channels accounts](AccountAdclientAdunitListLinkedCustomChannelCall) (response)
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct ListLinkedCustomChannelsResponse {
698 /// The custom channels returned in this list response.
699 #[serde(rename = "customChannels")]
700 pub custom_channels: Option<Vec<CustomChannel>>,
701 /// Continuation token used to page through alerts. To retrieve the next page of the results, set the next request's "page_token" value to this.
702 #[serde(rename = "nextPageToken")]
703 pub next_page_token: Option<String>,
704}
705
706impl common::ResponseResult for ListLinkedCustomChannelsResponse {}
707
708/// Response definition for the payments list rpc.
709///
710/// # Activities
711///
712/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
713/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
714///
715/// * [payments list accounts](AccountPaymentListCall) (response)
716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
717#[serde_with::serde_as]
718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
719pub struct ListPaymentsResponse {
720 /// The payments returned in this list response.
721 pub payments: Option<Vec<Payment>>,
722}
723
724impl common::ResponseResult for ListPaymentsResponse {}
725
726/// Response definition for the policy issues list rpc. Policy issues are reported only if the publisher has at least one AFC ad client in READY or GETTING_READY state. If the publisher has no such AFC ad client, the response will be an empty list.
727///
728/// # Activities
729///
730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
732///
733/// * [policy issues list accounts](AccountPolicyIssueListCall) (response)
734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
735#[serde_with::serde_as]
736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
737pub struct ListPolicyIssuesResponse {
738 /// Continuation token used to page through policy issues. To retrieve the next page of the results, set the next request's "page_token" value to this.
739 #[serde(rename = "nextPageToken")]
740 pub next_page_token: Option<String>,
741 /// The policy issues returned in the list response.
742 #[serde(rename = "policyIssues")]
743 pub policy_issues: Option<Vec<PolicyIssue>>,
744}
745
746impl common::ResponseResult for ListPolicyIssuesResponse {}
747
748/// Response definition for the saved reports list rpc.
749///
750/// # Activities
751///
752/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
753/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
754///
755/// * [reports saved list accounts](AccountReportSavedListCall) (response)
756#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
757#[serde_with::serde_as]
758#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
759pub struct ListSavedReportsResponse {
760 /// Continuation token used to page through reports. To retrieve the next page of the results, set the next request's "page_token" value to this.
761 #[serde(rename = "nextPageToken")]
762 pub next_page_token: Option<String>,
763 /// The reports returned in this list response.
764 #[serde(rename = "savedReports")]
765 pub saved_reports: Option<Vec<SavedReport>>,
766}
767
768impl common::ResponseResult for ListSavedReportsResponse {}
769
770/// Response definition for the sites list rpc.
771///
772/// # Activities
773///
774/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
775/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
776///
777/// * [sites list accounts](AccountSiteListCall) (response)
778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
779#[serde_with::serde_as]
780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
781pub struct ListSitesResponse {
782 /// Continuation token used to page through sites. To retrieve the next page of the results, set the next request's "page_token" value to this.
783 #[serde(rename = "nextPageToken")]
784 pub next_page_token: Option<String>,
785 /// The sites returned in this list response.
786 pub sites: Option<Vec<Site>>,
787}
788
789impl common::ResponseResult for ListSitesResponse {}
790
791/// Response definition for the url channels list rpc.
792///
793/// # Activities
794///
795/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
797///
798/// * [adclients urlchannels list accounts](AccountAdclientUrlchannelListCall) (response)
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct ListUrlChannelsResponse {
803 /// Continuation token used to page through url channels. To retrieve the next page of the results, set the next request's "page_token" value to this.
804 #[serde(rename = "nextPageToken")]
805 pub next_page_token: Option<String>,
806 /// The url channels returned in this list response.
807 #[serde(rename = "urlChannels")]
808 pub url_channels: Option<Vec<UrlChannel>>,
809}
810
811impl common::ResponseResult for ListUrlChannelsResponse {}
812
813/// Representation of an unpaid or paid payment. See [Payment timelines for AdSense](https://support.google.com/adsense/answer/7164703) for more information about payments and the [YouTube homepage and payments account](https://support.google.com/adsense/answer/11622510) article for information about dedicated payments accounts for YouTube.
814///
815/// This type is not used in any activity, and only used as *part* of another schema.
816///
817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
818#[serde_with::serde_as]
819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
820pub struct Payment {
821 /// Output only. The amount of unpaid or paid earnings, as a formatted string, including the currency. E.g. "¥1,235 JPY", "$1,234.57", "£87.65".
822 pub amount: Option<String>,
823 /// Output only. For paid earnings, the date that the payment was credited. For unpaid earnings, this field is empty. Payment dates are always returned in the billing timezone (America/Los_Angeles).
824 pub date: Option<Date>,
825 /// Output only. Resource name of the payment. Format: - accounts/{account}/payments/unpaid for unpaid (current) AdSense earnings. - accounts/{account}/payments/youtube-unpaid for unpaid (current) YouTube earnings. - accounts/{account}/payments/yyyy-MM-dd for paid AdSense earnings. - accounts/{account}/payments/youtube-yyyy-MM-dd for paid YouTube earnings.
826 pub name: Option<String>,
827}
828
829impl common::Part for Payment {}
830
831/// Representation of a policy issue for a single entity (site, site-section, or page). All issues for a single entity are represented by a single PolicyIssue resource, though that PolicyIssue can have multiple causes (or “topics”) that can change over time. Policy issues are removed if there are no issues detected recently or if there’s a recent successful appeal for the entity.
832///
833/// # Activities
834///
835/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
836/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
837///
838/// * [policy issues get accounts](AccountPolicyIssueGetCall) (response)
839#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
840#[serde_with::serde_as]
841#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
842pub struct PolicyIssue {
843 /// Required. The most severe action taken on the entity over the past seven days.
844 pub action: Option<String>,
845 /// Optional. List of ad clients associated with the policy issue (either as the primary ad client or an associated host/secondary ad client). In the latter case, this will be an ad client that is not owned by the current account.
846 #[serde(rename = "adClients")]
847 pub ad_clients: Option<Vec<String>>,
848 /// Required. Total number of ad requests affected by the policy violations over the past seven days.
849 #[serde(rename = "adRequestCount")]
850 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
851 pub ad_request_count: Option<i64>,
852 /// Required. Type of the entity indicating if the entity is a site, site-section, or page.
853 #[serde(rename = "entityType")]
854 pub entity_type: Option<String>,
855 /// Required. The date (in the America/Los_Angeles timezone) when policy violations were first detected on the entity.
856 #[serde(rename = "firstDetectedDate")]
857 pub first_detected_date: Option<Date>,
858 /// Required. The date (in the America/Los_Angeles timezone) when policy violations were last detected on the entity.
859 #[serde(rename = "lastDetectedDate")]
860 pub last_detected_date: Option<Date>,
861 /// Required. Resource name of the entity with policy issues. Format: accounts/{account}/policyIssues/{policy_issue}
862 pub name: Option<String>,
863 /// Required. Unordered list. The policy topics that this entity was found to violate over the past seven days.
864 #[serde(rename = "policyTopics")]
865 pub policy_topics: Option<Vec<PolicyTopic>>,
866 /// Required. Hostname/domain of the entity (for example "foo.com" or "www.foo.com"). This _should_ be a bare domain/host name without any protocol. This will be present for all policy issues.
867 pub site: Option<String>,
868 /// Optional. Prefix of the site-section having policy issues (For example "foo.com/bar-section"). This will be present if the `entity_type` is `SITE_SECTION` and will be absent for other entity types.
869 #[serde(rename = "siteSection")]
870 pub site_section: Option<String>,
871 /// Optional. URI of the page having policy violations (for example "foo.com/bar" or "www.foo.com/bar"). This will be present if the `entity_type` is `PAGE` and will be absent for other entity types.
872 pub uri: Option<String>,
873 /// Optional. The date (in the America/Los_Angeles timezone) when the entity will have ad serving demand restricted or ad serving disabled. This is present only for issues with a `WARNED` enforcement action. See https://support.google.com/adsense/answer/11066888.
874 #[serde(rename = "warningEscalationDate")]
875 pub warning_escalation_date: Option<Date>,
876}
877
878impl common::ResponseResult for PolicyIssue {}
879
880/// Information about a particular policy topic. A policy topic represents a single class of policy issue that can impact ad serving for your site. For example, sexual content or having ads that obscure your content. A single policy issue can have multiple policy topics for a single entity.
881///
882/// This type is not used in any activity, and only used as *part* of another schema.
883///
884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
885#[serde_with::serde_as]
886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
887pub struct PolicyTopic {
888 /// Required. Deprecated. Always set to false.
889 #[serde(rename = "mustFix")]
890 pub must_fix: Option<bool>,
891 /// Required. The policy topic. For example, "sexual-content" or "ads-obscuring-content"."
892 pub topic: Option<String>,
893 /// Optional. The type of policy topic. For example, "POLICY" represents all the policy topics that are related to the Google Publisher Policy (GPP). See https://support.google.com/adsense/answer/15689616.
894 #[serde(rename = "type")]
895 pub type_: Option<String>,
896}
897
898impl common::Part for PolicyTopic {}
899
900/// Result of a generated report.
901///
902/// # Activities
903///
904/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
905/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
906///
907/// * [reports saved generate accounts](AccountReportSavedGenerateCall) (response)
908/// * [reports generate accounts](AccountReportGenerateCall) (response)
909#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
910#[serde_with::serde_as]
911#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
912pub struct ReportResult {
913 /// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
914 pub averages: Option<Row>,
915 /// Required. End date of the range (inclusive).
916 #[serde(rename = "endDate")]
917 pub end_date: Option<Date>,
918 /// The header information; one for each dimension in the request, followed by one for each metric in the request.
919 pub headers: Option<Vec<Header>>,
920 /// 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.
921 pub rows: Option<Vec<Row>>,
922 /// Required. Start date of the range (inclusive).
923 #[serde(rename = "startDate")]
924 pub start_date: Option<Date>,
925 /// The total number of rows matched by the report request.
926 #[serde(rename = "totalMatchedRows")]
927 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
928 pub total_matched_rows: Option<i64>,
929 /// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
930 pub totals: Option<Row>,
931 /// Any warnings associated with generation of the report. These warnings are always returned in English.
932 pub warnings: Option<Vec<String>>,
933}
934
935impl common::ResponseResult for ReportResult {}
936
937/// Row representation.
938///
939/// This type is not used in any activity, and only used as *part* of another schema.
940///
941#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
942#[serde_with::serde_as]
943#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
944pub struct Row {
945 /// Cells in the row.
946 pub cells: Option<Vec<Cell>>,
947}
948
949impl common::Part for Row {}
950
951/// Representation of a saved report.
952///
953/// # Activities
954///
955/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
956/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
957///
958/// * [reports get saved accounts](AccountReportGetSavedCall) (response)
959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
960#[serde_with::serde_as]
961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
962pub struct SavedReport {
963 /// Output only. Resource name of the report. Format: accounts/{account}/reports/{report}
964 pub name: Option<String>,
965 /// Report title as specified by publisher.
966 pub title: Option<String>,
967}
968
969impl common::ResponseResult for SavedReport {}
970
971/// Representation of a Site.
972///
973/// # Activities
974///
975/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
976/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
977///
978/// * [sites get accounts](AccountSiteGetCall) (response)
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct Site {
983 /// Whether auto ads is turned on for the site.
984 #[serde(rename = "autoAdsEnabled")]
985 pub auto_ads_enabled: Option<bool>,
986 /// Domain (or subdomain) of the site, e.g. "example.com" or "www.example.com". This is used in the `OWNED_SITE_DOMAIN_NAME` reporting dimension.
987 pub domain: Option<String>,
988 /// Output only. Resource name of a site. Format: accounts/{account}/sites/{site}
989 pub name: Option<String>,
990 /// Output only. Unique ID of the site as used in the `OWNED_SITE_ID` reporting dimension.
991 #[serde(rename = "reportingDimensionId")]
992 pub reporting_dimension_id: Option<String>,
993 /// Output only. State of a site.
994 pub state: Option<String>,
995}
996
997impl common::ResponseResult for Site {}
998
999/// Represents a time zone from the [IANA Time Zone Database](https://www.iana.org/time-zones).
1000///
1001/// This type is not used in any activity, and only used as *part* of another schema.
1002///
1003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1004#[serde_with::serde_as]
1005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1006pub struct TimeZone {
1007 /// IANA Time Zone Database time zone. For example "America/New_York".
1008 pub id: Option<String>,
1009 /// Optional. IANA Time Zone Database version number. For example "2019a".
1010 pub version: Option<String>,
1011}
1012
1013impl common::Part for TimeZone {}
1014
1015/// Representation of a URL channel. URL channels allow you to track the performance of particular pages in your site; see [URL channels](https://support.google.com/adsense/answer/2923836) for more information.
1016///
1017/// # Activities
1018///
1019/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1020/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1021///
1022/// * [adclients urlchannels get accounts](AccountAdclientUrlchannelGetCall) (response)
1023#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1024#[serde_with::serde_as]
1025#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1026pub struct UrlChannel {
1027 /// Output only. Resource name of the URL channel. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
1028 pub name: Option<String>,
1029 /// Output only. Unique ID of the custom channel as used in the `URL_CHANNEL_ID` reporting dimension.
1030 #[serde(rename = "reportingDimensionId")]
1031 pub reporting_dimension_id: Option<String>,
1032 /// URI pattern of the channel. Does not include "http://" or "https://". Example: www.example.com/home
1033 #[serde(rename = "uriPattern")]
1034 pub uri_pattern: Option<String>,
1035}
1036
1037impl common::ResponseResult for UrlChannel {}
1038
1039// ###################
1040// MethodBuilders ###
1041// #################
1042
1043/// A builder providing access to all methods supported on *account* resources.
1044/// It is not used directly, but through the [`Adsense`] hub.
1045///
1046/// # Example
1047///
1048/// Instantiate a resource builder
1049///
1050/// ```test_harness,no_run
1051/// extern crate hyper;
1052/// extern crate hyper_rustls;
1053/// extern crate google_adsense2 as adsense2;
1054///
1055/// # async fn dox() {
1056/// use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1057///
1058/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1059/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1060/// .with_native_roots()
1061/// .unwrap()
1062/// .https_only()
1063/// .enable_http2()
1064/// .build();
1065///
1066/// let executor = hyper_util::rt::TokioExecutor::new();
1067/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1068/// secret,
1069/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1070/// yup_oauth2::client::CustomHyperClientBuilder::from(
1071/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1072/// ),
1073/// ).build().await.unwrap();
1074///
1075/// let client = hyper_util::client::legacy::Client::builder(
1076/// hyper_util::rt::TokioExecutor::new()
1077/// )
1078/// .build(
1079/// hyper_rustls::HttpsConnectorBuilder::new()
1080/// .with_native_roots()
1081/// .unwrap()
1082/// .https_or_http()
1083/// .enable_http2()
1084/// .build()
1085/// );
1086/// let mut hub = Adsense::new(client, auth);
1087/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1088/// // like `adclients_adunits_create(...)`, `adclients_adunits_get(...)`, `adclients_adunits_get_adcode(...)`, `adclients_adunits_list(...)`, `adclients_adunits_list_linked_custom_channels(...)`, `adclients_adunits_patch(...)`, `adclients_customchannels_create(...)`, `adclients_customchannels_delete(...)`, `adclients_customchannels_get(...)`, `adclients_customchannels_list(...)`, `adclients_customchannels_list_linked_ad_units(...)`, `adclients_customchannels_patch(...)`, `adclients_get(...)`, `adclients_get_adcode(...)`, `adclients_list(...)`, `adclients_urlchannels_get(...)`, `adclients_urlchannels_list(...)`, `alerts_list(...)`, `get(...)`, `get_ad_blocking_recovery_tag(...)`, `list(...)`, `list_child_accounts(...)`, `payments_list(...)`, `policy_issues_get(...)`, `policy_issues_list(...)`, `reports_generate(...)`, `reports_generate_csv(...)`, `reports_get_saved(...)`, `reports_saved_generate(...)`, `reports_saved_generate_csv(...)`, `reports_saved_list(...)`, `sites_get(...)` and `sites_list(...)`
1089/// // to build up your call.
1090/// let rb = hub.accounts();
1091/// # }
1092/// ```
1093pub struct AccountMethods<'a, C>
1094where
1095 C: 'a,
1096{
1097 hub: &'a Adsense<C>,
1098}
1099
1100impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
1101
1102impl<'a, C> AccountMethods<'a, C> {
1103 /// Create a builder to help you perform the following task:
1104 ///
1105 /// Creates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. Note that ad units can only be created for ad clients with an “AFC” product code. For more info see the [AdClient resource](https://developers.google.com/adsense/management/reference/rest/v2/accounts.adclients). For now, this method can only be used to create `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1106 ///
1107 /// # Arguments
1108 ///
1109 /// * `request` - No description provided.
1110 /// * `parent` - Required. Ad client to create an ad unit under. Format: accounts/{account}/adclients/{adclient}
1111 pub fn adclients_adunits_create(
1112 &self,
1113 request: AdUnit,
1114 parent: &str,
1115 ) -> AccountAdclientAdunitCreateCall<'a, C> {
1116 AccountAdclientAdunitCreateCall {
1117 hub: self.hub,
1118 _request: request,
1119 _parent: parent.to_string(),
1120 _delegate: Default::default(),
1121 _additional_params: Default::default(),
1122 _scopes: Default::default(),
1123 }
1124 }
1125
1126 /// Create a builder to help you perform the following task:
1127 ///
1128 /// Gets an ad unit from a specified account and ad client.
1129 ///
1130 /// # Arguments
1131 ///
1132 /// * `name` - Required. AdUnit to get information about. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1133 pub fn adclients_adunits_get(&self, name: &str) -> AccountAdclientAdunitGetCall<'a, C> {
1134 AccountAdclientAdunitGetCall {
1135 hub: self.hub,
1136 _name: name.to_string(),
1137 _delegate: Default::default(),
1138 _additional_params: Default::default(),
1139 _scopes: Default::default(),
1140 }
1141 }
1142
1143 /// Create a builder to help you perform the following task:
1144 ///
1145 /// Gets the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
1146 ///
1147 /// # Arguments
1148 ///
1149 /// * `name` - Required. Name of the adunit for which to get the adcode. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1150 pub fn adclients_adunits_get_adcode(
1151 &self,
1152 name: &str,
1153 ) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
1154 AccountAdclientAdunitGetAdcodeCall {
1155 hub: self.hub,
1156 _name: name.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 /// Lists all ad units under a specified account and ad client.
1166 ///
1167 /// # Arguments
1168 ///
1169 /// * `parent` - Required. The ad client which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}
1170 pub fn adclients_adunits_list(&self, parent: &str) -> AccountAdclientAdunitListCall<'a, C> {
1171 AccountAdclientAdunitListCall {
1172 hub: self.hub,
1173 _parent: parent.to_string(),
1174 _page_token: Default::default(),
1175 _page_size: Default::default(),
1176 _delegate: Default::default(),
1177 _additional_params: Default::default(),
1178 _scopes: Default::default(),
1179 }
1180 }
1181
1182 /// Create a builder to help you perform the following task:
1183 ///
1184 /// Lists all the custom channels available for an ad unit.
1185 ///
1186 /// # Arguments
1187 ///
1188 /// * `parent` - Required. The ad unit which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1189 pub fn adclients_adunits_list_linked_custom_channels(
1190 &self,
1191 parent: &str,
1192 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
1193 AccountAdclientAdunitListLinkedCustomChannelCall {
1194 hub: self.hub,
1195 _parent: parent.to_string(),
1196 _page_token: Default::default(),
1197 _page_size: Default::default(),
1198 _delegate: Default::default(),
1199 _additional_params: Default::default(),
1200 _scopes: Default::default(),
1201 }
1202 }
1203
1204 /// Create a builder to help you perform the following task:
1205 ///
1206 /// Updates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. For now, this method can only be used to update `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1207 ///
1208 /// # Arguments
1209 ///
1210 /// * `request` - No description provided.
1211 /// * `name` - Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
1212 pub fn adclients_adunits_patch(
1213 &self,
1214 request: AdUnit,
1215 name: &str,
1216 ) -> AccountAdclientAdunitPatchCall<'a, C> {
1217 AccountAdclientAdunitPatchCall {
1218 hub: self.hub,
1219 _request: request,
1220 _name: name.to_string(),
1221 _update_mask: Default::default(),
1222 _delegate: Default::default(),
1223 _additional_params: Default::default(),
1224 _scopes: Default::default(),
1225 }
1226 }
1227
1228 /// Create a builder to help you perform the following task:
1229 ///
1230 /// Creates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1231 ///
1232 /// # Arguments
1233 ///
1234 /// * `request` - No description provided.
1235 /// * `parent` - Required. The ad client to create a custom channel under. Format: accounts/{account}/adclients/{adclient}
1236 pub fn adclients_customchannels_create(
1237 &self,
1238 request: CustomChannel,
1239 parent: &str,
1240 ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
1241 AccountAdclientCustomchannelCreateCall {
1242 hub: self.hub,
1243 _request: request,
1244 _parent: parent.to_string(),
1245 _delegate: Default::default(),
1246 _additional_params: Default::default(),
1247 _scopes: Default::default(),
1248 }
1249 }
1250
1251 /// Create a builder to help you perform the following task:
1252 ///
1253 /// Deletes a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1254 ///
1255 /// # Arguments
1256 ///
1257 /// * `name` - Required. Name of the custom channel to delete. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1258 pub fn adclients_customchannels_delete(
1259 &self,
1260 name: &str,
1261 ) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
1262 AccountAdclientCustomchannelDeleteCall {
1263 hub: self.hub,
1264 _name: name.to_string(),
1265 _delegate: Default::default(),
1266 _additional_params: Default::default(),
1267 _scopes: Default::default(),
1268 }
1269 }
1270
1271 /// Create a builder to help you perform the following task:
1272 ///
1273 /// Gets information about the selected custom channel.
1274 ///
1275 /// # Arguments
1276 ///
1277 /// * `name` - Required. Name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1278 pub fn adclients_customchannels_get(
1279 &self,
1280 name: &str,
1281 ) -> AccountAdclientCustomchannelGetCall<'a, C> {
1282 AccountAdclientCustomchannelGetCall {
1283 hub: self.hub,
1284 _name: name.to_string(),
1285 _delegate: Default::default(),
1286 _additional_params: Default::default(),
1287 _scopes: Default::default(),
1288 }
1289 }
1290
1291 /// Create a builder to help you perform the following task:
1292 ///
1293 /// Lists all the custom channels available in an ad client.
1294 ///
1295 /// # Arguments
1296 ///
1297 /// * `parent` - Required. The ad client which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}
1298 pub fn adclients_customchannels_list(
1299 &self,
1300 parent: &str,
1301 ) -> AccountAdclientCustomchannelListCall<'a, C> {
1302 AccountAdclientCustomchannelListCall {
1303 hub: self.hub,
1304 _parent: parent.to_string(),
1305 _page_token: Default::default(),
1306 _page_size: Default::default(),
1307 _delegate: Default::default(),
1308 _additional_params: Default::default(),
1309 _scopes: Default::default(),
1310 }
1311 }
1312
1313 /// Create a builder to help you perform the following task:
1314 ///
1315 /// Lists all the ad units available for a custom channel.
1316 ///
1317 /// # Arguments
1318 ///
1319 /// * `parent` - Required. The custom channel which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1320 pub fn adclients_customchannels_list_linked_ad_units(
1321 &self,
1322 parent: &str,
1323 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
1324 AccountAdclientCustomchannelListLinkedAdUnitCall {
1325 hub: self.hub,
1326 _parent: parent.to_string(),
1327 _page_token: Default::default(),
1328 _page_size: Default::default(),
1329 _delegate: Default::default(),
1330 _additional_params: Default::default(),
1331 _scopes: Default::default(),
1332 }
1333 }
1334
1335 /// Create a builder to help you perform the following task:
1336 ///
1337 /// Updates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
1338 ///
1339 /// # Arguments
1340 ///
1341 /// * `request` - No description provided.
1342 /// * `name` - Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
1343 pub fn adclients_customchannels_patch(
1344 &self,
1345 request: CustomChannel,
1346 name: &str,
1347 ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
1348 AccountAdclientCustomchannelPatchCall {
1349 hub: self.hub,
1350 _request: request,
1351 _name: name.to_string(),
1352 _update_mask: Default::default(),
1353 _delegate: Default::default(),
1354 _additional_params: Default::default(),
1355 _scopes: Default::default(),
1356 }
1357 }
1358
1359 /// Create a builder to help you perform the following task:
1360 ///
1361 /// Gets information about the selected url channel.
1362 ///
1363 /// # Arguments
1364 ///
1365 /// * `name` - Required. The name of the url channel to retrieve. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
1366 pub fn adclients_urlchannels_get(&self, name: &str) -> AccountAdclientUrlchannelGetCall<'a, C> {
1367 AccountAdclientUrlchannelGetCall {
1368 hub: self.hub,
1369 _name: name.to_string(),
1370 _delegate: Default::default(),
1371 _additional_params: Default::default(),
1372 _scopes: Default::default(),
1373 }
1374 }
1375
1376 /// Create a builder to help you perform the following task:
1377 ///
1378 /// Lists active url channels.
1379 ///
1380 /// # Arguments
1381 ///
1382 /// * `parent` - Required. The ad client which owns the collection of url channels. Format: accounts/{account}/adclients/{adclient}
1383 pub fn adclients_urlchannels_list(
1384 &self,
1385 parent: &str,
1386 ) -> AccountAdclientUrlchannelListCall<'a, C> {
1387 AccountAdclientUrlchannelListCall {
1388 hub: self.hub,
1389 _parent: parent.to_string(),
1390 _page_token: Default::default(),
1391 _page_size: Default::default(),
1392 _delegate: Default::default(),
1393 _additional_params: Default::default(),
1394 _scopes: Default::default(),
1395 }
1396 }
1397
1398 /// Create a builder to help you perform the following task:
1399 ///
1400 /// Gets the ad client from the given resource name.
1401 ///
1402 /// # Arguments
1403 ///
1404 /// * `name` - Required. The name of the ad client to retrieve. Format: accounts/{account}/adclients/{adclient}
1405 pub fn adclients_get(&self, name: &str) -> AccountAdclientGetCall<'a, C> {
1406 AccountAdclientGetCall {
1407 hub: self.hub,
1408 _name: name.to_string(),
1409 _delegate: Default::default(),
1410 _additional_params: Default::default(),
1411 _scopes: Default::default(),
1412 }
1413 }
1414
1415 /// Create a builder to help you perform the following task:
1416 ///
1417 /// Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
1418 ///
1419 /// # Arguments
1420 ///
1421 /// * `name` - Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
1422 pub fn adclients_get_adcode(&self, name: &str) -> AccountAdclientGetAdcodeCall<'a, C> {
1423 AccountAdclientGetAdcodeCall {
1424 hub: self.hub,
1425 _name: name.to_string(),
1426 _delegate: Default::default(),
1427 _additional_params: Default::default(),
1428 _scopes: Default::default(),
1429 }
1430 }
1431
1432 /// Create a builder to help you perform the following task:
1433 ///
1434 /// Lists all the ad clients available in an account.
1435 ///
1436 /// # Arguments
1437 ///
1438 /// * `parent` - Required. The account which owns the collection of ad clients. Format: accounts/{account}
1439 pub fn adclients_list(&self, parent: &str) -> AccountAdclientListCall<'a, C> {
1440 AccountAdclientListCall {
1441 hub: self.hub,
1442 _parent: parent.to_string(),
1443 _page_token: Default::default(),
1444 _page_size: Default::default(),
1445 _delegate: Default::default(),
1446 _additional_params: Default::default(),
1447 _scopes: Default::default(),
1448 }
1449 }
1450
1451 /// Create a builder to help you perform the following task:
1452 ///
1453 /// Lists all the alerts available in an account.
1454 ///
1455 /// # Arguments
1456 ///
1457 /// * `parent` - Required. The account which owns the collection of alerts. Format: accounts/{account}
1458 pub fn alerts_list(&self, parent: &str) -> AccountAlertListCall<'a, C> {
1459 AccountAlertListCall {
1460 hub: self.hub,
1461 _parent: parent.to_string(),
1462 _language_code: Default::default(),
1463 _delegate: Default::default(),
1464 _additional_params: Default::default(),
1465 _scopes: Default::default(),
1466 }
1467 }
1468
1469 /// Create a builder to help you perform the following task:
1470 ///
1471 /// Lists all the payments available for an account.
1472 ///
1473 /// # Arguments
1474 ///
1475 /// * `parent` - Required. The account which owns the collection of payments. Format: accounts/{account}
1476 pub fn payments_list(&self, parent: &str) -> AccountPaymentListCall<'a, C> {
1477 AccountPaymentListCall {
1478 hub: self.hub,
1479 _parent: parent.to_string(),
1480 _delegate: Default::default(),
1481 _additional_params: Default::default(),
1482 _scopes: Default::default(),
1483 }
1484 }
1485
1486 /// Create a builder to help you perform the following task:
1487 ///
1488 /// Gets information about the selected policy issue.
1489 ///
1490 /// # Arguments
1491 ///
1492 /// * `name` - Required. Name of the policy issue. Format: accounts/{account}/policyIssues/{policy_issue}
1493 pub fn policy_issues_get(&self, name: &str) -> AccountPolicyIssueGetCall<'a, C> {
1494 AccountPolicyIssueGetCall {
1495 hub: self.hub,
1496 _name: name.to_string(),
1497 _delegate: Default::default(),
1498 _additional_params: Default::default(),
1499 _scopes: Default::default(),
1500 }
1501 }
1502
1503 /// Create a builder to help you perform the following task:
1504 ///
1505 /// Lists all the policy issues where the specified account is involved, both directly and through any AFP child accounts.
1506 ///
1507 /// # Arguments
1508 ///
1509 /// * `parent` - Required. The account for which policy issues are being retrieved. Format: accounts/{account}
1510 pub fn policy_issues_list(&self, parent: &str) -> AccountPolicyIssueListCall<'a, C> {
1511 AccountPolicyIssueListCall {
1512 hub: self.hub,
1513 _parent: parent.to_string(),
1514 _page_token: Default::default(),
1515 _page_size: Default::default(),
1516 _delegate: Default::default(),
1517 _additional_params: Default::default(),
1518 _scopes: Default::default(),
1519 }
1520 }
1521
1522 /// Create a builder to help you perform the following task:
1523 ///
1524 /// Generates a saved report.
1525 ///
1526 /// # Arguments
1527 ///
1528 /// * `name` - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
1529 pub fn reports_saved_generate(&self, name: &str) -> AccountReportSavedGenerateCall<'a, C> {
1530 AccountReportSavedGenerateCall {
1531 hub: self.hub,
1532 _name: name.to_string(),
1533 _start_date_year: Default::default(),
1534 _start_date_month: Default::default(),
1535 _start_date_day: Default::default(),
1536 _reporting_time_zone: Default::default(),
1537 _language_code: Default::default(),
1538 _end_date_year: Default::default(),
1539 _end_date_month: Default::default(),
1540 _end_date_day: Default::default(),
1541 _date_range: Default::default(),
1542 _currency_code: Default::default(),
1543 _delegate: Default::default(),
1544 _additional_params: Default::default(),
1545 _scopes: Default::default(),
1546 }
1547 }
1548
1549 /// Create a builder to help you perform the following task:
1550 ///
1551 /// Generates a csv formatted saved report.
1552 ///
1553 /// # Arguments
1554 ///
1555 /// * `name` - Required. Name of the saved report. Format: accounts/{account}/reports/{report}
1556 pub fn reports_saved_generate_csv(
1557 &self,
1558 name: &str,
1559 ) -> AccountReportSavedGenerateCsvCall<'a, C> {
1560 AccountReportSavedGenerateCsvCall {
1561 hub: self.hub,
1562 _name: name.to_string(),
1563 _start_date_year: Default::default(),
1564 _start_date_month: Default::default(),
1565 _start_date_day: Default::default(),
1566 _reporting_time_zone: Default::default(),
1567 _language_code: Default::default(),
1568 _end_date_year: Default::default(),
1569 _end_date_month: Default::default(),
1570 _end_date_day: Default::default(),
1571 _date_range: Default::default(),
1572 _currency_code: Default::default(),
1573 _delegate: Default::default(),
1574 _additional_params: Default::default(),
1575 _scopes: Default::default(),
1576 }
1577 }
1578
1579 /// Create a builder to help you perform the following task:
1580 ///
1581 /// Lists saved reports.
1582 ///
1583 /// # Arguments
1584 ///
1585 /// * `parent` - Required. The account which owns the collection of reports. Format: accounts/{account}
1586 pub fn reports_saved_list(&self, parent: &str) -> AccountReportSavedListCall<'a, C> {
1587 AccountReportSavedListCall {
1588 hub: self.hub,
1589 _parent: parent.to_string(),
1590 _page_token: Default::default(),
1591 _page_size: Default::default(),
1592 _delegate: Default::default(),
1593 _additional_params: Default::default(),
1594 _scopes: Default::default(),
1595 }
1596 }
1597
1598 /// Create a builder to help you perform the following task:
1599 ///
1600 /// Generates an ad hoc report.
1601 ///
1602 /// # Arguments
1603 ///
1604 /// * `account` - Required. The account which owns the collection of reports. Format: accounts/{account}
1605 pub fn reports_generate(&self, account: &str) -> AccountReportGenerateCall<'a, C> {
1606 AccountReportGenerateCall {
1607 hub: self.hub,
1608 _account: account.to_string(),
1609 _start_date_year: Default::default(),
1610 _start_date_month: Default::default(),
1611 _start_date_day: Default::default(),
1612 _reporting_time_zone: Default::default(),
1613 _order_by: Default::default(),
1614 _metrics: Default::default(),
1615 _limit: Default::default(),
1616 _language_code: Default::default(),
1617 _filters: Default::default(),
1618 _end_date_year: Default::default(),
1619 _end_date_month: Default::default(),
1620 _end_date_day: Default::default(),
1621 _dimensions: Default::default(),
1622 _date_range: Default::default(),
1623 _currency_code: Default::default(),
1624 _delegate: Default::default(),
1625 _additional_params: Default::default(),
1626 _scopes: Default::default(),
1627 }
1628 }
1629
1630 /// Create a builder to help you perform the following task:
1631 ///
1632 /// Generates a csv formatted ad hoc report.
1633 ///
1634 /// # Arguments
1635 ///
1636 /// * `account` - Required. The account which owns the collection of reports. Format: accounts/{account}
1637 pub fn reports_generate_csv(&self, account: &str) -> AccountReportGenerateCsvCall<'a, C> {
1638 AccountReportGenerateCsvCall {
1639 hub: self.hub,
1640 _account: account.to_string(),
1641 _start_date_year: Default::default(),
1642 _start_date_month: Default::default(),
1643 _start_date_day: Default::default(),
1644 _reporting_time_zone: Default::default(),
1645 _order_by: Default::default(),
1646 _metrics: Default::default(),
1647 _limit: Default::default(),
1648 _language_code: Default::default(),
1649 _filters: Default::default(),
1650 _end_date_year: Default::default(),
1651 _end_date_month: Default::default(),
1652 _end_date_day: Default::default(),
1653 _dimensions: Default::default(),
1654 _date_range: Default::default(),
1655 _currency_code: Default::default(),
1656 _delegate: Default::default(),
1657 _additional_params: Default::default(),
1658 _scopes: Default::default(),
1659 }
1660 }
1661
1662 /// Create a builder to help you perform the following task:
1663 ///
1664 /// Gets the saved report from the given resource name.
1665 ///
1666 /// # Arguments
1667 ///
1668 /// * `name` - Required. The name of the saved report to retrieve. Format: accounts/{account}/reports/{report}
1669 pub fn reports_get_saved(&self, name: &str) -> AccountReportGetSavedCall<'a, C> {
1670 AccountReportGetSavedCall {
1671 hub: self.hub,
1672 _name: name.to_string(),
1673 _delegate: Default::default(),
1674 _additional_params: Default::default(),
1675 _scopes: Default::default(),
1676 }
1677 }
1678
1679 /// Create a builder to help you perform the following task:
1680 ///
1681 /// Gets information about the selected site.
1682 ///
1683 /// # Arguments
1684 ///
1685 /// * `name` - Required. Name of the site. Format: accounts/{account}/sites/{site}
1686 pub fn sites_get(&self, name: &str) -> AccountSiteGetCall<'a, C> {
1687 AccountSiteGetCall {
1688 hub: self.hub,
1689 _name: name.to_string(),
1690 _delegate: Default::default(),
1691 _additional_params: Default::default(),
1692 _scopes: Default::default(),
1693 }
1694 }
1695
1696 /// Create a builder to help you perform the following task:
1697 ///
1698 /// Lists all the sites available in an account.
1699 ///
1700 /// # Arguments
1701 ///
1702 /// * `parent` - Required. The account which owns the collection of sites. Format: accounts/{account}
1703 pub fn sites_list(&self, parent: &str) -> AccountSiteListCall<'a, C> {
1704 AccountSiteListCall {
1705 hub: self.hub,
1706 _parent: parent.to_string(),
1707 _page_token: Default::default(),
1708 _page_size: Default::default(),
1709 _delegate: Default::default(),
1710 _additional_params: Default::default(),
1711 _scopes: Default::default(),
1712 }
1713 }
1714
1715 /// Create a builder to help you perform the following task:
1716 ///
1717 /// Gets information about the selected AdSense account.
1718 ///
1719 /// # Arguments
1720 ///
1721 /// * `name` - Required. Account to get information about. Format: accounts/{account}
1722 pub fn get(&self, name: &str) -> AccountGetCall<'a, C> {
1723 AccountGetCall {
1724 hub: self.hub,
1725 _name: name.to_string(),
1726 _delegate: Default::default(),
1727 _additional_params: Default::default(),
1728 _scopes: Default::default(),
1729 }
1730 }
1731
1732 /// Create a builder to help you perform the following task:
1733 ///
1734 /// Gets the ad blocking recovery tag of an account.
1735 ///
1736 /// # Arguments
1737 ///
1738 /// * `name` - Required. The name of the account to get the tag for. Format: accounts/{account}
1739 pub fn get_ad_blocking_recovery_tag(
1740 &self,
1741 name: &str,
1742 ) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
1743 AccountGetAdBlockingRecoveryTagCall {
1744 hub: self.hub,
1745 _name: name.to_string(),
1746 _delegate: Default::default(),
1747 _additional_params: Default::default(),
1748 _scopes: Default::default(),
1749 }
1750 }
1751
1752 /// Create a builder to help you perform the following task:
1753 ///
1754 /// Lists all accounts available to this user.
1755 pub fn list(&self) -> AccountListCall<'a, C> {
1756 AccountListCall {
1757 hub: self.hub,
1758 _page_token: Default::default(),
1759 _page_size: Default::default(),
1760 _delegate: Default::default(),
1761 _additional_params: Default::default(),
1762 _scopes: Default::default(),
1763 }
1764 }
1765
1766 /// Create a builder to help you perform the following task:
1767 ///
1768 /// Lists all accounts directly managed by the given AdSense account.
1769 ///
1770 /// # Arguments
1771 ///
1772 /// * `parent` - Required. The parent account, which owns the child accounts. Format: accounts/{account}
1773 pub fn list_child_accounts(&self, parent: &str) -> AccountListChildAccountCall<'a, C> {
1774 AccountListChildAccountCall {
1775 hub: self.hub,
1776 _parent: parent.to_string(),
1777 _page_token: Default::default(),
1778 _page_size: Default::default(),
1779 _delegate: Default::default(),
1780 _additional_params: Default::default(),
1781 _scopes: Default::default(),
1782 }
1783 }
1784}
1785
1786// ###################
1787// CallBuilders ###
1788// #################
1789
1790/// Creates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. Note that ad units can only be created for ad clients with an “AFC” product code. For more info see the [AdClient resource](https://developers.google.com/adsense/management/reference/rest/v2/accounts.adclients). For now, this method can only be used to create `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
1791///
1792/// A builder for the *adclients.adunits.create* method supported by a *account* resource.
1793/// It is not used directly, but through a [`AccountMethods`] instance.
1794///
1795/// # Example
1796///
1797/// Instantiate a resource method builder
1798///
1799/// ```test_harness,no_run
1800/// # extern crate hyper;
1801/// # extern crate hyper_rustls;
1802/// # extern crate google_adsense2 as adsense2;
1803/// use adsense2::api::AdUnit;
1804/// # async fn dox() {
1805/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1806///
1807/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1808/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1809/// # .with_native_roots()
1810/// # .unwrap()
1811/// # .https_only()
1812/// # .enable_http2()
1813/// # .build();
1814///
1815/// # let executor = hyper_util::rt::TokioExecutor::new();
1816/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1817/// # secret,
1818/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1819/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1820/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1821/// # ),
1822/// # ).build().await.unwrap();
1823///
1824/// # let client = hyper_util::client::legacy::Client::builder(
1825/// # hyper_util::rt::TokioExecutor::new()
1826/// # )
1827/// # .build(
1828/// # hyper_rustls::HttpsConnectorBuilder::new()
1829/// # .with_native_roots()
1830/// # .unwrap()
1831/// # .https_or_http()
1832/// # .enable_http2()
1833/// # .build()
1834/// # );
1835/// # let mut hub = Adsense::new(client, auth);
1836/// // As the method needs a request, you would usually fill it with the desired information
1837/// // into the respective structure. Some of the parts shown here might not be applicable !
1838/// // Values shown here are possibly random and not representative !
1839/// let mut req = AdUnit::default();
1840///
1841/// // You can configure optional parameters by calling the respective setters at will, and
1842/// // execute the final call using `doit()`.
1843/// // Values shown here are possibly random and not representative !
1844/// let result = hub.accounts().adclients_adunits_create(req, "parent")
1845/// .doit().await;
1846/// # }
1847/// ```
1848pub struct AccountAdclientAdunitCreateCall<'a, C>
1849where
1850 C: 'a,
1851{
1852 hub: &'a Adsense<C>,
1853 _request: AdUnit,
1854 _parent: String,
1855 _delegate: Option<&'a mut dyn common::Delegate>,
1856 _additional_params: HashMap<String, String>,
1857 _scopes: BTreeSet<String>,
1858}
1859
1860impl<'a, C> common::CallBuilder for AccountAdclientAdunitCreateCall<'a, C> {}
1861
1862impl<'a, C> AccountAdclientAdunitCreateCall<'a, C>
1863where
1864 C: common::Connector,
1865{
1866 /// Perform the operation you have build so far.
1867 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
1868 use std::borrow::Cow;
1869 use std::io::{Read, Seek};
1870
1871 use common::{url::Params, ToParts};
1872 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1873
1874 let mut dd = common::DefaultDelegate;
1875 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1876 dlg.begin(common::MethodInfo {
1877 id: "adsense.accounts.adclients.adunits.create",
1878 http_method: hyper::Method::POST,
1879 });
1880
1881 for &field in ["alt", "parent"].iter() {
1882 if self._additional_params.contains_key(field) {
1883 dlg.finished(false);
1884 return Err(common::Error::FieldClash(field));
1885 }
1886 }
1887
1888 let mut params = Params::with_capacity(4 + self._additional_params.len());
1889 params.push("parent", self._parent);
1890
1891 params.extend(self._additional_params.iter());
1892
1893 params.push("alt", "json");
1894 let mut url = self.hub._base_url.clone() + "v2/{+parent}/adunits";
1895 if self._scopes.is_empty() {
1896 self._scopes.insert(Scope::Full.as_ref().to_string());
1897 }
1898
1899 #[allow(clippy::single_element_loop)]
1900 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1901 url = params.uri_replacement(url, param_name, find_this, true);
1902 }
1903 {
1904 let to_remove = ["parent"];
1905 params.remove_params(&to_remove);
1906 }
1907
1908 let url = params.parse_with_url(&url);
1909
1910 let mut json_mime_type = mime::APPLICATION_JSON;
1911 let mut request_value_reader = {
1912 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1913 common::remove_json_null_values(&mut value);
1914 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1915 serde_json::to_writer(&mut dst, &value).unwrap();
1916 dst
1917 };
1918 let request_size = request_value_reader
1919 .seek(std::io::SeekFrom::End(0))
1920 .unwrap();
1921 request_value_reader
1922 .seek(std::io::SeekFrom::Start(0))
1923 .unwrap();
1924
1925 loop {
1926 let token = match self
1927 .hub
1928 .auth
1929 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1930 .await
1931 {
1932 Ok(token) => token,
1933 Err(e) => match dlg.token(e) {
1934 Ok(token) => token,
1935 Err(e) => {
1936 dlg.finished(false);
1937 return Err(common::Error::MissingToken(e));
1938 }
1939 },
1940 };
1941 request_value_reader
1942 .seek(std::io::SeekFrom::Start(0))
1943 .unwrap();
1944 let mut req_result = {
1945 let client = &self.hub.client;
1946 dlg.pre_request();
1947 let mut req_builder = hyper::Request::builder()
1948 .method(hyper::Method::POST)
1949 .uri(url.as_str())
1950 .header(USER_AGENT, self.hub._user_agent.clone());
1951
1952 if let Some(token) = token.as_ref() {
1953 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1954 }
1955
1956 let request = req_builder
1957 .header(CONTENT_TYPE, json_mime_type.to_string())
1958 .header(CONTENT_LENGTH, request_size as u64)
1959 .body(common::to_body(
1960 request_value_reader.get_ref().clone().into(),
1961 ));
1962
1963 client.request(request.unwrap()).await
1964 };
1965
1966 match req_result {
1967 Err(err) => {
1968 if let common::Retry::After(d) = dlg.http_error(&err) {
1969 sleep(d).await;
1970 continue;
1971 }
1972 dlg.finished(false);
1973 return Err(common::Error::HttpError(err));
1974 }
1975 Ok(res) => {
1976 let (mut parts, body) = res.into_parts();
1977 let mut body = common::Body::new(body);
1978 if !parts.status.is_success() {
1979 let bytes = common::to_bytes(body).await.unwrap_or_default();
1980 let error = serde_json::from_str(&common::to_string(&bytes));
1981 let response = common::to_response(parts, bytes.into());
1982
1983 if let common::Retry::After(d) =
1984 dlg.http_failure(&response, error.as_ref().ok())
1985 {
1986 sleep(d).await;
1987 continue;
1988 }
1989
1990 dlg.finished(false);
1991
1992 return Err(match error {
1993 Ok(value) => common::Error::BadRequest(value),
1994 _ => common::Error::Failure(response),
1995 });
1996 }
1997 let response = {
1998 let bytes = common::to_bytes(body).await.unwrap_or_default();
1999 let encoded = common::to_string(&bytes);
2000 match serde_json::from_str(&encoded) {
2001 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2002 Err(error) => {
2003 dlg.response_json_decode_error(&encoded, &error);
2004 return Err(common::Error::JsonDecodeError(
2005 encoded.to_string(),
2006 error,
2007 ));
2008 }
2009 }
2010 };
2011
2012 dlg.finished(true);
2013 return Ok(response);
2014 }
2015 }
2016 }
2017 }
2018
2019 ///
2020 /// Sets the *request* property to the given value.
2021 ///
2022 /// Even though the property as already been set when instantiating this call,
2023 /// we provide this method for API completeness.
2024 pub fn request(mut self, new_value: AdUnit) -> AccountAdclientAdunitCreateCall<'a, C> {
2025 self._request = new_value;
2026 self
2027 }
2028 /// Required. Ad client to create an ad unit under. Format: accounts/{account}/adclients/{adclient}
2029 ///
2030 /// Sets the *parent* path property to the given value.
2031 ///
2032 /// Even though the property as already been set when instantiating this call,
2033 /// we provide this method for API completeness.
2034 pub fn parent(mut self, new_value: &str) -> AccountAdclientAdunitCreateCall<'a, C> {
2035 self._parent = new_value.to_string();
2036 self
2037 }
2038 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2039 /// while executing the actual API request.
2040 ///
2041 /// ````text
2042 /// It should be used to handle progress information, and to implement a certain level of resilience.
2043 /// ````
2044 ///
2045 /// Sets the *delegate* property to the given value.
2046 pub fn delegate(
2047 mut self,
2048 new_value: &'a mut dyn common::Delegate,
2049 ) -> AccountAdclientAdunitCreateCall<'a, C> {
2050 self._delegate = Some(new_value);
2051 self
2052 }
2053
2054 /// Set any additional parameter of the query string used in the request.
2055 /// It should be used to set parameters which are not yet available through their own
2056 /// setters.
2057 ///
2058 /// Please note that this method must not be used to set any of the known parameters
2059 /// which have their own setter method. If done anyway, the request will fail.
2060 ///
2061 /// # Additional Parameters
2062 ///
2063 /// * *$.xgafv* (query-string) - V1 error format.
2064 /// * *access_token* (query-string) - OAuth access token.
2065 /// * *alt* (query-string) - Data format for response.
2066 /// * *callback* (query-string) - JSONP
2067 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2068 /// * *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.
2069 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2070 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2071 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2072 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2073 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2074 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitCreateCall<'a, C>
2075 where
2076 T: AsRef<str>,
2077 {
2078 self._additional_params
2079 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2080 self
2081 }
2082
2083 /// Identifies the authorization scope for the method you are building.
2084 ///
2085 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2086 /// [`Scope::Full`].
2087 ///
2088 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2089 /// tokens for more than one scope.
2090 ///
2091 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2092 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2093 /// sufficient, a read-write scope will do as well.
2094 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitCreateCall<'a, C>
2095 where
2096 St: AsRef<str>,
2097 {
2098 self._scopes.insert(String::from(scope.as_ref()));
2099 self
2100 }
2101 /// Identifies the authorization scope(s) for the method you are building.
2102 ///
2103 /// See [`Self::add_scope()`] for details.
2104 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitCreateCall<'a, C>
2105 where
2106 I: IntoIterator<Item = St>,
2107 St: AsRef<str>,
2108 {
2109 self._scopes
2110 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2111 self
2112 }
2113
2114 /// Removes all scopes, and no default scope will be used either.
2115 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2116 /// for details).
2117 pub fn clear_scopes(mut self) -> AccountAdclientAdunitCreateCall<'a, C> {
2118 self._scopes.clear();
2119 self
2120 }
2121}
2122
2123/// Gets an ad unit from a specified account and ad client.
2124///
2125/// A builder for the *adclients.adunits.get* method supported by a *account* resource.
2126/// It is not used directly, but through a [`AccountMethods`] instance.
2127///
2128/// # Example
2129///
2130/// Instantiate a resource method builder
2131///
2132/// ```test_harness,no_run
2133/// # extern crate hyper;
2134/// # extern crate hyper_rustls;
2135/// # extern crate google_adsense2 as adsense2;
2136/// # async fn dox() {
2137/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2138///
2139/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2140/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2141/// # .with_native_roots()
2142/// # .unwrap()
2143/// # .https_only()
2144/// # .enable_http2()
2145/// # .build();
2146///
2147/// # let executor = hyper_util::rt::TokioExecutor::new();
2148/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2149/// # secret,
2150/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2151/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2152/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2153/// # ),
2154/// # ).build().await.unwrap();
2155///
2156/// # let client = hyper_util::client::legacy::Client::builder(
2157/// # hyper_util::rt::TokioExecutor::new()
2158/// # )
2159/// # .build(
2160/// # hyper_rustls::HttpsConnectorBuilder::new()
2161/// # .with_native_roots()
2162/// # .unwrap()
2163/// # .https_or_http()
2164/// # .enable_http2()
2165/// # .build()
2166/// # );
2167/// # let mut hub = Adsense::new(client, auth);
2168/// // You can configure optional parameters by calling the respective setters at will, and
2169/// // execute the final call using `doit()`.
2170/// // Values shown here are possibly random and not representative !
2171/// let result = hub.accounts().adclients_adunits_get("name")
2172/// .doit().await;
2173/// # }
2174/// ```
2175pub struct AccountAdclientAdunitGetCall<'a, C>
2176where
2177 C: 'a,
2178{
2179 hub: &'a Adsense<C>,
2180 _name: String,
2181 _delegate: Option<&'a mut dyn common::Delegate>,
2182 _additional_params: HashMap<String, String>,
2183 _scopes: BTreeSet<String>,
2184}
2185
2186impl<'a, C> common::CallBuilder for AccountAdclientAdunitGetCall<'a, C> {}
2187
2188impl<'a, C> AccountAdclientAdunitGetCall<'a, C>
2189where
2190 C: common::Connector,
2191{
2192 /// Perform the operation you have build so far.
2193 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
2194 use std::borrow::Cow;
2195 use std::io::{Read, Seek};
2196
2197 use common::{url::Params, ToParts};
2198 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2199
2200 let mut dd = common::DefaultDelegate;
2201 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2202 dlg.begin(common::MethodInfo {
2203 id: "adsense.accounts.adclients.adunits.get",
2204 http_method: hyper::Method::GET,
2205 });
2206
2207 for &field in ["alt", "name"].iter() {
2208 if self._additional_params.contains_key(field) {
2209 dlg.finished(false);
2210 return Err(common::Error::FieldClash(field));
2211 }
2212 }
2213
2214 let mut params = Params::with_capacity(3 + self._additional_params.len());
2215 params.push("name", self._name);
2216
2217 params.extend(self._additional_params.iter());
2218
2219 params.push("alt", "json");
2220 let mut url = self.hub._base_url.clone() + "v2/{+name}";
2221 if self._scopes.is_empty() {
2222 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2223 }
2224
2225 #[allow(clippy::single_element_loop)]
2226 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2227 url = params.uri_replacement(url, param_name, find_this, true);
2228 }
2229 {
2230 let to_remove = ["name"];
2231 params.remove_params(&to_remove);
2232 }
2233
2234 let url = params.parse_with_url(&url);
2235
2236 loop {
2237 let token = match self
2238 .hub
2239 .auth
2240 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2241 .await
2242 {
2243 Ok(token) => token,
2244 Err(e) => match dlg.token(e) {
2245 Ok(token) => token,
2246 Err(e) => {
2247 dlg.finished(false);
2248 return Err(common::Error::MissingToken(e));
2249 }
2250 },
2251 };
2252 let mut req_result = {
2253 let client = &self.hub.client;
2254 dlg.pre_request();
2255 let mut req_builder = hyper::Request::builder()
2256 .method(hyper::Method::GET)
2257 .uri(url.as_str())
2258 .header(USER_AGENT, self.hub._user_agent.clone());
2259
2260 if let Some(token) = token.as_ref() {
2261 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2262 }
2263
2264 let request = req_builder
2265 .header(CONTENT_LENGTH, 0_u64)
2266 .body(common::to_body::<String>(None));
2267
2268 client.request(request.unwrap()).await
2269 };
2270
2271 match req_result {
2272 Err(err) => {
2273 if let common::Retry::After(d) = dlg.http_error(&err) {
2274 sleep(d).await;
2275 continue;
2276 }
2277 dlg.finished(false);
2278 return Err(common::Error::HttpError(err));
2279 }
2280 Ok(res) => {
2281 let (mut parts, body) = res.into_parts();
2282 let mut body = common::Body::new(body);
2283 if !parts.status.is_success() {
2284 let bytes = common::to_bytes(body).await.unwrap_or_default();
2285 let error = serde_json::from_str(&common::to_string(&bytes));
2286 let response = common::to_response(parts, bytes.into());
2287
2288 if let common::Retry::After(d) =
2289 dlg.http_failure(&response, error.as_ref().ok())
2290 {
2291 sleep(d).await;
2292 continue;
2293 }
2294
2295 dlg.finished(false);
2296
2297 return Err(match error {
2298 Ok(value) => common::Error::BadRequest(value),
2299 _ => common::Error::Failure(response),
2300 });
2301 }
2302 let response = {
2303 let bytes = common::to_bytes(body).await.unwrap_or_default();
2304 let encoded = common::to_string(&bytes);
2305 match serde_json::from_str(&encoded) {
2306 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2307 Err(error) => {
2308 dlg.response_json_decode_error(&encoded, &error);
2309 return Err(common::Error::JsonDecodeError(
2310 encoded.to_string(),
2311 error,
2312 ));
2313 }
2314 }
2315 };
2316
2317 dlg.finished(true);
2318 return Ok(response);
2319 }
2320 }
2321 }
2322 }
2323
2324 /// Required. AdUnit to get information about. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
2325 ///
2326 /// Sets the *name* path property to the given value.
2327 ///
2328 /// Even though the property as already been set when instantiating this call,
2329 /// we provide this method for API completeness.
2330 pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitGetCall<'a, C> {
2331 self._name = new_value.to_string();
2332 self
2333 }
2334 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2335 /// while executing the actual API request.
2336 ///
2337 /// ````text
2338 /// It should be used to handle progress information, and to implement a certain level of resilience.
2339 /// ````
2340 ///
2341 /// Sets the *delegate* property to the given value.
2342 pub fn delegate(
2343 mut self,
2344 new_value: &'a mut dyn common::Delegate,
2345 ) -> AccountAdclientAdunitGetCall<'a, C> {
2346 self._delegate = Some(new_value);
2347 self
2348 }
2349
2350 /// Set any additional parameter of the query string used in the request.
2351 /// It should be used to set parameters which are not yet available through their own
2352 /// setters.
2353 ///
2354 /// Please note that this method must not be used to set any of the known parameters
2355 /// which have their own setter method. If done anyway, the request will fail.
2356 ///
2357 /// # Additional Parameters
2358 ///
2359 /// * *$.xgafv* (query-string) - V1 error format.
2360 /// * *access_token* (query-string) - OAuth access token.
2361 /// * *alt* (query-string) - Data format for response.
2362 /// * *callback* (query-string) - JSONP
2363 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2364 /// * *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.
2365 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2366 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2367 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2368 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2369 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2370 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitGetCall<'a, C>
2371 where
2372 T: AsRef<str>,
2373 {
2374 self._additional_params
2375 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2376 self
2377 }
2378
2379 /// Identifies the authorization scope for the method you are building.
2380 ///
2381 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2382 /// [`Scope::Readonly`].
2383 ///
2384 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2385 /// tokens for more than one scope.
2386 ///
2387 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2388 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2389 /// sufficient, a read-write scope will do as well.
2390 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitGetCall<'a, C>
2391 where
2392 St: AsRef<str>,
2393 {
2394 self._scopes.insert(String::from(scope.as_ref()));
2395 self
2396 }
2397 /// Identifies the authorization scope(s) for the method you are building.
2398 ///
2399 /// See [`Self::add_scope()`] for details.
2400 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitGetCall<'a, C>
2401 where
2402 I: IntoIterator<Item = St>,
2403 St: AsRef<str>,
2404 {
2405 self._scopes
2406 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2407 self
2408 }
2409
2410 /// Removes all scopes, and no default scope will be used either.
2411 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2412 /// for details).
2413 pub fn clear_scopes(mut self) -> AccountAdclientAdunitGetCall<'a, C> {
2414 self._scopes.clear();
2415 self
2416 }
2417}
2418
2419/// Gets the ad unit code for a given ad unit. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634) and [Where to place the ad code in your HTML](https://support.google.com/adsense/answer/9190028).
2420///
2421/// A builder for the *adclients.adunits.getAdcode* method supported by a *account* resource.
2422/// It is not used directly, but through a [`AccountMethods`] instance.
2423///
2424/// # Example
2425///
2426/// Instantiate a resource method builder
2427///
2428/// ```test_harness,no_run
2429/// # extern crate hyper;
2430/// # extern crate hyper_rustls;
2431/// # extern crate google_adsense2 as adsense2;
2432/// # async fn dox() {
2433/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2434///
2435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2436/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2437/// # .with_native_roots()
2438/// # .unwrap()
2439/// # .https_only()
2440/// # .enable_http2()
2441/// # .build();
2442///
2443/// # let executor = hyper_util::rt::TokioExecutor::new();
2444/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2445/// # secret,
2446/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2447/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2448/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2449/// # ),
2450/// # ).build().await.unwrap();
2451///
2452/// # let client = hyper_util::client::legacy::Client::builder(
2453/// # hyper_util::rt::TokioExecutor::new()
2454/// # )
2455/// # .build(
2456/// # hyper_rustls::HttpsConnectorBuilder::new()
2457/// # .with_native_roots()
2458/// # .unwrap()
2459/// # .https_or_http()
2460/// # .enable_http2()
2461/// # .build()
2462/// # );
2463/// # let mut hub = Adsense::new(client, auth);
2464/// // You can configure optional parameters by calling the respective setters at will, and
2465/// // execute the final call using `doit()`.
2466/// // Values shown here are possibly random and not representative !
2467/// let result = hub.accounts().adclients_adunits_get_adcode("name")
2468/// .doit().await;
2469/// # }
2470/// ```
2471pub struct AccountAdclientAdunitGetAdcodeCall<'a, C>
2472where
2473 C: 'a,
2474{
2475 hub: &'a Adsense<C>,
2476 _name: String,
2477 _delegate: Option<&'a mut dyn common::Delegate>,
2478 _additional_params: HashMap<String, String>,
2479 _scopes: BTreeSet<String>,
2480}
2481
2482impl<'a, C> common::CallBuilder for AccountAdclientAdunitGetAdcodeCall<'a, C> {}
2483
2484impl<'a, C> AccountAdclientAdunitGetAdcodeCall<'a, C>
2485where
2486 C: common::Connector,
2487{
2488 /// Perform the operation you have build so far.
2489 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnitAdCode)> {
2490 use std::borrow::Cow;
2491 use std::io::{Read, Seek};
2492
2493 use common::{url::Params, ToParts};
2494 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2495
2496 let mut dd = common::DefaultDelegate;
2497 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2498 dlg.begin(common::MethodInfo {
2499 id: "adsense.accounts.adclients.adunits.getAdcode",
2500 http_method: hyper::Method::GET,
2501 });
2502
2503 for &field in ["alt", "name"].iter() {
2504 if self._additional_params.contains_key(field) {
2505 dlg.finished(false);
2506 return Err(common::Error::FieldClash(field));
2507 }
2508 }
2509
2510 let mut params = Params::with_capacity(3 + self._additional_params.len());
2511 params.push("name", self._name);
2512
2513 params.extend(self._additional_params.iter());
2514
2515 params.push("alt", "json");
2516 let mut url = self.hub._base_url.clone() + "v2/{+name}/adcode";
2517 if self._scopes.is_empty() {
2518 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2519 }
2520
2521 #[allow(clippy::single_element_loop)]
2522 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2523 url = params.uri_replacement(url, param_name, find_this, true);
2524 }
2525 {
2526 let to_remove = ["name"];
2527 params.remove_params(&to_remove);
2528 }
2529
2530 let url = params.parse_with_url(&url);
2531
2532 loop {
2533 let token = match self
2534 .hub
2535 .auth
2536 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2537 .await
2538 {
2539 Ok(token) => token,
2540 Err(e) => match dlg.token(e) {
2541 Ok(token) => token,
2542 Err(e) => {
2543 dlg.finished(false);
2544 return Err(common::Error::MissingToken(e));
2545 }
2546 },
2547 };
2548 let mut req_result = {
2549 let client = &self.hub.client;
2550 dlg.pre_request();
2551 let mut req_builder = hyper::Request::builder()
2552 .method(hyper::Method::GET)
2553 .uri(url.as_str())
2554 .header(USER_AGENT, self.hub._user_agent.clone());
2555
2556 if let Some(token) = token.as_ref() {
2557 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2558 }
2559
2560 let request = req_builder
2561 .header(CONTENT_LENGTH, 0_u64)
2562 .body(common::to_body::<String>(None));
2563
2564 client.request(request.unwrap()).await
2565 };
2566
2567 match req_result {
2568 Err(err) => {
2569 if let common::Retry::After(d) = dlg.http_error(&err) {
2570 sleep(d).await;
2571 continue;
2572 }
2573 dlg.finished(false);
2574 return Err(common::Error::HttpError(err));
2575 }
2576 Ok(res) => {
2577 let (mut parts, body) = res.into_parts();
2578 let mut body = common::Body::new(body);
2579 if !parts.status.is_success() {
2580 let bytes = common::to_bytes(body).await.unwrap_or_default();
2581 let error = serde_json::from_str(&common::to_string(&bytes));
2582 let response = common::to_response(parts, bytes.into());
2583
2584 if let common::Retry::After(d) =
2585 dlg.http_failure(&response, error.as_ref().ok())
2586 {
2587 sleep(d).await;
2588 continue;
2589 }
2590
2591 dlg.finished(false);
2592
2593 return Err(match error {
2594 Ok(value) => common::Error::BadRequest(value),
2595 _ => common::Error::Failure(response),
2596 });
2597 }
2598 let response = {
2599 let bytes = common::to_bytes(body).await.unwrap_or_default();
2600 let encoded = common::to_string(&bytes);
2601 match serde_json::from_str(&encoded) {
2602 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2603 Err(error) => {
2604 dlg.response_json_decode_error(&encoded, &error);
2605 return Err(common::Error::JsonDecodeError(
2606 encoded.to_string(),
2607 error,
2608 ));
2609 }
2610 }
2611 };
2612
2613 dlg.finished(true);
2614 return Ok(response);
2615 }
2616 }
2617 }
2618 }
2619
2620 /// Required. Name of the adunit for which to get the adcode. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
2621 ///
2622 /// Sets the *name* path property to the given value.
2623 ///
2624 /// Even though the property as already been set when instantiating this call,
2625 /// we provide this method for API completeness.
2626 pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2627 self._name = new_value.to_string();
2628 self
2629 }
2630 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2631 /// while executing the actual API request.
2632 ///
2633 /// ````text
2634 /// It should be used to handle progress information, and to implement a certain level of resilience.
2635 /// ````
2636 ///
2637 /// Sets the *delegate* property to the given value.
2638 pub fn delegate(
2639 mut self,
2640 new_value: &'a mut dyn common::Delegate,
2641 ) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2642 self._delegate = Some(new_value);
2643 self
2644 }
2645
2646 /// Set any additional parameter of the query string used in the request.
2647 /// It should be used to set parameters which are not yet available through their own
2648 /// setters.
2649 ///
2650 /// Please note that this method must not be used to set any of the known parameters
2651 /// which have their own setter method. If done anyway, the request will fail.
2652 ///
2653 /// # Additional Parameters
2654 ///
2655 /// * *$.xgafv* (query-string) - V1 error format.
2656 /// * *access_token* (query-string) - OAuth access token.
2657 /// * *alt* (query-string) - Data format for response.
2658 /// * *callback* (query-string) - JSONP
2659 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2660 /// * *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.
2661 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2662 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2663 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2664 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2665 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2666 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2667 where
2668 T: AsRef<str>,
2669 {
2670 self._additional_params
2671 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2672 self
2673 }
2674
2675 /// Identifies the authorization scope for the method you are building.
2676 ///
2677 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2678 /// [`Scope::Readonly`].
2679 ///
2680 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2681 /// tokens for more than one scope.
2682 ///
2683 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2684 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2685 /// sufficient, a read-write scope will do as well.
2686 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2687 where
2688 St: AsRef<str>,
2689 {
2690 self._scopes.insert(String::from(scope.as_ref()));
2691 self
2692 }
2693 /// Identifies the authorization scope(s) for the method you are building.
2694 ///
2695 /// See [`Self::add_scope()`] for details.
2696 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitGetAdcodeCall<'a, C>
2697 where
2698 I: IntoIterator<Item = St>,
2699 St: AsRef<str>,
2700 {
2701 self._scopes
2702 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2703 self
2704 }
2705
2706 /// Removes all scopes, and no default scope will be used either.
2707 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2708 /// for details).
2709 pub fn clear_scopes(mut self) -> AccountAdclientAdunitGetAdcodeCall<'a, C> {
2710 self._scopes.clear();
2711 self
2712 }
2713}
2714
2715/// Lists all ad units under a specified account and ad client.
2716///
2717/// A builder for the *adclients.adunits.list* method supported by a *account* resource.
2718/// It is not used directly, but through a [`AccountMethods`] instance.
2719///
2720/// # Example
2721///
2722/// Instantiate a resource method builder
2723///
2724/// ```test_harness,no_run
2725/// # extern crate hyper;
2726/// # extern crate hyper_rustls;
2727/// # extern crate google_adsense2 as adsense2;
2728/// # async fn dox() {
2729/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2730///
2731/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2732/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2733/// # .with_native_roots()
2734/// # .unwrap()
2735/// # .https_only()
2736/// # .enable_http2()
2737/// # .build();
2738///
2739/// # let executor = hyper_util::rt::TokioExecutor::new();
2740/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2741/// # secret,
2742/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2743/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2744/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2745/// # ),
2746/// # ).build().await.unwrap();
2747///
2748/// # let client = hyper_util::client::legacy::Client::builder(
2749/// # hyper_util::rt::TokioExecutor::new()
2750/// # )
2751/// # .build(
2752/// # hyper_rustls::HttpsConnectorBuilder::new()
2753/// # .with_native_roots()
2754/// # .unwrap()
2755/// # .https_or_http()
2756/// # .enable_http2()
2757/// # .build()
2758/// # );
2759/// # let mut hub = Adsense::new(client, auth);
2760/// // You can configure optional parameters by calling the respective setters at will, and
2761/// // execute the final call using `doit()`.
2762/// // Values shown here are possibly random and not representative !
2763/// let result = hub.accounts().adclients_adunits_list("parent")
2764/// .page_token("dolore")
2765/// .page_size(-22)
2766/// .doit().await;
2767/// # }
2768/// ```
2769pub struct AccountAdclientAdunitListCall<'a, C>
2770where
2771 C: 'a,
2772{
2773 hub: &'a Adsense<C>,
2774 _parent: String,
2775 _page_token: Option<String>,
2776 _page_size: Option<i32>,
2777 _delegate: Option<&'a mut dyn common::Delegate>,
2778 _additional_params: HashMap<String, String>,
2779 _scopes: BTreeSet<String>,
2780}
2781
2782impl<'a, C> common::CallBuilder for AccountAdclientAdunitListCall<'a, C> {}
2783
2784impl<'a, C> AccountAdclientAdunitListCall<'a, C>
2785where
2786 C: common::Connector,
2787{
2788 /// Perform the operation you have build so far.
2789 pub async fn doit(mut self) -> common::Result<(common::Response, ListAdUnitsResponse)> {
2790 use std::borrow::Cow;
2791 use std::io::{Read, Seek};
2792
2793 use common::{url::Params, ToParts};
2794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2795
2796 let mut dd = common::DefaultDelegate;
2797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2798 dlg.begin(common::MethodInfo {
2799 id: "adsense.accounts.adclients.adunits.list",
2800 http_method: hyper::Method::GET,
2801 });
2802
2803 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2804 if self._additional_params.contains_key(field) {
2805 dlg.finished(false);
2806 return Err(common::Error::FieldClash(field));
2807 }
2808 }
2809
2810 let mut params = Params::with_capacity(5 + self._additional_params.len());
2811 params.push("parent", self._parent);
2812 if let Some(value) = self._page_token.as_ref() {
2813 params.push("pageToken", value);
2814 }
2815 if let Some(value) = self._page_size.as_ref() {
2816 params.push("pageSize", value.to_string());
2817 }
2818
2819 params.extend(self._additional_params.iter());
2820
2821 params.push("alt", "json");
2822 let mut url = self.hub._base_url.clone() + "v2/{+parent}/adunits";
2823 if self._scopes.is_empty() {
2824 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2825 }
2826
2827 #[allow(clippy::single_element_loop)]
2828 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2829 url = params.uri_replacement(url, param_name, find_this, true);
2830 }
2831 {
2832 let to_remove = ["parent"];
2833 params.remove_params(&to_remove);
2834 }
2835
2836 let url = params.parse_with_url(&url);
2837
2838 loop {
2839 let token = match self
2840 .hub
2841 .auth
2842 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2843 .await
2844 {
2845 Ok(token) => token,
2846 Err(e) => match dlg.token(e) {
2847 Ok(token) => token,
2848 Err(e) => {
2849 dlg.finished(false);
2850 return Err(common::Error::MissingToken(e));
2851 }
2852 },
2853 };
2854 let mut req_result = {
2855 let client = &self.hub.client;
2856 dlg.pre_request();
2857 let mut req_builder = hyper::Request::builder()
2858 .method(hyper::Method::GET)
2859 .uri(url.as_str())
2860 .header(USER_AGENT, self.hub._user_agent.clone());
2861
2862 if let Some(token) = token.as_ref() {
2863 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2864 }
2865
2866 let request = req_builder
2867 .header(CONTENT_LENGTH, 0_u64)
2868 .body(common::to_body::<String>(None));
2869
2870 client.request(request.unwrap()).await
2871 };
2872
2873 match req_result {
2874 Err(err) => {
2875 if let common::Retry::After(d) = dlg.http_error(&err) {
2876 sleep(d).await;
2877 continue;
2878 }
2879 dlg.finished(false);
2880 return Err(common::Error::HttpError(err));
2881 }
2882 Ok(res) => {
2883 let (mut parts, body) = res.into_parts();
2884 let mut body = common::Body::new(body);
2885 if !parts.status.is_success() {
2886 let bytes = common::to_bytes(body).await.unwrap_or_default();
2887 let error = serde_json::from_str(&common::to_string(&bytes));
2888 let response = common::to_response(parts, bytes.into());
2889
2890 if let common::Retry::After(d) =
2891 dlg.http_failure(&response, error.as_ref().ok())
2892 {
2893 sleep(d).await;
2894 continue;
2895 }
2896
2897 dlg.finished(false);
2898
2899 return Err(match error {
2900 Ok(value) => common::Error::BadRequest(value),
2901 _ => common::Error::Failure(response),
2902 });
2903 }
2904 let response = {
2905 let bytes = common::to_bytes(body).await.unwrap_or_default();
2906 let encoded = common::to_string(&bytes);
2907 match serde_json::from_str(&encoded) {
2908 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2909 Err(error) => {
2910 dlg.response_json_decode_error(&encoded, &error);
2911 return Err(common::Error::JsonDecodeError(
2912 encoded.to_string(),
2913 error,
2914 ));
2915 }
2916 }
2917 };
2918
2919 dlg.finished(true);
2920 return Ok(response);
2921 }
2922 }
2923 }
2924 }
2925
2926 /// Required. The ad client which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}
2927 ///
2928 /// Sets the *parent* path property to the given value.
2929 ///
2930 /// Even though the property as already been set when instantiating this call,
2931 /// we provide this method for API completeness.
2932 pub fn parent(mut self, new_value: &str) -> AccountAdclientAdunitListCall<'a, C> {
2933 self._parent = new_value.to_string();
2934 self
2935 }
2936 /// A page token, received from a previous `ListAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdUnits` must match the call that provided the page token.
2937 ///
2938 /// Sets the *page token* query property to the given value.
2939 pub fn page_token(mut self, new_value: &str) -> AccountAdclientAdunitListCall<'a, C> {
2940 self._page_token = Some(new_value.to_string());
2941 self
2942 }
2943 /// The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
2944 ///
2945 /// Sets the *page size* query property to the given value.
2946 pub fn page_size(mut self, new_value: i32) -> AccountAdclientAdunitListCall<'a, C> {
2947 self._page_size = Some(new_value);
2948 self
2949 }
2950 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2951 /// while executing the actual API request.
2952 ///
2953 /// ````text
2954 /// It should be used to handle progress information, and to implement a certain level of resilience.
2955 /// ````
2956 ///
2957 /// Sets the *delegate* property to the given value.
2958 pub fn delegate(
2959 mut self,
2960 new_value: &'a mut dyn common::Delegate,
2961 ) -> AccountAdclientAdunitListCall<'a, C> {
2962 self._delegate = Some(new_value);
2963 self
2964 }
2965
2966 /// Set any additional parameter of the query string used in the request.
2967 /// It should be used to set parameters which are not yet available through their own
2968 /// setters.
2969 ///
2970 /// Please note that this method must not be used to set any of the known parameters
2971 /// which have their own setter method. If done anyway, the request will fail.
2972 ///
2973 /// # Additional Parameters
2974 ///
2975 /// * *$.xgafv* (query-string) - V1 error format.
2976 /// * *access_token* (query-string) - OAuth access token.
2977 /// * *alt* (query-string) - Data format for response.
2978 /// * *callback* (query-string) - JSONP
2979 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2980 /// * *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.
2981 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2982 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2983 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2984 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2985 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2986 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitListCall<'a, C>
2987 where
2988 T: AsRef<str>,
2989 {
2990 self._additional_params
2991 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2992 self
2993 }
2994
2995 /// Identifies the authorization scope for the method you are building.
2996 ///
2997 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2998 /// [`Scope::Readonly`].
2999 ///
3000 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3001 /// tokens for more than one scope.
3002 ///
3003 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3004 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3005 /// sufficient, a read-write scope will do as well.
3006 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitListCall<'a, C>
3007 where
3008 St: AsRef<str>,
3009 {
3010 self._scopes.insert(String::from(scope.as_ref()));
3011 self
3012 }
3013 /// Identifies the authorization scope(s) for the method you are building.
3014 ///
3015 /// See [`Self::add_scope()`] for details.
3016 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitListCall<'a, C>
3017 where
3018 I: IntoIterator<Item = St>,
3019 St: AsRef<str>,
3020 {
3021 self._scopes
3022 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3023 self
3024 }
3025
3026 /// Removes all scopes, and no default scope will be used either.
3027 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3028 /// for details).
3029 pub fn clear_scopes(mut self) -> AccountAdclientAdunitListCall<'a, C> {
3030 self._scopes.clear();
3031 self
3032 }
3033}
3034
3035/// Lists all the custom channels available for an ad unit.
3036///
3037/// A builder for the *adclients.adunits.listLinkedCustomChannels* method supported by a *account* resource.
3038/// It is not used directly, but through a [`AccountMethods`] instance.
3039///
3040/// # Example
3041///
3042/// Instantiate a resource method builder
3043///
3044/// ```test_harness,no_run
3045/// # extern crate hyper;
3046/// # extern crate hyper_rustls;
3047/// # extern crate google_adsense2 as adsense2;
3048/// # async fn dox() {
3049/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3050///
3051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3052/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3053/// # .with_native_roots()
3054/// # .unwrap()
3055/// # .https_only()
3056/// # .enable_http2()
3057/// # .build();
3058///
3059/// # let executor = hyper_util::rt::TokioExecutor::new();
3060/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3061/// # secret,
3062/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3063/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3064/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3065/// # ),
3066/// # ).build().await.unwrap();
3067///
3068/// # let client = hyper_util::client::legacy::Client::builder(
3069/// # hyper_util::rt::TokioExecutor::new()
3070/// # )
3071/// # .build(
3072/// # hyper_rustls::HttpsConnectorBuilder::new()
3073/// # .with_native_roots()
3074/// # .unwrap()
3075/// # .https_or_http()
3076/// # .enable_http2()
3077/// # .build()
3078/// # );
3079/// # let mut hub = Adsense::new(client, auth);
3080/// // You can configure optional parameters by calling the respective setters at will, and
3081/// // execute the final call using `doit()`.
3082/// // Values shown here are possibly random and not representative !
3083/// let result = hub.accounts().adclients_adunits_list_linked_custom_channels("parent")
3084/// .page_token("amet.")
3085/// .page_size(-96)
3086/// .doit().await;
3087/// # }
3088/// ```
3089pub struct AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3090where
3091 C: 'a,
3092{
3093 hub: &'a Adsense<C>,
3094 _parent: String,
3095 _page_token: Option<String>,
3096 _page_size: Option<i32>,
3097 _delegate: Option<&'a mut dyn common::Delegate>,
3098 _additional_params: HashMap<String, String>,
3099 _scopes: BTreeSet<String>,
3100}
3101
3102impl<'a, C> common::CallBuilder for AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {}
3103
3104impl<'a, C> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3105where
3106 C: common::Connector,
3107{
3108 /// Perform the operation you have build so far.
3109 pub async fn doit(
3110 mut self,
3111 ) -> common::Result<(common::Response, ListLinkedCustomChannelsResponse)> {
3112 use std::borrow::Cow;
3113 use std::io::{Read, Seek};
3114
3115 use common::{url::Params, ToParts};
3116 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3117
3118 let mut dd = common::DefaultDelegate;
3119 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3120 dlg.begin(common::MethodInfo {
3121 id: "adsense.accounts.adclients.adunits.listLinkedCustomChannels",
3122 http_method: hyper::Method::GET,
3123 });
3124
3125 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3126 if self._additional_params.contains_key(field) {
3127 dlg.finished(false);
3128 return Err(common::Error::FieldClash(field));
3129 }
3130 }
3131
3132 let mut params = Params::with_capacity(5 + self._additional_params.len());
3133 params.push("parent", self._parent);
3134 if let Some(value) = self._page_token.as_ref() {
3135 params.push("pageToken", value);
3136 }
3137 if let Some(value) = self._page_size.as_ref() {
3138 params.push("pageSize", value.to_string());
3139 }
3140
3141 params.extend(self._additional_params.iter());
3142
3143 params.push("alt", "json");
3144 let mut url = self.hub._base_url.clone() + "v2/{+parent}:listLinkedCustomChannels";
3145 if self._scopes.is_empty() {
3146 self._scopes.insert(Scope::Readonly.as_ref().to_string());
3147 }
3148
3149 #[allow(clippy::single_element_loop)]
3150 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3151 url = params.uri_replacement(url, param_name, find_this, true);
3152 }
3153 {
3154 let to_remove = ["parent"];
3155 params.remove_params(&to_remove);
3156 }
3157
3158 let url = params.parse_with_url(&url);
3159
3160 loop {
3161 let token = match self
3162 .hub
3163 .auth
3164 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3165 .await
3166 {
3167 Ok(token) => token,
3168 Err(e) => match dlg.token(e) {
3169 Ok(token) => token,
3170 Err(e) => {
3171 dlg.finished(false);
3172 return Err(common::Error::MissingToken(e));
3173 }
3174 },
3175 };
3176 let mut req_result = {
3177 let client = &self.hub.client;
3178 dlg.pre_request();
3179 let mut req_builder = hyper::Request::builder()
3180 .method(hyper::Method::GET)
3181 .uri(url.as_str())
3182 .header(USER_AGENT, self.hub._user_agent.clone());
3183
3184 if let Some(token) = token.as_ref() {
3185 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3186 }
3187
3188 let request = req_builder
3189 .header(CONTENT_LENGTH, 0_u64)
3190 .body(common::to_body::<String>(None));
3191
3192 client.request(request.unwrap()).await
3193 };
3194
3195 match req_result {
3196 Err(err) => {
3197 if let common::Retry::After(d) = dlg.http_error(&err) {
3198 sleep(d).await;
3199 continue;
3200 }
3201 dlg.finished(false);
3202 return Err(common::Error::HttpError(err));
3203 }
3204 Ok(res) => {
3205 let (mut parts, body) = res.into_parts();
3206 let mut body = common::Body::new(body);
3207 if !parts.status.is_success() {
3208 let bytes = common::to_bytes(body).await.unwrap_or_default();
3209 let error = serde_json::from_str(&common::to_string(&bytes));
3210 let response = common::to_response(parts, bytes.into());
3211
3212 if let common::Retry::After(d) =
3213 dlg.http_failure(&response, error.as_ref().ok())
3214 {
3215 sleep(d).await;
3216 continue;
3217 }
3218
3219 dlg.finished(false);
3220
3221 return Err(match error {
3222 Ok(value) => common::Error::BadRequest(value),
3223 _ => common::Error::Failure(response),
3224 });
3225 }
3226 let response = {
3227 let bytes = common::to_bytes(body).await.unwrap_or_default();
3228 let encoded = common::to_string(&bytes);
3229 match serde_json::from_str(&encoded) {
3230 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3231 Err(error) => {
3232 dlg.response_json_decode_error(&encoded, &error);
3233 return Err(common::Error::JsonDecodeError(
3234 encoded.to_string(),
3235 error,
3236 ));
3237 }
3238 }
3239 };
3240
3241 dlg.finished(true);
3242 return Ok(response);
3243 }
3244 }
3245 }
3246 }
3247
3248 /// Required. The ad unit which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
3249 ///
3250 /// Sets the *parent* path property to the given value.
3251 ///
3252 /// Even though the property as already been set when instantiating this call,
3253 /// we provide this method for API completeness.
3254 pub fn parent(
3255 mut self,
3256 new_value: &str,
3257 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3258 self._parent = new_value.to_string();
3259 self
3260 }
3261 /// A page token, received from a previous `ListLinkedCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedCustomChannels` must match the call that provided the page token.
3262 ///
3263 /// Sets the *page token* query property to the given value.
3264 pub fn page_token(
3265 mut self,
3266 new_value: &str,
3267 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3268 self._page_token = Some(new_value.to_string());
3269 self
3270 }
3271 /// The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
3272 ///
3273 /// Sets the *page size* query property to the given value.
3274 pub fn page_size(
3275 mut self,
3276 new_value: i32,
3277 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3278 self._page_size = Some(new_value);
3279 self
3280 }
3281 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3282 /// while executing the actual API request.
3283 ///
3284 /// ````text
3285 /// It should be used to handle progress information, and to implement a certain level of resilience.
3286 /// ````
3287 ///
3288 /// Sets the *delegate* property to the given value.
3289 pub fn delegate(
3290 mut self,
3291 new_value: &'a mut dyn common::Delegate,
3292 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3293 self._delegate = Some(new_value);
3294 self
3295 }
3296
3297 /// Set any additional parameter of the query string used in the request.
3298 /// It should be used to set parameters which are not yet available through their own
3299 /// setters.
3300 ///
3301 /// Please note that this method must not be used to set any of the known parameters
3302 /// which have their own setter method. If done anyway, the request will fail.
3303 ///
3304 /// # Additional Parameters
3305 ///
3306 /// * *$.xgafv* (query-string) - V1 error format.
3307 /// * *access_token* (query-string) - OAuth access token.
3308 /// * *alt* (query-string) - Data format for response.
3309 /// * *callback* (query-string) - JSONP
3310 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3311 /// * *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.
3312 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3313 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3314 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3315 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3316 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3317 pub fn param<T>(
3318 mut self,
3319 name: T,
3320 value: T,
3321 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3322 where
3323 T: AsRef<str>,
3324 {
3325 self._additional_params
3326 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3327 self
3328 }
3329
3330 /// Identifies the authorization scope for the method you are building.
3331 ///
3332 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3333 /// [`Scope::Readonly`].
3334 ///
3335 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3336 /// tokens for more than one scope.
3337 ///
3338 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3339 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3340 /// sufficient, a read-write scope will do as well.
3341 pub fn add_scope<St>(
3342 mut self,
3343 scope: St,
3344 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3345 where
3346 St: AsRef<str>,
3347 {
3348 self._scopes.insert(String::from(scope.as_ref()));
3349 self
3350 }
3351 /// Identifies the authorization scope(s) for the method you are building.
3352 ///
3353 /// See [`Self::add_scope()`] for details.
3354 pub fn add_scopes<I, St>(
3355 mut self,
3356 scopes: I,
3357 ) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C>
3358 where
3359 I: IntoIterator<Item = St>,
3360 St: AsRef<str>,
3361 {
3362 self._scopes
3363 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3364 self
3365 }
3366
3367 /// Removes all scopes, and no default scope will be used either.
3368 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3369 /// for details).
3370 pub fn clear_scopes(mut self) -> AccountAdclientAdunitListLinkedCustomChannelCall<'a, C> {
3371 self._scopes.clear();
3372 self
3373 }
3374}
3375
3376/// Updates an ad unit. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method. For now, this method can only be used to update `DISPLAY` ad units. See: https://support.google.com/adsense/answer/9183566
3377///
3378/// A builder for the *adclients.adunits.patch* method supported by a *account* resource.
3379/// It is not used directly, but through a [`AccountMethods`] instance.
3380///
3381/// # Example
3382///
3383/// Instantiate a resource method builder
3384///
3385/// ```test_harness,no_run
3386/// # extern crate hyper;
3387/// # extern crate hyper_rustls;
3388/// # extern crate google_adsense2 as adsense2;
3389/// use adsense2::api::AdUnit;
3390/// # async fn dox() {
3391/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3392///
3393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3394/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3395/// # .with_native_roots()
3396/// # .unwrap()
3397/// # .https_only()
3398/// # .enable_http2()
3399/// # .build();
3400///
3401/// # let executor = hyper_util::rt::TokioExecutor::new();
3402/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3403/// # secret,
3404/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3405/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3406/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3407/// # ),
3408/// # ).build().await.unwrap();
3409///
3410/// # let client = hyper_util::client::legacy::Client::builder(
3411/// # hyper_util::rt::TokioExecutor::new()
3412/// # )
3413/// # .build(
3414/// # hyper_rustls::HttpsConnectorBuilder::new()
3415/// # .with_native_roots()
3416/// # .unwrap()
3417/// # .https_or_http()
3418/// # .enable_http2()
3419/// # .build()
3420/// # );
3421/// # let mut hub = Adsense::new(client, auth);
3422/// // As the method needs a request, you would usually fill it with the desired information
3423/// // into the respective structure. Some of the parts shown here might not be applicable !
3424/// // Values shown here are possibly random and not representative !
3425/// let mut req = AdUnit::default();
3426///
3427/// // You can configure optional parameters by calling the respective setters at will, and
3428/// // execute the final call using `doit()`.
3429/// // Values shown here are possibly random and not representative !
3430/// let result = hub.accounts().adclients_adunits_patch(req, "name")
3431/// .update_mask(FieldMask::new::<&str>(&[]))
3432/// .doit().await;
3433/// # }
3434/// ```
3435pub struct AccountAdclientAdunitPatchCall<'a, C>
3436where
3437 C: 'a,
3438{
3439 hub: &'a Adsense<C>,
3440 _request: AdUnit,
3441 _name: String,
3442 _update_mask: Option<common::FieldMask>,
3443 _delegate: Option<&'a mut dyn common::Delegate>,
3444 _additional_params: HashMap<String, String>,
3445 _scopes: BTreeSet<String>,
3446}
3447
3448impl<'a, C> common::CallBuilder for AccountAdclientAdunitPatchCall<'a, C> {}
3449
3450impl<'a, C> AccountAdclientAdunitPatchCall<'a, C>
3451where
3452 C: common::Connector,
3453{
3454 /// Perform the operation you have build so far.
3455 pub async fn doit(mut self) -> common::Result<(common::Response, AdUnit)> {
3456 use std::borrow::Cow;
3457 use std::io::{Read, Seek};
3458
3459 use common::{url::Params, ToParts};
3460 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3461
3462 let mut dd = common::DefaultDelegate;
3463 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3464 dlg.begin(common::MethodInfo {
3465 id: "adsense.accounts.adclients.adunits.patch",
3466 http_method: hyper::Method::PATCH,
3467 });
3468
3469 for &field in ["alt", "name", "updateMask"].iter() {
3470 if self._additional_params.contains_key(field) {
3471 dlg.finished(false);
3472 return Err(common::Error::FieldClash(field));
3473 }
3474 }
3475
3476 let mut params = Params::with_capacity(5 + self._additional_params.len());
3477 params.push("name", self._name);
3478 if let Some(value) = self._update_mask.as_ref() {
3479 params.push("updateMask", value.to_string());
3480 }
3481
3482 params.extend(self._additional_params.iter());
3483
3484 params.push("alt", "json");
3485 let mut url = self.hub._base_url.clone() + "v2/{+name}";
3486 if self._scopes.is_empty() {
3487 self._scopes.insert(Scope::Full.as_ref().to_string());
3488 }
3489
3490 #[allow(clippy::single_element_loop)]
3491 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3492 url = params.uri_replacement(url, param_name, find_this, true);
3493 }
3494 {
3495 let to_remove = ["name"];
3496 params.remove_params(&to_remove);
3497 }
3498
3499 let url = params.parse_with_url(&url);
3500
3501 let mut json_mime_type = mime::APPLICATION_JSON;
3502 let mut request_value_reader = {
3503 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3504 common::remove_json_null_values(&mut value);
3505 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3506 serde_json::to_writer(&mut dst, &value).unwrap();
3507 dst
3508 };
3509 let request_size = request_value_reader
3510 .seek(std::io::SeekFrom::End(0))
3511 .unwrap();
3512 request_value_reader
3513 .seek(std::io::SeekFrom::Start(0))
3514 .unwrap();
3515
3516 loop {
3517 let token = match self
3518 .hub
3519 .auth
3520 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3521 .await
3522 {
3523 Ok(token) => token,
3524 Err(e) => match dlg.token(e) {
3525 Ok(token) => token,
3526 Err(e) => {
3527 dlg.finished(false);
3528 return Err(common::Error::MissingToken(e));
3529 }
3530 },
3531 };
3532 request_value_reader
3533 .seek(std::io::SeekFrom::Start(0))
3534 .unwrap();
3535 let mut req_result = {
3536 let client = &self.hub.client;
3537 dlg.pre_request();
3538 let mut req_builder = hyper::Request::builder()
3539 .method(hyper::Method::PATCH)
3540 .uri(url.as_str())
3541 .header(USER_AGENT, self.hub._user_agent.clone());
3542
3543 if let Some(token) = token.as_ref() {
3544 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3545 }
3546
3547 let request = req_builder
3548 .header(CONTENT_TYPE, json_mime_type.to_string())
3549 .header(CONTENT_LENGTH, request_size as u64)
3550 .body(common::to_body(
3551 request_value_reader.get_ref().clone().into(),
3552 ));
3553
3554 client.request(request.unwrap()).await
3555 };
3556
3557 match req_result {
3558 Err(err) => {
3559 if let common::Retry::After(d) = dlg.http_error(&err) {
3560 sleep(d).await;
3561 continue;
3562 }
3563 dlg.finished(false);
3564 return Err(common::Error::HttpError(err));
3565 }
3566 Ok(res) => {
3567 let (mut parts, body) = res.into_parts();
3568 let mut body = common::Body::new(body);
3569 if !parts.status.is_success() {
3570 let bytes = common::to_bytes(body).await.unwrap_or_default();
3571 let error = serde_json::from_str(&common::to_string(&bytes));
3572 let response = common::to_response(parts, bytes.into());
3573
3574 if let common::Retry::After(d) =
3575 dlg.http_failure(&response, error.as_ref().ok())
3576 {
3577 sleep(d).await;
3578 continue;
3579 }
3580
3581 dlg.finished(false);
3582
3583 return Err(match error {
3584 Ok(value) => common::Error::BadRequest(value),
3585 _ => common::Error::Failure(response),
3586 });
3587 }
3588 let response = {
3589 let bytes = common::to_bytes(body).await.unwrap_or_default();
3590 let encoded = common::to_string(&bytes);
3591 match serde_json::from_str(&encoded) {
3592 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3593 Err(error) => {
3594 dlg.response_json_decode_error(&encoded, &error);
3595 return Err(common::Error::JsonDecodeError(
3596 encoded.to_string(),
3597 error,
3598 ));
3599 }
3600 }
3601 };
3602
3603 dlg.finished(true);
3604 return Ok(response);
3605 }
3606 }
3607 }
3608 }
3609
3610 ///
3611 /// Sets the *request* property to the given value.
3612 ///
3613 /// Even though the property as already been set when instantiating this call,
3614 /// we provide this method for API completeness.
3615 pub fn request(mut self, new_value: AdUnit) -> AccountAdclientAdunitPatchCall<'a, C> {
3616 self._request = new_value;
3617 self
3618 }
3619 /// Output only. Resource name of the ad unit. Format: accounts/{account}/adclients/{adclient}/adunits/{adunit}
3620 ///
3621 /// Sets the *name* path property to the given value.
3622 ///
3623 /// Even though the property as already been set when instantiating this call,
3624 /// we provide this method for API completeness.
3625 pub fn name(mut self, new_value: &str) -> AccountAdclientAdunitPatchCall<'a, C> {
3626 self._name = new_value.to_string();
3627 self
3628 }
3629 /// The list of fields to update. If empty, a full update is performed.
3630 ///
3631 /// Sets the *update mask* query property to the given value.
3632 pub fn update_mask(
3633 mut self,
3634 new_value: common::FieldMask,
3635 ) -> AccountAdclientAdunitPatchCall<'a, C> {
3636 self._update_mask = Some(new_value);
3637 self
3638 }
3639 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3640 /// while executing the actual API request.
3641 ///
3642 /// ````text
3643 /// It should be used to handle progress information, and to implement a certain level of resilience.
3644 /// ````
3645 ///
3646 /// Sets the *delegate* property to the given value.
3647 pub fn delegate(
3648 mut self,
3649 new_value: &'a mut dyn common::Delegate,
3650 ) -> AccountAdclientAdunitPatchCall<'a, C> {
3651 self._delegate = Some(new_value);
3652 self
3653 }
3654
3655 /// Set any additional parameter of the query string used in the request.
3656 /// It should be used to set parameters which are not yet available through their own
3657 /// setters.
3658 ///
3659 /// Please note that this method must not be used to set any of the known parameters
3660 /// which have their own setter method. If done anyway, the request will fail.
3661 ///
3662 /// # Additional Parameters
3663 ///
3664 /// * *$.xgafv* (query-string) - V1 error format.
3665 /// * *access_token* (query-string) - OAuth access token.
3666 /// * *alt* (query-string) - Data format for response.
3667 /// * *callback* (query-string) - JSONP
3668 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3669 /// * *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.
3670 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3671 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3672 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3673 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3674 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3675 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientAdunitPatchCall<'a, C>
3676 where
3677 T: AsRef<str>,
3678 {
3679 self._additional_params
3680 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3681 self
3682 }
3683
3684 /// Identifies the authorization scope for the method you are building.
3685 ///
3686 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3687 /// [`Scope::Full`].
3688 ///
3689 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3690 /// tokens for more than one scope.
3691 ///
3692 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3693 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3694 /// sufficient, a read-write scope will do as well.
3695 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientAdunitPatchCall<'a, C>
3696 where
3697 St: AsRef<str>,
3698 {
3699 self._scopes.insert(String::from(scope.as_ref()));
3700 self
3701 }
3702 /// Identifies the authorization scope(s) for the method you are building.
3703 ///
3704 /// See [`Self::add_scope()`] for details.
3705 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientAdunitPatchCall<'a, C>
3706 where
3707 I: IntoIterator<Item = St>,
3708 St: AsRef<str>,
3709 {
3710 self._scopes
3711 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3712 self
3713 }
3714
3715 /// Removes all scopes, and no default scope will be used either.
3716 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3717 /// for details).
3718 pub fn clear_scopes(mut self) -> AccountAdclientAdunitPatchCall<'a, C> {
3719 self._scopes.clear();
3720 self
3721 }
3722}
3723
3724/// Creates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
3725///
3726/// A builder for the *adclients.customchannels.create* method supported by a *account* resource.
3727/// It is not used directly, but through a [`AccountMethods`] instance.
3728///
3729/// # Example
3730///
3731/// Instantiate a resource method builder
3732///
3733/// ```test_harness,no_run
3734/// # extern crate hyper;
3735/// # extern crate hyper_rustls;
3736/// # extern crate google_adsense2 as adsense2;
3737/// use adsense2::api::CustomChannel;
3738/// # async fn dox() {
3739/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3740///
3741/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3742/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3743/// # .with_native_roots()
3744/// # .unwrap()
3745/// # .https_only()
3746/// # .enable_http2()
3747/// # .build();
3748///
3749/// # let executor = hyper_util::rt::TokioExecutor::new();
3750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3751/// # secret,
3752/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3753/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3754/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3755/// # ),
3756/// # ).build().await.unwrap();
3757///
3758/// # let client = hyper_util::client::legacy::Client::builder(
3759/// # hyper_util::rt::TokioExecutor::new()
3760/// # )
3761/// # .build(
3762/// # hyper_rustls::HttpsConnectorBuilder::new()
3763/// # .with_native_roots()
3764/// # .unwrap()
3765/// # .https_or_http()
3766/// # .enable_http2()
3767/// # .build()
3768/// # );
3769/// # let mut hub = Adsense::new(client, auth);
3770/// // As the method needs a request, you would usually fill it with the desired information
3771/// // into the respective structure. Some of the parts shown here might not be applicable !
3772/// // Values shown here are possibly random and not representative !
3773/// let mut req = CustomChannel::default();
3774///
3775/// // You can configure optional parameters by calling the respective setters at will, and
3776/// // execute the final call using `doit()`.
3777/// // Values shown here are possibly random and not representative !
3778/// let result = hub.accounts().adclients_customchannels_create(req, "parent")
3779/// .doit().await;
3780/// # }
3781/// ```
3782pub struct AccountAdclientCustomchannelCreateCall<'a, C>
3783where
3784 C: 'a,
3785{
3786 hub: &'a Adsense<C>,
3787 _request: CustomChannel,
3788 _parent: String,
3789 _delegate: Option<&'a mut dyn common::Delegate>,
3790 _additional_params: HashMap<String, String>,
3791 _scopes: BTreeSet<String>,
3792}
3793
3794impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelCreateCall<'a, C> {}
3795
3796impl<'a, C> AccountAdclientCustomchannelCreateCall<'a, C>
3797where
3798 C: common::Connector,
3799{
3800 /// Perform the operation you have build so far.
3801 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
3802 use std::borrow::Cow;
3803 use std::io::{Read, Seek};
3804
3805 use common::{url::Params, ToParts};
3806 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3807
3808 let mut dd = common::DefaultDelegate;
3809 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3810 dlg.begin(common::MethodInfo {
3811 id: "adsense.accounts.adclients.customchannels.create",
3812 http_method: hyper::Method::POST,
3813 });
3814
3815 for &field in ["alt", "parent"].iter() {
3816 if self._additional_params.contains_key(field) {
3817 dlg.finished(false);
3818 return Err(common::Error::FieldClash(field));
3819 }
3820 }
3821
3822 let mut params = Params::with_capacity(4 + self._additional_params.len());
3823 params.push("parent", self._parent);
3824
3825 params.extend(self._additional_params.iter());
3826
3827 params.push("alt", "json");
3828 let mut url = self.hub._base_url.clone() + "v2/{+parent}/customchannels";
3829 if self._scopes.is_empty() {
3830 self._scopes.insert(Scope::Full.as_ref().to_string());
3831 }
3832
3833 #[allow(clippy::single_element_loop)]
3834 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3835 url = params.uri_replacement(url, param_name, find_this, true);
3836 }
3837 {
3838 let to_remove = ["parent"];
3839 params.remove_params(&to_remove);
3840 }
3841
3842 let url = params.parse_with_url(&url);
3843
3844 let mut json_mime_type = mime::APPLICATION_JSON;
3845 let mut request_value_reader = {
3846 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3847 common::remove_json_null_values(&mut value);
3848 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3849 serde_json::to_writer(&mut dst, &value).unwrap();
3850 dst
3851 };
3852 let request_size = request_value_reader
3853 .seek(std::io::SeekFrom::End(0))
3854 .unwrap();
3855 request_value_reader
3856 .seek(std::io::SeekFrom::Start(0))
3857 .unwrap();
3858
3859 loop {
3860 let token = match self
3861 .hub
3862 .auth
3863 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3864 .await
3865 {
3866 Ok(token) => token,
3867 Err(e) => match dlg.token(e) {
3868 Ok(token) => token,
3869 Err(e) => {
3870 dlg.finished(false);
3871 return Err(common::Error::MissingToken(e));
3872 }
3873 },
3874 };
3875 request_value_reader
3876 .seek(std::io::SeekFrom::Start(0))
3877 .unwrap();
3878 let mut req_result = {
3879 let client = &self.hub.client;
3880 dlg.pre_request();
3881 let mut req_builder = hyper::Request::builder()
3882 .method(hyper::Method::POST)
3883 .uri(url.as_str())
3884 .header(USER_AGENT, self.hub._user_agent.clone());
3885
3886 if let Some(token) = token.as_ref() {
3887 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3888 }
3889
3890 let request = req_builder
3891 .header(CONTENT_TYPE, json_mime_type.to_string())
3892 .header(CONTENT_LENGTH, request_size as u64)
3893 .body(common::to_body(
3894 request_value_reader.get_ref().clone().into(),
3895 ));
3896
3897 client.request(request.unwrap()).await
3898 };
3899
3900 match req_result {
3901 Err(err) => {
3902 if let common::Retry::After(d) = dlg.http_error(&err) {
3903 sleep(d).await;
3904 continue;
3905 }
3906 dlg.finished(false);
3907 return Err(common::Error::HttpError(err));
3908 }
3909 Ok(res) => {
3910 let (mut parts, body) = res.into_parts();
3911 let mut body = common::Body::new(body);
3912 if !parts.status.is_success() {
3913 let bytes = common::to_bytes(body).await.unwrap_or_default();
3914 let error = serde_json::from_str(&common::to_string(&bytes));
3915 let response = common::to_response(parts, bytes.into());
3916
3917 if let common::Retry::After(d) =
3918 dlg.http_failure(&response, error.as_ref().ok())
3919 {
3920 sleep(d).await;
3921 continue;
3922 }
3923
3924 dlg.finished(false);
3925
3926 return Err(match error {
3927 Ok(value) => common::Error::BadRequest(value),
3928 _ => common::Error::Failure(response),
3929 });
3930 }
3931 let response = {
3932 let bytes = common::to_bytes(body).await.unwrap_or_default();
3933 let encoded = common::to_string(&bytes);
3934 match serde_json::from_str(&encoded) {
3935 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3936 Err(error) => {
3937 dlg.response_json_decode_error(&encoded, &error);
3938 return Err(common::Error::JsonDecodeError(
3939 encoded.to_string(),
3940 error,
3941 ));
3942 }
3943 }
3944 };
3945
3946 dlg.finished(true);
3947 return Ok(response);
3948 }
3949 }
3950 }
3951 }
3952
3953 ///
3954 /// Sets the *request* property to the given value.
3955 ///
3956 /// Even though the property as already been set when instantiating this call,
3957 /// we provide this method for API completeness.
3958 pub fn request(
3959 mut self,
3960 new_value: CustomChannel,
3961 ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3962 self._request = new_value;
3963 self
3964 }
3965 /// Required. The ad client to create a custom channel under. Format: accounts/{account}/adclients/{adclient}
3966 ///
3967 /// Sets the *parent* path property to the given value.
3968 ///
3969 /// Even though the property as already been set when instantiating this call,
3970 /// we provide this method for API completeness.
3971 pub fn parent(mut self, new_value: &str) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3972 self._parent = new_value.to_string();
3973 self
3974 }
3975 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3976 /// while executing the actual API request.
3977 ///
3978 /// ````text
3979 /// It should be used to handle progress information, and to implement a certain level of resilience.
3980 /// ````
3981 ///
3982 /// Sets the *delegate* property to the given value.
3983 pub fn delegate(
3984 mut self,
3985 new_value: &'a mut dyn common::Delegate,
3986 ) -> AccountAdclientCustomchannelCreateCall<'a, C> {
3987 self._delegate = Some(new_value);
3988 self
3989 }
3990
3991 /// Set any additional parameter of the query string used in the request.
3992 /// It should be used to set parameters which are not yet available through their own
3993 /// setters.
3994 ///
3995 /// Please note that this method must not be used to set any of the known parameters
3996 /// which have their own setter method. If done anyway, the request will fail.
3997 ///
3998 /// # Additional Parameters
3999 ///
4000 /// * *$.xgafv* (query-string) - V1 error format.
4001 /// * *access_token* (query-string) - OAuth access token.
4002 /// * *alt* (query-string) - Data format for response.
4003 /// * *callback* (query-string) - JSONP
4004 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4005 /// * *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.
4006 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4007 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4008 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4009 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4010 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4011 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelCreateCall<'a, C>
4012 where
4013 T: AsRef<str>,
4014 {
4015 self._additional_params
4016 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4017 self
4018 }
4019
4020 /// Identifies the authorization scope for the method you are building.
4021 ///
4022 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4023 /// [`Scope::Full`].
4024 ///
4025 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4026 /// tokens for more than one scope.
4027 ///
4028 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4029 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4030 /// sufficient, a read-write scope will do as well.
4031 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelCreateCall<'a, C>
4032 where
4033 St: AsRef<str>,
4034 {
4035 self._scopes.insert(String::from(scope.as_ref()));
4036 self
4037 }
4038 /// Identifies the authorization scope(s) for the method you are building.
4039 ///
4040 /// See [`Self::add_scope()`] for details.
4041 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelCreateCall<'a, C>
4042 where
4043 I: IntoIterator<Item = St>,
4044 St: AsRef<str>,
4045 {
4046 self._scopes
4047 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4048 self
4049 }
4050
4051 /// Removes all scopes, and no default scope will be used either.
4052 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4053 /// for details).
4054 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelCreateCall<'a, C> {
4055 self._scopes.clear();
4056 self
4057 }
4058}
4059
4060/// Deletes a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
4061///
4062/// A builder for the *adclients.customchannels.delete* method supported by a *account* resource.
4063/// It is not used directly, but through a [`AccountMethods`] instance.
4064///
4065/// # Example
4066///
4067/// Instantiate a resource method builder
4068///
4069/// ```test_harness,no_run
4070/// # extern crate hyper;
4071/// # extern crate hyper_rustls;
4072/// # extern crate google_adsense2 as adsense2;
4073/// # async fn dox() {
4074/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4075///
4076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4078/// # .with_native_roots()
4079/// # .unwrap()
4080/// # .https_only()
4081/// # .enable_http2()
4082/// # .build();
4083///
4084/// # let executor = hyper_util::rt::TokioExecutor::new();
4085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4086/// # secret,
4087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4090/// # ),
4091/// # ).build().await.unwrap();
4092///
4093/// # let client = hyper_util::client::legacy::Client::builder(
4094/// # hyper_util::rt::TokioExecutor::new()
4095/// # )
4096/// # .build(
4097/// # hyper_rustls::HttpsConnectorBuilder::new()
4098/// # .with_native_roots()
4099/// # .unwrap()
4100/// # .https_or_http()
4101/// # .enable_http2()
4102/// # .build()
4103/// # );
4104/// # let mut hub = Adsense::new(client, auth);
4105/// // You can configure optional parameters by calling the respective setters at will, and
4106/// // execute the final call using `doit()`.
4107/// // Values shown here are possibly random and not representative !
4108/// let result = hub.accounts().adclients_customchannels_delete("name")
4109/// .doit().await;
4110/// # }
4111/// ```
4112pub struct AccountAdclientCustomchannelDeleteCall<'a, C>
4113where
4114 C: 'a,
4115{
4116 hub: &'a Adsense<C>,
4117 _name: String,
4118 _delegate: Option<&'a mut dyn common::Delegate>,
4119 _additional_params: HashMap<String, String>,
4120 _scopes: BTreeSet<String>,
4121}
4122
4123impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelDeleteCall<'a, C> {}
4124
4125impl<'a, C> AccountAdclientCustomchannelDeleteCall<'a, C>
4126where
4127 C: common::Connector,
4128{
4129 /// Perform the operation you have build so far.
4130 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4131 use std::borrow::Cow;
4132 use std::io::{Read, Seek};
4133
4134 use common::{url::Params, ToParts};
4135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4136
4137 let mut dd = common::DefaultDelegate;
4138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4139 dlg.begin(common::MethodInfo {
4140 id: "adsense.accounts.adclients.customchannels.delete",
4141 http_method: hyper::Method::DELETE,
4142 });
4143
4144 for &field in ["alt", "name"].iter() {
4145 if self._additional_params.contains_key(field) {
4146 dlg.finished(false);
4147 return Err(common::Error::FieldClash(field));
4148 }
4149 }
4150
4151 let mut params = Params::with_capacity(3 + self._additional_params.len());
4152 params.push("name", self._name);
4153
4154 params.extend(self._additional_params.iter());
4155
4156 params.push("alt", "json");
4157 let mut url = self.hub._base_url.clone() + "v2/{+name}";
4158 if self._scopes.is_empty() {
4159 self._scopes.insert(Scope::Full.as_ref().to_string());
4160 }
4161
4162 #[allow(clippy::single_element_loop)]
4163 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4164 url = params.uri_replacement(url, param_name, find_this, true);
4165 }
4166 {
4167 let to_remove = ["name"];
4168 params.remove_params(&to_remove);
4169 }
4170
4171 let url = params.parse_with_url(&url);
4172
4173 loop {
4174 let token = match self
4175 .hub
4176 .auth
4177 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4178 .await
4179 {
4180 Ok(token) => token,
4181 Err(e) => match dlg.token(e) {
4182 Ok(token) => token,
4183 Err(e) => {
4184 dlg.finished(false);
4185 return Err(common::Error::MissingToken(e));
4186 }
4187 },
4188 };
4189 let mut req_result = {
4190 let client = &self.hub.client;
4191 dlg.pre_request();
4192 let mut req_builder = hyper::Request::builder()
4193 .method(hyper::Method::DELETE)
4194 .uri(url.as_str())
4195 .header(USER_AGENT, self.hub._user_agent.clone());
4196
4197 if let Some(token) = token.as_ref() {
4198 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4199 }
4200
4201 let request = req_builder
4202 .header(CONTENT_LENGTH, 0_u64)
4203 .body(common::to_body::<String>(None));
4204
4205 client.request(request.unwrap()).await
4206 };
4207
4208 match req_result {
4209 Err(err) => {
4210 if let common::Retry::After(d) = dlg.http_error(&err) {
4211 sleep(d).await;
4212 continue;
4213 }
4214 dlg.finished(false);
4215 return Err(common::Error::HttpError(err));
4216 }
4217 Ok(res) => {
4218 let (mut parts, body) = res.into_parts();
4219 let mut body = common::Body::new(body);
4220 if !parts.status.is_success() {
4221 let bytes = common::to_bytes(body).await.unwrap_or_default();
4222 let error = serde_json::from_str(&common::to_string(&bytes));
4223 let response = common::to_response(parts, bytes.into());
4224
4225 if let common::Retry::After(d) =
4226 dlg.http_failure(&response, error.as_ref().ok())
4227 {
4228 sleep(d).await;
4229 continue;
4230 }
4231
4232 dlg.finished(false);
4233
4234 return Err(match error {
4235 Ok(value) => common::Error::BadRequest(value),
4236 _ => common::Error::Failure(response),
4237 });
4238 }
4239 let response = {
4240 let bytes = common::to_bytes(body).await.unwrap_or_default();
4241 let encoded = common::to_string(&bytes);
4242 match serde_json::from_str(&encoded) {
4243 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4244 Err(error) => {
4245 dlg.response_json_decode_error(&encoded, &error);
4246 return Err(common::Error::JsonDecodeError(
4247 encoded.to_string(),
4248 error,
4249 ));
4250 }
4251 }
4252 };
4253
4254 dlg.finished(true);
4255 return Ok(response);
4256 }
4257 }
4258 }
4259 }
4260
4261 /// Required. Name of the custom channel to delete. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
4262 ///
4263 /// Sets the *name* path property to the given value.
4264 ///
4265 /// Even though the property as already been set when instantiating this call,
4266 /// we provide this method for API completeness.
4267 pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4268 self._name = new_value.to_string();
4269 self
4270 }
4271 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4272 /// while executing the actual API request.
4273 ///
4274 /// ````text
4275 /// It should be used to handle progress information, and to implement a certain level of resilience.
4276 /// ````
4277 ///
4278 /// Sets the *delegate* property to the given value.
4279 pub fn delegate(
4280 mut self,
4281 new_value: &'a mut dyn common::Delegate,
4282 ) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4283 self._delegate = Some(new_value);
4284 self
4285 }
4286
4287 /// Set any additional parameter of the query string used in the request.
4288 /// It should be used to set parameters which are not yet available through their own
4289 /// setters.
4290 ///
4291 /// Please note that this method must not be used to set any of the known parameters
4292 /// which have their own setter method. If done anyway, the request will fail.
4293 ///
4294 /// # Additional Parameters
4295 ///
4296 /// * *$.xgafv* (query-string) - V1 error format.
4297 /// * *access_token* (query-string) - OAuth access token.
4298 /// * *alt* (query-string) - Data format for response.
4299 /// * *callback* (query-string) - JSONP
4300 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4301 /// * *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.
4302 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4303 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4304 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4305 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4306 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4307 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4308 where
4309 T: AsRef<str>,
4310 {
4311 self._additional_params
4312 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4313 self
4314 }
4315
4316 /// Identifies the authorization scope for the method you are building.
4317 ///
4318 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4319 /// [`Scope::Full`].
4320 ///
4321 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4322 /// tokens for more than one scope.
4323 ///
4324 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4325 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4326 /// sufficient, a read-write scope will do as well.
4327 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4328 where
4329 St: AsRef<str>,
4330 {
4331 self._scopes.insert(String::from(scope.as_ref()));
4332 self
4333 }
4334 /// Identifies the authorization scope(s) for the method you are building.
4335 ///
4336 /// See [`Self::add_scope()`] for details.
4337 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelDeleteCall<'a, C>
4338 where
4339 I: IntoIterator<Item = St>,
4340 St: AsRef<str>,
4341 {
4342 self._scopes
4343 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4344 self
4345 }
4346
4347 /// Removes all scopes, and no default scope will be used either.
4348 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4349 /// for details).
4350 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelDeleteCall<'a, C> {
4351 self._scopes.clear();
4352 self
4353 }
4354}
4355
4356/// Gets information about the selected custom channel.
4357///
4358/// A builder for the *adclients.customchannels.get* method supported by a *account* resource.
4359/// It is not used directly, but through a [`AccountMethods`] instance.
4360///
4361/// # Example
4362///
4363/// Instantiate a resource method builder
4364///
4365/// ```test_harness,no_run
4366/// # extern crate hyper;
4367/// # extern crate hyper_rustls;
4368/// # extern crate google_adsense2 as adsense2;
4369/// # async fn dox() {
4370/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4371///
4372/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4373/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4374/// # .with_native_roots()
4375/// # .unwrap()
4376/// # .https_only()
4377/// # .enable_http2()
4378/// # .build();
4379///
4380/// # let executor = hyper_util::rt::TokioExecutor::new();
4381/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4382/// # secret,
4383/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4384/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4385/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4386/// # ),
4387/// # ).build().await.unwrap();
4388///
4389/// # let client = hyper_util::client::legacy::Client::builder(
4390/// # hyper_util::rt::TokioExecutor::new()
4391/// # )
4392/// # .build(
4393/// # hyper_rustls::HttpsConnectorBuilder::new()
4394/// # .with_native_roots()
4395/// # .unwrap()
4396/// # .https_or_http()
4397/// # .enable_http2()
4398/// # .build()
4399/// # );
4400/// # let mut hub = Adsense::new(client, auth);
4401/// // You can configure optional parameters by calling the respective setters at will, and
4402/// // execute the final call using `doit()`.
4403/// // Values shown here are possibly random and not representative !
4404/// let result = hub.accounts().adclients_customchannels_get("name")
4405/// .doit().await;
4406/// # }
4407/// ```
4408pub struct AccountAdclientCustomchannelGetCall<'a, C>
4409where
4410 C: 'a,
4411{
4412 hub: &'a Adsense<C>,
4413 _name: String,
4414 _delegate: Option<&'a mut dyn common::Delegate>,
4415 _additional_params: HashMap<String, String>,
4416 _scopes: BTreeSet<String>,
4417}
4418
4419impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelGetCall<'a, C> {}
4420
4421impl<'a, C> AccountAdclientCustomchannelGetCall<'a, C>
4422where
4423 C: common::Connector,
4424{
4425 /// Perform the operation you have build so far.
4426 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
4427 use std::borrow::Cow;
4428 use std::io::{Read, Seek};
4429
4430 use common::{url::Params, ToParts};
4431 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4432
4433 let mut dd = common::DefaultDelegate;
4434 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4435 dlg.begin(common::MethodInfo {
4436 id: "adsense.accounts.adclients.customchannels.get",
4437 http_method: hyper::Method::GET,
4438 });
4439
4440 for &field in ["alt", "name"].iter() {
4441 if self._additional_params.contains_key(field) {
4442 dlg.finished(false);
4443 return Err(common::Error::FieldClash(field));
4444 }
4445 }
4446
4447 let mut params = Params::with_capacity(3 + self._additional_params.len());
4448 params.push("name", self._name);
4449
4450 params.extend(self._additional_params.iter());
4451
4452 params.push("alt", "json");
4453 let mut url = self.hub._base_url.clone() + "v2/{+name}";
4454 if self._scopes.is_empty() {
4455 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4456 }
4457
4458 #[allow(clippy::single_element_loop)]
4459 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4460 url = params.uri_replacement(url, param_name, find_this, true);
4461 }
4462 {
4463 let to_remove = ["name"];
4464 params.remove_params(&to_remove);
4465 }
4466
4467 let url = params.parse_with_url(&url);
4468
4469 loop {
4470 let token = match self
4471 .hub
4472 .auth
4473 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4474 .await
4475 {
4476 Ok(token) => token,
4477 Err(e) => match dlg.token(e) {
4478 Ok(token) => token,
4479 Err(e) => {
4480 dlg.finished(false);
4481 return Err(common::Error::MissingToken(e));
4482 }
4483 },
4484 };
4485 let mut req_result = {
4486 let client = &self.hub.client;
4487 dlg.pre_request();
4488 let mut req_builder = hyper::Request::builder()
4489 .method(hyper::Method::GET)
4490 .uri(url.as_str())
4491 .header(USER_AGENT, self.hub._user_agent.clone());
4492
4493 if let Some(token) = token.as_ref() {
4494 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4495 }
4496
4497 let request = req_builder
4498 .header(CONTENT_LENGTH, 0_u64)
4499 .body(common::to_body::<String>(None));
4500
4501 client.request(request.unwrap()).await
4502 };
4503
4504 match req_result {
4505 Err(err) => {
4506 if let common::Retry::After(d) = dlg.http_error(&err) {
4507 sleep(d).await;
4508 continue;
4509 }
4510 dlg.finished(false);
4511 return Err(common::Error::HttpError(err));
4512 }
4513 Ok(res) => {
4514 let (mut parts, body) = res.into_parts();
4515 let mut body = common::Body::new(body);
4516 if !parts.status.is_success() {
4517 let bytes = common::to_bytes(body).await.unwrap_or_default();
4518 let error = serde_json::from_str(&common::to_string(&bytes));
4519 let response = common::to_response(parts, bytes.into());
4520
4521 if let common::Retry::After(d) =
4522 dlg.http_failure(&response, error.as_ref().ok())
4523 {
4524 sleep(d).await;
4525 continue;
4526 }
4527
4528 dlg.finished(false);
4529
4530 return Err(match error {
4531 Ok(value) => common::Error::BadRequest(value),
4532 _ => common::Error::Failure(response),
4533 });
4534 }
4535 let response = {
4536 let bytes = common::to_bytes(body).await.unwrap_or_default();
4537 let encoded = common::to_string(&bytes);
4538 match serde_json::from_str(&encoded) {
4539 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4540 Err(error) => {
4541 dlg.response_json_decode_error(&encoded, &error);
4542 return Err(common::Error::JsonDecodeError(
4543 encoded.to_string(),
4544 error,
4545 ));
4546 }
4547 }
4548 };
4549
4550 dlg.finished(true);
4551 return Ok(response);
4552 }
4553 }
4554 }
4555 }
4556
4557 /// Required. Name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
4558 ///
4559 /// Sets the *name* path property to the given value.
4560 ///
4561 /// Even though the property as already been set when instantiating this call,
4562 /// we provide this method for API completeness.
4563 pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelGetCall<'a, C> {
4564 self._name = new_value.to_string();
4565 self
4566 }
4567 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4568 /// while executing the actual API request.
4569 ///
4570 /// ````text
4571 /// It should be used to handle progress information, and to implement a certain level of resilience.
4572 /// ````
4573 ///
4574 /// Sets the *delegate* property to the given value.
4575 pub fn delegate(
4576 mut self,
4577 new_value: &'a mut dyn common::Delegate,
4578 ) -> AccountAdclientCustomchannelGetCall<'a, C> {
4579 self._delegate = Some(new_value);
4580 self
4581 }
4582
4583 /// Set any additional parameter of the query string used in the request.
4584 /// It should be used to set parameters which are not yet available through their own
4585 /// setters.
4586 ///
4587 /// Please note that this method must not be used to set any of the known parameters
4588 /// which have their own setter method. If done anyway, the request will fail.
4589 ///
4590 /// # Additional Parameters
4591 ///
4592 /// * *$.xgafv* (query-string) - V1 error format.
4593 /// * *access_token* (query-string) - OAuth access token.
4594 /// * *alt* (query-string) - Data format for response.
4595 /// * *callback* (query-string) - JSONP
4596 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4597 /// * *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.
4598 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4599 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4600 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4601 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4602 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4603 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelGetCall<'a, C>
4604 where
4605 T: AsRef<str>,
4606 {
4607 self._additional_params
4608 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4609 self
4610 }
4611
4612 /// Identifies the authorization scope for the method you are building.
4613 ///
4614 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4615 /// [`Scope::Readonly`].
4616 ///
4617 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4618 /// tokens for more than one scope.
4619 ///
4620 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4621 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4622 /// sufficient, a read-write scope will do as well.
4623 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelGetCall<'a, C>
4624 where
4625 St: AsRef<str>,
4626 {
4627 self._scopes.insert(String::from(scope.as_ref()));
4628 self
4629 }
4630 /// Identifies the authorization scope(s) for the method you are building.
4631 ///
4632 /// See [`Self::add_scope()`] for details.
4633 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelGetCall<'a, C>
4634 where
4635 I: IntoIterator<Item = St>,
4636 St: AsRef<str>,
4637 {
4638 self._scopes
4639 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4640 self
4641 }
4642
4643 /// Removes all scopes, and no default scope will be used either.
4644 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4645 /// for details).
4646 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelGetCall<'a, C> {
4647 self._scopes.clear();
4648 self
4649 }
4650}
4651
4652/// Lists all the custom channels available in an ad client.
4653///
4654/// A builder for the *adclients.customchannels.list* method supported by a *account* resource.
4655/// It is not used directly, but through a [`AccountMethods`] instance.
4656///
4657/// # Example
4658///
4659/// Instantiate a resource method builder
4660///
4661/// ```test_harness,no_run
4662/// # extern crate hyper;
4663/// # extern crate hyper_rustls;
4664/// # extern crate google_adsense2 as adsense2;
4665/// # async fn dox() {
4666/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4667///
4668/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4669/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4670/// # .with_native_roots()
4671/// # .unwrap()
4672/// # .https_only()
4673/// # .enable_http2()
4674/// # .build();
4675///
4676/// # let executor = hyper_util::rt::TokioExecutor::new();
4677/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4678/// # secret,
4679/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4680/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4681/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4682/// # ),
4683/// # ).build().await.unwrap();
4684///
4685/// # let client = hyper_util::client::legacy::Client::builder(
4686/// # hyper_util::rt::TokioExecutor::new()
4687/// # )
4688/// # .build(
4689/// # hyper_rustls::HttpsConnectorBuilder::new()
4690/// # .with_native_roots()
4691/// # .unwrap()
4692/// # .https_or_http()
4693/// # .enable_http2()
4694/// # .build()
4695/// # );
4696/// # let mut hub = Adsense::new(client, auth);
4697/// // You can configure optional parameters by calling the respective setters at will, and
4698/// // execute the final call using `doit()`.
4699/// // Values shown here are possibly random and not representative !
4700/// let result = hub.accounts().adclients_customchannels_list("parent")
4701/// .page_token("Stet")
4702/// .page_size(-99)
4703/// .doit().await;
4704/// # }
4705/// ```
4706pub struct AccountAdclientCustomchannelListCall<'a, C>
4707where
4708 C: 'a,
4709{
4710 hub: &'a Adsense<C>,
4711 _parent: String,
4712 _page_token: Option<String>,
4713 _page_size: Option<i32>,
4714 _delegate: Option<&'a mut dyn common::Delegate>,
4715 _additional_params: HashMap<String, String>,
4716 _scopes: BTreeSet<String>,
4717}
4718
4719impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelListCall<'a, C> {}
4720
4721impl<'a, C> AccountAdclientCustomchannelListCall<'a, C>
4722where
4723 C: common::Connector,
4724{
4725 /// Perform the operation you have build so far.
4726 pub async fn doit(mut self) -> common::Result<(common::Response, ListCustomChannelsResponse)> {
4727 use std::borrow::Cow;
4728 use std::io::{Read, Seek};
4729
4730 use common::{url::Params, ToParts};
4731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4732
4733 let mut dd = common::DefaultDelegate;
4734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4735 dlg.begin(common::MethodInfo {
4736 id: "adsense.accounts.adclients.customchannels.list",
4737 http_method: hyper::Method::GET,
4738 });
4739
4740 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4741 if self._additional_params.contains_key(field) {
4742 dlg.finished(false);
4743 return Err(common::Error::FieldClash(field));
4744 }
4745 }
4746
4747 let mut params = Params::with_capacity(5 + self._additional_params.len());
4748 params.push("parent", self._parent);
4749 if let Some(value) = self._page_token.as_ref() {
4750 params.push("pageToken", value);
4751 }
4752 if let Some(value) = self._page_size.as_ref() {
4753 params.push("pageSize", value.to_string());
4754 }
4755
4756 params.extend(self._additional_params.iter());
4757
4758 params.push("alt", "json");
4759 let mut url = self.hub._base_url.clone() + "v2/{+parent}/customchannels";
4760 if self._scopes.is_empty() {
4761 self._scopes.insert(Scope::Readonly.as_ref().to_string());
4762 }
4763
4764 #[allow(clippy::single_element_loop)]
4765 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4766 url = params.uri_replacement(url, param_name, find_this, true);
4767 }
4768 {
4769 let to_remove = ["parent"];
4770 params.remove_params(&to_remove);
4771 }
4772
4773 let url = params.parse_with_url(&url);
4774
4775 loop {
4776 let token = match self
4777 .hub
4778 .auth
4779 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4780 .await
4781 {
4782 Ok(token) => token,
4783 Err(e) => match dlg.token(e) {
4784 Ok(token) => token,
4785 Err(e) => {
4786 dlg.finished(false);
4787 return Err(common::Error::MissingToken(e));
4788 }
4789 },
4790 };
4791 let mut req_result = {
4792 let client = &self.hub.client;
4793 dlg.pre_request();
4794 let mut req_builder = hyper::Request::builder()
4795 .method(hyper::Method::GET)
4796 .uri(url.as_str())
4797 .header(USER_AGENT, self.hub._user_agent.clone());
4798
4799 if let Some(token) = token.as_ref() {
4800 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4801 }
4802
4803 let request = req_builder
4804 .header(CONTENT_LENGTH, 0_u64)
4805 .body(common::to_body::<String>(None));
4806
4807 client.request(request.unwrap()).await
4808 };
4809
4810 match req_result {
4811 Err(err) => {
4812 if let common::Retry::After(d) = dlg.http_error(&err) {
4813 sleep(d).await;
4814 continue;
4815 }
4816 dlg.finished(false);
4817 return Err(common::Error::HttpError(err));
4818 }
4819 Ok(res) => {
4820 let (mut parts, body) = res.into_parts();
4821 let mut body = common::Body::new(body);
4822 if !parts.status.is_success() {
4823 let bytes = common::to_bytes(body).await.unwrap_or_default();
4824 let error = serde_json::from_str(&common::to_string(&bytes));
4825 let response = common::to_response(parts, bytes.into());
4826
4827 if let common::Retry::After(d) =
4828 dlg.http_failure(&response, error.as_ref().ok())
4829 {
4830 sleep(d).await;
4831 continue;
4832 }
4833
4834 dlg.finished(false);
4835
4836 return Err(match error {
4837 Ok(value) => common::Error::BadRequest(value),
4838 _ => common::Error::Failure(response),
4839 });
4840 }
4841 let response = {
4842 let bytes = common::to_bytes(body).await.unwrap_or_default();
4843 let encoded = common::to_string(&bytes);
4844 match serde_json::from_str(&encoded) {
4845 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4846 Err(error) => {
4847 dlg.response_json_decode_error(&encoded, &error);
4848 return Err(common::Error::JsonDecodeError(
4849 encoded.to_string(),
4850 error,
4851 ));
4852 }
4853 }
4854 };
4855
4856 dlg.finished(true);
4857 return Ok(response);
4858 }
4859 }
4860 }
4861 }
4862
4863 /// Required. The ad client which owns the collection of custom channels. Format: accounts/{account}/adclients/{adclient}
4864 ///
4865 /// Sets the *parent* path property to the given value.
4866 ///
4867 /// Even though the property as already been set when instantiating this call,
4868 /// we provide this method for API completeness.
4869 pub fn parent(mut self, new_value: &str) -> AccountAdclientCustomchannelListCall<'a, C> {
4870 self._parent = new_value.to_string();
4871 self
4872 }
4873 /// A page token, received from a previous `ListCustomChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCustomChannels` must match the call that provided the page token.
4874 ///
4875 /// Sets the *page token* query property to the given value.
4876 pub fn page_token(mut self, new_value: &str) -> AccountAdclientCustomchannelListCall<'a, C> {
4877 self._page_token = Some(new_value.to_string());
4878 self
4879 }
4880 /// The maximum number of custom channels to include in the response, used for paging. If unspecified, at most 10000 custom channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
4881 ///
4882 /// Sets the *page size* query property to the given value.
4883 pub fn page_size(mut self, new_value: i32) -> AccountAdclientCustomchannelListCall<'a, C> {
4884 self._page_size = Some(new_value);
4885 self
4886 }
4887 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4888 /// while executing the actual API request.
4889 ///
4890 /// ````text
4891 /// It should be used to handle progress information, and to implement a certain level of resilience.
4892 /// ````
4893 ///
4894 /// Sets the *delegate* property to the given value.
4895 pub fn delegate(
4896 mut self,
4897 new_value: &'a mut dyn common::Delegate,
4898 ) -> AccountAdclientCustomchannelListCall<'a, C> {
4899 self._delegate = Some(new_value);
4900 self
4901 }
4902
4903 /// Set any additional parameter of the query string used in the request.
4904 /// It should be used to set parameters which are not yet available through their own
4905 /// setters.
4906 ///
4907 /// Please note that this method must not be used to set any of the known parameters
4908 /// which have their own setter method. If done anyway, the request will fail.
4909 ///
4910 /// # Additional Parameters
4911 ///
4912 /// * *$.xgafv* (query-string) - V1 error format.
4913 /// * *access_token* (query-string) - OAuth access token.
4914 /// * *alt* (query-string) - Data format for response.
4915 /// * *callback* (query-string) - JSONP
4916 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4917 /// * *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.
4918 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4919 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4920 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4921 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4922 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4923 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelListCall<'a, C>
4924 where
4925 T: AsRef<str>,
4926 {
4927 self._additional_params
4928 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4929 self
4930 }
4931
4932 /// Identifies the authorization scope for the method you are building.
4933 ///
4934 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4935 /// [`Scope::Readonly`].
4936 ///
4937 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4938 /// tokens for more than one scope.
4939 ///
4940 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4941 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4942 /// sufficient, a read-write scope will do as well.
4943 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelListCall<'a, C>
4944 where
4945 St: AsRef<str>,
4946 {
4947 self._scopes.insert(String::from(scope.as_ref()));
4948 self
4949 }
4950 /// Identifies the authorization scope(s) for the method you are building.
4951 ///
4952 /// See [`Self::add_scope()`] for details.
4953 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelListCall<'a, C>
4954 where
4955 I: IntoIterator<Item = St>,
4956 St: AsRef<str>,
4957 {
4958 self._scopes
4959 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4960 self
4961 }
4962
4963 /// Removes all scopes, and no default scope will be used either.
4964 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4965 /// for details).
4966 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelListCall<'a, C> {
4967 self._scopes.clear();
4968 self
4969 }
4970}
4971
4972/// Lists all the ad units available for a custom channel.
4973///
4974/// A builder for the *adclients.customchannels.listLinkedAdUnits* method supported by a *account* resource.
4975/// It is not used directly, but through a [`AccountMethods`] instance.
4976///
4977/// # Example
4978///
4979/// Instantiate a resource method builder
4980///
4981/// ```test_harness,no_run
4982/// # extern crate hyper;
4983/// # extern crate hyper_rustls;
4984/// # extern crate google_adsense2 as adsense2;
4985/// # async fn dox() {
4986/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4987///
4988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4990/// # .with_native_roots()
4991/// # .unwrap()
4992/// # .https_only()
4993/// # .enable_http2()
4994/// # .build();
4995///
4996/// # let executor = hyper_util::rt::TokioExecutor::new();
4997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4998/// # secret,
4999/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5000/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5001/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5002/// # ),
5003/// # ).build().await.unwrap();
5004///
5005/// # let client = hyper_util::client::legacy::Client::builder(
5006/// # hyper_util::rt::TokioExecutor::new()
5007/// # )
5008/// # .build(
5009/// # hyper_rustls::HttpsConnectorBuilder::new()
5010/// # .with_native_roots()
5011/// # .unwrap()
5012/// # .https_or_http()
5013/// # .enable_http2()
5014/// # .build()
5015/// # );
5016/// # let mut hub = Adsense::new(client, auth);
5017/// // You can configure optional parameters by calling the respective setters at will, and
5018/// // execute the final call using `doit()`.
5019/// // Values shown here are possibly random and not representative !
5020/// let result = hub.accounts().adclients_customchannels_list_linked_ad_units("parent")
5021/// .page_token("vero")
5022/// .page_size(-76)
5023/// .doit().await;
5024/// # }
5025/// ```
5026pub struct AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5027where
5028 C: 'a,
5029{
5030 hub: &'a Adsense<C>,
5031 _parent: String,
5032 _page_token: Option<String>,
5033 _page_size: Option<i32>,
5034 _delegate: Option<&'a mut dyn common::Delegate>,
5035 _additional_params: HashMap<String, String>,
5036 _scopes: BTreeSet<String>,
5037}
5038
5039impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {}
5040
5041impl<'a, C> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5042where
5043 C: common::Connector,
5044{
5045 /// Perform the operation you have build so far.
5046 pub async fn doit(mut self) -> common::Result<(common::Response, ListLinkedAdUnitsResponse)> {
5047 use std::borrow::Cow;
5048 use std::io::{Read, Seek};
5049
5050 use common::{url::Params, ToParts};
5051 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5052
5053 let mut dd = common::DefaultDelegate;
5054 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5055 dlg.begin(common::MethodInfo {
5056 id: "adsense.accounts.adclients.customchannels.listLinkedAdUnits",
5057 http_method: hyper::Method::GET,
5058 });
5059
5060 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5061 if self._additional_params.contains_key(field) {
5062 dlg.finished(false);
5063 return Err(common::Error::FieldClash(field));
5064 }
5065 }
5066
5067 let mut params = Params::with_capacity(5 + self._additional_params.len());
5068 params.push("parent", self._parent);
5069 if let Some(value) = self._page_token.as_ref() {
5070 params.push("pageToken", value);
5071 }
5072 if let Some(value) = self._page_size.as_ref() {
5073 params.push("pageSize", value.to_string());
5074 }
5075
5076 params.extend(self._additional_params.iter());
5077
5078 params.push("alt", "json");
5079 let mut url = self.hub._base_url.clone() + "v2/{+parent}:listLinkedAdUnits";
5080 if self._scopes.is_empty() {
5081 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5082 }
5083
5084 #[allow(clippy::single_element_loop)]
5085 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5086 url = params.uri_replacement(url, param_name, find_this, true);
5087 }
5088 {
5089 let to_remove = ["parent"];
5090 params.remove_params(&to_remove);
5091 }
5092
5093 let url = params.parse_with_url(&url);
5094
5095 loop {
5096 let token = match self
5097 .hub
5098 .auth
5099 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5100 .await
5101 {
5102 Ok(token) => token,
5103 Err(e) => match dlg.token(e) {
5104 Ok(token) => token,
5105 Err(e) => {
5106 dlg.finished(false);
5107 return Err(common::Error::MissingToken(e));
5108 }
5109 },
5110 };
5111 let mut req_result = {
5112 let client = &self.hub.client;
5113 dlg.pre_request();
5114 let mut req_builder = hyper::Request::builder()
5115 .method(hyper::Method::GET)
5116 .uri(url.as_str())
5117 .header(USER_AGENT, self.hub._user_agent.clone());
5118
5119 if let Some(token) = token.as_ref() {
5120 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5121 }
5122
5123 let request = req_builder
5124 .header(CONTENT_LENGTH, 0_u64)
5125 .body(common::to_body::<String>(None));
5126
5127 client.request(request.unwrap()).await
5128 };
5129
5130 match req_result {
5131 Err(err) => {
5132 if let common::Retry::After(d) = dlg.http_error(&err) {
5133 sleep(d).await;
5134 continue;
5135 }
5136 dlg.finished(false);
5137 return Err(common::Error::HttpError(err));
5138 }
5139 Ok(res) => {
5140 let (mut parts, body) = res.into_parts();
5141 let mut body = common::Body::new(body);
5142 if !parts.status.is_success() {
5143 let bytes = common::to_bytes(body).await.unwrap_or_default();
5144 let error = serde_json::from_str(&common::to_string(&bytes));
5145 let response = common::to_response(parts, bytes.into());
5146
5147 if let common::Retry::After(d) =
5148 dlg.http_failure(&response, error.as_ref().ok())
5149 {
5150 sleep(d).await;
5151 continue;
5152 }
5153
5154 dlg.finished(false);
5155
5156 return Err(match error {
5157 Ok(value) => common::Error::BadRequest(value),
5158 _ => common::Error::Failure(response),
5159 });
5160 }
5161 let response = {
5162 let bytes = common::to_bytes(body).await.unwrap_or_default();
5163 let encoded = common::to_string(&bytes);
5164 match serde_json::from_str(&encoded) {
5165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5166 Err(error) => {
5167 dlg.response_json_decode_error(&encoded, &error);
5168 return Err(common::Error::JsonDecodeError(
5169 encoded.to_string(),
5170 error,
5171 ));
5172 }
5173 }
5174 };
5175
5176 dlg.finished(true);
5177 return Ok(response);
5178 }
5179 }
5180 }
5181 }
5182
5183 /// Required. The custom channel which owns the collection of ad units. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
5184 ///
5185 /// Sets the *parent* path property to the given value.
5186 ///
5187 /// Even though the property as already been set when instantiating this call,
5188 /// we provide this method for API completeness.
5189 pub fn parent(
5190 mut self,
5191 new_value: &str,
5192 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5193 self._parent = new_value.to_string();
5194 self
5195 }
5196 /// A page token, received from a previous `ListLinkedAdUnits` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListLinkedAdUnits` must match the call that provided the page token.
5197 ///
5198 /// Sets the *page token* query property to the given value.
5199 pub fn page_token(
5200 mut self,
5201 new_value: &str,
5202 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5203 self._page_token = Some(new_value.to_string());
5204 self
5205 }
5206 /// The maximum number of ad units to include in the response, used for paging. If unspecified, at most 10000 ad units will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
5207 ///
5208 /// Sets the *page size* query property to the given value.
5209 pub fn page_size(
5210 mut self,
5211 new_value: i32,
5212 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5213 self._page_size = Some(new_value);
5214 self
5215 }
5216 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5217 /// while executing the actual API request.
5218 ///
5219 /// ````text
5220 /// It should be used to handle progress information, and to implement a certain level of resilience.
5221 /// ````
5222 ///
5223 /// Sets the *delegate* property to the given value.
5224 pub fn delegate(
5225 mut self,
5226 new_value: &'a mut dyn common::Delegate,
5227 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5228 self._delegate = Some(new_value);
5229 self
5230 }
5231
5232 /// Set any additional parameter of the query string used in the request.
5233 /// It should be used to set parameters which are not yet available through their own
5234 /// setters.
5235 ///
5236 /// Please note that this method must not be used to set any of the known parameters
5237 /// which have their own setter method. If done anyway, the request will fail.
5238 ///
5239 /// # Additional Parameters
5240 ///
5241 /// * *$.xgafv* (query-string) - V1 error format.
5242 /// * *access_token* (query-string) - OAuth access token.
5243 /// * *alt* (query-string) - Data format for response.
5244 /// * *callback* (query-string) - JSONP
5245 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5246 /// * *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.
5247 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5248 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5249 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5250 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5251 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5252 pub fn param<T>(
5253 mut self,
5254 name: T,
5255 value: T,
5256 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5257 where
5258 T: AsRef<str>,
5259 {
5260 self._additional_params
5261 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5262 self
5263 }
5264
5265 /// Identifies the authorization scope for the method you are building.
5266 ///
5267 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5268 /// [`Scope::Readonly`].
5269 ///
5270 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5271 /// tokens for more than one scope.
5272 ///
5273 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5274 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5275 /// sufficient, a read-write scope will do as well.
5276 pub fn add_scope<St>(
5277 mut self,
5278 scope: St,
5279 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5280 where
5281 St: AsRef<str>,
5282 {
5283 self._scopes.insert(String::from(scope.as_ref()));
5284 self
5285 }
5286 /// Identifies the authorization scope(s) for the method you are building.
5287 ///
5288 /// See [`Self::add_scope()`] for details.
5289 pub fn add_scopes<I, St>(
5290 mut self,
5291 scopes: I,
5292 ) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C>
5293 where
5294 I: IntoIterator<Item = St>,
5295 St: AsRef<str>,
5296 {
5297 self._scopes
5298 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5299 self
5300 }
5301
5302 /// Removes all scopes, and no default scope will be used either.
5303 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5304 /// for details).
5305 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelListLinkedAdUnitCall<'a, C> {
5306 self._scopes.clear();
5307 self
5308 }
5309}
5310
5311/// Updates a custom channel. This method can be called only by a restricted set of projects, which are usually owned by [AdSense for Platforms](https://developers.google.com/adsense/platforms/) publishers. Contact your account manager if you need to use this method.
5312///
5313/// A builder for the *adclients.customchannels.patch* method supported by a *account* resource.
5314/// It is not used directly, but through a [`AccountMethods`] instance.
5315///
5316/// # Example
5317///
5318/// Instantiate a resource method builder
5319///
5320/// ```test_harness,no_run
5321/// # extern crate hyper;
5322/// # extern crate hyper_rustls;
5323/// # extern crate google_adsense2 as adsense2;
5324/// use adsense2::api::CustomChannel;
5325/// # async fn dox() {
5326/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5327///
5328/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5329/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5330/// # .with_native_roots()
5331/// # .unwrap()
5332/// # .https_only()
5333/// # .enable_http2()
5334/// # .build();
5335///
5336/// # let executor = hyper_util::rt::TokioExecutor::new();
5337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5338/// # secret,
5339/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5340/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5341/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5342/// # ),
5343/// # ).build().await.unwrap();
5344///
5345/// # let client = hyper_util::client::legacy::Client::builder(
5346/// # hyper_util::rt::TokioExecutor::new()
5347/// # )
5348/// # .build(
5349/// # hyper_rustls::HttpsConnectorBuilder::new()
5350/// # .with_native_roots()
5351/// # .unwrap()
5352/// # .https_or_http()
5353/// # .enable_http2()
5354/// # .build()
5355/// # );
5356/// # let mut hub = Adsense::new(client, auth);
5357/// // As the method needs a request, you would usually fill it with the desired information
5358/// // into the respective structure. Some of the parts shown here might not be applicable !
5359/// // Values shown here are possibly random and not representative !
5360/// let mut req = CustomChannel::default();
5361///
5362/// // You can configure optional parameters by calling the respective setters at will, and
5363/// // execute the final call using `doit()`.
5364/// // Values shown here are possibly random and not representative !
5365/// let result = hub.accounts().adclients_customchannels_patch(req, "name")
5366/// .update_mask(FieldMask::new::<&str>(&[]))
5367/// .doit().await;
5368/// # }
5369/// ```
5370pub struct AccountAdclientCustomchannelPatchCall<'a, C>
5371where
5372 C: 'a,
5373{
5374 hub: &'a Adsense<C>,
5375 _request: CustomChannel,
5376 _name: String,
5377 _update_mask: Option<common::FieldMask>,
5378 _delegate: Option<&'a mut dyn common::Delegate>,
5379 _additional_params: HashMap<String, String>,
5380 _scopes: BTreeSet<String>,
5381}
5382
5383impl<'a, C> common::CallBuilder for AccountAdclientCustomchannelPatchCall<'a, C> {}
5384
5385impl<'a, C> AccountAdclientCustomchannelPatchCall<'a, C>
5386where
5387 C: common::Connector,
5388{
5389 /// Perform the operation you have build so far.
5390 pub async fn doit(mut self) -> common::Result<(common::Response, CustomChannel)> {
5391 use std::borrow::Cow;
5392 use std::io::{Read, Seek};
5393
5394 use common::{url::Params, ToParts};
5395 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5396
5397 let mut dd = common::DefaultDelegate;
5398 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5399 dlg.begin(common::MethodInfo {
5400 id: "adsense.accounts.adclients.customchannels.patch",
5401 http_method: hyper::Method::PATCH,
5402 });
5403
5404 for &field in ["alt", "name", "updateMask"].iter() {
5405 if self._additional_params.contains_key(field) {
5406 dlg.finished(false);
5407 return Err(common::Error::FieldClash(field));
5408 }
5409 }
5410
5411 let mut params = Params::with_capacity(5 + self._additional_params.len());
5412 params.push("name", self._name);
5413 if let Some(value) = self._update_mask.as_ref() {
5414 params.push("updateMask", value.to_string());
5415 }
5416
5417 params.extend(self._additional_params.iter());
5418
5419 params.push("alt", "json");
5420 let mut url = self.hub._base_url.clone() + "v2/{+name}";
5421 if self._scopes.is_empty() {
5422 self._scopes.insert(Scope::Full.as_ref().to_string());
5423 }
5424
5425 #[allow(clippy::single_element_loop)]
5426 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5427 url = params.uri_replacement(url, param_name, find_this, true);
5428 }
5429 {
5430 let to_remove = ["name"];
5431 params.remove_params(&to_remove);
5432 }
5433
5434 let url = params.parse_with_url(&url);
5435
5436 let mut json_mime_type = mime::APPLICATION_JSON;
5437 let mut request_value_reader = {
5438 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5439 common::remove_json_null_values(&mut value);
5440 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5441 serde_json::to_writer(&mut dst, &value).unwrap();
5442 dst
5443 };
5444 let request_size = request_value_reader
5445 .seek(std::io::SeekFrom::End(0))
5446 .unwrap();
5447 request_value_reader
5448 .seek(std::io::SeekFrom::Start(0))
5449 .unwrap();
5450
5451 loop {
5452 let token = match self
5453 .hub
5454 .auth
5455 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5456 .await
5457 {
5458 Ok(token) => token,
5459 Err(e) => match dlg.token(e) {
5460 Ok(token) => token,
5461 Err(e) => {
5462 dlg.finished(false);
5463 return Err(common::Error::MissingToken(e));
5464 }
5465 },
5466 };
5467 request_value_reader
5468 .seek(std::io::SeekFrom::Start(0))
5469 .unwrap();
5470 let mut req_result = {
5471 let client = &self.hub.client;
5472 dlg.pre_request();
5473 let mut req_builder = hyper::Request::builder()
5474 .method(hyper::Method::PATCH)
5475 .uri(url.as_str())
5476 .header(USER_AGENT, self.hub._user_agent.clone());
5477
5478 if let Some(token) = token.as_ref() {
5479 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5480 }
5481
5482 let request = req_builder
5483 .header(CONTENT_TYPE, json_mime_type.to_string())
5484 .header(CONTENT_LENGTH, request_size as u64)
5485 .body(common::to_body(
5486 request_value_reader.get_ref().clone().into(),
5487 ));
5488
5489 client.request(request.unwrap()).await
5490 };
5491
5492 match req_result {
5493 Err(err) => {
5494 if let common::Retry::After(d) = dlg.http_error(&err) {
5495 sleep(d).await;
5496 continue;
5497 }
5498 dlg.finished(false);
5499 return Err(common::Error::HttpError(err));
5500 }
5501 Ok(res) => {
5502 let (mut parts, body) = res.into_parts();
5503 let mut body = common::Body::new(body);
5504 if !parts.status.is_success() {
5505 let bytes = common::to_bytes(body).await.unwrap_or_default();
5506 let error = serde_json::from_str(&common::to_string(&bytes));
5507 let response = common::to_response(parts, bytes.into());
5508
5509 if let common::Retry::After(d) =
5510 dlg.http_failure(&response, error.as_ref().ok())
5511 {
5512 sleep(d).await;
5513 continue;
5514 }
5515
5516 dlg.finished(false);
5517
5518 return Err(match error {
5519 Ok(value) => common::Error::BadRequest(value),
5520 _ => common::Error::Failure(response),
5521 });
5522 }
5523 let response = {
5524 let bytes = common::to_bytes(body).await.unwrap_or_default();
5525 let encoded = common::to_string(&bytes);
5526 match serde_json::from_str(&encoded) {
5527 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5528 Err(error) => {
5529 dlg.response_json_decode_error(&encoded, &error);
5530 return Err(common::Error::JsonDecodeError(
5531 encoded.to_string(),
5532 error,
5533 ));
5534 }
5535 }
5536 };
5537
5538 dlg.finished(true);
5539 return Ok(response);
5540 }
5541 }
5542 }
5543 }
5544
5545 ///
5546 /// Sets the *request* property to the given value.
5547 ///
5548 /// Even though the property as already been set when instantiating this call,
5549 /// we provide this method for API completeness.
5550 pub fn request(
5551 mut self,
5552 new_value: CustomChannel,
5553 ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5554 self._request = new_value;
5555 self
5556 }
5557 /// Output only. Resource name of the custom channel. Format: accounts/{account}/adclients/{adclient}/customchannels/{customchannel}
5558 ///
5559 /// Sets the *name* path property to the given value.
5560 ///
5561 /// Even though the property as already been set when instantiating this call,
5562 /// we provide this method for API completeness.
5563 pub fn name(mut self, new_value: &str) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5564 self._name = new_value.to_string();
5565 self
5566 }
5567 /// The list of fields to update. If empty, a full update is performed.
5568 ///
5569 /// Sets the *update mask* query property to the given value.
5570 pub fn update_mask(
5571 mut self,
5572 new_value: common::FieldMask,
5573 ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5574 self._update_mask = Some(new_value);
5575 self
5576 }
5577 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5578 /// while executing the actual API request.
5579 ///
5580 /// ````text
5581 /// It should be used to handle progress information, and to implement a certain level of resilience.
5582 /// ````
5583 ///
5584 /// Sets the *delegate* property to the given value.
5585 pub fn delegate(
5586 mut self,
5587 new_value: &'a mut dyn common::Delegate,
5588 ) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5589 self._delegate = Some(new_value);
5590 self
5591 }
5592
5593 /// Set any additional parameter of the query string used in the request.
5594 /// It should be used to set parameters which are not yet available through their own
5595 /// setters.
5596 ///
5597 /// Please note that this method must not be used to set any of the known parameters
5598 /// which have their own setter method. If done anyway, the request will fail.
5599 ///
5600 /// # Additional Parameters
5601 ///
5602 /// * *$.xgafv* (query-string) - V1 error format.
5603 /// * *access_token* (query-string) - OAuth access token.
5604 /// * *alt* (query-string) - Data format for response.
5605 /// * *callback* (query-string) - JSONP
5606 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5607 /// * *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.
5608 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5609 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5610 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5611 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5612 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5613 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientCustomchannelPatchCall<'a, C>
5614 where
5615 T: AsRef<str>,
5616 {
5617 self._additional_params
5618 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5619 self
5620 }
5621
5622 /// Identifies the authorization scope for the method you are building.
5623 ///
5624 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5625 /// [`Scope::Full`].
5626 ///
5627 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5628 /// tokens for more than one scope.
5629 ///
5630 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5631 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5632 /// sufficient, a read-write scope will do as well.
5633 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientCustomchannelPatchCall<'a, C>
5634 where
5635 St: AsRef<str>,
5636 {
5637 self._scopes.insert(String::from(scope.as_ref()));
5638 self
5639 }
5640 /// Identifies the authorization scope(s) for the method you are building.
5641 ///
5642 /// See [`Self::add_scope()`] for details.
5643 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientCustomchannelPatchCall<'a, C>
5644 where
5645 I: IntoIterator<Item = St>,
5646 St: AsRef<str>,
5647 {
5648 self._scopes
5649 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5650 self
5651 }
5652
5653 /// Removes all scopes, and no default scope will be used either.
5654 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5655 /// for details).
5656 pub fn clear_scopes(mut self) -> AccountAdclientCustomchannelPatchCall<'a, C> {
5657 self._scopes.clear();
5658 self
5659 }
5660}
5661
5662/// Gets information about the selected url channel.
5663///
5664/// A builder for the *adclients.urlchannels.get* method supported by a *account* resource.
5665/// It is not used directly, but through a [`AccountMethods`] instance.
5666///
5667/// # Example
5668///
5669/// Instantiate a resource method builder
5670///
5671/// ```test_harness,no_run
5672/// # extern crate hyper;
5673/// # extern crate hyper_rustls;
5674/// # extern crate google_adsense2 as adsense2;
5675/// # async fn dox() {
5676/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5677///
5678/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5679/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5680/// # .with_native_roots()
5681/// # .unwrap()
5682/// # .https_only()
5683/// # .enable_http2()
5684/// # .build();
5685///
5686/// # let executor = hyper_util::rt::TokioExecutor::new();
5687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5688/// # secret,
5689/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5690/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5691/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5692/// # ),
5693/// # ).build().await.unwrap();
5694///
5695/// # let client = hyper_util::client::legacy::Client::builder(
5696/// # hyper_util::rt::TokioExecutor::new()
5697/// # )
5698/// # .build(
5699/// # hyper_rustls::HttpsConnectorBuilder::new()
5700/// # .with_native_roots()
5701/// # .unwrap()
5702/// # .https_or_http()
5703/// # .enable_http2()
5704/// # .build()
5705/// # );
5706/// # let mut hub = Adsense::new(client, auth);
5707/// // You can configure optional parameters by calling the respective setters at will, and
5708/// // execute the final call using `doit()`.
5709/// // Values shown here are possibly random and not representative !
5710/// let result = hub.accounts().adclients_urlchannels_get("name")
5711/// .doit().await;
5712/// # }
5713/// ```
5714pub struct AccountAdclientUrlchannelGetCall<'a, C>
5715where
5716 C: 'a,
5717{
5718 hub: &'a Adsense<C>,
5719 _name: String,
5720 _delegate: Option<&'a mut dyn common::Delegate>,
5721 _additional_params: HashMap<String, String>,
5722 _scopes: BTreeSet<String>,
5723}
5724
5725impl<'a, C> common::CallBuilder for AccountAdclientUrlchannelGetCall<'a, C> {}
5726
5727impl<'a, C> AccountAdclientUrlchannelGetCall<'a, C>
5728where
5729 C: common::Connector,
5730{
5731 /// Perform the operation you have build so far.
5732 pub async fn doit(mut self) -> common::Result<(common::Response, UrlChannel)> {
5733 use std::borrow::Cow;
5734 use std::io::{Read, Seek};
5735
5736 use common::{url::Params, ToParts};
5737 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5738
5739 let mut dd = common::DefaultDelegate;
5740 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5741 dlg.begin(common::MethodInfo {
5742 id: "adsense.accounts.adclients.urlchannels.get",
5743 http_method: hyper::Method::GET,
5744 });
5745
5746 for &field in ["alt", "name"].iter() {
5747 if self._additional_params.contains_key(field) {
5748 dlg.finished(false);
5749 return Err(common::Error::FieldClash(field));
5750 }
5751 }
5752
5753 let mut params = Params::with_capacity(3 + self._additional_params.len());
5754 params.push("name", self._name);
5755
5756 params.extend(self._additional_params.iter());
5757
5758 params.push("alt", "json");
5759 let mut url = self.hub._base_url.clone() + "v2/{+name}";
5760 if self._scopes.is_empty() {
5761 self._scopes.insert(Scope::Readonly.as_ref().to_string());
5762 }
5763
5764 #[allow(clippy::single_element_loop)]
5765 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5766 url = params.uri_replacement(url, param_name, find_this, true);
5767 }
5768 {
5769 let to_remove = ["name"];
5770 params.remove_params(&to_remove);
5771 }
5772
5773 let url = params.parse_with_url(&url);
5774
5775 loop {
5776 let token = match self
5777 .hub
5778 .auth
5779 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5780 .await
5781 {
5782 Ok(token) => token,
5783 Err(e) => match dlg.token(e) {
5784 Ok(token) => token,
5785 Err(e) => {
5786 dlg.finished(false);
5787 return Err(common::Error::MissingToken(e));
5788 }
5789 },
5790 };
5791 let mut req_result = {
5792 let client = &self.hub.client;
5793 dlg.pre_request();
5794 let mut req_builder = hyper::Request::builder()
5795 .method(hyper::Method::GET)
5796 .uri(url.as_str())
5797 .header(USER_AGENT, self.hub._user_agent.clone());
5798
5799 if let Some(token) = token.as_ref() {
5800 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5801 }
5802
5803 let request = req_builder
5804 .header(CONTENT_LENGTH, 0_u64)
5805 .body(common::to_body::<String>(None));
5806
5807 client.request(request.unwrap()).await
5808 };
5809
5810 match req_result {
5811 Err(err) => {
5812 if let common::Retry::After(d) = dlg.http_error(&err) {
5813 sleep(d).await;
5814 continue;
5815 }
5816 dlg.finished(false);
5817 return Err(common::Error::HttpError(err));
5818 }
5819 Ok(res) => {
5820 let (mut parts, body) = res.into_parts();
5821 let mut body = common::Body::new(body);
5822 if !parts.status.is_success() {
5823 let bytes = common::to_bytes(body).await.unwrap_or_default();
5824 let error = serde_json::from_str(&common::to_string(&bytes));
5825 let response = common::to_response(parts, bytes.into());
5826
5827 if let common::Retry::After(d) =
5828 dlg.http_failure(&response, error.as_ref().ok())
5829 {
5830 sleep(d).await;
5831 continue;
5832 }
5833
5834 dlg.finished(false);
5835
5836 return Err(match error {
5837 Ok(value) => common::Error::BadRequest(value),
5838 _ => common::Error::Failure(response),
5839 });
5840 }
5841 let response = {
5842 let bytes = common::to_bytes(body).await.unwrap_or_default();
5843 let encoded = common::to_string(&bytes);
5844 match serde_json::from_str(&encoded) {
5845 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5846 Err(error) => {
5847 dlg.response_json_decode_error(&encoded, &error);
5848 return Err(common::Error::JsonDecodeError(
5849 encoded.to_string(),
5850 error,
5851 ));
5852 }
5853 }
5854 };
5855
5856 dlg.finished(true);
5857 return Ok(response);
5858 }
5859 }
5860 }
5861 }
5862
5863 /// Required. The name of the url channel to retrieve. Format: accounts/{account}/adclients/{adclient}/urlchannels/{urlchannel}
5864 ///
5865 /// Sets the *name* path property to the given value.
5866 ///
5867 /// Even though the property as already been set when instantiating this call,
5868 /// we provide this method for API completeness.
5869 pub fn name(mut self, new_value: &str) -> AccountAdclientUrlchannelGetCall<'a, C> {
5870 self._name = new_value.to_string();
5871 self
5872 }
5873 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5874 /// while executing the actual API request.
5875 ///
5876 /// ````text
5877 /// It should be used to handle progress information, and to implement a certain level of resilience.
5878 /// ````
5879 ///
5880 /// Sets the *delegate* property to the given value.
5881 pub fn delegate(
5882 mut self,
5883 new_value: &'a mut dyn common::Delegate,
5884 ) -> AccountAdclientUrlchannelGetCall<'a, C> {
5885 self._delegate = Some(new_value);
5886 self
5887 }
5888
5889 /// Set any additional parameter of the query string used in the request.
5890 /// It should be used to set parameters which are not yet available through their own
5891 /// setters.
5892 ///
5893 /// Please note that this method must not be used to set any of the known parameters
5894 /// which have their own setter method. If done anyway, the request will fail.
5895 ///
5896 /// # Additional Parameters
5897 ///
5898 /// * *$.xgafv* (query-string) - V1 error format.
5899 /// * *access_token* (query-string) - OAuth access token.
5900 /// * *alt* (query-string) - Data format for response.
5901 /// * *callback* (query-string) - JSONP
5902 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5903 /// * *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.
5904 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5905 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5906 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5907 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5908 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5909 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientUrlchannelGetCall<'a, C>
5910 where
5911 T: AsRef<str>,
5912 {
5913 self._additional_params
5914 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5915 self
5916 }
5917
5918 /// Identifies the authorization scope for the method you are building.
5919 ///
5920 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5921 /// [`Scope::Readonly`].
5922 ///
5923 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5924 /// tokens for more than one scope.
5925 ///
5926 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5927 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5928 /// sufficient, a read-write scope will do as well.
5929 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientUrlchannelGetCall<'a, C>
5930 where
5931 St: AsRef<str>,
5932 {
5933 self._scopes.insert(String::from(scope.as_ref()));
5934 self
5935 }
5936 /// Identifies the authorization scope(s) for the method you are building.
5937 ///
5938 /// See [`Self::add_scope()`] for details.
5939 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientUrlchannelGetCall<'a, C>
5940 where
5941 I: IntoIterator<Item = St>,
5942 St: AsRef<str>,
5943 {
5944 self._scopes
5945 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5946 self
5947 }
5948
5949 /// Removes all scopes, and no default scope will be used either.
5950 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5951 /// for details).
5952 pub fn clear_scopes(mut self) -> AccountAdclientUrlchannelGetCall<'a, C> {
5953 self._scopes.clear();
5954 self
5955 }
5956}
5957
5958/// Lists active url channels.
5959///
5960/// A builder for the *adclients.urlchannels.list* method supported by a *account* resource.
5961/// It is not used directly, but through a [`AccountMethods`] instance.
5962///
5963/// # Example
5964///
5965/// Instantiate a resource method builder
5966///
5967/// ```test_harness,no_run
5968/// # extern crate hyper;
5969/// # extern crate hyper_rustls;
5970/// # extern crate google_adsense2 as adsense2;
5971/// # async fn dox() {
5972/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5973///
5974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5975/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5976/// # .with_native_roots()
5977/// # .unwrap()
5978/// # .https_only()
5979/// # .enable_http2()
5980/// # .build();
5981///
5982/// # let executor = hyper_util::rt::TokioExecutor::new();
5983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5984/// # secret,
5985/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5986/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5987/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5988/// # ),
5989/// # ).build().await.unwrap();
5990///
5991/// # let client = hyper_util::client::legacy::Client::builder(
5992/// # hyper_util::rt::TokioExecutor::new()
5993/// # )
5994/// # .build(
5995/// # hyper_rustls::HttpsConnectorBuilder::new()
5996/// # .with_native_roots()
5997/// # .unwrap()
5998/// # .https_or_http()
5999/// # .enable_http2()
6000/// # .build()
6001/// # );
6002/// # let mut hub = Adsense::new(client, auth);
6003/// // You can configure optional parameters by calling the respective setters at will, and
6004/// // execute the final call using `doit()`.
6005/// // Values shown here are possibly random and not representative !
6006/// let result = hub.accounts().adclients_urlchannels_list("parent")
6007/// .page_token("elitr")
6008/// .page_size(-6)
6009/// .doit().await;
6010/// # }
6011/// ```
6012pub struct AccountAdclientUrlchannelListCall<'a, C>
6013where
6014 C: 'a,
6015{
6016 hub: &'a Adsense<C>,
6017 _parent: String,
6018 _page_token: Option<String>,
6019 _page_size: Option<i32>,
6020 _delegate: Option<&'a mut dyn common::Delegate>,
6021 _additional_params: HashMap<String, String>,
6022 _scopes: BTreeSet<String>,
6023}
6024
6025impl<'a, C> common::CallBuilder for AccountAdclientUrlchannelListCall<'a, C> {}
6026
6027impl<'a, C> AccountAdclientUrlchannelListCall<'a, C>
6028where
6029 C: common::Connector,
6030{
6031 /// Perform the operation you have build so far.
6032 pub async fn doit(mut self) -> common::Result<(common::Response, ListUrlChannelsResponse)> {
6033 use std::borrow::Cow;
6034 use std::io::{Read, Seek};
6035
6036 use common::{url::Params, ToParts};
6037 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6038
6039 let mut dd = common::DefaultDelegate;
6040 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6041 dlg.begin(common::MethodInfo {
6042 id: "adsense.accounts.adclients.urlchannels.list",
6043 http_method: hyper::Method::GET,
6044 });
6045
6046 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6047 if self._additional_params.contains_key(field) {
6048 dlg.finished(false);
6049 return Err(common::Error::FieldClash(field));
6050 }
6051 }
6052
6053 let mut params = Params::with_capacity(5 + self._additional_params.len());
6054 params.push("parent", self._parent);
6055 if let Some(value) = self._page_token.as_ref() {
6056 params.push("pageToken", value);
6057 }
6058 if let Some(value) = self._page_size.as_ref() {
6059 params.push("pageSize", value.to_string());
6060 }
6061
6062 params.extend(self._additional_params.iter());
6063
6064 params.push("alt", "json");
6065 let mut url = self.hub._base_url.clone() + "v2/{+parent}/urlchannels";
6066 if self._scopes.is_empty() {
6067 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6068 }
6069
6070 #[allow(clippy::single_element_loop)]
6071 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6072 url = params.uri_replacement(url, param_name, find_this, true);
6073 }
6074 {
6075 let to_remove = ["parent"];
6076 params.remove_params(&to_remove);
6077 }
6078
6079 let url = params.parse_with_url(&url);
6080
6081 loop {
6082 let token = match self
6083 .hub
6084 .auth
6085 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6086 .await
6087 {
6088 Ok(token) => token,
6089 Err(e) => match dlg.token(e) {
6090 Ok(token) => token,
6091 Err(e) => {
6092 dlg.finished(false);
6093 return Err(common::Error::MissingToken(e));
6094 }
6095 },
6096 };
6097 let mut req_result = {
6098 let client = &self.hub.client;
6099 dlg.pre_request();
6100 let mut req_builder = hyper::Request::builder()
6101 .method(hyper::Method::GET)
6102 .uri(url.as_str())
6103 .header(USER_AGENT, self.hub._user_agent.clone());
6104
6105 if let Some(token) = token.as_ref() {
6106 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6107 }
6108
6109 let request = req_builder
6110 .header(CONTENT_LENGTH, 0_u64)
6111 .body(common::to_body::<String>(None));
6112
6113 client.request(request.unwrap()).await
6114 };
6115
6116 match req_result {
6117 Err(err) => {
6118 if let common::Retry::After(d) = dlg.http_error(&err) {
6119 sleep(d).await;
6120 continue;
6121 }
6122 dlg.finished(false);
6123 return Err(common::Error::HttpError(err));
6124 }
6125 Ok(res) => {
6126 let (mut parts, body) = res.into_parts();
6127 let mut body = common::Body::new(body);
6128 if !parts.status.is_success() {
6129 let bytes = common::to_bytes(body).await.unwrap_or_default();
6130 let error = serde_json::from_str(&common::to_string(&bytes));
6131 let response = common::to_response(parts, bytes.into());
6132
6133 if let common::Retry::After(d) =
6134 dlg.http_failure(&response, error.as_ref().ok())
6135 {
6136 sleep(d).await;
6137 continue;
6138 }
6139
6140 dlg.finished(false);
6141
6142 return Err(match error {
6143 Ok(value) => common::Error::BadRequest(value),
6144 _ => common::Error::Failure(response),
6145 });
6146 }
6147 let response = {
6148 let bytes = common::to_bytes(body).await.unwrap_or_default();
6149 let encoded = common::to_string(&bytes);
6150 match serde_json::from_str(&encoded) {
6151 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6152 Err(error) => {
6153 dlg.response_json_decode_error(&encoded, &error);
6154 return Err(common::Error::JsonDecodeError(
6155 encoded.to_string(),
6156 error,
6157 ));
6158 }
6159 }
6160 };
6161
6162 dlg.finished(true);
6163 return Ok(response);
6164 }
6165 }
6166 }
6167 }
6168
6169 /// Required. The ad client which owns the collection of url channels. Format: accounts/{account}/adclients/{adclient}
6170 ///
6171 /// Sets the *parent* path property to the given value.
6172 ///
6173 /// Even though the property as already been set when instantiating this call,
6174 /// we provide this method for API completeness.
6175 pub fn parent(mut self, new_value: &str) -> AccountAdclientUrlchannelListCall<'a, C> {
6176 self._parent = new_value.to_string();
6177 self
6178 }
6179 /// A page token, received from a previous `ListUrlChannels` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUrlChannels` must match the call that provided the page token.
6180 ///
6181 /// Sets the *page token* query property to the given value.
6182 pub fn page_token(mut self, new_value: &str) -> AccountAdclientUrlchannelListCall<'a, C> {
6183 self._page_token = Some(new_value.to_string());
6184 self
6185 }
6186 /// The maximum number of url channels to include in the response, used for paging. If unspecified, at most 10000 url channels will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
6187 ///
6188 /// Sets the *page size* query property to the given value.
6189 pub fn page_size(mut self, new_value: i32) -> AccountAdclientUrlchannelListCall<'a, C> {
6190 self._page_size = Some(new_value);
6191 self
6192 }
6193 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6194 /// while executing the actual API request.
6195 ///
6196 /// ````text
6197 /// It should be used to handle progress information, and to implement a certain level of resilience.
6198 /// ````
6199 ///
6200 /// Sets the *delegate* property to the given value.
6201 pub fn delegate(
6202 mut self,
6203 new_value: &'a mut dyn common::Delegate,
6204 ) -> AccountAdclientUrlchannelListCall<'a, C> {
6205 self._delegate = Some(new_value);
6206 self
6207 }
6208
6209 /// Set any additional parameter of the query string used in the request.
6210 /// It should be used to set parameters which are not yet available through their own
6211 /// setters.
6212 ///
6213 /// Please note that this method must not be used to set any of the known parameters
6214 /// which have their own setter method. If done anyway, the request will fail.
6215 ///
6216 /// # Additional Parameters
6217 ///
6218 /// * *$.xgafv* (query-string) - V1 error format.
6219 /// * *access_token* (query-string) - OAuth access token.
6220 /// * *alt* (query-string) - Data format for response.
6221 /// * *callback* (query-string) - JSONP
6222 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6223 /// * *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.
6224 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6225 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6226 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6227 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6228 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6229 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientUrlchannelListCall<'a, C>
6230 where
6231 T: AsRef<str>,
6232 {
6233 self._additional_params
6234 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6235 self
6236 }
6237
6238 /// Identifies the authorization scope for the method you are building.
6239 ///
6240 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6241 /// [`Scope::Readonly`].
6242 ///
6243 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6244 /// tokens for more than one scope.
6245 ///
6246 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6247 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6248 /// sufficient, a read-write scope will do as well.
6249 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientUrlchannelListCall<'a, C>
6250 where
6251 St: AsRef<str>,
6252 {
6253 self._scopes.insert(String::from(scope.as_ref()));
6254 self
6255 }
6256 /// Identifies the authorization scope(s) for the method you are building.
6257 ///
6258 /// See [`Self::add_scope()`] for details.
6259 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientUrlchannelListCall<'a, C>
6260 where
6261 I: IntoIterator<Item = St>,
6262 St: AsRef<str>,
6263 {
6264 self._scopes
6265 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6266 self
6267 }
6268
6269 /// Removes all scopes, and no default scope will be used either.
6270 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6271 /// for details).
6272 pub fn clear_scopes(mut self) -> AccountAdclientUrlchannelListCall<'a, C> {
6273 self._scopes.clear();
6274 self
6275 }
6276}
6277
6278/// Gets the ad client from the given resource name.
6279///
6280/// A builder for the *adclients.get* method supported by a *account* resource.
6281/// It is not used directly, but through a [`AccountMethods`] instance.
6282///
6283/// # Example
6284///
6285/// Instantiate a resource method builder
6286///
6287/// ```test_harness,no_run
6288/// # extern crate hyper;
6289/// # extern crate hyper_rustls;
6290/// # extern crate google_adsense2 as adsense2;
6291/// # async fn dox() {
6292/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6293///
6294/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6295/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6296/// # .with_native_roots()
6297/// # .unwrap()
6298/// # .https_only()
6299/// # .enable_http2()
6300/// # .build();
6301///
6302/// # let executor = hyper_util::rt::TokioExecutor::new();
6303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6304/// # secret,
6305/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6306/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6307/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6308/// # ),
6309/// # ).build().await.unwrap();
6310///
6311/// # let client = hyper_util::client::legacy::Client::builder(
6312/// # hyper_util::rt::TokioExecutor::new()
6313/// # )
6314/// # .build(
6315/// # hyper_rustls::HttpsConnectorBuilder::new()
6316/// # .with_native_roots()
6317/// # .unwrap()
6318/// # .https_or_http()
6319/// # .enable_http2()
6320/// # .build()
6321/// # );
6322/// # let mut hub = Adsense::new(client, auth);
6323/// // You can configure optional parameters by calling the respective setters at will, and
6324/// // execute the final call using `doit()`.
6325/// // Values shown here are possibly random and not representative !
6326/// let result = hub.accounts().adclients_get("name")
6327/// .doit().await;
6328/// # }
6329/// ```
6330pub struct AccountAdclientGetCall<'a, C>
6331where
6332 C: 'a,
6333{
6334 hub: &'a Adsense<C>,
6335 _name: String,
6336 _delegate: Option<&'a mut dyn common::Delegate>,
6337 _additional_params: HashMap<String, String>,
6338 _scopes: BTreeSet<String>,
6339}
6340
6341impl<'a, C> common::CallBuilder for AccountAdclientGetCall<'a, C> {}
6342
6343impl<'a, C> AccountAdclientGetCall<'a, C>
6344where
6345 C: common::Connector,
6346{
6347 /// Perform the operation you have build so far.
6348 pub async fn doit(mut self) -> common::Result<(common::Response, AdClient)> {
6349 use std::borrow::Cow;
6350 use std::io::{Read, Seek};
6351
6352 use common::{url::Params, ToParts};
6353 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6354
6355 let mut dd = common::DefaultDelegate;
6356 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6357 dlg.begin(common::MethodInfo {
6358 id: "adsense.accounts.adclients.get",
6359 http_method: hyper::Method::GET,
6360 });
6361
6362 for &field in ["alt", "name"].iter() {
6363 if self._additional_params.contains_key(field) {
6364 dlg.finished(false);
6365 return Err(common::Error::FieldClash(field));
6366 }
6367 }
6368
6369 let mut params = Params::with_capacity(3 + self._additional_params.len());
6370 params.push("name", self._name);
6371
6372 params.extend(self._additional_params.iter());
6373
6374 params.push("alt", "json");
6375 let mut url = self.hub._base_url.clone() + "v2/{+name}";
6376 if self._scopes.is_empty() {
6377 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6378 }
6379
6380 #[allow(clippy::single_element_loop)]
6381 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6382 url = params.uri_replacement(url, param_name, find_this, true);
6383 }
6384 {
6385 let to_remove = ["name"];
6386 params.remove_params(&to_remove);
6387 }
6388
6389 let url = params.parse_with_url(&url);
6390
6391 loop {
6392 let token = match self
6393 .hub
6394 .auth
6395 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6396 .await
6397 {
6398 Ok(token) => token,
6399 Err(e) => match dlg.token(e) {
6400 Ok(token) => token,
6401 Err(e) => {
6402 dlg.finished(false);
6403 return Err(common::Error::MissingToken(e));
6404 }
6405 },
6406 };
6407 let mut req_result = {
6408 let client = &self.hub.client;
6409 dlg.pre_request();
6410 let mut req_builder = hyper::Request::builder()
6411 .method(hyper::Method::GET)
6412 .uri(url.as_str())
6413 .header(USER_AGENT, self.hub._user_agent.clone());
6414
6415 if let Some(token) = token.as_ref() {
6416 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6417 }
6418
6419 let request = req_builder
6420 .header(CONTENT_LENGTH, 0_u64)
6421 .body(common::to_body::<String>(None));
6422
6423 client.request(request.unwrap()).await
6424 };
6425
6426 match req_result {
6427 Err(err) => {
6428 if let common::Retry::After(d) = dlg.http_error(&err) {
6429 sleep(d).await;
6430 continue;
6431 }
6432 dlg.finished(false);
6433 return Err(common::Error::HttpError(err));
6434 }
6435 Ok(res) => {
6436 let (mut parts, body) = res.into_parts();
6437 let mut body = common::Body::new(body);
6438 if !parts.status.is_success() {
6439 let bytes = common::to_bytes(body).await.unwrap_or_default();
6440 let error = serde_json::from_str(&common::to_string(&bytes));
6441 let response = common::to_response(parts, bytes.into());
6442
6443 if let common::Retry::After(d) =
6444 dlg.http_failure(&response, error.as_ref().ok())
6445 {
6446 sleep(d).await;
6447 continue;
6448 }
6449
6450 dlg.finished(false);
6451
6452 return Err(match error {
6453 Ok(value) => common::Error::BadRequest(value),
6454 _ => common::Error::Failure(response),
6455 });
6456 }
6457 let response = {
6458 let bytes = common::to_bytes(body).await.unwrap_or_default();
6459 let encoded = common::to_string(&bytes);
6460 match serde_json::from_str(&encoded) {
6461 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6462 Err(error) => {
6463 dlg.response_json_decode_error(&encoded, &error);
6464 return Err(common::Error::JsonDecodeError(
6465 encoded.to_string(),
6466 error,
6467 ));
6468 }
6469 }
6470 };
6471
6472 dlg.finished(true);
6473 return Ok(response);
6474 }
6475 }
6476 }
6477 }
6478
6479 /// Required. The name of the ad client to retrieve. Format: accounts/{account}/adclients/{adclient}
6480 ///
6481 /// Sets the *name* path property to the given value.
6482 ///
6483 /// Even though the property as already been set when instantiating this call,
6484 /// we provide this method for API completeness.
6485 pub fn name(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C> {
6486 self._name = new_value.to_string();
6487 self
6488 }
6489 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6490 /// while executing the actual API request.
6491 ///
6492 /// ````text
6493 /// It should be used to handle progress information, and to implement a certain level of resilience.
6494 /// ````
6495 ///
6496 /// Sets the *delegate* property to the given value.
6497 pub fn delegate(
6498 mut self,
6499 new_value: &'a mut dyn common::Delegate,
6500 ) -> AccountAdclientGetCall<'a, C> {
6501 self._delegate = Some(new_value);
6502 self
6503 }
6504
6505 /// Set any additional parameter of the query string used in the request.
6506 /// It should be used to set parameters which are not yet available through their own
6507 /// setters.
6508 ///
6509 /// Please note that this method must not be used to set any of the known parameters
6510 /// which have their own setter method. If done anyway, the request will fail.
6511 ///
6512 /// # Additional Parameters
6513 ///
6514 /// * *$.xgafv* (query-string) - V1 error format.
6515 /// * *access_token* (query-string) - OAuth access token.
6516 /// * *alt* (query-string) - Data format for response.
6517 /// * *callback* (query-string) - JSONP
6518 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6519 /// * *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.
6520 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6521 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6522 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6523 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6524 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6525 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetCall<'a, C>
6526 where
6527 T: AsRef<str>,
6528 {
6529 self._additional_params
6530 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6531 self
6532 }
6533
6534 /// Identifies the authorization scope for the method you are building.
6535 ///
6536 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6537 /// [`Scope::Readonly`].
6538 ///
6539 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6540 /// tokens for more than one scope.
6541 ///
6542 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6543 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6544 /// sufficient, a read-write scope will do as well.
6545 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetCall<'a, C>
6546 where
6547 St: AsRef<str>,
6548 {
6549 self._scopes.insert(String::from(scope.as_ref()));
6550 self
6551 }
6552 /// Identifies the authorization scope(s) for the method you are building.
6553 ///
6554 /// See [`Self::add_scope()`] for details.
6555 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetCall<'a, C>
6556 where
6557 I: IntoIterator<Item = St>,
6558 St: AsRef<str>,
6559 {
6560 self._scopes
6561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6562 self
6563 }
6564
6565 /// Removes all scopes, and no default scope will be used either.
6566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6567 /// for details).
6568 pub fn clear_scopes(mut self) -> AccountAdclientGetCall<'a, C> {
6569 self._scopes.clear();
6570 self
6571 }
6572}
6573
6574/// Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'. This is only supported for ad clients with a product_code of AFC. For more information, see [About the AdSense code](https://support.google.com/adsense/answer/9274634).
6575///
6576/// A builder for the *adclients.getAdcode* method supported by a *account* resource.
6577/// It is not used directly, but through a [`AccountMethods`] instance.
6578///
6579/// # Example
6580///
6581/// Instantiate a resource method builder
6582///
6583/// ```test_harness,no_run
6584/// # extern crate hyper;
6585/// # extern crate hyper_rustls;
6586/// # extern crate google_adsense2 as adsense2;
6587/// # async fn dox() {
6588/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6589///
6590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6591/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6592/// # .with_native_roots()
6593/// # .unwrap()
6594/// # .https_only()
6595/// # .enable_http2()
6596/// # .build();
6597///
6598/// # let executor = hyper_util::rt::TokioExecutor::new();
6599/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6600/// # secret,
6601/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6602/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6603/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6604/// # ),
6605/// # ).build().await.unwrap();
6606///
6607/// # let client = hyper_util::client::legacy::Client::builder(
6608/// # hyper_util::rt::TokioExecutor::new()
6609/// # )
6610/// # .build(
6611/// # hyper_rustls::HttpsConnectorBuilder::new()
6612/// # .with_native_roots()
6613/// # .unwrap()
6614/// # .https_or_http()
6615/// # .enable_http2()
6616/// # .build()
6617/// # );
6618/// # let mut hub = Adsense::new(client, auth);
6619/// // You can configure optional parameters by calling the respective setters at will, and
6620/// // execute the final call using `doit()`.
6621/// // Values shown here are possibly random and not representative !
6622/// let result = hub.accounts().adclients_get_adcode("name")
6623/// .doit().await;
6624/// # }
6625/// ```
6626pub struct AccountAdclientGetAdcodeCall<'a, C>
6627where
6628 C: 'a,
6629{
6630 hub: &'a Adsense<C>,
6631 _name: String,
6632 _delegate: Option<&'a mut dyn common::Delegate>,
6633 _additional_params: HashMap<String, String>,
6634 _scopes: BTreeSet<String>,
6635}
6636
6637impl<'a, C> common::CallBuilder for AccountAdclientGetAdcodeCall<'a, C> {}
6638
6639impl<'a, C> AccountAdclientGetAdcodeCall<'a, C>
6640where
6641 C: common::Connector,
6642{
6643 /// Perform the operation you have build so far.
6644 pub async fn doit(mut self) -> common::Result<(common::Response, AdClientAdCode)> {
6645 use std::borrow::Cow;
6646 use std::io::{Read, Seek};
6647
6648 use common::{url::Params, ToParts};
6649 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6650
6651 let mut dd = common::DefaultDelegate;
6652 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6653 dlg.begin(common::MethodInfo {
6654 id: "adsense.accounts.adclients.getAdcode",
6655 http_method: hyper::Method::GET,
6656 });
6657
6658 for &field in ["alt", "name"].iter() {
6659 if self._additional_params.contains_key(field) {
6660 dlg.finished(false);
6661 return Err(common::Error::FieldClash(field));
6662 }
6663 }
6664
6665 let mut params = Params::with_capacity(3 + self._additional_params.len());
6666 params.push("name", self._name);
6667
6668 params.extend(self._additional_params.iter());
6669
6670 params.push("alt", "json");
6671 let mut url = self.hub._base_url.clone() + "v2/{+name}/adcode";
6672 if self._scopes.is_empty() {
6673 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6674 }
6675
6676 #[allow(clippy::single_element_loop)]
6677 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6678 url = params.uri_replacement(url, param_name, find_this, true);
6679 }
6680 {
6681 let to_remove = ["name"];
6682 params.remove_params(&to_remove);
6683 }
6684
6685 let url = params.parse_with_url(&url);
6686
6687 loop {
6688 let token = match self
6689 .hub
6690 .auth
6691 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6692 .await
6693 {
6694 Ok(token) => token,
6695 Err(e) => match dlg.token(e) {
6696 Ok(token) => token,
6697 Err(e) => {
6698 dlg.finished(false);
6699 return Err(common::Error::MissingToken(e));
6700 }
6701 },
6702 };
6703 let mut req_result = {
6704 let client = &self.hub.client;
6705 dlg.pre_request();
6706 let mut req_builder = hyper::Request::builder()
6707 .method(hyper::Method::GET)
6708 .uri(url.as_str())
6709 .header(USER_AGENT, self.hub._user_agent.clone());
6710
6711 if let Some(token) = token.as_ref() {
6712 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6713 }
6714
6715 let request = req_builder
6716 .header(CONTENT_LENGTH, 0_u64)
6717 .body(common::to_body::<String>(None));
6718
6719 client.request(request.unwrap()).await
6720 };
6721
6722 match req_result {
6723 Err(err) => {
6724 if let common::Retry::After(d) = dlg.http_error(&err) {
6725 sleep(d).await;
6726 continue;
6727 }
6728 dlg.finished(false);
6729 return Err(common::Error::HttpError(err));
6730 }
6731 Ok(res) => {
6732 let (mut parts, body) = res.into_parts();
6733 let mut body = common::Body::new(body);
6734 if !parts.status.is_success() {
6735 let bytes = common::to_bytes(body).await.unwrap_or_default();
6736 let error = serde_json::from_str(&common::to_string(&bytes));
6737 let response = common::to_response(parts, bytes.into());
6738
6739 if let common::Retry::After(d) =
6740 dlg.http_failure(&response, error.as_ref().ok())
6741 {
6742 sleep(d).await;
6743 continue;
6744 }
6745
6746 dlg.finished(false);
6747
6748 return Err(match error {
6749 Ok(value) => common::Error::BadRequest(value),
6750 _ => common::Error::Failure(response),
6751 });
6752 }
6753 let response = {
6754 let bytes = common::to_bytes(body).await.unwrap_or_default();
6755 let encoded = common::to_string(&bytes);
6756 match serde_json::from_str(&encoded) {
6757 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6758 Err(error) => {
6759 dlg.response_json_decode_error(&encoded, &error);
6760 return Err(common::Error::JsonDecodeError(
6761 encoded.to_string(),
6762 error,
6763 ));
6764 }
6765 }
6766 };
6767
6768 dlg.finished(true);
6769 return Ok(response);
6770 }
6771 }
6772 }
6773 }
6774
6775 /// Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}
6776 ///
6777 /// Sets the *name* path property to the given value.
6778 ///
6779 /// Even though the property as already been set when instantiating this call,
6780 /// we provide this method for API completeness.
6781 pub fn name(mut self, new_value: &str) -> AccountAdclientGetAdcodeCall<'a, C> {
6782 self._name = new_value.to_string();
6783 self
6784 }
6785 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6786 /// while executing the actual API request.
6787 ///
6788 /// ````text
6789 /// It should be used to handle progress information, and to implement a certain level of resilience.
6790 /// ````
6791 ///
6792 /// Sets the *delegate* property to the given value.
6793 pub fn delegate(
6794 mut self,
6795 new_value: &'a mut dyn common::Delegate,
6796 ) -> AccountAdclientGetAdcodeCall<'a, C> {
6797 self._delegate = Some(new_value);
6798 self
6799 }
6800
6801 /// Set any additional parameter of the query string used in the request.
6802 /// It should be used to set parameters which are not yet available through their own
6803 /// setters.
6804 ///
6805 /// Please note that this method must not be used to set any of the known parameters
6806 /// which have their own setter method. If done anyway, the request will fail.
6807 ///
6808 /// # Additional Parameters
6809 ///
6810 /// * *$.xgafv* (query-string) - V1 error format.
6811 /// * *access_token* (query-string) - OAuth access token.
6812 /// * *alt* (query-string) - Data format for response.
6813 /// * *callback* (query-string) - JSONP
6814 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6815 /// * *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.
6816 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6817 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6818 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6819 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6820 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6821 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientGetAdcodeCall<'a, C>
6822 where
6823 T: AsRef<str>,
6824 {
6825 self._additional_params
6826 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6827 self
6828 }
6829
6830 /// Identifies the authorization scope for the method you are building.
6831 ///
6832 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6833 /// [`Scope::Readonly`].
6834 ///
6835 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6836 /// tokens for more than one scope.
6837 ///
6838 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6839 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6840 /// sufficient, a read-write scope will do as well.
6841 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientGetAdcodeCall<'a, C>
6842 where
6843 St: AsRef<str>,
6844 {
6845 self._scopes.insert(String::from(scope.as_ref()));
6846 self
6847 }
6848 /// Identifies the authorization scope(s) for the method you are building.
6849 ///
6850 /// See [`Self::add_scope()`] for details.
6851 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientGetAdcodeCall<'a, C>
6852 where
6853 I: IntoIterator<Item = St>,
6854 St: AsRef<str>,
6855 {
6856 self._scopes
6857 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6858 self
6859 }
6860
6861 /// Removes all scopes, and no default scope will be used either.
6862 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6863 /// for details).
6864 pub fn clear_scopes(mut self) -> AccountAdclientGetAdcodeCall<'a, C> {
6865 self._scopes.clear();
6866 self
6867 }
6868}
6869
6870/// Lists all the ad clients available in an account.
6871///
6872/// A builder for the *adclients.list* method supported by a *account* resource.
6873/// It is not used directly, but through a [`AccountMethods`] instance.
6874///
6875/// # Example
6876///
6877/// Instantiate a resource method builder
6878///
6879/// ```test_harness,no_run
6880/// # extern crate hyper;
6881/// # extern crate hyper_rustls;
6882/// # extern crate google_adsense2 as adsense2;
6883/// # async fn dox() {
6884/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6885///
6886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6887/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6888/// # .with_native_roots()
6889/// # .unwrap()
6890/// # .https_only()
6891/// # .enable_http2()
6892/// # .build();
6893///
6894/// # let executor = hyper_util::rt::TokioExecutor::new();
6895/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6896/// # secret,
6897/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6898/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6899/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6900/// # ),
6901/// # ).build().await.unwrap();
6902///
6903/// # let client = hyper_util::client::legacy::Client::builder(
6904/// # hyper_util::rt::TokioExecutor::new()
6905/// # )
6906/// # .build(
6907/// # hyper_rustls::HttpsConnectorBuilder::new()
6908/// # .with_native_roots()
6909/// # .unwrap()
6910/// # .https_or_http()
6911/// # .enable_http2()
6912/// # .build()
6913/// # );
6914/// # let mut hub = Adsense::new(client, auth);
6915/// // You can configure optional parameters by calling the respective setters at will, and
6916/// // execute the final call using `doit()`.
6917/// // Values shown here are possibly random and not representative !
6918/// let result = hub.accounts().adclients_list("parent")
6919/// .page_token("accusam")
6920/// .page_size(-59)
6921/// .doit().await;
6922/// # }
6923/// ```
6924pub struct AccountAdclientListCall<'a, C>
6925where
6926 C: 'a,
6927{
6928 hub: &'a Adsense<C>,
6929 _parent: String,
6930 _page_token: Option<String>,
6931 _page_size: Option<i32>,
6932 _delegate: Option<&'a mut dyn common::Delegate>,
6933 _additional_params: HashMap<String, String>,
6934 _scopes: BTreeSet<String>,
6935}
6936
6937impl<'a, C> common::CallBuilder for AccountAdclientListCall<'a, C> {}
6938
6939impl<'a, C> AccountAdclientListCall<'a, C>
6940where
6941 C: common::Connector,
6942{
6943 /// Perform the operation you have build so far.
6944 pub async fn doit(mut self) -> common::Result<(common::Response, ListAdClientsResponse)> {
6945 use std::borrow::Cow;
6946 use std::io::{Read, Seek};
6947
6948 use common::{url::Params, ToParts};
6949 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6950
6951 let mut dd = common::DefaultDelegate;
6952 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6953 dlg.begin(common::MethodInfo {
6954 id: "adsense.accounts.adclients.list",
6955 http_method: hyper::Method::GET,
6956 });
6957
6958 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6959 if self._additional_params.contains_key(field) {
6960 dlg.finished(false);
6961 return Err(common::Error::FieldClash(field));
6962 }
6963 }
6964
6965 let mut params = Params::with_capacity(5 + self._additional_params.len());
6966 params.push("parent", self._parent);
6967 if let Some(value) = self._page_token.as_ref() {
6968 params.push("pageToken", value);
6969 }
6970 if let Some(value) = self._page_size.as_ref() {
6971 params.push("pageSize", value.to_string());
6972 }
6973
6974 params.extend(self._additional_params.iter());
6975
6976 params.push("alt", "json");
6977 let mut url = self.hub._base_url.clone() + "v2/{+parent}/adclients";
6978 if self._scopes.is_empty() {
6979 self._scopes.insert(Scope::Readonly.as_ref().to_string());
6980 }
6981
6982 #[allow(clippy::single_element_loop)]
6983 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6984 url = params.uri_replacement(url, param_name, find_this, true);
6985 }
6986 {
6987 let to_remove = ["parent"];
6988 params.remove_params(&to_remove);
6989 }
6990
6991 let url = params.parse_with_url(&url);
6992
6993 loop {
6994 let token = match self
6995 .hub
6996 .auth
6997 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6998 .await
6999 {
7000 Ok(token) => token,
7001 Err(e) => match dlg.token(e) {
7002 Ok(token) => token,
7003 Err(e) => {
7004 dlg.finished(false);
7005 return Err(common::Error::MissingToken(e));
7006 }
7007 },
7008 };
7009 let mut req_result = {
7010 let client = &self.hub.client;
7011 dlg.pre_request();
7012 let mut req_builder = hyper::Request::builder()
7013 .method(hyper::Method::GET)
7014 .uri(url.as_str())
7015 .header(USER_AGENT, self.hub._user_agent.clone());
7016
7017 if let Some(token) = token.as_ref() {
7018 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7019 }
7020
7021 let request = req_builder
7022 .header(CONTENT_LENGTH, 0_u64)
7023 .body(common::to_body::<String>(None));
7024
7025 client.request(request.unwrap()).await
7026 };
7027
7028 match req_result {
7029 Err(err) => {
7030 if let common::Retry::After(d) = dlg.http_error(&err) {
7031 sleep(d).await;
7032 continue;
7033 }
7034 dlg.finished(false);
7035 return Err(common::Error::HttpError(err));
7036 }
7037 Ok(res) => {
7038 let (mut parts, body) = res.into_parts();
7039 let mut body = common::Body::new(body);
7040 if !parts.status.is_success() {
7041 let bytes = common::to_bytes(body).await.unwrap_or_default();
7042 let error = serde_json::from_str(&common::to_string(&bytes));
7043 let response = common::to_response(parts, bytes.into());
7044
7045 if let common::Retry::After(d) =
7046 dlg.http_failure(&response, error.as_ref().ok())
7047 {
7048 sleep(d).await;
7049 continue;
7050 }
7051
7052 dlg.finished(false);
7053
7054 return Err(match error {
7055 Ok(value) => common::Error::BadRequest(value),
7056 _ => common::Error::Failure(response),
7057 });
7058 }
7059 let response = {
7060 let bytes = common::to_bytes(body).await.unwrap_or_default();
7061 let encoded = common::to_string(&bytes);
7062 match serde_json::from_str(&encoded) {
7063 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7064 Err(error) => {
7065 dlg.response_json_decode_error(&encoded, &error);
7066 return Err(common::Error::JsonDecodeError(
7067 encoded.to_string(),
7068 error,
7069 ));
7070 }
7071 }
7072 };
7073
7074 dlg.finished(true);
7075 return Ok(response);
7076 }
7077 }
7078 }
7079 }
7080
7081 /// Required. The account which owns the collection of ad clients. Format: accounts/{account}
7082 ///
7083 /// Sets the *parent* path property to the given value.
7084 ///
7085 /// Even though the property as already been set when instantiating this call,
7086 /// we provide this method for API completeness.
7087 pub fn parent(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
7088 self._parent = new_value.to_string();
7089 self
7090 }
7091 /// A page token, received from a previous `ListAdClients` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAdClients` must match the call that provided the page token.
7092 ///
7093 /// Sets the *page token* query property to the given value.
7094 pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C> {
7095 self._page_token = Some(new_value.to_string());
7096 self
7097 }
7098 /// The maximum number of ad clients to include in the response, used for paging. If unspecified, at most 10000 ad clients will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
7099 ///
7100 /// Sets the *page size* query property to the given value.
7101 pub fn page_size(mut self, new_value: i32) -> AccountAdclientListCall<'a, C> {
7102 self._page_size = Some(new_value);
7103 self
7104 }
7105 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7106 /// while executing the actual API request.
7107 ///
7108 /// ````text
7109 /// It should be used to handle progress information, and to implement a certain level of resilience.
7110 /// ````
7111 ///
7112 /// Sets the *delegate* property to the given value.
7113 pub fn delegate(
7114 mut self,
7115 new_value: &'a mut dyn common::Delegate,
7116 ) -> AccountAdclientListCall<'a, C> {
7117 self._delegate = Some(new_value);
7118 self
7119 }
7120
7121 /// Set any additional parameter of the query string used in the request.
7122 /// It should be used to set parameters which are not yet available through their own
7123 /// setters.
7124 ///
7125 /// Please note that this method must not be used to set any of the known parameters
7126 /// which have their own setter method. If done anyway, the request will fail.
7127 ///
7128 /// # Additional Parameters
7129 ///
7130 /// * *$.xgafv* (query-string) - V1 error format.
7131 /// * *access_token* (query-string) - OAuth access token.
7132 /// * *alt* (query-string) - Data format for response.
7133 /// * *callback* (query-string) - JSONP
7134 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7135 /// * *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.
7136 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7137 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7138 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7139 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7140 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7141 pub fn param<T>(mut self, name: T, value: T) -> AccountAdclientListCall<'a, C>
7142 where
7143 T: AsRef<str>,
7144 {
7145 self._additional_params
7146 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7147 self
7148 }
7149
7150 /// Identifies the authorization scope for the method you are building.
7151 ///
7152 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7153 /// [`Scope::Readonly`].
7154 ///
7155 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7156 /// tokens for more than one scope.
7157 ///
7158 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7159 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7160 /// sufficient, a read-write scope will do as well.
7161 pub fn add_scope<St>(mut self, scope: St) -> AccountAdclientListCall<'a, C>
7162 where
7163 St: AsRef<str>,
7164 {
7165 self._scopes.insert(String::from(scope.as_ref()));
7166 self
7167 }
7168 /// Identifies the authorization scope(s) for the method you are building.
7169 ///
7170 /// See [`Self::add_scope()`] for details.
7171 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAdclientListCall<'a, C>
7172 where
7173 I: IntoIterator<Item = St>,
7174 St: AsRef<str>,
7175 {
7176 self._scopes
7177 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7178 self
7179 }
7180
7181 /// Removes all scopes, and no default scope will be used either.
7182 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7183 /// for details).
7184 pub fn clear_scopes(mut self) -> AccountAdclientListCall<'a, C> {
7185 self._scopes.clear();
7186 self
7187 }
7188}
7189
7190/// Lists all the alerts available in an account.
7191///
7192/// A builder for the *alerts.list* method supported by a *account* resource.
7193/// It is not used directly, but through a [`AccountMethods`] instance.
7194///
7195/// # Example
7196///
7197/// Instantiate a resource method builder
7198///
7199/// ```test_harness,no_run
7200/// # extern crate hyper;
7201/// # extern crate hyper_rustls;
7202/// # extern crate google_adsense2 as adsense2;
7203/// # async fn dox() {
7204/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7205///
7206/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7207/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7208/// # .with_native_roots()
7209/// # .unwrap()
7210/// # .https_only()
7211/// # .enable_http2()
7212/// # .build();
7213///
7214/// # let executor = hyper_util::rt::TokioExecutor::new();
7215/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7216/// # secret,
7217/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7218/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7219/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7220/// # ),
7221/// # ).build().await.unwrap();
7222///
7223/// # let client = hyper_util::client::legacy::Client::builder(
7224/// # hyper_util::rt::TokioExecutor::new()
7225/// # )
7226/// # .build(
7227/// # hyper_rustls::HttpsConnectorBuilder::new()
7228/// # .with_native_roots()
7229/// # .unwrap()
7230/// # .https_or_http()
7231/// # .enable_http2()
7232/// # .build()
7233/// # );
7234/// # let mut hub = Adsense::new(client, auth);
7235/// // You can configure optional parameters by calling the respective setters at will, and
7236/// // execute the final call using `doit()`.
7237/// // Values shown here are possibly random and not representative !
7238/// let result = hub.accounts().alerts_list("parent")
7239/// .language_code("voluptua.")
7240/// .doit().await;
7241/// # }
7242/// ```
7243pub struct AccountAlertListCall<'a, C>
7244where
7245 C: 'a,
7246{
7247 hub: &'a Adsense<C>,
7248 _parent: String,
7249 _language_code: Option<String>,
7250 _delegate: Option<&'a mut dyn common::Delegate>,
7251 _additional_params: HashMap<String, String>,
7252 _scopes: BTreeSet<String>,
7253}
7254
7255impl<'a, C> common::CallBuilder for AccountAlertListCall<'a, C> {}
7256
7257impl<'a, C> AccountAlertListCall<'a, C>
7258where
7259 C: common::Connector,
7260{
7261 /// Perform the operation you have build so far.
7262 pub async fn doit(mut self) -> common::Result<(common::Response, ListAlertsResponse)> {
7263 use std::borrow::Cow;
7264 use std::io::{Read, Seek};
7265
7266 use common::{url::Params, ToParts};
7267 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7268
7269 let mut dd = common::DefaultDelegate;
7270 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7271 dlg.begin(common::MethodInfo {
7272 id: "adsense.accounts.alerts.list",
7273 http_method: hyper::Method::GET,
7274 });
7275
7276 for &field in ["alt", "parent", "languageCode"].iter() {
7277 if self._additional_params.contains_key(field) {
7278 dlg.finished(false);
7279 return Err(common::Error::FieldClash(field));
7280 }
7281 }
7282
7283 let mut params = Params::with_capacity(4 + self._additional_params.len());
7284 params.push("parent", self._parent);
7285 if let Some(value) = self._language_code.as_ref() {
7286 params.push("languageCode", value);
7287 }
7288
7289 params.extend(self._additional_params.iter());
7290
7291 params.push("alt", "json");
7292 let mut url = self.hub._base_url.clone() + "v2/{+parent}/alerts";
7293 if self._scopes.is_empty() {
7294 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7295 }
7296
7297 #[allow(clippy::single_element_loop)]
7298 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7299 url = params.uri_replacement(url, param_name, find_this, true);
7300 }
7301 {
7302 let to_remove = ["parent"];
7303 params.remove_params(&to_remove);
7304 }
7305
7306 let url = params.parse_with_url(&url);
7307
7308 loop {
7309 let token = match self
7310 .hub
7311 .auth
7312 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7313 .await
7314 {
7315 Ok(token) => token,
7316 Err(e) => match dlg.token(e) {
7317 Ok(token) => token,
7318 Err(e) => {
7319 dlg.finished(false);
7320 return Err(common::Error::MissingToken(e));
7321 }
7322 },
7323 };
7324 let mut req_result = {
7325 let client = &self.hub.client;
7326 dlg.pre_request();
7327 let mut req_builder = hyper::Request::builder()
7328 .method(hyper::Method::GET)
7329 .uri(url.as_str())
7330 .header(USER_AGENT, self.hub._user_agent.clone());
7331
7332 if let Some(token) = token.as_ref() {
7333 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7334 }
7335
7336 let request = req_builder
7337 .header(CONTENT_LENGTH, 0_u64)
7338 .body(common::to_body::<String>(None));
7339
7340 client.request(request.unwrap()).await
7341 };
7342
7343 match req_result {
7344 Err(err) => {
7345 if let common::Retry::After(d) = dlg.http_error(&err) {
7346 sleep(d).await;
7347 continue;
7348 }
7349 dlg.finished(false);
7350 return Err(common::Error::HttpError(err));
7351 }
7352 Ok(res) => {
7353 let (mut parts, body) = res.into_parts();
7354 let mut body = common::Body::new(body);
7355 if !parts.status.is_success() {
7356 let bytes = common::to_bytes(body).await.unwrap_or_default();
7357 let error = serde_json::from_str(&common::to_string(&bytes));
7358 let response = common::to_response(parts, bytes.into());
7359
7360 if let common::Retry::After(d) =
7361 dlg.http_failure(&response, error.as_ref().ok())
7362 {
7363 sleep(d).await;
7364 continue;
7365 }
7366
7367 dlg.finished(false);
7368
7369 return Err(match error {
7370 Ok(value) => common::Error::BadRequest(value),
7371 _ => common::Error::Failure(response),
7372 });
7373 }
7374 let response = {
7375 let bytes = common::to_bytes(body).await.unwrap_or_default();
7376 let encoded = common::to_string(&bytes);
7377 match serde_json::from_str(&encoded) {
7378 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7379 Err(error) => {
7380 dlg.response_json_decode_error(&encoded, &error);
7381 return Err(common::Error::JsonDecodeError(
7382 encoded.to_string(),
7383 error,
7384 ));
7385 }
7386 }
7387 };
7388
7389 dlg.finished(true);
7390 return Ok(response);
7391 }
7392 }
7393 }
7394 }
7395
7396 /// Required. The account which owns the collection of alerts. Format: accounts/{account}
7397 ///
7398 /// Sets the *parent* path property to the given value.
7399 ///
7400 /// Even though the property as already been set when instantiating this call,
7401 /// we provide this method for API completeness.
7402 pub fn parent(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
7403 self._parent = new_value.to_string();
7404 self
7405 }
7406 /// The language to use for translating alert messages. If unspecified, this defaults to the user's display language. If the given language is not supported, alerts will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
7407 ///
7408 /// Sets the *language code* query property to the given value.
7409 pub fn language_code(mut self, new_value: &str) -> AccountAlertListCall<'a, C> {
7410 self._language_code = Some(new_value.to_string());
7411 self
7412 }
7413 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7414 /// while executing the actual API request.
7415 ///
7416 /// ````text
7417 /// It should be used to handle progress information, and to implement a certain level of resilience.
7418 /// ````
7419 ///
7420 /// Sets the *delegate* property to the given value.
7421 pub fn delegate(
7422 mut self,
7423 new_value: &'a mut dyn common::Delegate,
7424 ) -> AccountAlertListCall<'a, C> {
7425 self._delegate = Some(new_value);
7426 self
7427 }
7428
7429 /// Set any additional parameter of the query string used in the request.
7430 /// It should be used to set parameters which are not yet available through their own
7431 /// setters.
7432 ///
7433 /// Please note that this method must not be used to set any of the known parameters
7434 /// which have their own setter method. If done anyway, the request will fail.
7435 ///
7436 /// # Additional Parameters
7437 ///
7438 /// * *$.xgafv* (query-string) - V1 error format.
7439 /// * *access_token* (query-string) - OAuth access token.
7440 /// * *alt* (query-string) - Data format for response.
7441 /// * *callback* (query-string) - JSONP
7442 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7443 /// * *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.
7444 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7445 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7446 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7447 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7448 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7449 pub fn param<T>(mut self, name: T, value: T) -> AccountAlertListCall<'a, C>
7450 where
7451 T: AsRef<str>,
7452 {
7453 self._additional_params
7454 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7455 self
7456 }
7457
7458 /// Identifies the authorization scope for the method you are building.
7459 ///
7460 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7461 /// [`Scope::Readonly`].
7462 ///
7463 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7464 /// tokens for more than one scope.
7465 ///
7466 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7467 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7468 /// sufficient, a read-write scope will do as well.
7469 pub fn add_scope<St>(mut self, scope: St) -> AccountAlertListCall<'a, C>
7470 where
7471 St: AsRef<str>,
7472 {
7473 self._scopes.insert(String::from(scope.as_ref()));
7474 self
7475 }
7476 /// Identifies the authorization scope(s) for the method you are building.
7477 ///
7478 /// See [`Self::add_scope()`] for details.
7479 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountAlertListCall<'a, C>
7480 where
7481 I: IntoIterator<Item = St>,
7482 St: AsRef<str>,
7483 {
7484 self._scopes
7485 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7486 self
7487 }
7488
7489 /// Removes all scopes, and no default scope will be used either.
7490 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7491 /// for details).
7492 pub fn clear_scopes(mut self) -> AccountAlertListCall<'a, C> {
7493 self._scopes.clear();
7494 self
7495 }
7496}
7497
7498/// Lists all the payments available for an account.
7499///
7500/// A builder for the *payments.list* method supported by a *account* resource.
7501/// It is not used directly, but through a [`AccountMethods`] instance.
7502///
7503/// # Example
7504///
7505/// Instantiate a resource method builder
7506///
7507/// ```test_harness,no_run
7508/// # extern crate hyper;
7509/// # extern crate hyper_rustls;
7510/// # extern crate google_adsense2 as adsense2;
7511/// # async fn dox() {
7512/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7513///
7514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7516/// # .with_native_roots()
7517/// # .unwrap()
7518/// # .https_only()
7519/// # .enable_http2()
7520/// # .build();
7521///
7522/// # let executor = hyper_util::rt::TokioExecutor::new();
7523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7524/// # secret,
7525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7526/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7527/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7528/// # ),
7529/// # ).build().await.unwrap();
7530///
7531/// # let client = hyper_util::client::legacy::Client::builder(
7532/// # hyper_util::rt::TokioExecutor::new()
7533/// # )
7534/// # .build(
7535/// # hyper_rustls::HttpsConnectorBuilder::new()
7536/// # .with_native_roots()
7537/// # .unwrap()
7538/// # .https_or_http()
7539/// # .enable_http2()
7540/// # .build()
7541/// # );
7542/// # let mut hub = Adsense::new(client, auth);
7543/// // You can configure optional parameters by calling the respective setters at will, and
7544/// // execute the final call using `doit()`.
7545/// // Values shown here are possibly random and not representative !
7546/// let result = hub.accounts().payments_list("parent")
7547/// .doit().await;
7548/// # }
7549/// ```
7550pub struct AccountPaymentListCall<'a, C>
7551where
7552 C: 'a,
7553{
7554 hub: &'a Adsense<C>,
7555 _parent: String,
7556 _delegate: Option<&'a mut dyn common::Delegate>,
7557 _additional_params: HashMap<String, String>,
7558 _scopes: BTreeSet<String>,
7559}
7560
7561impl<'a, C> common::CallBuilder for AccountPaymentListCall<'a, C> {}
7562
7563impl<'a, C> AccountPaymentListCall<'a, C>
7564where
7565 C: common::Connector,
7566{
7567 /// Perform the operation you have build so far.
7568 pub async fn doit(mut self) -> common::Result<(common::Response, ListPaymentsResponse)> {
7569 use std::borrow::Cow;
7570 use std::io::{Read, Seek};
7571
7572 use common::{url::Params, ToParts};
7573 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7574
7575 let mut dd = common::DefaultDelegate;
7576 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7577 dlg.begin(common::MethodInfo {
7578 id: "adsense.accounts.payments.list",
7579 http_method: hyper::Method::GET,
7580 });
7581
7582 for &field in ["alt", "parent"].iter() {
7583 if self._additional_params.contains_key(field) {
7584 dlg.finished(false);
7585 return Err(common::Error::FieldClash(field));
7586 }
7587 }
7588
7589 let mut params = Params::with_capacity(3 + self._additional_params.len());
7590 params.push("parent", self._parent);
7591
7592 params.extend(self._additional_params.iter());
7593
7594 params.push("alt", "json");
7595 let mut url = self.hub._base_url.clone() + "v2/{+parent}/payments";
7596 if self._scopes.is_empty() {
7597 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7598 }
7599
7600 #[allow(clippy::single_element_loop)]
7601 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7602 url = params.uri_replacement(url, param_name, find_this, true);
7603 }
7604 {
7605 let to_remove = ["parent"];
7606 params.remove_params(&to_remove);
7607 }
7608
7609 let url = params.parse_with_url(&url);
7610
7611 loop {
7612 let token = match self
7613 .hub
7614 .auth
7615 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7616 .await
7617 {
7618 Ok(token) => token,
7619 Err(e) => match dlg.token(e) {
7620 Ok(token) => token,
7621 Err(e) => {
7622 dlg.finished(false);
7623 return Err(common::Error::MissingToken(e));
7624 }
7625 },
7626 };
7627 let mut req_result = {
7628 let client = &self.hub.client;
7629 dlg.pre_request();
7630 let mut req_builder = hyper::Request::builder()
7631 .method(hyper::Method::GET)
7632 .uri(url.as_str())
7633 .header(USER_AGENT, self.hub._user_agent.clone());
7634
7635 if let Some(token) = token.as_ref() {
7636 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7637 }
7638
7639 let request = req_builder
7640 .header(CONTENT_LENGTH, 0_u64)
7641 .body(common::to_body::<String>(None));
7642
7643 client.request(request.unwrap()).await
7644 };
7645
7646 match req_result {
7647 Err(err) => {
7648 if let common::Retry::After(d) = dlg.http_error(&err) {
7649 sleep(d).await;
7650 continue;
7651 }
7652 dlg.finished(false);
7653 return Err(common::Error::HttpError(err));
7654 }
7655 Ok(res) => {
7656 let (mut parts, body) = res.into_parts();
7657 let mut body = common::Body::new(body);
7658 if !parts.status.is_success() {
7659 let bytes = common::to_bytes(body).await.unwrap_or_default();
7660 let error = serde_json::from_str(&common::to_string(&bytes));
7661 let response = common::to_response(parts, bytes.into());
7662
7663 if let common::Retry::After(d) =
7664 dlg.http_failure(&response, error.as_ref().ok())
7665 {
7666 sleep(d).await;
7667 continue;
7668 }
7669
7670 dlg.finished(false);
7671
7672 return Err(match error {
7673 Ok(value) => common::Error::BadRequest(value),
7674 _ => common::Error::Failure(response),
7675 });
7676 }
7677 let response = {
7678 let bytes = common::to_bytes(body).await.unwrap_or_default();
7679 let encoded = common::to_string(&bytes);
7680 match serde_json::from_str(&encoded) {
7681 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7682 Err(error) => {
7683 dlg.response_json_decode_error(&encoded, &error);
7684 return Err(common::Error::JsonDecodeError(
7685 encoded.to_string(),
7686 error,
7687 ));
7688 }
7689 }
7690 };
7691
7692 dlg.finished(true);
7693 return Ok(response);
7694 }
7695 }
7696 }
7697 }
7698
7699 /// Required. The account which owns the collection of payments. Format: accounts/{account}
7700 ///
7701 /// Sets the *parent* path property to the given value.
7702 ///
7703 /// Even though the property as already been set when instantiating this call,
7704 /// we provide this method for API completeness.
7705 pub fn parent(mut self, new_value: &str) -> AccountPaymentListCall<'a, C> {
7706 self._parent = new_value.to_string();
7707 self
7708 }
7709 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7710 /// while executing the actual API request.
7711 ///
7712 /// ````text
7713 /// It should be used to handle progress information, and to implement a certain level of resilience.
7714 /// ````
7715 ///
7716 /// Sets the *delegate* property to the given value.
7717 pub fn delegate(
7718 mut self,
7719 new_value: &'a mut dyn common::Delegate,
7720 ) -> AccountPaymentListCall<'a, C> {
7721 self._delegate = Some(new_value);
7722 self
7723 }
7724
7725 /// Set any additional parameter of the query string used in the request.
7726 /// It should be used to set parameters which are not yet available through their own
7727 /// setters.
7728 ///
7729 /// Please note that this method must not be used to set any of the known parameters
7730 /// which have their own setter method. If done anyway, the request will fail.
7731 ///
7732 /// # Additional Parameters
7733 ///
7734 /// * *$.xgafv* (query-string) - V1 error format.
7735 /// * *access_token* (query-string) - OAuth access token.
7736 /// * *alt* (query-string) - Data format for response.
7737 /// * *callback* (query-string) - JSONP
7738 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7739 /// * *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.
7740 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7741 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7742 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7743 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7744 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7745 pub fn param<T>(mut self, name: T, value: T) -> AccountPaymentListCall<'a, C>
7746 where
7747 T: AsRef<str>,
7748 {
7749 self._additional_params
7750 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7751 self
7752 }
7753
7754 /// Identifies the authorization scope for the method you are building.
7755 ///
7756 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7757 /// [`Scope::Readonly`].
7758 ///
7759 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7760 /// tokens for more than one scope.
7761 ///
7762 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7763 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7764 /// sufficient, a read-write scope will do as well.
7765 pub fn add_scope<St>(mut self, scope: St) -> AccountPaymentListCall<'a, C>
7766 where
7767 St: AsRef<str>,
7768 {
7769 self._scopes.insert(String::from(scope.as_ref()));
7770 self
7771 }
7772 /// Identifies the authorization scope(s) for the method you are building.
7773 ///
7774 /// See [`Self::add_scope()`] for details.
7775 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPaymentListCall<'a, C>
7776 where
7777 I: IntoIterator<Item = St>,
7778 St: AsRef<str>,
7779 {
7780 self._scopes
7781 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7782 self
7783 }
7784
7785 /// Removes all scopes, and no default scope will be used either.
7786 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7787 /// for details).
7788 pub fn clear_scopes(mut self) -> AccountPaymentListCall<'a, C> {
7789 self._scopes.clear();
7790 self
7791 }
7792}
7793
7794/// Gets information about the selected policy issue.
7795///
7796/// A builder for the *policyIssues.get* method supported by a *account* resource.
7797/// It is not used directly, but through a [`AccountMethods`] instance.
7798///
7799/// # Example
7800///
7801/// Instantiate a resource method builder
7802///
7803/// ```test_harness,no_run
7804/// # extern crate hyper;
7805/// # extern crate hyper_rustls;
7806/// # extern crate google_adsense2 as adsense2;
7807/// # async fn dox() {
7808/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7809///
7810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7812/// # .with_native_roots()
7813/// # .unwrap()
7814/// # .https_only()
7815/// # .enable_http2()
7816/// # .build();
7817///
7818/// # let executor = hyper_util::rt::TokioExecutor::new();
7819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7820/// # secret,
7821/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7822/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7823/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7824/// # ),
7825/// # ).build().await.unwrap();
7826///
7827/// # let client = hyper_util::client::legacy::Client::builder(
7828/// # hyper_util::rt::TokioExecutor::new()
7829/// # )
7830/// # .build(
7831/// # hyper_rustls::HttpsConnectorBuilder::new()
7832/// # .with_native_roots()
7833/// # .unwrap()
7834/// # .https_or_http()
7835/// # .enable_http2()
7836/// # .build()
7837/// # );
7838/// # let mut hub = Adsense::new(client, auth);
7839/// // You can configure optional parameters by calling the respective setters at will, and
7840/// // execute the final call using `doit()`.
7841/// // Values shown here are possibly random and not representative !
7842/// let result = hub.accounts().policy_issues_get("name")
7843/// .doit().await;
7844/// # }
7845/// ```
7846pub struct AccountPolicyIssueGetCall<'a, C>
7847where
7848 C: 'a,
7849{
7850 hub: &'a Adsense<C>,
7851 _name: String,
7852 _delegate: Option<&'a mut dyn common::Delegate>,
7853 _additional_params: HashMap<String, String>,
7854 _scopes: BTreeSet<String>,
7855}
7856
7857impl<'a, C> common::CallBuilder for AccountPolicyIssueGetCall<'a, C> {}
7858
7859impl<'a, C> AccountPolicyIssueGetCall<'a, C>
7860where
7861 C: common::Connector,
7862{
7863 /// Perform the operation you have build so far.
7864 pub async fn doit(mut self) -> common::Result<(common::Response, PolicyIssue)> {
7865 use std::borrow::Cow;
7866 use std::io::{Read, Seek};
7867
7868 use common::{url::Params, ToParts};
7869 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7870
7871 let mut dd = common::DefaultDelegate;
7872 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7873 dlg.begin(common::MethodInfo {
7874 id: "adsense.accounts.policyIssues.get",
7875 http_method: hyper::Method::GET,
7876 });
7877
7878 for &field in ["alt", "name"].iter() {
7879 if self._additional_params.contains_key(field) {
7880 dlg.finished(false);
7881 return Err(common::Error::FieldClash(field));
7882 }
7883 }
7884
7885 let mut params = Params::with_capacity(3 + self._additional_params.len());
7886 params.push("name", self._name);
7887
7888 params.extend(self._additional_params.iter());
7889
7890 params.push("alt", "json");
7891 let mut url = self.hub._base_url.clone() + "v2/{+name}";
7892 if self._scopes.is_empty() {
7893 self._scopes.insert(Scope::Readonly.as_ref().to_string());
7894 }
7895
7896 #[allow(clippy::single_element_loop)]
7897 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7898 url = params.uri_replacement(url, param_name, find_this, true);
7899 }
7900 {
7901 let to_remove = ["name"];
7902 params.remove_params(&to_remove);
7903 }
7904
7905 let url = params.parse_with_url(&url);
7906
7907 loop {
7908 let token = match self
7909 .hub
7910 .auth
7911 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7912 .await
7913 {
7914 Ok(token) => token,
7915 Err(e) => match dlg.token(e) {
7916 Ok(token) => token,
7917 Err(e) => {
7918 dlg.finished(false);
7919 return Err(common::Error::MissingToken(e));
7920 }
7921 },
7922 };
7923 let mut req_result = {
7924 let client = &self.hub.client;
7925 dlg.pre_request();
7926 let mut req_builder = hyper::Request::builder()
7927 .method(hyper::Method::GET)
7928 .uri(url.as_str())
7929 .header(USER_AGENT, self.hub._user_agent.clone());
7930
7931 if let Some(token) = token.as_ref() {
7932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7933 }
7934
7935 let request = req_builder
7936 .header(CONTENT_LENGTH, 0_u64)
7937 .body(common::to_body::<String>(None));
7938
7939 client.request(request.unwrap()).await
7940 };
7941
7942 match req_result {
7943 Err(err) => {
7944 if let common::Retry::After(d) = dlg.http_error(&err) {
7945 sleep(d).await;
7946 continue;
7947 }
7948 dlg.finished(false);
7949 return Err(common::Error::HttpError(err));
7950 }
7951 Ok(res) => {
7952 let (mut parts, body) = res.into_parts();
7953 let mut body = common::Body::new(body);
7954 if !parts.status.is_success() {
7955 let bytes = common::to_bytes(body).await.unwrap_or_default();
7956 let error = serde_json::from_str(&common::to_string(&bytes));
7957 let response = common::to_response(parts, bytes.into());
7958
7959 if let common::Retry::After(d) =
7960 dlg.http_failure(&response, error.as_ref().ok())
7961 {
7962 sleep(d).await;
7963 continue;
7964 }
7965
7966 dlg.finished(false);
7967
7968 return Err(match error {
7969 Ok(value) => common::Error::BadRequest(value),
7970 _ => common::Error::Failure(response),
7971 });
7972 }
7973 let response = {
7974 let bytes = common::to_bytes(body).await.unwrap_or_default();
7975 let encoded = common::to_string(&bytes);
7976 match serde_json::from_str(&encoded) {
7977 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7978 Err(error) => {
7979 dlg.response_json_decode_error(&encoded, &error);
7980 return Err(common::Error::JsonDecodeError(
7981 encoded.to_string(),
7982 error,
7983 ));
7984 }
7985 }
7986 };
7987
7988 dlg.finished(true);
7989 return Ok(response);
7990 }
7991 }
7992 }
7993 }
7994
7995 /// Required. Name of the policy issue. Format: accounts/{account}/policyIssues/{policy_issue}
7996 ///
7997 /// Sets the *name* path property to the given value.
7998 ///
7999 /// Even though the property as already been set when instantiating this call,
8000 /// we provide this method for API completeness.
8001 pub fn name(mut self, new_value: &str) -> AccountPolicyIssueGetCall<'a, C> {
8002 self._name = new_value.to_string();
8003 self
8004 }
8005 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8006 /// while executing the actual API request.
8007 ///
8008 /// ````text
8009 /// It should be used to handle progress information, and to implement a certain level of resilience.
8010 /// ````
8011 ///
8012 /// Sets the *delegate* property to the given value.
8013 pub fn delegate(
8014 mut self,
8015 new_value: &'a mut dyn common::Delegate,
8016 ) -> AccountPolicyIssueGetCall<'a, C> {
8017 self._delegate = Some(new_value);
8018 self
8019 }
8020
8021 /// Set any additional parameter of the query string used in the request.
8022 /// It should be used to set parameters which are not yet available through their own
8023 /// setters.
8024 ///
8025 /// Please note that this method must not be used to set any of the known parameters
8026 /// which have their own setter method. If done anyway, the request will fail.
8027 ///
8028 /// # Additional Parameters
8029 ///
8030 /// * *$.xgafv* (query-string) - V1 error format.
8031 /// * *access_token* (query-string) - OAuth access token.
8032 /// * *alt* (query-string) - Data format for response.
8033 /// * *callback* (query-string) - JSONP
8034 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8035 /// * *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.
8036 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8037 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8038 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8039 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8040 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8041 pub fn param<T>(mut self, name: T, value: T) -> AccountPolicyIssueGetCall<'a, C>
8042 where
8043 T: AsRef<str>,
8044 {
8045 self._additional_params
8046 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8047 self
8048 }
8049
8050 /// Identifies the authorization scope for the method you are building.
8051 ///
8052 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8053 /// [`Scope::Readonly`].
8054 ///
8055 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8056 /// tokens for more than one scope.
8057 ///
8058 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8059 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8060 /// sufficient, a read-write scope will do as well.
8061 pub fn add_scope<St>(mut self, scope: St) -> AccountPolicyIssueGetCall<'a, C>
8062 where
8063 St: AsRef<str>,
8064 {
8065 self._scopes.insert(String::from(scope.as_ref()));
8066 self
8067 }
8068 /// Identifies the authorization scope(s) for the method you are building.
8069 ///
8070 /// See [`Self::add_scope()`] for details.
8071 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPolicyIssueGetCall<'a, C>
8072 where
8073 I: IntoIterator<Item = St>,
8074 St: AsRef<str>,
8075 {
8076 self._scopes
8077 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8078 self
8079 }
8080
8081 /// Removes all scopes, and no default scope will be used either.
8082 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8083 /// for details).
8084 pub fn clear_scopes(mut self) -> AccountPolicyIssueGetCall<'a, C> {
8085 self._scopes.clear();
8086 self
8087 }
8088}
8089
8090/// Lists all the policy issues where the specified account is involved, both directly and through any AFP child accounts.
8091///
8092/// A builder for the *policyIssues.list* method supported by a *account* resource.
8093/// It is not used directly, but through a [`AccountMethods`] instance.
8094///
8095/// # Example
8096///
8097/// Instantiate a resource method builder
8098///
8099/// ```test_harness,no_run
8100/// # extern crate hyper;
8101/// # extern crate hyper_rustls;
8102/// # extern crate google_adsense2 as adsense2;
8103/// # async fn dox() {
8104/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8105///
8106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8107/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8108/// # .with_native_roots()
8109/// # .unwrap()
8110/// # .https_only()
8111/// # .enable_http2()
8112/// # .build();
8113///
8114/// # let executor = hyper_util::rt::TokioExecutor::new();
8115/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8116/// # secret,
8117/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8118/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8119/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8120/// # ),
8121/// # ).build().await.unwrap();
8122///
8123/// # let client = hyper_util::client::legacy::Client::builder(
8124/// # hyper_util::rt::TokioExecutor::new()
8125/// # )
8126/// # .build(
8127/// # hyper_rustls::HttpsConnectorBuilder::new()
8128/// # .with_native_roots()
8129/// # .unwrap()
8130/// # .https_or_http()
8131/// # .enable_http2()
8132/// # .build()
8133/// # );
8134/// # let mut hub = Adsense::new(client, auth);
8135/// // You can configure optional parameters by calling the respective setters at will, and
8136/// // execute the final call using `doit()`.
8137/// // Values shown here are possibly random and not representative !
8138/// let result = hub.accounts().policy_issues_list("parent")
8139/// .page_token("amet.")
8140/// .page_size(-30)
8141/// .doit().await;
8142/// # }
8143/// ```
8144pub struct AccountPolicyIssueListCall<'a, C>
8145where
8146 C: 'a,
8147{
8148 hub: &'a Adsense<C>,
8149 _parent: String,
8150 _page_token: Option<String>,
8151 _page_size: Option<i32>,
8152 _delegate: Option<&'a mut dyn common::Delegate>,
8153 _additional_params: HashMap<String, String>,
8154 _scopes: BTreeSet<String>,
8155}
8156
8157impl<'a, C> common::CallBuilder for AccountPolicyIssueListCall<'a, C> {}
8158
8159impl<'a, C> AccountPolicyIssueListCall<'a, C>
8160where
8161 C: common::Connector,
8162{
8163 /// Perform the operation you have build so far.
8164 pub async fn doit(mut self) -> common::Result<(common::Response, ListPolicyIssuesResponse)> {
8165 use std::borrow::Cow;
8166 use std::io::{Read, Seek};
8167
8168 use common::{url::Params, ToParts};
8169 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8170
8171 let mut dd = common::DefaultDelegate;
8172 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8173 dlg.begin(common::MethodInfo {
8174 id: "adsense.accounts.policyIssues.list",
8175 http_method: hyper::Method::GET,
8176 });
8177
8178 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8179 if self._additional_params.contains_key(field) {
8180 dlg.finished(false);
8181 return Err(common::Error::FieldClash(field));
8182 }
8183 }
8184
8185 let mut params = Params::with_capacity(5 + self._additional_params.len());
8186 params.push("parent", self._parent);
8187 if let Some(value) = self._page_token.as_ref() {
8188 params.push("pageToken", value);
8189 }
8190 if let Some(value) = self._page_size.as_ref() {
8191 params.push("pageSize", value.to_string());
8192 }
8193
8194 params.extend(self._additional_params.iter());
8195
8196 params.push("alt", "json");
8197 let mut url = self.hub._base_url.clone() + "v2/{+parent}/policyIssues";
8198 if self._scopes.is_empty() {
8199 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8200 }
8201
8202 #[allow(clippy::single_element_loop)]
8203 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8204 url = params.uri_replacement(url, param_name, find_this, true);
8205 }
8206 {
8207 let to_remove = ["parent"];
8208 params.remove_params(&to_remove);
8209 }
8210
8211 let url = params.parse_with_url(&url);
8212
8213 loop {
8214 let token = match self
8215 .hub
8216 .auth
8217 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8218 .await
8219 {
8220 Ok(token) => token,
8221 Err(e) => match dlg.token(e) {
8222 Ok(token) => token,
8223 Err(e) => {
8224 dlg.finished(false);
8225 return Err(common::Error::MissingToken(e));
8226 }
8227 },
8228 };
8229 let mut req_result = {
8230 let client = &self.hub.client;
8231 dlg.pre_request();
8232 let mut req_builder = hyper::Request::builder()
8233 .method(hyper::Method::GET)
8234 .uri(url.as_str())
8235 .header(USER_AGENT, self.hub._user_agent.clone());
8236
8237 if let Some(token) = token.as_ref() {
8238 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8239 }
8240
8241 let request = req_builder
8242 .header(CONTENT_LENGTH, 0_u64)
8243 .body(common::to_body::<String>(None));
8244
8245 client.request(request.unwrap()).await
8246 };
8247
8248 match req_result {
8249 Err(err) => {
8250 if let common::Retry::After(d) = dlg.http_error(&err) {
8251 sleep(d).await;
8252 continue;
8253 }
8254 dlg.finished(false);
8255 return Err(common::Error::HttpError(err));
8256 }
8257 Ok(res) => {
8258 let (mut parts, body) = res.into_parts();
8259 let mut body = common::Body::new(body);
8260 if !parts.status.is_success() {
8261 let bytes = common::to_bytes(body).await.unwrap_or_default();
8262 let error = serde_json::from_str(&common::to_string(&bytes));
8263 let response = common::to_response(parts, bytes.into());
8264
8265 if let common::Retry::After(d) =
8266 dlg.http_failure(&response, error.as_ref().ok())
8267 {
8268 sleep(d).await;
8269 continue;
8270 }
8271
8272 dlg.finished(false);
8273
8274 return Err(match error {
8275 Ok(value) => common::Error::BadRequest(value),
8276 _ => common::Error::Failure(response),
8277 });
8278 }
8279 let response = {
8280 let bytes = common::to_bytes(body).await.unwrap_or_default();
8281 let encoded = common::to_string(&bytes);
8282 match serde_json::from_str(&encoded) {
8283 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8284 Err(error) => {
8285 dlg.response_json_decode_error(&encoded, &error);
8286 return Err(common::Error::JsonDecodeError(
8287 encoded.to_string(),
8288 error,
8289 ));
8290 }
8291 }
8292 };
8293
8294 dlg.finished(true);
8295 return Ok(response);
8296 }
8297 }
8298 }
8299 }
8300
8301 /// Required. The account for which policy issues are being retrieved. Format: accounts/{account}
8302 ///
8303 /// Sets the *parent* path property to the given value.
8304 ///
8305 /// Even though the property as already been set when instantiating this call,
8306 /// we provide this method for API completeness.
8307 pub fn parent(mut self, new_value: &str) -> AccountPolicyIssueListCall<'a, C> {
8308 self._parent = new_value.to_string();
8309 self
8310 }
8311 /// A page token, received from a previous `ListPolicyIssues` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPolicyIssues` must match the call that provided the page token.
8312 ///
8313 /// Sets the *page token* query property to the given value.
8314 pub fn page_token(mut self, new_value: &str) -> AccountPolicyIssueListCall<'a, C> {
8315 self._page_token = Some(new_value.to_string());
8316 self
8317 }
8318 /// The maximum number of policy issues to include in the response, used for paging. If unspecified, at most 10000 policy issues will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
8319 ///
8320 /// Sets the *page size* query property to the given value.
8321 pub fn page_size(mut self, new_value: i32) -> AccountPolicyIssueListCall<'a, C> {
8322 self._page_size = Some(new_value);
8323 self
8324 }
8325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8326 /// while executing the actual API request.
8327 ///
8328 /// ````text
8329 /// It should be used to handle progress information, and to implement a certain level of resilience.
8330 /// ````
8331 ///
8332 /// Sets the *delegate* property to the given value.
8333 pub fn delegate(
8334 mut self,
8335 new_value: &'a mut dyn common::Delegate,
8336 ) -> AccountPolicyIssueListCall<'a, C> {
8337 self._delegate = Some(new_value);
8338 self
8339 }
8340
8341 /// Set any additional parameter of the query string used in the request.
8342 /// It should be used to set parameters which are not yet available through their own
8343 /// setters.
8344 ///
8345 /// Please note that this method must not be used to set any of the known parameters
8346 /// which have their own setter method. If done anyway, the request will fail.
8347 ///
8348 /// # Additional Parameters
8349 ///
8350 /// * *$.xgafv* (query-string) - V1 error format.
8351 /// * *access_token* (query-string) - OAuth access token.
8352 /// * *alt* (query-string) - Data format for response.
8353 /// * *callback* (query-string) - JSONP
8354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8355 /// * *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.
8356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8358 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8361 pub fn param<T>(mut self, name: T, value: T) -> AccountPolicyIssueListCall<'a, C>
8362 where
8363 T: AsRef<str>,
8364 {
8365 self._additional_params
8366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8367 self
8368 }
8369
8370 /// Identifies the authorization scope for the method you are building.
8371 ///
8372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8373 /// [`Scope::Readonly`].
8374 ///
8375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8376 /// tokens for more than one scope.
8377 ///
8378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8380 /// sufficient, a read-write scope will do as well.
8381 pub fn add_scope<St>(mut self, scope: St) -> AccountPolicyIssueListCall<'a, C>
8382 where
8383 St: AsRef<str>,
8384 {
8385 self._scopes.insert(String::from(scope.as_ref()));
8386 self
8387 }
8388 /// Identifies the authorization scope(s) for the method you are building.
8389 ///
8390 /// See [`Self::add_scope()`] for details.
8391 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPolicyIssueListCall<'a, C>
8392 where
8393 I: IntoIterator<Item = St>,
8394 St: AsRef<str>,
8395 {
8396 self._scopes
8397 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8398 self
8399 }
8400
8401 /// Removes all scopes, and no default scope will be used either.
8402 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8403 /// for details).
8404 pub fn clear_scopes(mut self) -> AccountPolicyIssueListCall<'a, C> {
8405 self._scopes.clear();
8406 self
8407 }
8408}
8409
8410/// Generates a saved report.
8411///
8412/// A builder for the *reports.saved.generate* method supported by a *account* resource.
8413/// It is not used directly, but through a [`AccountMethods`] instance.
8414///
8415/// # Example
8416///
8417/// Instantiate a resource method builder
8418///
8419/// ```test_harness,no_run
8420/// # extern crate hyper;
8421/// # extern crate hyper_rustls;
8422/// # extern crate google_adsense2 as adsense2;
8423/// # async fn dox() {
8424/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8425///
8426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8427/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8428/// # .with_native_roots()
8429/// # .unwrap()
8430/// # .https_only()
8431/// # .enable_http2()
8432/// # .build();
8433///
8434/// # let executor = hyper_util::rt::TokioExecutor::new();
8435/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8436/// # secret,
8437/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8438/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8439/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8440/// # ),
8441/// # ).build().await.unwrap();
8442///
8443/// # let client = hyper_util::client::legacy::Client::builder(
8444/// # hyper_util::rt::TokioExecutor::new()
8445/// # )
8446/// # .build(
8447/// # hyper_rustls::HttpsConnectorBuilder::new()
8448/// # .with_native_roots()
8449/// # .unwrap()
8450/// # .https_or_http()
8451/// # .enable_http2()
8452/// # .build()
8453/// # );
8454/// # let mut hub = Adsense::new(client, auth);
8455/// // You can configure optional parameters by calling the respective setters at will, and
8456/// // execute the final call using `doit()`.
8457/// // Values shown here are possibly random and not representative !
8458/// let result = hub.accounts().reports_saved_generate("name")
8459/// .start_date_year(-19)
8460/// .start_date_month(-62)
8461/// .start_date_day(-74)
8462/// .reporting_time_zone("accusam")
8463/// .language_code("voluptua.")
8464/// .end_date_year(-34)
8465/// .end_date_month(-34)
8466/// .end_date_day(-34)
8467/// .date_range("voluptua.")
8468/// .currency_code("amet.")
8469/// .doit().await;
8470/// # }
8471/// ```
8472pub struct AccountReportSavedGenerateCall<'a, C>
8473where
8474 C: 'a,
8475{
8476 hub: &'a Adsense<C>,
8477 _name: String,
8478 _start_date_year: Option<i32>,
8479 _start_date_month: Option<i32>,
8480 _start_date_day: Option<i32>,
8481 _reporting_time_zone: Option<String>,
8482 _language_code: Option<String>,
8483 _end_date_year: Option<i32>,
8484 _end_date_month: Option<i32>,
8485 _end_date_day: Option<i32>,
8486 _date_range: Option<String>,
8487 _currency_code: Option<String>,
8488 _delegate: Option<&'a mut dyn common::Delegate>,
8489 _additional_params: HashMap<String, String>,
8490 _scopes: BTreeSet<String>,
8491}
8492
8493impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCall<'a, C> {}
8494
8495impl<'a, C> AccountReportSavedGenerateCall<'a, C>
8496where
8497 C: common::Connector,
8498{
8499 /// Perform the operation you have build so far.
8500 pub async fn doit(mut self) -> common::Result<(common::Response, ReportResult)> {
8501 use std::borrow::Cow;
8502 use std::io::{Read, Seek};
8503
8504 use common::{url::Params, ToParts};
8505 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8506
8507 let mut dd = common::DefaultDelegate;
8508 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8509 dlg.begin(common::MethodInfo {
8510 id: "adsense.accounts.reports.saved.generate",
8511 http_method: hyper::Method::GET,
8512 });
8513
8514 for &field in [
8515 "alt",
8516 "name",
8517 "startDate.year",
8518 "startDate.month",
8519 "startDate.day",
8520 "reportingTimeZone",
8521 "languageCode",
8522 "endDate.year",
8523 "endDate.month",
8524 "endDate.day",
8525 "dateRange",
8526 "currencyCode",
8527 ]
8528 .iter()
8529 {
8530 if self._additional_params.contains_key(field) {
8531 dlg.finished(false);
8532 return Err(common::Error::FieldClash(field));
8533 }
8534 }
8535
8536 let mut params = Params::with_capacity(13 + self._additional_params.len());
8537 params.push("name", self._name);
8538 if let Some(value) = self._start_date_year.as_ref() {
8539 params.push("startDate.year", value.to_string());
8540 }
8541 if let Some(value) = self._start_date_month.as_ref() {
8542 params.push("startDate.month", value.to_string());
8543 }
8544 if let Some(value) = self._start_date_day.as_ref() {
8545 params.push("startDate.day", value.to_string());
8546 }
8547 if let Some(value) = self._reporting_time_zone.as_ref() {
8548 params.push("reportingTimeZone", value);
8549 }
8550 if let Some(value) = self._language_code.as_ref() {
8551 params.push("languageCode", value);
8552 }
8553 if let Some(value) = self._end_date_year.as_ref() {
8554 params.push("endDate.year", value.to_string());
8555 }
8556 if let Some(value) = self._end_date_month.as_ref() {
8557 params.push("endDate.month", value.to_string());
8558 }
8559 if let Some(value) = self._end_date_day.as_ref() {
8560 params.push("endDate.day", value.to_string());
8561 }
8562 if let Some(value) = self._date_range.as_ref() {
8563 params.push("dateRange", value);
8564 }
8565 if let Some(value) = self._currency_code.as_ref() {
8566 params.push("currencyCode", value);
8567 }
8568
8569 params.extend(self._additional_params.iter());
8570
8571 params.push("alt", "json");
8572 let mut url = self.hub._base_url.clone() + "v2/{+name}/saved:generate";
8573 if self._scopes.is_empty() {
8574 self._scopes.insert(Scope::Readonly.as_ref().to_string());
8575 }
8576
8577 #[allow(clippy::single_element_loop)]
8578 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8579 url = params.uri_replacement(url, param_name, find_this, true);
8580 }
8581 {
8582 let to_remove = ["name"];
8583 params.remove_params(&to_remove);
8584 }
8585
8586 let url = params.parse_with_url(&url);
8587
8588 loop {
8589 let token = match self
8590 .hub
8591 .auth
8592 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8593 .await
8594 {
8595 Ok(token) => token,
8596 Err(e) => match dlg.token(e) {
8597 Ok(token) => token,
8598 Err(e) => {
8599 dlg.finished(false);
8600 return Err(common::Error::MissingToken(e));
8601 }
8602 },
8603 };
8604 let mut req_result = {
8605 let client = &self.hub.client;
8606 dlg.pre_request();
8607 let mut req_builder = hyper::Request::builder()
8608 .method(hyper::Method::GET)
8609 .uri(url.as_str())
8610 .header(USER_AGENT, self.hub._user_agent.clone());
8611
8612 if let Some(token) = token.as_ref() {
8613 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8614 }
8615
8616 let request = req_builder
8617 .header(CONTENT_LENGTH, 0_u64)
8618 .body(common::to_body::<String>(None));
8619
8620 client.request(request.unwrap()).await
8621 };
8622
8623 match req_result {
8624 Err(err) => {
8625 if let common::Retry::After(d) = dlg.http_error(&err) {
8626 sleep(d).await;
8627 continue;
8628 }
8629 dlg.finished(false);
8630 return Err(common::Error::HttpError(err));
8631 }
8632 Ok(res) => {
8633 let (mut parts, body) = res.into_parts();
8634 let mut body = common::Body::new(body);
8635 if !parts.status.is_success() {
8636 let bytes = common::to_bytes(body).await.unwrap_or_default();
8637 let error = serde_json::from_str(&common::to_string(&bytes));
8638 let response = common::to_response(parts, bytes.into());
8639
8640 if let common::Retry::After(d) =
8641 dlg.http_failure(&response, error.as_ref().ok())
8642 {
8643 sleep(d).await;
8644 continue;
8645 }
8646
8647 dlg.finished(false);
8648
8649 return Err(match error {
8650 Ok(value) => common::Error::BadRequest(value),
8651 _ => common::Error::Failure(response),
8652 });
8653 }
8654 let response = {
8655 let bytes = common::to_bytes(body).await.unwrap_or_default();
8656 let encoded = common::to_string(&bytes);
8657 match serde_json::from_str(&encoded) {
8658 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8659 Err(error) => {
8660 dlg.response_json_decode_error(&encoded, &error);
8661 return Err(common::Error::JsonDecodeError(
8662 encoded.to_string(),
8663 error,
8664 ));
8665 }
8666 }
8667 };
8668
8669 dlg.finished(true);
8670 return Ok(response);
8671 }
8672 }
8673 }
8674 }
8675
8676 /// Required. Name of the saved report. Format: accounts/{account}/reports/{report}
8677 ///
8678 /// Sets the *name* path property to the given value.
8679 ///
8680 /// Even though the property as already been set when instantiating this call,
8681 /// we provide this method for API completeness.
8682 pub fn name(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8683 self._name = new_value.to_string();
8684 self
8685 }
8686 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8687 ///
8688 /// Sets the *start date.year* query property to the given value.
8689 pub fn start_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8690 self._start_date_year = Some(new_value);
8691 self
8692 }
8693 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8694 ///
8695 /// Sets the *start date.month* query property to the given value.
8696 pub fn start_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8697 self._start_date_month = Some(new_value);
8698 self
8699 }
8700 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8701 ///
8702 /// Sets the *start date.day* query property to the given value.
8703 pub fn start_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8704 self._start_date_day = Some(new_value);
8705 self
8706 }
8707 /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
8708 ///
8709 /// Sets the *reporting time zone* query property to the given value.
8710 pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8711 self._reporting_time_zone = Some(new_value.to_string());
8712 self
8713 }
8714 /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
8715 ///
8716 /// Sets the *language code* query property to the given value.
8717 pub fn language_code(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8718 self._language_code = Some(new_value.to_string());
8719 self
8720 }
8721 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
8722 ///
8723 /// Sets the *end date.year* query property to the given value.
8724 pub fn end_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8725 self._end_date_year = Some(new_value);
8726 self
8727 }
8728 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
8729 ///
8730 /// Sets the *end date.month* query property to the given value.
8731 pub fn end_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8732 self._end_date_month = Some(new_value);
8733 self
8734 }
8735 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
8736 ///
8737 /// Sets the *end date.day* query property to the given value.
8738 pub fn end_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCall<'a, C> {
8739 self._end_date_day = Some(new_value);
8740 self
8741 }
8742 /// Date range of the report, if unset the range will be considered CUSTOM.
8743 ///
8744 /// Sets the *date range* query property to the given value.
8745 pub fn date_range(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8746 self._date_range = Some(new_value.to_string());
8747 self
8748 }
8749 /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
8750 ///
8751 /// Sets the *currency code* query property to the given value.
8752 pub fn currency_code(mut self, new_value: &str) -> AccountReportSavedGenerateCall<'a, C> {
8753 self._currency_code = Some(new_value.to_string());
8754 self
8755 }
8756 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8757 /// while executing the actual API request.
8758 ///
8759 /// ````text
8760 /// It should be used to handle progress information, and to implement a certain level of resilience.
8761 /// ````
8762 ///
8763 /// Sets the *delegate* property to the given value.
8764 pub fn delegate(
8765 mut self,
8766 new_value: &'a mut dyn common::Delegate,
8767 ) -> AccountReportSavedGenerateCall<'a, C> {
8768 self._delegate = Some(new_value);
8769 self
8770 }
8771
8772 /// Set any additional parameter of the query string used in the request.
8773 /// It should be used to set parameters which are not yet available through their own
8774 /// setters.
8775 ///
8776 /// Please note that this method must not be used to set any of the known parameters
8777 /// which have their own setter method. If done anyway, the request will fail.
8778 ///
8779 /// # Additional Parameters
8780 ///
8781 /// * *$.xgafv* (query-string) - V1 error format.
8782 /// * *access_token* (query-string) - OAuth access token.
8783 /// * *alt* (query-string) - Data format for response.
8784 /// * *callback* (query-string) - JSONP
8785 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8786 /// * *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.
8787 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8788 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8789 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8790 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8791 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8792 pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCall<'a, C>
8793 where
8794 T: AsRef<str>,
8795 {
8796 self._additional_params
8797 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8798 self
8799 }
8800
8801 /// Identifies the authorization scope for the method you are building.
8802 ///
8803 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8804 /// [`Scope::Readonly`].
8805 ///
8806 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8807 /// tokens for more than one scope.
8808 ///
8809 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8810 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8811 /// sufficient, a read-write scope will do as well.
8812 pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCall<'a, C>
8813 where
8814 St: AsRef<str>,
8815 {
8816 self._scopes.insert(String::from(scope.as_ref()));
8817 self
8818 }
8819 /// Identifies the authorization scope(s) for the method you are building.
8820 ///
8821 /// See [`Self::add_scope()`] for details.
8822 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCall<'a, C>
8823 where
8824 I: IntoIterator<Item = St>,
8825 St: AsRef<str>,
8826 {
8827 self._scopes
8828 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8829 self
8830 }
8831
8832 /// Removes all scopes, and no default scope will be used either.
8833 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8834 /// for details).
8835 pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCall<'a, C> {
8836 self._scopes.clear();
8837 self
8838 }
8839}
8840
8841/// Generates a csv formatted saved report.
8842///
8843/// A builder for the *reports.saved.generateCsv* method supported by a *account* resource.
8844/// It is not used directly, but through a [`AccountMethods`] instance.
8845///
8846/// # Example
8847///
8848/// Instantiate a resource method builder
8849///
8850/// ```test_harness,no_run
8851/// # extern crate hyper;
8852/// # extern crate hyper_rustls;
8853/// # extern crate google_adsense2 as adsense2;
8854/// # async fn dox() {
8855/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8856///
8857/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8858/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8859/// # .with_native_roots()
8860/// # .unwrap()
8861/// # .https_only()
8862/// # .enable_http2()
8863/// # .build();
8864///
8865/// # let executor = hyper_util::rt::TokioExecutor::new();
8866/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8867/// # secret,
8868/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8869/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8870/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8871/// # ),
8872/// # ).build().await.unwrap();
8873///
8874/// # let client = hyper_util::client::legacy::Client::builder(
8875/// # hyper_util::rt::TokioExecutor::new()
8876/// # )
8877/// # .build(
8878/// # hyper_rustls::HttpsConnectorBuilder::new()
8879/// # .with_native_roots()
8880/// # .unwrap()
8881/// # .https_or_http()
8882/// # .enable_http2()
8883/// # .build()
8884/// # );
8885/// # let mut hub = Adsense::new(client, auth);
8886/// // You can configure optional parameters by calling the respective setters at will, and
8887/// // execute the final call using `doit()`.
8888/// // Values shown here are possibly random and not representative !
8889/// let result = hub.accounts().reports_saved_generate_csv("name")
8890/// .start_date_year(-95)
8891/// .start_date_month(-6)
8892/// .start_date_day(-38)
8893/// .reporting_time_zone("no")
8894/// .language_code("est")
8895/// .end_date_year(-27)
8896/// .end_date_month(-43)
8897/// .end_date_day(-98)
8898/// .date_range("et")
8899/// .currency_code("tempor")
8900/// .doit().await;
8901/// # }
8902/// ```
8903pub struct AccountReportSavedGenerateCsvCall<'a, C>
8904where
8905 C: 'a,
8906{
8907 hub: &'a Adsense<C>,
8908 _name: String,
8909 _start_date_year: Option<i32>,
8910 _start_date_month: Option<i32>,
8911 _start_date_day: Option<i32>,
8912 _reporting_time_zone: Option<String>,
8913 _language_code: Option<String>,
8914 _end_date_year: Option<i32>,
8915 _end_date_month: Option<i32>,
8916 _end_date_day: Option<i32>,
8917 _date_range: Option<String>,
8918 _currency_code: Option<String>,
8919 _delegate: Option<&'a mut dyn common::Delegate>,
8920 _additional_params: HashMap<String, String>,
8921 _scopes: BTreeSet<String>,
8922}
8923
8924impl<'a, C> common::CallBuilder for AccountReportSavedGenerateCsvCall<'a, C> {}
8925
8926impl<'a, C> AccountReportSavedGenerateCsvCall<'a, C>
8927where
8928 C: common::Connector,
8929{
8930 /// Perform the operation you have build so far.
8931 pub async fn doit(mut self) -> common::Result<(common::Response, HttpBody)> {
8932 use std::borrow::Cow;
8933 use std::io::{Read, Seek};
8934
8935 use common::{url::Params, ToParts};
8936 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8937
8938 let mut dd = common::DefaultDelegate;
8939 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8940 dlg.begin(common::MethodInfo {
8941 id: "adsense.accounts.reports.saved.generateCsv",
8942 http_method: hyper::Method::GET,
8943 });
8944
8945 for &field in [
8946 "alt",
8947 "name",
8948 "startDate.year",
8949 "startDate.month",
8950 "startDate.day",
8951 "reportingTimeZone",
8952 "languageCode",
8953 "endDate.year",
8954 "endDate.month",
8955 "endDate.day",
8956 "dateRange",
8957 "currencyCode",
8958 ]
8959 .iter()
8960 {
8961 if self._additional_params.contains_key(field) {
8962 dlg.finished(false);
8963 return Err(common::Error::FieldClash(field));
8964 }
8965 }
8966
8967 let mut params = Params::with_capacity(13 + self._additional_params.len());
8968 params.push("name", self._name);
8969 if let Some(value) = self._start_date_year.as_ref() {
8970 params.push("startDate.year", value.to_string());
8971 }
8972 if let Some(value) = self._start_date_month.as_ref() {
8973 params.push("startDate.month", value.to_string());
8974 }
8975 if let Some(value) = self._start_date_day.as_ref() {
8976 params.push("startDate.day", value.to_string());
8977 }
8978 if let Some(value) = self._reporting_time_zone.as_ref() {
8979 params.push("reportingTimeZone", value);
8980 }
8981 if let Some(value) = self._language_code.as_ref() {
8982 params.push("languageCode", value);
8983 }
8984 if let Some(value) = self._end_date_year.as_ref() {
8985 params.push("endDate.year", value.to_string());
8986 }
8987 if let Some(value) = self._end_date_month.as_ref() {
8988 params.push("endDate.month", value.to_string());
8989 }
8990 if let Some(value) = self._end_date_day.as_ref() {
8991 params.push("endDate.day", value.to_string());
8992 }
8993 if let Some(value) = self._date_range.as_ref() {
8994 params.push("dateRange", value);
8995 }
8996 if let Some(value) = self._currency_code.as_ref() {
8997 params.push("currencyCode", value);
8998 }
8999
9000 params.extend(self._additional_params.iter());
9001
9002 params.push("alt", "json");
9003 let mut url = self.hub._base_url.clone() + "v2/{+name}/saved:generateCsv";
9004 if self._scopes.is_empty() {
9005 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9006 }
9007
9008 #[allow(clippy::single_element_loop)]
9009 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9010 url = params.uri_replacement(url, param_name, find_this, true);
9011 }
9012 {
9013 let to_remove = ["name"];
9014 params.remove_params(&to_remove);
9015 }
9016
9017 let url = params.parse_with_url(&url);
9018
9019 loop {
9020 let token = match self
9021 .hub
9022 .auth
9023 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9024 .await
9025 {
9026 Ok(token) => token,
9027 Err(e) => match dlg.token(e) {
9028 Ok(token) => token,
9029 Err(e) => {
9030 dlg.finished(false);
9031 return Err(common::Error::MissingToken(e));
9032 }
9033 },
9034 };
9035 let mut req_result = {
9036 let client = &self.hub.client;
9037 dlg.pre_request();
9038 let mut req_builder = hyper::Request::builder()
9039 .method(hyper::Method::GET)
9040 .uri(url.as_str())
9041 .header(USER_AGENT, self.hub._user_agent.clone());
9042
9043 if let Some(token) = token.as_ref() {
9044 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9045 }
9046
9047 let request = req_builder
9048 .header(CONTENT_LENGTH, 0_u64)
9049 .body(common::to_body::<String>(None));
9050
9051 client.request(request.unwrap()).await
9052 };
9053
9054 match req_result {
9055 Err(err) => {
9056 if let common::Retry::After(d) = dlg.http_error(&err) {
9057 sleep(d).await;
9058 continue;
9059 }
9060 dlg.finished(false);
9061 return Err(common::Error::HttpError(err));
9062 }
9063 Ok(res) => {
9064 let (mut parts, body) = res.into_parts();
9065 let mut body = common::Body::new(body);
9066 if !parts.status.is_success() {
9067 let bytes = common::to_bytes(body).await.unwrap_or_default();
9068 let error = serde_json::from_str(&common::to_string(&bytes));
9069 let response = common::to_response(parts, bytes.into());
9070
9071 if let common::Retry::After(d) =
9072 dlg.http_failure(&response, error.as_ref().ok())
9073 {
9074 sleep(d).await;
9075 continue;
9076 }
9077
9078 dlg.finished(false);
9079
9080 return Err(match error {
9081 Ok(value) => common::Error::BadRequest(value),
9082 _ => common::Error::Failure(response),
9083 });
9084 }
9085 let response = {
9086 let bytes = common::to_bytes(body).await.unwrap_or_default();
9087 let encoded = common::to_string(&bytes);
9088 match serde_json::from_str(&encoded) {
9089 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9090 Err(error) => {
9091 dlg.response_json_decode_error(&encoded, &error);
9092 return Err(common::Error::JsonDecodeError(
9093 encoded.to_string(),
9094 error,
9095 ));
9096 }
9097 }
9098 };
9099
9100 dlg.finished(true);
9101 return Ok(response);
9102 }
9103 }
9104 }
9105 }
9106
9107 /// Required. Name of the saved report. Format: accounts/{account}/reports/{report}
9108 ///
9109 /// Sets the *name* path property to the given value.
9110 ///
9111 /// Even though the property as already been set when instantiating this call,
9112 /// we provide this method for API completeness.
9113 pub fn name(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
9114 self._name = new_value.to_string();
9115 self
9116 }
9117 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9118 ///
9119 /// Sets the *start date.year* query property to the given value.
9120 pub fn start_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9121 self._start_date_year = Some(new_value);
9122 self
9123 }
9124 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9125 ///
9126 /// Sets the *start date.month* query property to the given value.
9127 pub fn start_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9128 self._start_date_month = Some(new_value);
9129 self
9130 }
9131 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9132 ///
9133 /// Sets the *start date.day* query property to the given value.
9134 pub fn start_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9135 self._start_date_day = Some(new_value);
9136 self
9137 }
9138 /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
9139 ///
9140 /// Sets the *reporting time zone* query property to the given value.
9141 pub fn reporting_time_zone(
9142 mut self,
9143 new_value: &str,
9144 ) -> AccountReportSavedGenerateCsvCall<'a, C> {
9145 self._reporting_time_zone = Some(new_value.to_string());
9146 self
9147 }
9148 /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
9149 ///
9150 /// Sets the *language code* query property to the given value.
9151 pub fn language_code(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
9152 self._language_code = Some(new_value.to_string());
9153 self
9154 }
9155 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9156 ///
9157 /// Sets the *end date.year* query property to the given value.
9158 pub fn end_date_year(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9159 self._end_date_year = Some(new_value);
9160 self
9161 }
9162 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9163 ///
9164 /// Sets the *end date.month* query property to the given value.
9165 pub fn end_date_month(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9166 self._end_date_month = Some(new_value);
9167 self
9168 }
9169 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9170 ///
9171 /// Sets the *end date.day* query property to the given value.
9172 pub fn end_date_day(mut self, new_value: i32) -> AccountReportSavedGenerateCsvCall<'a, C> {
9173 self._end_date_day = Some(new_value);
9174 self
9175 }
9176 /// Date range of the report, if unset the range will be considered CUSTOM.
9177 ///
9178 /// Sets the *date range* query property to the given value.
9179 pub fn date_range(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
9180 self._date_range = Some(new_value.to_string());
9181 self
9182 }
9183 /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
9184 ///
9185 /// Sets the *currency code* query property to the given value.
9186 pub fn currency_code(mut self, new_value: &str) -> AccountReportSavedGenerateCsvCall<'a, C> {
9187 self._currency_code = Some(new_value.to_string());
9188 self
9189 }
9190 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9191 /// while executing the actual API request.
9192 ///
9193 /// ````text
9194 /// It should be used to handle progress information, and to implement a certain level of resilience.
9195 /// ````
9196 ///
9197 /// Sets the *delegate* property to the given value.
9198 pub fn delegate(
9199 mut self,
9200 new_value: &'a mut dyn common::Delegate,
9201 ) -> AccountReportSavedGenerateCsvCall<'a, C> {
9202 self._delegate = Some(new_value);
9203 self
9204 }
9205
9206 /// Set any additional parameter of the query string used in the request.
9207 /// It should be used to set parameters which are not yet available through their own
9208 /// setters.
9209 ///
9210 /// Please note that this method must not be used to set any of the known parameters
9211 /// which have their own setter method. If done anyway, the request will fail.
9212 ///
9213 /// # Additional Parameters
9214 ///
9215 /// * *$.xgafv* (query-string) - V1 error format.
9216 /// * *access_token* (query-string) - OAuth access token.
9217 /// * *alt* (query-string) - Data format for response.
9218 /// * *callback* (query-string) - JSONP
9219 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9220 /// * *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.
9221 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9222 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9223 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9224 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9225 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9226 pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedGenerateCsvCall<'a, C>
9227 where
9228 T: AsRef<str>,
9229 {
9230 self._additional_params
9231 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9232 self
9233 }
9234
9235 /// Identifies the authorization scope for the method you are building.
9236 ///
9237 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9238 /// [`Scope::Readonly`].
9239 ///
9240 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9241 /// tokens for more than one scope.
9242 ///
9243 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9244 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9245 /// sufficient, a read-write scope will do as well.
9246 pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedGenerateCsvCall<'a, C>
9247 where
9248 St: AsRef<str>,
9249 {
9250 self._scopes.insert(String::from(scope.as_ref()));
9251 self
9252 }
9253 /// Identifies the authorization scope(s) for the method you are building.
9254 ///
9255 /// See [`Self::add_scope()`] for details.
9256 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedGenerateCsvCall<'a, C>
9257 where
9258 I: IntoIterator<Item = St>,
9259 St: AsRef<str>,
9260 {
9261 self._scopes
9262 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9263 self
9264 }
9265
9266 /// Removes all scopes, and no default scope will be used either.
9267 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9268 /// for details).
9269 pub fn clear_scopes(mut self) -> AccountReportSavedGenerateCsvCall<'a, C> {
9270 self._scopes.clear();
9271 self
9272 }
9273}
9274
9275/// Lists saved reports.
9276///
9277/// A builder for the *reports.saved.list* method supported by a *account* resource.
9278/// It is not used directly, but through a [`AccountMethods`] instance.
9279///
9280/// # Example
9281///
9282/// Instantiate a resource method builder
9283///
9284/// ```test_harness,no_run
9285/// # extern crate hyper;
9286/// # extern crate hyper_rustls;
9287/// # extern crate google_adsense2 as adsense2;
9288/// # async fn dox() {
9289/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9290///
9291/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9292/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9293/// # .with_native_roots()
9294/// # .unwrap()
9295/// # .https_only()
9296/// # .enable_http2()
9297/// # .build();
9298///
9299/// # let executor = hyper_util::rt::TokioExecutor::new();
9300/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9301/// # secret,
9302/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9303/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9304/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9305/// # ),
9306/// # ).build().await.unwrap();
9307///
9308/// # let client = hyper_util::client::legacy::Client::builder(
9309/// # hyper_util::rt::TokioExecutor::new()
9310/// # )
9311/// # .build(
9312/// # hyper_rustls::HttpsConnectorBuilder::new()
9313/// # .with_native_roots()
9314/// # .unwrap()
9315/// # .https_or_http()
9316/// # .enable_http2()
9317/// # .build()
9318/// # );
9319/// # let mut hub = Adsense::new(client, auth);
9320/// // You can configure optional parameters by calling the respective setters at will, and
9321/// // execute the final call using `doit()`.
9322/// // Values shown here are possibly random and not representative !
9323/// let result = hub.accounts().reports_saved_list("parent")
9324/// .page_token("ipsum")
9325/// .page_size(-18)
9326/// .doit().await;
9327/// # }
9328/// ```
9329pub struct AccountReportSavedListCall<'a, C>
9330where
9331 C: 'a,
9332{
9333 hub: &'a Adsense<C>,
9334 _parent: String,
9335 _page_token: Option<String>,
9336 _page_size: Option<i32>,
9337 _delegate: Option<&'a mut dyn common::Delegate>,
9338 _additional_params: HashMap<String, String>,
9339 _scopes: BTreeSet<String>,
9340}
9341
9342impl<'a, C> common::CallBuilder for AccountReportSavedListCall<'a, C> {}
9343
9344impl<'a, C> AccountReportSavedListCall<'a, C>
9345where
9346 C: common::Connector,
9347{
9348 /// Perform the operation you have build so far.
9349 pub async fn doit(mut self) -> common::Result<(common::Response, ListSavedReportsResponse)> {
9350 use std::borrow::Cow;
9351 use std::io::{Read, Seek};
9352
9353 use common::{url::Params, ToParts};
9354 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9355
9356 let mut dd = common::DefaultDelegate;
9357 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9358 dlg.begin(common::MethodInfo {
9359 id: "adsense.accounts.reports.saved.list",
9360 http_method: hyper::Method::GET,
9361 });
9362
9363 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9364 if self._additional_params.contains_key(field) {
9365 dlg.finished(false);
9366 return Err(common::Error::FieldClash(field));
9367 }
9368 }
9369
9370 let mut params = Params::with_capacity(5 + self._additional_params.len());
9371 params.push("parent", self._parent);
9372 if let Some(value) = self._page_token.as_ref() {
9373 params.push("pageToken", value);
9374 }
9375 if let Some(value) = self._page_size.as_ref() {
9376 params.push("pageSize", value.to_string());
9377 }
9378
9379 params.extend(self._additional_params.iter());
9380
9381 params.push("alt", "json");
9382 let mut url = self.hub._base_url.clone() + "v2/{+parent}/reports/saved";
9383 if self._scopes.is_empty() {
9384 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9385 }
9386
9387 #[allow(clippy::single_element_loop)]
9388 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9389 url = params.uri_replacement(url, param_name, find_this, true);
9390 }
9391 {
9392 let to_remove = ["parent"];
9393 params.remove_params(&to_remove);
9394 }
9395
9396 let url = params.parse_with_url(&url);
9397
9398 loop {
9399 let token = match self
9400 .hub
9401 .auth
9402 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9403 .await
9404 {
9405 Ok(token) => token,
9406 Err(e) => match dlg.token(e) {
9407 Ok(token) => token,
9408 Err(e) => {
9409 dlg.finished(false);
9410 return Err(common::Error::MissingToken(e));
9411 }
9412 },
9413 };
9414 let mut req_result = {
9415 let client = &self.hub.client;
9416 dlg.pre_request();
9417 let mut req_builder = hyper::Request::builder()
9418 .method(hyper::Method::GET)
9419 .uri(url.as_str())
9420 .header(USER_AGENT, self.hub._user_agent.clone());
9421
9422 if let Some(token) = token.as_ref() {
9423 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9424 }
9425
9426 let request = req_builder
9427 .header(CONTENT_LENGTH, 0_u64)
9428 .body(common::to_body::<String>(None));
9429
9430 client.request(request.unwrap()).await
9431 };
9432
9433 match req_result {
9434 Err(err) => {
9435 if let common::Retry::After(d) = dlg.http_error(&err) {
9436 sleep(d).await;
9437 continue;
9438 }
9439 dlg.finished(false);
9440 return Err(common::Error::HttpError(err));
9441 }
9442 Ok(res) => {
9443 let (mut parts, body) = res.into_parts();
9444 let mut body = common::Body::new(body);
9445 if !parts.status.is_success() {
9446 let bytes = common::to_bytes(body).await.unwrap_or_default();
9447 let error = serde_json::from_str(&common::to_string(&bytes));
9448 let response = common::to_response(parts, bytes.into());
9449
9450 if let common::Retry::After(d) =
9451 dlg.http_failure(&response, error.as_ref().ok())
9452 {
9453 sleep(d).await;
9454 continue;
9455 }
9456
9457 dlg.finished(false);
9458
9459 return Err(match error {
9460 Ok(value) => common::Error::BadRequest(value),
9461 _ => common::Error::Failure(response),
9462 });
9463 }
9464 let response = {
9465 let bytes = common::to_bytes(body).await.unwrap_or_default();
9466 let encoded = common::to_string(&bytes);
9467 match serde_json::from_str(&encoded) {
9468 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9469 Err(error) => {
9470 dlg.response_json_decode_error(&encoded, &error);
9471 return Err(common::Error::JsonDecodeError(
9472 encoded.to_string(),
9473 error,
9474 ));
9475 }
9476 }
9477 };
9478
9479 dlg.finished(true);
9480 return Ok(response);
9481 }
9482 }
9483 }
9484 }
9485
9486 /// Required. The account which owns the collection of reports. Format: accounts/{account}
9487 ///
9488 /// Sets the *parent* path property to the given value.
9489 ///
9490 /// Even though the property as already been set when instantiating this call,
9491 /// we provide this method for API completeness.
9492 pub fn parent(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
9493 self._parent = new_value.to_string();
9494 self
9495 }
9496 /// A page token, received from a previous `ListSavedReports` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSavedReports` must match the call that provided the page token.
9497 ///
9498 /// Sets the *page token* query property to the given value.
9499 pub fn page_token(mut self, new_value: &str) -> AccountReportSavedListCall<'a, C> {
9500 self._page_token = Some(new_value.to_string());
9501 self
9502 }
9503 /// The maximum number of reports to include in the response, used for paging. If unspecified, at most 10000 reports will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
9504 ///
9505 /// Sets the *page size* query property to the given value.
9506 pub fn page_size(mut self, new_value: i32) -> AccountReportSavedListCall<'a, C> {
9507 self._page_size = Some(new_value);
9508 self
9509 }
9510 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9511 /// while executing the actual API request.
9512 ///
9513 /// ````text
9514 /// It should be used to handle progress information, and to implement a certain level of resilience.
9515 /// ````
9516 ///
9517 /// Sets the *delegate* property to the given value.
9518 pub fn delegate(
9519 mut self,
9520 new_value: &'a mut dyn common::Delegate,
9521 ) -> AccountReportSavedListCall<'a, C> {
9522 self._delegate = Some(new_value);
9523 self
9524 }
9525
9526 /// Set any additional parameter of the query string used in the request.
9527 /// It should be used to set parameters which are not yet available through their own
9528 /// setters.
9529 ///
9530 /// Please note that this method must not be used to set any of the known parameters
9531 /// which have their own setter method. If done anyway, the request will fail.
9532 ///
9533 /// # Additional Parameters
9534 ///
9535 /// * *$.xgafv* (query-string) - V1 error format.
9536 /// * *access_token* (query-string) - OAuth access token.
9537 /// * *alt* (query-string) - Data format for response.
9538 /// * *callback* (query-string) - JSONP
9539 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9540 /// * *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.
9541 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9542 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9543 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9544 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9545 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9546 pub fn param<T>(mut self, name: T, value: T) -> AccountReportSavedListCall<'a, C>
9547 where
9548 T: AsRef<str>,
9549 {
9550 self._additional_params
9551 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9552 self
9553 }
9554
9555 /// Identifies the authorization scope for the method you are building.
9556 ///
9557 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9558 /// [`Scope::Readonly`].
9559 ///
9560 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9561 /// tokens for more than one scope.
9562 ///
9563 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9564 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9565 /// sufficient, a read-write scope will do as well.
9566 pub fn add_scope<St>(mut self, scope: St) -> AccountReportSavedListCall<'a, C>
9567 where
9568 St: AsRef<str>,
9569 {
9570 self._scopes.insert(String::from(scope.as_ref()));
9571 self
9572 }
9573 /// Identifies the authorization scope(s) for the method you are building.
9574 ///
9575 /// See [`Self::add_scope()`] for details.
9576 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportSavedListCall<'a, C>
9577 where
9578 I: IntoIterator<Item = St>,
9579 St: AsRef<str>,
9580 {
9581 self._scopes
9582 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9583 self
9584 }
9585
9586 /// Removes all scopes, and no default scope will be used either.
9587 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9588 /// for details).
9589 pub fn clear_scopes(mut self) -> AccountReportSavedListCall<'a, C> {
9590 self._scopes.clear();
9591 self
9592 }
9593}
9594
9595/// Generates an ad hoc report.
9596///
9597/// A builder for the *reports.generate* method supported by a *account* resource.
9598/// It is not used directly, but through a [`AccountMethods`] instance.
9599///
9600/// # Example
9601///
9602/// Instantiate a resource method builder
9603///
9604/// ```test_harness,no_run
9605/// # extern crate hyper;
9606/// # extern crate hyper_rustls;
9607/// # extern crate google_adsense2 as adsense2;
9608/// # async fn dox() {
9609/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9610///
9611/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9612/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9613/// # .with_native_roots()
9614/// # .unwrap()
9615/// # .https_only()
9616/// # .enable_http2()
9617/// # .build();
9618///
9619/// # let executor = hyper_util::rt::TokioExecutor::new();
9620/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9621/// # secret,
9622/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9623/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9624/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9625/// # ),
9626/// # ).build().await.unwrap();
9627///
9628/// # let client = hyper_util::client::legacy::Client::builder(
9629/// # hyper_util::rt::TokioExecutor::new()
9630/// # )
9631/// # .build(
9632/// # hyper_rustls::HttpsConnectorBuilder::new()
9633/// # .with_native_roots()
9634/// # .unwrap()
9635/// # .https_or_http()
9636/// # .enable_http2()
9637/// # .build()
9638/// # );
9639/// # let mut hub = Adsense::new(client, auth);
9640/// // You can configure optional parameters by calling the respective setters at will, and
9641/// // execute the final call using `doit()`.
9642/// // Values shown here are possibly random and not representative !
9643/// let result = hub.accounts().reports_generate("account")
9644/// .start_date_year(-56)
9645/// .start_date_month(-7)
9646/// .start_date_day(-30)
9647/// .reporting_time_zone("diam")
9648/// .add_order_by("dolores")
9649/// .add_metrics("dolores")
9650/// .limit(-68)
9651/// .language_code("sed")
9652/// .add_filters("no")
9653/// .end_date_year(-85)
9654/// .end_date_month(-94)
9655/// .end_date_day(-80)
9656/// .add_dimensions("no")
9657/// .date_range("nonumy")
9658/// .currency_code("At")
9659/// .doit().await;
9660/// # }
9661/// ```
9662pub struct AccountReportGenerateCall<'a, C>
9663where
9664 C: 'a,
9665{
9666 hub: &'a Adsense<C>,
9667 _account: String,
9668 _start_date_year: Option<i32>,
9669 _start_date_month: Option<i32>,
9670 _start_date_day: Option<i32>,
9671 _reporting_time_zone: Option<String>,
9672 _order_by: Vec<String>,
9673 _metrics: Vec<String>,
9674 _limit: Option<i32>,
9675 _language_code: Option<String>,
9676 _filters: Vec<String>,
9677 _end_date_year: Option<i32>,
9678 _end_date_month: Option<i32>,
9679 _end_date_day: Option<i32>,
9680 _dimensions: Vec<String>,
9681 _date_range: Option<String>,
9682 _currency_code: Option<String>,
9683 _delegate: Option<&'a mut dyn common::Delegate>,
9684 _additional_params: HashMap<String, String>,
9685 _scopes: BTreeSet<String>,
9686}
9687
9688impl<'a, C> common::CallBuilder for AccountReportGenerateCall<'a, C> {}
9689
9690impl<'a, C> AccountReportGenerateCall<'a, C>
9691where
9692 C: common::Connector,
9693{
9694 /// Perform the operation you have build so far.
9695 pub async fn doit(mut self) -> common::Result<(common::Response, ReportResult)> {
9696 use std::borrow::Cow;
9697 use std::io::{Read, Seek};
9698
9699 use common::{url::Params, ToParts};
9700 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9701
9702 let mut dd = common::DefaultDelegate;
9703 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9704 dlg.begin(common::MethodInfo {
9705 id: "adsense.accounts.reports.generate",
9706 http_method: hyper::Method::GET,
9707 });
9708
9709 for &field in [
9710 "alt",
9711 "account",
9712 "startDate.year",
9713 "startDate.month",
9714 "startDate.day",
9715 "reportingTimeZone",
9716 "orderBy",
9717 "metrics",
9718 "limit",
9719 "languageCode",
9720 "filters",
9721 "endDate.year",
9722 "endDate.month",
9723 "endDate.day",
9724 "dimensions",
9725 "dateRange",
9726 "currencyCode",
9727 ]
9728 .iter()
9729 {
9730 if self._additional_params.contains_key(field) {
9731 dlg.finished(false);
9732 return Err(common::Error::FieldClash(field));
9733 }
9734 }
9735
9736 let mut params = Params::with_capacity(18 + self._additional_params.len());
9737 params.push("account", self._account);
9738 if let Some(value) = self._start_date_year.as_ref() {
9739 params.push("startDate.year", value.to_string());
9740 }
9741 if let Some(value) = self._start_date_month.as_ref() {
9742 params.push("startDate.month", value.to_string());
9743 }
9744 if let Some(value) = self._start_date_day.as_ref() {
9745 params.push("startDate.day", value.to_string());
9746 }
9747 if let Some(value) = self._reporting_time_zone.as_ref() {
9748 params.push("reportingTimeZone", value);
9749 }
9750 if !self._order_by.is_empty() {
9751 for f in self._order_by.iter() {
9752 params.push("orderBy", f);
9753 }
9754 }
9755 if !self._metrics.is_empty() {
9756 for f in self._metrics.iter() {
9757 params.push("metrics", f);
9758 }
9759 }
9760 if let Some(value) = self._limit.as_ref() {
9761 params.push("limit", value.to_string());
9762 }
9763 if let Some(value) = self._language_code.as_ref() {
9764 params.push("languageCode", value);
9765 }
9766 if !self._filters.is_empty() {
9767 for f in self._filters.iter() {
9768 params.push("filters", f);
9769 }
9770 }
9771 if let Some(value) = self._end_date_year.as_ref() {
9772 params.push("endDate.year", value.to_string());
9773 }
9774 if let Some(value) = self._end_date_month.as_ref() {
9775 params.push("endDate.month", value.to_string());
9776 }
9777 if let Some(value) = self._end_date_day.as_ref() {
9778 params.push("endDate.day", value.to_string());
9779 }
9780 if !self._dimensions.is_empty() {
9781 for f in self._dimensions.iter() {
9782 params.push("dimensions", f);
9783 }
9784 }
9785 if let Some(value) = self._date_range.as_ref() {
9786 params.push("dateRange", value);
9787 }
9788 if let Some(value) = self._currency_code.as_ref() {
9789 params.push("currencyCode", value);
9790 }
9791
9792 params.extend(self._additional_params.iter());
9793
9794 params.push("alt", "json");
9795 let mut url = self.hub._base_url.clone() + "v2/{+account}/reports:generate";
9796 if self._scopes.is_empty() {
9797 self._scopes.insert(Scope::Readonly.as_ref().to_string());
9798 }
9799
9800 #[allow(clippy::single_element_loop)]
9801 for &(find_this, param_name) in [("{+account}", "account")].iter() {
9802 url = params.uri_replacement(url, param_name, find_this, true);
9803 }
9804 {
9805 let to_remove = ["account"];
9806 params.remove_params(&to_remove);
9807 }
9808
9809 let url = params.parse_with_url(&url);
9810
9811 loop {
9812 let token = match self
9813 .hub
9814 .auth
9815 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9816 .await
9817 {
9818 Ok(token) => token,
9819 Err(e) => match dlg.token(e) {
9820 Ok(token) => token,
9821 Err(e) => {
9822 dlg.finished(false);
9823 return Err(common::Error::MissingToken(e));
9824 }
9825 },
9826 };
9827 let mut req_result = {
9828 let client = &self.hub.client;
9829 dlg.pre_request();
9830 let mut req_builder = hyper::Request::builder()
9831 .method(hyper::Method::GET)
9832 .uri(url.as_str())
9833 .header(USER_AGENT, self.hub._user_agent.clone());
9834
9835 if let Some(token) = token.as_ref() {
9836 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9837 }
9838
9839 let request = req_builder
9840 .header(CONTENT_LENGTH, 0_u64)
9841 .body(common::to_body::<String>(None));
9842
9843 client.request(request.unwrap()).await
9844 };
9845
9846 match req_result {
9847 Err(err) => {
9848 if let common::Retry::After(d) = dlg.http_error(&err) {
9849 sleep(d).await;
9850 continue;
9851 }
9852 dlg.finished(false);
9853 return Err(common::Error::HttpError(err));
9854 }
9855 Ok(res) => {
9856 let (mut parts, body) = res.into_parts();
9857 let mut body = common::Body::new(body);
9858 if !parts.status.is_success() {
9859 let bytes = common::to_bytes(body).await.unwrap_or_default();
9860 let error = serde_json::from_str(&common::to_string(&bytes));
9861 let response = common::to_response(parts, bytes.into());
9862
9863 if let common::Retry::After(d) =
9864 dlg.http_failure(&response, error.as_ref().ok())
9865 {
9866 sleep(d).await;
9867 continue;
9868 }
9869
9870 dlg.finished(false);
9871
9872 return Err(match error {
9873 Ok(value) => common::Error::BadRequest(value),
9874 _ => common::Error::Failure(response),
9875 });
9876 }
9877 let response = {
9878 let bytes = common::to_bytes(body).await.unwrap_or_default();
9879 let encoded = common::to_string(&bytes);
9880 match serde_json::from_str(&encoded) {
9881 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9882 Err(error) => {
9883 dlg.response_json_decode_error(&encoded, &error);
9884 return Err(common::Error::JsonDecodeError(
9885 encoded.to_string(),
9886 error,
9887 ));
9888 }
9889 }
9890 };
9891
9892 dlg.finished(true);
9893 return Ok(response);
9894 }
9895 }
9896 }
9897 }
9898
9899 /// Required. The account which owns the collection of reports. Format: accounts/{account}
9900 ///
9901 /// Sets the *account* path property to the given value.
9902 ///
9903 /// Even though the property as already been set when instantiating this call,
9904 /// we provide this method for API completeness.
9905 pub fn account(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9906 self._account = new_value.to_string();
9907 self
9908 }
9909 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9910 ///
9911 /// Sets the *start date.year* query property to the given value.
9912 pub fn start_date_year(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9913 self._start_date_year = Some(new_value);
9914 self
9915 }
9916 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9917 ///
9918 /// Sets the *start date.month* query property to the given value.
9919 pub fn start_date_month(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9920 self._start_date_month = Some(new_value);
9921 self
9922 }
9923 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9924 ///
9925 /// Sets the *start date.day* query property to the given value.
9926 pub fn start_date_day(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9927 self._start_date_day = Some(new_value);
9928 self
9929 }
9930 /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
9931 ///
9932 /// Sets the *reporting time zone* query property to the given value.
9933 pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9934 self._reporting_time_zone = Some(new_value.to_string());
9935 self
9936 }
9937 /// The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
9938 ///
9939 /// Append the given value to the *order by* query property.
9940 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9941 pub fn add_order_by(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9942 self._order_by.push(new_value.to_string());
9943 self
9944 }
9945 /// Required. Reporting metrics.
9946 ///
9947 /// Append the given value to the *metrics* query property.
9948 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9949 pub fn add_metrics(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9950 self._metrics.push(new_value.to_string());
9951 self
9952 }
9953 /// The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
9954 ///
9955 /// Sets the *limit* query property to the given value.
9956 pub fn limit(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9957 self._limit = Some(new_value);
9958 self
9959 }
9960 /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
9961 ///
9962 /// Sets the *language code* query property to the given value.
9963 pub fn language_code(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9964 self._language_code = Some(new_value.to_string());
9965 self
9966 }
9967 /// A list of [filters](https://developers.google.com/adsense/management/reporting/filtering) to apply to the report. All provided filters must match in order for the data to be included in the report.
9968 ///
9969 /// Append the given value to the *filters* query property.
9970 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9971 pub fn add_filters(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
9972 self._filters.push(new_value.to_string());
9973 self
9974 }
9975 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
9976 ///
9977 /// Sets the *end date.year* query property to the given value.
9978 pub fn end_date_year(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9979 self._end_date_year = Some(new_value);
9980 self
9981 }
9982 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
9983 ///
9984 /// Sets the *end date.month* query property to the given value.
9985 pub fn end_date_month(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9986 self._end_date_month = Some(new_value);
9987 self
9988 }
9989 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
9990 ///
9991 /// Sets the *end date.day* query property to the given value.
9992 pub fn end_date_day(mut self, new_value: i32) -> AccountReportGenerateCall<'a, C> {
9993 self._end_date_day = Some(new_value);
9994 self
9995 }
9996 /// Dimensions to base the report on.
9997 ///
9998 /// Append the given value to the *dimensions* query property.
9999 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10000 pub fn add_dimensions(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
10001 self._dimensions.push(new_value.to_string());
10002 self
10003 }
10004 /// Date range of the report, if unset the range will be considered CUSTOM.
10005 ///
10006 /// Sets the *date range* query property to the given value.
10007 pub fn date_range(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
10008 self._date_range = Some(new_value.to_string());
10009 self
10010 }
10011 /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
10012 ///
10013 /// Sets the *currency code* query property to the given value.
10014 pub fn currency_code(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C> {
10015 self._currency_code = Some(new_value.to_string());
10016 self
10017 }
10018 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10019 /// while executing the actual API request.
10020 ///
10021 /// ````text
10022 /// It should be used to handle progress information, and to implement a certain level of resilience.
10023 /// ````
10024 ///
10025 /// Sets the *delegate* property to the given value.
10026 pub fn delegate(
10027 mut self,
10028 new_value: &'a mut dyn common::Delegate,
10029 ) -> AccountReportGenerateCall<'a, C> {
10030 self._delegate = Some(new_value);
10031 self
10032 }
10033
10034 /// Set any additional parameter of the query string used in the request.
10035 /// It should be used to set parameters which are not yet available through their own
10036 /// setters.
10037 ///
10038 /// Please note that this method must not be used to set any of the known parameters
10039 /// which have their own setter method. If done anyway, the request will fail.
10040 ///
10041 /// # Additional Parameters
10042 ///
10043 /// * *$.xgafv* (query-string) - V1 error format.
10044 /// * *access_token* (query-string) - OAuth access token.
10045 /// * *alt* (query-string) - Data format for response.
10046 /// * *callback* (query-string) - JSONP
10047 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10048 /// * *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.
10049 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10050 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10051 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10052 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10053 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10054 pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCall<'a, C>
10055 where
10056 T: AsRef<str>,
10057 {
10058 self._additional_params
10059 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10060 self
10061 }
10062
10063 /// Identifies the authorization scope for the method you are building.
10064 ///
10065 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10066 /// [`Scope::Readonly`].
10067 ///
10068 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10069 /// tokens for more than one scope.
10070 ///
10071 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10072 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10073 /// sufficient, a read-write scope will do as well.
10074 pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCall<'a, C>
10075 where
10076 St: AsRef<str>,
10077 {
10078 self._scopes.insert(String::from(scope.as_ref()));
10079 self
10080 }
10081 /// Identifies the authorization scope(s) for the method you are building.
10082 ///
10083 /// See [`Self::add_scope()`] for details.
10084 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCall<'a, C>
10085 where
10086 I: IntoIterator<Item = St>,
10087 St: AsRef<str>,
10088 {
10089 self._scopes
10090 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10091 self
10092 }
10093
10094 /// Removes all scopes, and no default scope will be used either.
10095 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10096 /// for details).
10097 pub fn clear_scopes(mut self) -> AccountReportGenerateCall<'a, C> {
10098 self._scopes.clear();
10099 self
10100 }
10101}
10102
10103/// Generates a csv formatted ad hoc report.
10104///
10105/// A builder for the *reports.generateCsv* method supported by a *account* resource.
10106/// It is not used directly, but through a [`AccountMethods`] instance.
10107///
10108/// # Example
10109///
10110/// Instantiate a resource method builder
10111///
10112/// ```test_harness,no_run
10113/// # extern crate hyper;
10114/// # extern crate hyper_rustls;
10115/// # extern crate google_adsense2 as adsense2;
10116/// # async fn dox() {
10117/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10118///
10119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10121/// # .with_native_roots()
10122/// # .unwrap()
10123/// # .https_only()
10124/// # .enable_http2()
10125/// # .build();
10126///
10127/// # let executor = hyper_util::rt::TokioExecutor::new();
10128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10129/// # secret,
10130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10131/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10132/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10133/// # ),
10134/// # ).build().await.unwrap();
10135///
10136/// # let client = hyper_util::client::legacy::Client::builder(
10137/// # hyper_util::rt::TokioExecutor::new()
10138/// # )
10139/// # .build(
10140/// # hyper_rustls::HttpsConnectorBuilder::new()
10141/// # .with_native_roots()
10142/// # .unwrap()
10143/// # .https_or_http()
10144/// # .enable_http2()
10145/// # .build()
10146/// # );
10147/// # let mut hub = Adsense::new(client, auth);
10148/// // You can configure optional parameters by calling the respective setters at will, and
10149/// // execute the final call using `doit()`.
10150/// // Values shown here are possibly random and not representative !
10151/// let result = hub.accounts().reports_generate_csv("account")
10152/// .start_date_year(-32)
10153/// .start_date_month(-69)
10154/// .start_date_day(-95)
10155/// .reporting_time_zone("erat")
10156/// .add_order_by("aliquyam")
10157/// .add_metrics("amet")
10158/// .limit(-57)
10159/// .language_code("et")
10160/// .add_filters("sea")
10161/// .end_date_year(-96)
10162/// .end_date_month(-46)
10163/// .end_date_day(-65)
10164/// .add_dimensions("est")
10165/// .date_range("aliquyam")
10166/// .currency_code("elitr")
10167/// .doit().await;
10168/// # }
10169/// ```
10170pub struct AccountReportGenerateCsvCall<'a, C>
10171where
10172 C: 'a,
10173{
10174 hub: &'a Adsense<C>,
10175 _account: String,
10176 _start_date_year: Option<i32>,
10177 _start_date_month: Option<i32>,
10178 _start_date_day: Option<i32>,
10179 _reporting_time_zone: Option<String>,
10180 _order_by: Vec<String>,
10181 _metrics: Vec<String>,
10182 _limit: Option<i32>,
10183 _language_code: Option<String>,
10184 _filters: Vec<String>,
10185 _end_date_year: Option<i32>,
10186 _end_date_month: Option<i32>,
10187 _end_date_day: Option<i32>,
10188 _dimensions: Vec<String>,
10189 _date_range: Option<String>,
10190 _currency_code: Option<String>,
10191 _delegate: Option<&'a mut dyn common::Delegate>,
10192 _additional_params: HashMap<String, String>,
10193 _scopes: BTreeSet<String>,
10194}
10195
10196impl<'a, C> common::CallBuilder for AccountReportGenerateCsvCall<'a, C> {}
10197
10198impl<'a, C> AccountReportGenerateCsvCall<'a, C>
10199where
10200 C: common::Connector,
10201{
10202 /// Perform the operation you have build so far.
10203 pub async fn doit(mut self) -> common::Result<(common::Response, HttpBody)> {
10204 use std::borrow::Cow;
10205 use std::io::{Read, Seek};
10206
10207 use common::{url::Params, ToParts};
10208 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10209
10210 let mut dd = common::DefaultDelegate;
10211 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10212 dlg.begin(common::MethodInfo {
10213 id: "adsense.accounts.reports.generateCsv",
10214 http_method: hyper::Method::GET,
10215 });
10216
10217 for &field in [
10218 "alt",
10219 "account",
10220 "startDate.year",
10221 "startDate.month",
10222 "startDate.day",
10223 "reportingTimeZone",
10224 "orderBy",
10225 "metrics",
10226 "limit",
10227 "languageCode",
10228 "filters",
10229 "endDate.year",
10230 "endDate.month",
10231 "endDate.day",
10232 "dimensions",
10233 "dateRange",
10234 "currencyCode",
10235 ]
10236 .iter()
10237 {
10238 if self._additional_params.contains_key(field) {
10239 dlg.finished(false);
10240 return Err(common::Error::FieldClash(field));
10241 }
10242 }
10243
10244 let mut params = Params::with_capacity(18 + self._additional_params.len());
10245 params.push("account", self._account);
10246 if let Some(value) = self._start_date_year.as_ref() {
10247 params.push("startDate.year", value.to_string());
10248 }
10249 if let Some(value) = self._start_date_month.as_ref() {
10250 params.push("startDate.month", value.to_string());
10251 }
10252 if let Some(value) = self._start_date_day.as_ref() {
10253 params.push("startDate.day", value.to_string());
10254 }
10255 if let Some(value) = self._reporting_time_zone.as_ref() {
10256 params.push("reportingTimeZone", value);
10257 }
10258 if !self._order_by.is_empty() {
10259 for f in self._order_by.iter() {
10260 params.push("orderBy", f);
10261 }
10262 }
10263 if !self._metrics.is_empty() {
10264 for f in self._metrics.iter() {
10265 params.push("metrics", f);
10266 }
10267 }
10268 if let Some(value) = self._limit.as_ref() {
10269 params.push("limit", value.to_string());
10270 }
10271 if let Some(value) = self._language_code.as_ref() {
10272 params.push("languageCode", value);
10273 }
10274 if !self._filters.is_empty() {
10275 for f in self._filters.iter() {
10276 params.push("filters", f);
10277 }
10278 }
10279 if let Some(value) = self._end_date_year.as_ref() {
10280 params.push("endDate.year", value.to_string());
10281 }
10282 if let Some(value) = self._end_date_month.as_ref() {
10283 params.push("endDate.month", value.to_string());
10284 }
10285 if let Some(value) = self._end_date_day.as_ref() {
10286 params.push("endDate.day", value.to_string());
10287 }
10288 if !self._dimensions.is_empty() {
10289 for f in self._dimensions.iter() {
10290 params.push("dimensions", f);
10291 }
10292 }
10293 if let Some(value) = self._date_range.as_ref() {
10294 params.push("dateRange", value);
10295 }
10296 if let Some(value) = self._currency_code.as_ref() {
10297 params.push("currencyCode", value);
10298 }
10299
10300 params.extend(self._additional_params.iter());
10301
10302 params.push("alt", "json");
10303 let mut url = self.hub._base_url.clone() + "v2/{+account}/reports:generateCsv";
10304 if self._scopes.is_empty() {
10305 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10306 }
10307
10308 #[allow(clippy::single_element_loop)]
10309 for &(find_this, param_name) in [("{+account}", "account")].iter() {
10310 url = params.uri_replacement(url, param_name, find_this, true);
10311 }
10312 {
10313 let to_remove = ["account"];
10314 params.remove_params(&to_remove);
10315 }
10316
10317 let url = params.parse_with_url(&url);
10318
10319 loop {
10320 let token = match self
10321 .hub
10322 .auth
10323 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10324 .await
10325 {
10326 Ok(token) => token,
10327 Err(e) => match dlg.token(e) {
10328 Ok(token) => token,
10329 Err(e) => {
10330 dlg.finished(false);
10331 return Err(common::Error::MissingToken(e));
10332 }
10333 },
10334 };
10335 let mut req_result = {
10336 let client = &self.hub.client;
10337 dlg.pre_request();
10338 let mut req_builder = hyper::Request::builder()
10339 .method(hyper::Method::GET)
10340 .uri(url.as_str())
10341 .header(USER_AGENT, self.hub._user_agent.clone());
10342
10343 if let Some(token) = token.as_ref() {
10344 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10345 }
10346
10347 let request = req_builder
10348 .header(CONTENT_LENGTH, 0_u64)
10349 .body(common::to_body::<String>(None));
10350
10351 client.request(request.unwrap()).await
10352 };
10353
10354 match req_result {
10355 Err(err) => {
10356 if let common::Retry::After(d) = dlg.http_error(&err) {
10357 sleep(d).await;
10358 continue;
10359 }
10360 dlg.finished(false);
10361 return Err(common::Error::HttpError(err));
10362 }
10363 Ok(res) => {
10364 let (mut parts, body) = res.into_parts();
10365 let mut body = common::Body::new(body);
10366 if !parts.status.is_success() {
10367 let bytes = common::to_bytes(body).await.unwrap_or_default();
10368 let error = serde_json::from_str(&common::to_string(&bytes));
10369 let response = common::to_response(parts, bytes.into());
10370
10371 if let common::Retry::After(d) =
10372 dlg.http_failure(&response, error.as_ref().ok())
10373 {
10374 sleep(d).await;
10375 continue;
10376 }
10377
10378 dlg.finished(false);
10379
10380 return Err(match error {
10381 Ok(value) => common::Error::BadRequest(value),
10382 _ => common::Error::Failure(response),
10383 });
10384 }
10385 let response = {
10386 let bytes = common::to_bytes(body).await.unwrap_or_default();
10387 let encoded = common::to_string(&bytes);
10388 match serde_json::from_str(&encoded) {
10389 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10390 Err(error) => {
10391 dlg.response_json_decode_error(&encoded, &error);
10392 return Err(common::Error::JsonDecodeError(
10393 encoded.to_string(),
10394 error,
10395 ));
10396 }
10397 }
10398 };
10399
10400 dlg.finished(true);
10401 return Ok(response);
10402 }
10403 }
10404 }
10405 }
10406
10407 /// Required. The account which owns the collection of reports. Format: accounts/{account}
10408 ///
10409 /// Sets the *account* path property to the given value.
10410 ///
10411 /// Even though the property as already been set when instantiating this call,
10412 /// we provide this method for API completeness.
10413 pub fn account(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10414 self._account = new_value.to_string();
10415 self
10416 }
10417 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
10418 ///
10419 /// Sets the *start date.year* query property to the given value.
10420 pub fn start_date_year(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10421 self._start_date_year = Some(new_value);
10422 self
10423 }
10424 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
10425 ///
10426 /// Sets the *start date.month* query property to the given value.
10427 pub fn start_date_month(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10428 self._start_date_month = Some(new_value);
10429 self
10430 }
10431 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
10432 ///
10433 /// Sets the *start date.day* query property to the given value.
10434 pub fn start_date_day(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10435 self._start_date_day = Some(new_value);
10436 self
10437 }
10438 /// Timezone in which to generate the report. If unspecified, this defaults to the account timezone. For more information, see [changing the time zone of your reports](https://support.google.com/adsense/answer/9830725).
10439 ///
10440 /// Sets the *reporting time zone* query property to the given value.
10441 pub fn reporting_time_zone(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10442 self._reporting_time_zone = Some(new_value.to_string());
10443 self
10444 }
10445 /// The name of a dimension or metric to sort the resulting report on, can be prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
10446 ///
10447 /// Append the given value to the *order by* query property.
10448 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10449 pub fn add_order_by(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10450 self._order_by.push(new_value.to_string());
10451 self
10452 }
10453 /// Required. Reporting metrics.
10454 ///
10455 /// Append the given value to the *metrics* query property.
10456 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10457 pub fn add_metrics(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10458 self._metrics.push(new_value.to_string());
10459 self
10460 }
10461 /// The maximum number of rows of report data to return. Reports producing more rows than the requested limit will be truncated. If unset, this defaults to 100,000 rows for `Reports.GenerateReport` and 1,000,000 rows for `Reports.GenerateCsvReport`, which are also the maximum values permitted here. Report truncation can be identified (for `Reports.GenerateReport` only) by comparing the number of rows returned to the value returned in `total_matched_rows`.
10462 ///
10463 /// Sets the *limit* query property to the given value.
10464 pub fn limit(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10465 self._limit = Some(new_value);
10466 self
10467 }
10468 /// The language to use for translating report output. If unspecified, this defaults to English ("en"). If the given language is not supported, report output will be returned in English. The language is specified as an [IETF BCP-47 language code](https://en.wikipedia.org/wiki/IETF_language_tag).
10469 ///
10470 /// Sets the *language code* query property to the given value.
10471 pub fn language_code(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10472 self._language_code = Some(new_value.to_string());
10473 self
10474 }
10475 /// A list of [filters](https://developers.google.com/adsense/management/reporting/filtering) to apply to the report. All provided filters must match in order for the data to be included in the report.
10476 ///
10477 /// Append the given value to the *filters* query property.
10478 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10479 pub fn add_filters(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10480 self._filters.push(new_value.to_string());
10481 self
10482 }
10483 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
10484 ///
10485 /// Sets the *end date.year* query property to the given value.
10486 pub fn end_date_year(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10487 self._end_date_year = Some(new_value);
10488 self
10489 }
10490 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
10491 ///
10492 /// Sets the *end date.month* query property to the given value.
10493 pub fn end_date_month(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10494 self._end_date_month = Some(new_value);
10495 self
10496 }
10497 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
10498 ///
10499 /// Sets the *end date.day* query property to the given value.
10500 pub fn end_date_day(mut self, new_value: i32) -> AccountReportGenerateCsvCall<'a, C> {
10501 self._end_date_day = Some(new_value);
10502 self
10503 }
10504 /// Dimensions to base the report on.
10505 ///
10506 /// Append the given value to the *dimensions* query property.
10507 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10508 pub fn add_dimensions(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10509 self._dimensions.push(new_value.to_string());
10510 self
10511 }
10512 /// Date range of the report, if unset the range will be considered CUSTOM.
10513 ///
10514 /// Sets the *date range* query property to the given value.
10515 pub fn date_range(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10516 self._date_range = Some(new_value.to_string());
10517 self
10518 }
10519 /// The [ISO-4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) to use when reporting on monetary metrics. Defaults to the account's currency if not set.
10520 ///
10521 /// Sets the *currency code* query property to the given value.
10522 pub fn currency_code(mut self, new_value: &str) -> AccountReportGenerateCsvCall<'a, C> {
10523 self._currency_code = Some(new_value.to_string());
10524 self
10525 }
10526 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10527 /// while executing the actual API request.
10528 ///
10529 /// ````text
10530 /// It should be used to handle progress information, and to implement a certain level of resilience.
10531 /// ````
10532 ///
10533 /// Sets the *delegate* property to the given value.
10534 pub fn delegate(
10535 mut self,
10536 new_value: &'a mut dyn common::Delegate,
10537 ) -> AccountReportGenerateCsvCall<'a, C> {
10538 self._delegate = Some(new_value);
10539 self
10540 }
10541
10542 /// Set any additional parameter of the query string used in the request.
10543 /// It should be used to set parameters which are not yet available through their own
10544 /// setters.
10545 ///
10546 /// Please note that this method must not be used to set any of the known parameters
10547 /// which have their own setter method. If done anyway, the request will fail.
10548 ///
10549 /// # Additional Parameters
10550 ///
10551 /// * *$.xgafv* (query-string) - V1 error format.
10552 /// * *access_token* (query-string) - OAuth access token.
10553 /// * *alt* (query-string) - Data format for response.
10554 /// * *callback* (query-string) - JSONP
10555 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10556 /// * *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.
10557 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10558 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10559 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10560 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10561 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10562 pub fn param<T>(mut self, name: T, value: T) -> AccountReportGenerateCsvCall<'a, C>
10563 where
10564 T: AsRef<str>,
10565 {
10566 self._additional_params
10567 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10568 self
10569 }
10570
10571 /// Identifies the authorization scope for the method you are building.
10572 ///
10573 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10574 /// [`Scope::Readonly`].
10575 ///
10576 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10577 /// tokens for more than one scope.
10578 ///
10579 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10580 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10581 /// sufficient, a read-write scope will do as well.
10582 pub fn add_scope<St>(mut self, scope: St) -> AccountReportGenerateCsvCall<'a, C>
10583 where
10584 St: AsRef<str>,
10585 {
10586 self._scopes.insert(String::from(scope.as_ref()));
10587 self
10588 }
10589 /// Identifies the authorization scope(s) for the method you are building.
10590 ///
10591 /// See [`Self::add_scope()`] for details.
10592 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGenerateCsvCall<'a, C>
10593 where
10594 I: IntoIterator<Item = St>,
10595 St: AsRef<str>,
10596 {
10597 self._scopes
10598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10599 self
10600 }
10601
10602 /// Removes all scopes, and no default scope will be used either.
10603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10604 /// for details).
10605 pub fn clear_scopes(mut self) -> AccountReportGenerateCsvCall<'a, C> {
10606 self._scopes.clear();
10607 self
10608 }
10609}
10610
10611/// Gets the saved report from the given resource name.
10612///
10613/// A builder for the *reports.getSaved* method supported by a *account* resource.
10614/// It is not used directly, but through a [`AccountMethods`] instance.
10615///
10616/// # Example
10617///
10618/// Instantiate a resource method builder
10619///
10620/// ```test_harness,no_run
10621/// # extern crate hyper;
10622/// # extern crate hyper_rustls;
10623/// # extern crate google_adsense2 as adsense2;
10624/// # async fn dox() {
10625/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10626///
10627/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10628/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10629/// # .with_native_roots()
10630/// # .unwrap()
10631/// # .https_only()
10632/// # .enable_http2()
10633/// # .build();
10634///
10635/// # let executor = hyper_util::rt::TokioExecutor::new();
10636/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10637/// # secret,
10638/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10639/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10640/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10641/// # ),
10642/// # ).build().await.unwrap();
10643///
10644/// # let client = hyper_util::client::legacy::Client::builder(
10645/// # hyper_util::rt::TokioExecutor::new()
10646/// # )
10647/// # .build(
10648/// # hyper_rustls::HttpsConnectorBuilder::new()
10649/// # .with_native_roots()
10650/// # .unwrap()
10651/// # .https_or_http()
10652/// # .enable_http2()
10653/// # .build()
10654/// # );
10655/// # let mut hub = Adsense::new(client, auth);
10656/// // You can configure optional parameters by calling the respective setters at will, and
10657/// // execute the final call using `doit()`.
10658/// // Values shown here are possibly random and not representative !
10659/// let result = hub.accounts().reports_get_saved("name")
10660/// .doit().await;
10661/// # }
10662/// ```
10663pub struct AccountReportGetSavedCall<'a, C>
10664where
10665 C: 'a,
10666{
10667 hub: &'a Adsense<C>,
10668 _name: String,
10669 _delegate: Option<&'a mut dyn common::Delegate>,
10670 _additional_params: HashMap<String, String>,
10671 _scopes: BTreeSet<String>,
10672}
10673
10674impl<'a, C> common::CallBuilder for AccountReportGetSavedCall<'a, C> {}
10675
10676impl<'a, C> AccountReportGetSavedCall<'a, C>
10677where
10678 C: common::Connector,
10679{
10680 /// Perform the operation you have build so far.
10681 pub async fn doit(mut self) -> common::Result<(common::Response, SavedReport)> {
10682 use std::borrow::Cow;
10683 use std::io::{Read, Seek};
10684
10685 use common::{url::Params, ToParts};
10686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10687
10688 let mut dd = common::DefaultDelegate;
10689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10690 dlg.begin(common::MethodInfo {
10691 id: "adsense.accounts.reports.getSaved",
10692 http_method: hyper::Method::GET,
10693 });
10694
10695 for &field in ["alt", "name"].iter() {
10696 if self._additional_params.contains_key(field) {
10697 dlg.finished(false);
10698 return Err(common::Error::FieldClash(field));
10699 }
10700 }
10701
10702 let mut params = Params::with_capacity(3 + self._additional_params.len());
10703 params.push("name", self._name);
10704
10705 params.extend(self._additional_params.iter());
10706
10707 params.push("alt", "json");
10708 let mut url = self.hub._base_url.clone() + "v2/{+name}/saved";
10709 if self._scopes.is_empty() {
10710 self._scopes.insert(Scope::Readonly.as_ref().to_string());
10711 }
10712
10713 #[allow(clippy::single_element_loop)]
10714 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10715 url = params.uri_replacement(url, param_name, find_this, true);
10716 }
10717 {
10718 let to_remove = ["name"];
10719 params.remove_params(&to_remove);
10720 }
10721
10722 let url = params.parse_with_url(&url);
10723
10724 loop {
10725 let token = match self
10726 .hub
10727 .auth
10728 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10729 .await
10730 {
10731 Ok(token) => token,
10732 Err(e) => match dlg.token(e) {
10733 Ok(token) => token,
10734 Err(e) => {
10735 dlg.finished(false);
10736 return Err(common::Error::MissingToken(e));
10737 }
10738 },
10739 };
10740 let mut req_result = {
10741 let client = &self.hub.client;
10742 dlg.pre_request();
10743 let mut req_builder = hyper::Request::builder()
10744 .method(hyper::Method::GET)
10745 .uri(url.as_str())
10746 .header(USER_AGENT, self.hub._user_agent.clone());
10747
10748 if let Some(token) = token.as_ref() {
10749 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10750 }
10751
10752 let request = req_builder
10753 .header(CONTENT_LENGTH, 0_u64)
10754 .body(common::to_body::<String>(None));
10755
10756 client.request(request.unwrap()).await
10757 };
10758
10759 match req_result {
10760 Err(err) => {
10761 if let common::Retry::After(d) = dlg.http_error(&err) {
10762 sleep(d).await;
10763 continue;
10764 }
10765 dlg.finished(false);
10766 return Err(common::Error::HttpError(err));
10767 }
10768 Ok(res) => {
10769 let (mut parts, body) = res.into_parts();
10770 let mut body = common::Body::new(body);
10771 if !parts.status.is_success() {
10772 let bytes = common::to_bytes(body).await.unwrap_or_default();
10773 let error = serde_json::from_str(&common::to_string(&bytes));
10774 let response = common::to_response(parts, bytes.into());
10775
10776 if let common::Retry::After(d) =
10777 dlg.http_failure(&response, error.as_ref().ok())
10778 {
10779 sleep(d).await;
10780 continue;
10781 }
10782
10783 dlg.finished(false);
10784
10785 return Err(match error {
10786 Ok(value) => common::Error::BadRequest(value),
10787 _ => common::Error::Failure(response),
10788 });
10789 }
10790 let response = {
10791 let bytes = common::to_bytes(body).await.unwrap_or_default();
10792 let encoded = common::to_string(&bytes);
10793 match serde_json::from_str(&encoded) {
10794 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10795 Err(error) => {
10796 dlg.response_json_decode_error(&encoded, &error);
10797 return Err(common::Error::JsonDecodeError(
10798 encoded.to_string(),
10799 error,
10800 ));
10801 }
10802 }
10803 };
10804
10805 dlg.finished(true);
10806 return Ok(response);
10807 }
10808 }
10809 }
10810 }
10811
10812 /// Required. The name of the saved report to retrieve. Format: accounts/{account}/reports/{report}
10813 ///
10814 /// Sets the *name* path property to the given value.
10815 ///
10816 /// Even though the property as already been set when instantiating this call,
10817 /// we provide this method for API completeness.
10818 pub fn name(mut self, new_value: &str) -> AccountReportGetSavedCall<'a, C> {
10819 self._name = new_value.to_string();
10820 self
10821 }
10822 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10823 /// while executing the actual API request.
10824 ///
10825 /// ````text
10826 /// It should be used to handle progress information, and to implement a certain level of resilience.
10827 /// ````
10828 ///
10829 /// Sets the *delegate* property to the given value.
10830 pub fn delegate(
10831 mut self,
10832 new_value: &'a mut dyn common::Delegate,
10833 ) -> AccountReportGetSavedCall<'a, C> {
10834 self._delegate = Some(new_value);
10835 self
10836 }
10837
10838 /// Set any additional parameter of the query string used in the request.
10839 /// It should be used to set parameters which are not yet available through their own
10840 /// setters.
10841 ///
10842 /// Please note that this method must not be used to set any of the known parameters
10843 /// which have their own setter method. If done anyway, the request will fail.
10844 ///
10845 /// # Additional Parameters
10846 ///
10847 /// * *$.xgafv* (query-string) - V1 error format.
10848 /// * *access_token* (query-string) - OAuth access token.
10849 /// * *alt* (query-string) - Data format for response.
10850 /// * *callback* (query-string) - JSONP
10851 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10852 /// * *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.
10853 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10854 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10855 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10856 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10857 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10858 pub fn param<T>(mut self, name: T, value: T) -> AccountReportGetSavedCall<'a, C>
10859 where
10860 T: AsRef<str>,
10861 {
10862 self._additional_params
10863 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10864 self
10865 }
10866
10867 /// Identifies the authorization scope for the method you are building.
10868 ///
10869 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10870 /// [`Scope::Readonly`].
10871 ///
10872 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10873 /// tokens for more than one scope.
10874 ///
10875 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10876 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10877 /// sufficient, a read-write scope will do as well.
10878 pub fn add_scope<St>(mut self, scope: St) -> AccountReportGetSavedCall<'a, C>
10879 where
10880 St: AsRef<str>,
10881 {
10882 self._scopes.insert(String::from(scope.as_ref()));
10883 self
10884 }
10885 /// Identifies the authorization scope(s) for the method you are building.
10886 ///
10887 /// See [`Self::add_scope()`] for details.
10888 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountReportGetSavedCall<'a, C>
10889 where
10890 I: IntoIterator<Item = St>,
10891 St: AsRef<str>,
10892 {
10893 self._scopes
10894 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10895 self
10896 }
10897
10898 /// Removes all scopes, and no default scope will be used either.
10899 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10900 /// for details).
10901 pub fn clear_scopes(mut self) -> AccountReportGetSavedCall<'a, C> {
10902 self._scopes.clear();
10903 self
10904 }
10905}
10906
10907/// Gets information about the selected site.
10908///
10909/// A builder for the *sites.get* method supported by a *account* resource.
10910/// It is not used directly, but through a [`AccountMethods`] instance.
10911///
10912/// # Example
10913///
10914/// Instantiate a resource method builder
10915///
10916/// ```test_harness,no_run
10917/// # extern crate hyper;
10918/// # extern crate hyper_rustls;
10919/// # extern crate google_adsense2 as adsense2;
10920/// # async fn dox() {
10921/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10922///
10923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10924/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10925/// # .with_native_roots()
10926/// # .unwrap()
10927/// # .https_only()
10928/// # .enable_http2()
10929/// # .build();
10930///
10931/// # let executor = hyper_util::rt::TokioExecutor::new();
10932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10933/// # secret,
10934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10935/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10936/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10937/// # ),
10938/// # ).build().await.unwrap();
10939///
10940/// # let client = hyper_util::client::legacy::Client::builder(
10941/// # hyper_util::rt::TokioExecutor::new()
10942/// # )
10943/// # .build(
10944/// # hyper_rustls::HttpsConnectorBuilder::new()
10945/// # .with_native_roots()
10946/// # .unwrap()
10947/// # .https_or_http()
10948/// # .enable_http2()
10949/// # .build()
10950/// # );
10951/// # let mut hub = Adsense::new(client, auth);
10952/// // You can configure optional parameters by calling the respective setters at will, and
10953/// // execute the final call using `doit()`.
10954/// // Values shown here are possibly random and not representative !
10955/// let result = hub.accounts().sites_get("name")
10956/// .doit().await;
10957/// # }
10958/// ```
10959pub struct AccountSiteGetCall<'a, C>
10960where
10961 C: 'a,
10962{
10963 hub: &'a Adsense<C>,
10964 _name: String,
10965 _delegate: Option<&'a mut dyn common::Delegate>,
10966 _additional_params: HashMap<String, String>,
10967 _scopes: BTreeSet<String>,
10968}
10969
10970impl<'a, C> common::CallBuilder for AccountSiteGetCall<'a, C> {}
10971
10972impl<'a, C> AccountSiteGetCall<'a, C>
10973where
10974 C: common::Connector,
10975{
10976 /// Perform the operation you have build so far.
10977 pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
10978 use std::borrow::Cow;
10979 use std::io::{Read, Seek};
10980
10981 use common::{url::Params, ToParts};
10982 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10983
10984 let mut dd = common::DefaultDelegate;
10985 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10986 dlg.begin(common::MethodInfo {
10987 id: "adsense.accounts.sites.get",
10988 http_method: hyper::Method::GET,
10989 });
10990
10991 for &field in ["alt", "name"].iter() {
10992 if self._additional_params.contains_key(field) {
10993 dlg.finished(false);
10994 return Err(common::Error::FieldClash(field));
10995 }
10996 }
10997
10998 let mut params = Params::with_capacity(3 + self._additional_params.len());
10999 params.push("name", self._name);
11000
11001 params.extend(self._additional_params.iter());
11002
11003 params.push("alt", "json");
11004 let mut url = self.hub._base_url.clone() + "v2/{+name}";
11005 if self._scopes.is_empty() {
11006 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11007 }
11008
11009 #[allow(clippy::single_element_loop)]
11010 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11011 url = params.uri_replacement(url, param_name, find_this, true);
11012 }
11013 {
11014 let to_remove = ["name"];
11015 params.remove_params(&to_remove);
11016 }
11017
11018 let url = params.parse_with_url(&url);
11019
11020 loop {
11021 let token = match self
11022 .hub
11023 .auth
11024 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11025 .await
11026 {
11027 Ok(token) => token,
11028 Err(e) => match dlg.token(e) {
11029 Ok(token) => token,
11030 Err(e) => {
11031 dlg.finished(false);
11032 return Err(common::Error::MissingToken(e));
11033 }
11034 },
11035 };
11036 let mut req_result = {
11037 let client = &self.hub.client;
11038 dlg.pre_request();
11039 let mut req_builder = hyper::Request::builder()
11040 .method(hyper::Method::GET)
11041 .uri(url.as_str())
11042 .header(USER_AGENT, self.hub._user_agent.clone());
11043
11044 if let Some(token) = token.as_ref() {
11045 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11046 }
11047
11048 let request = req_builder
11049 .header(CONTENT_LENGTH, 0_u64)
11050 .body(common::to_body::<String>(None));
11051
11052 client.request(request.unwrap()).await
11053 };
11054
11055 match req_result {
11056 Err(err) => {
11057 if let common::Retry::After(d) = dlg.http_error(&err) {
11058 sleep(d).await;
11059 continue;
11060 }
11061 dlg.finished(false);
11062 return Err(common::Error::HttpError(err));
11063 }
11064 Ok(res) => {
11065 let (mut parts, body) = res.into_parts();
11066 let mut body = common::Body::new(body);
11067 if !parts.status.is_success() {
11068 let bytes = common::to_bytes(body).await.unwrap_or_default();
11069 let error = serde_json::from_str(&common::to_string(&bytes));
11070 let response = common::to_response(parts, bytes.into());
11071
11072 if let common::Retry::After(d) =
11073 dlg.http_failure(&response, error.as_ref().ok())
11074 {
11075 sleep(d).await;
11076 continue;
11077 }
11078
11079 dlg.finished(false);
11080
11081 return Err(match error {
11082 Ok(value) => common::Error::BadRequest(value),
11083 _ => common::Error::Failure(response),
11084 });
11085 }
11086 let response = {
11087 let bytes = common::to_bytes(body).await.unwrap_or_default();
11088 let encoded = common::to_string(&bytes);
11089 match serde_json::from_str(&encoded) {
11090 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11091 Err(error) => {
11092 dlg.response_json_decode_error(&encoded, &error);
11093 return Err(common::Error::JsonDecodeError(
11094 encoded.to_string(),
11095 error,
11096 ));
11097 }
11098 }
11099 };
11100
11101 dlg.finished(true);
11102 return Ok(response);
11103 }
11104 }
11105 }
11106 }
11107
11108 /// Required. Name of the site. Format: accounts/{account}/sites/{site}
11109 ///
11110 /// Sets the *name* path property to the given value.
11111 ///
11112 /// Even though the property as already been set when instantiating this call,
11113 /// we provide this method for API completeness.
11114 pub fn name(mut self, new_value: &str) -> AccountSiteGetCall<'a, C> {
11115 self._name = new_value.to_string();
11116 self
11117 }
11118 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11119 /// while executing the actual API request.
11120 ///
11121 /// ````text
11122 /// It should be used to handle progress information, and to implement a certain level of resilience.
11123 /// ````
11124 ///
11125 /// Sets the *delegate* property to the given value.
11126 pub fn delegate(
11127 mut self,
11128 new_value: &'a mut dyn common::Delegate,
11129 ) -> AccountSiteGetCall<'a, C> {
11130 self._delegate = Some(new_value);
11131 self
11132 }
11133
11134 /// Set any additional parameter of the query string used in the request.
11135 /// It should be used to set parameters which are not yet available through their own
11136 /// setters.
11137 ///
11138 /// Please note that this method must not be used to set any of the known parameters
11139 /// which have their own setter method. If done anyway, the request will fail.
11140 ///
11141 /// # Additional Parameters
11142 ///
11143 /// * *$.xgafv* (query-string) - V1 error format.
11144 /// * *access_token* (query-string) - OAuth access token.
11145 /// * *alt* (query-string) - Data format for response.
11146 /// * *callback* (query-string) - JSONP
11147 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11148 /// * *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.
11149 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11150 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11151 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11152 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11153 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11154 pub fn param<T>(mut self, name: T, value: T) -> AccountSiteGetCall<'a, C>
11155 where
11156 T: AsRef<str>,
11157 {
11158 self._additional_params
11159 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11160 self
11161 }
11162
11163 /// Identifies the authorization scope for the method you are building.
11164 ///
11165 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11166 /// [`Scope::Readonly`].
11167 ///
11168 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11169 /// tokens for more than one scope.
11170 ///
11171 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11172 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11173 /// sufficient, a read-write scope will do as well.
11174 pub fn add_scope<St>(mut self, scope: St) -> AccountSiteGetCall<'a, C>
11175 where
11176 St: AsRef<str>,
11177 {
11178 self._scopes.insert(String::from(scope.as_ref()));
11179 self
11180 }
11181 /// Identifies the authorization scope(s) for the method you are building.
11182 ///
11183 /// See [`Self::add_scope()`] for details.
11184 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSiteGetCall<'a, C>
11185 where
11186 I: IntoIterator<Item = St>,
11187 St: AsRef<str>,
11188 {
11189 self._scopes
11190 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11191 self
11192 }
11193
11194 /// Removes all scopes, and no default scope will be used either.
11195 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11196 /// for details).
11197 pub fn clear_scopes(mut self) -> AccountSiteGetCall<'a, C> {
11198 self._scopes.clear();
11199 self
11200 }
11201}
11202
11203/// Lists all the sites available in an account.
11204///
11205/// A builder for the *sites.list* method supported by a *account* resource.
11206/// It is not used directly, but through a [`AccountMethods`] instance.
11207///
11208/// # Example
11209///
11210/// Instantiate a resource method builder
11211///
11212/// ```test_harness,no_run
11213/// # extern crate hyper;
11214/// # extern crate hyper_rustls;
11215/// # extern crate google_adsense2 as adsense2;
11216/// # async fn dox() {
11217/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11218///
11219/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11220/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11221/// # .with_native_roots()
11222/// # .unwrap()
11223/// # .https_only()
11224/// # .enable_http2()
11225/// # .build();
11226///
11227/// # let executor = hyper_util::rt::TokioExecutor::new();
11228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11229/// # secret,
11230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11231/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11232/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11233/// # ),
11234/// # ).build().await.unwrap();
11235///
11236/// # let client = hyper_util::client::legacy::Client::builder(
11237/// # hyper_util::rt::TokioExecutor::new()
11238/// # )
11239/// # .build(
11240/// # hyper_rustls::HttpsConnectorBuilder::new()
11241/// # .with_native_roots()
11242/// # .unwrap()
11243/// # .https_or_http()
11244/// # .enable_http2()
11245/// # .build()
11246/// # );
11247/// # let mut hub = Adsense::new(client, auth);
11248/// // You can configure optional parameters by calling the respective setters at will, and
11249/// // execute the final call using `doit()`.
11250/// // Values shown here are possibly random and not representative !
11251/// let result = hub.accounts().sites_list("parent")
11252/// .page_token("sit")
11253/// .page_size(-93)
11254/// .doit().await;
11255/// # }
11256/// ```
11257pub struct AccountSiteListCall<'a, C>
11258where
11259 C: 'a,
11260{
11261 hub: &'a Adsense<C>,
11262 _parent: String,
11263 _page_token: Option<String>,
11264 _page_size: Option<i32>,
11265 _delegate: Option<&'a mut dyn common::Delegate>,
11266 _additional_params: HashMap<String, String>,
11267 _scopes: BTreeSet<String>,
11268}
11269
11270impl<'a, C> common::CallBuilder for AccountSiteListCall<'a, C> {}
11271
11272impl<'a, C> AccountSiteListCall<'a, C>
11273where
11274 C: common::Connector,
11275{
11276 /// Perform the operation you have build so far.
11277 pub async fn doit(mut self) -> common::Result<(common::Response, ListSitesResponse)> {
11278 use std::borrow::Cow;
11279 use std::io::{Read, Seek};
11280
11281 use common::{url::Params, ToParts};
11282 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11283
11284 let mut dd = common::DefaultDelegate;
11285 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11286 dlg.begin(common::MethodInfo {
11287 id: "adsense.accounts.sites.list",
11288 http_method: hyper::Method::GET,
11289 });
11290
11291 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11292 if self._additional_params.contains_key(field) {
11293 dlg.finished(false);
11294 return Err(common::Error::FieldClash(field));
11295 }
11296 }
11297
11298 let mut params = Params::with_capacity(5 + self._additional_params.len());
11299 params.push("parent", self._parent);
11300 if let Some(value) = self._page_token.as_ref() {
11301 params.push("pageToken", value);
11302 }
11303 if let Some(value) = self._page_size.as_ref() {
11304 params.push("pageSize", value.to_string());
11305 }
11306
11307 params.extend(self._additional_params.iter());
11308
11309 params.push("alt", "json");
11310 let mut url = self.hub._base_url.clone() + "v2/{+parent}/sites";
11311 if self._scopes.is_empty() {
11312 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11313 }
11314
11315 #[allow(clippy::single_element_loop)]
11316 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11317 url = params.uri_replacement(url, param_name, find_this, true);
11318 }
11319 {
11320 let to_remove = ["parent"];
11321 params.remove_params(&to_remove);
11322 }
11323
11324 let url = params.parse_with_url(&url);
11325
11326 loop {
11327 let token = match self
11328 .hub
11329 .auth
11330 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11331 .await
11332 {
11333 Ok(token) => token,
11334 Err(e) => match dlg.token(e) {
11335 Ok(token) => token,
11336 Err(e) => {
11337 dlg.finished(false);
11338 return Err(common::Error::MissingToken(e));
11339 }
11340 },
11341 };
11342 let mut req_result = {
11343 let client = &self.hub.client;
11344 dlg.pre_request();
11345 let mut req_builder = hyper::Request::builder()
11346 .method(hyper::Method::GET)
11347 .uri(url.as_str())
11348 .header(USER_AGENT, self.hub._user_agent.clone());
11349
11350 if let Some(token) = token.as_ref() {
11351 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11352 }
11353
11354 let request = req_builder
11355 .header(CONTENT_LENGTH, 0_u64)
11356 .body(common::to_body::<String>(None));
11357
11358 client.request(request.unwrap()).await
11359 };
11360
11361 match req_result {
11362 Err(err) => {
11363 if let common::Retry::After(d) = dlg.http_error(&err) {
11364 sleep(d).await;
11365 continue;
11366 }
11367 dlg.finished(false);
11368 return Err(common::Error::HttpError(err));
11369 }
11370 Ok(res) => {
11371 let (mut parts, body) = res.into_parts();
11372 let mut body = common::Body::new(body);
11373 if !parts.status.is_success() {
11374 let bytes = common::to_bytes(body).await.unwrap_or_default();
11375 let error = serde_json::from_str(&common::to_string(&bytes));
11376 let response = common::to_response(parts, bytes.into());
11377
11378 if let common::Retry::After(d) =
11379 dlg.http_failure(&response, error.as_ref().ok())
11380 {
11381 sleep(d).await;
11382 continue;
11383 }
11384
11385 dlg.finished(false);
11386
11387 return Err(match error {
11388 Ok(value) => common::Error::BadRequest(value),
11389 _ => common::Error::Failure(response),
11390 });
11391 }
11392 let response = {
11393 let bytes = common::to_bytes(body).await.unwrap_or_default();
11394 let encoded = common::to_string(&bytes);
11395 match serde_json::from_str(&encoded) {
11396 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11397 Err(error) => {
11398 dlg.response_json_decode_error(&encoded, &error);
11399 return Err(common::Error::JsonDecodeError(
11400 encoded.to_string(),
11401 error,
11402 ));
11403 }
11404 }
11405 };
11406
11407 dlg.finished(true);
11408 return Ok(response);
11409 }
11410 }
11411 }
11412 }
11413
11414 /// Required. The account which owns the collection of sites. Format: accounts/{account}
11415 ///
11416 /// Sets the *parent* path property to the given value.
11417 ///
11418 /// Even though the property as already been set when instantiating this call,
11419 /// we provide this method for API completeness.
11420 pub fn parent(mut self, new_value: &str) -> AccountSiteListCall<'a, C> {
11421 self._parent = new_value.to_string();
11422 self
11423 }
11424 /// A page token, received from a previous `ListSites` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSites` must match the call that provided the page token.
11425 ///
11426 /// Sets the *page token* query property to the given value.
11427 pub fn page_token(mut self, new_value: &str) -> AccountSiteListCall<'a, C> {
11428 self._page_token = Some(new_value.to_string());
11429 self
11430 }
11431 /// The maximum number of sites to include in the response, used for paging. If unspecified, at most 10000 sites will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
11432 ///
11433 /// Sets the *page size* query property to the given value.
11434 pub fn page_size(mut self, new_value: i32) -> AccountSiteListCall<'a, C> {
11435 self._page_size = Some(new_value);
11436 self
11437 }
11438 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11439 /// while executing the actual API request.
11440 ///
11441 /// ````text
11442 /// It should be used to handle progress information, and to implement a certain level of resilience.
11443 /// ````
11444 ///
11445 /// Sets the *delegate* property to the given value.
11446 pub fn delegate(
11447 mut self,
11448 new_value: &'a mut dyn common::Delegate,
11449 ) -> AccountSiteListCall<'a, C> {
11450 self._delegate = Some(new_value);
11451 self
11452 }
11453
11454 /// Set any additional parameter of the query string used in the request.
11455 /// It should be used to set parameters which are not yet available through their own
11456 /// setters.
11457 ///
11458 /// Please note that this method must not be used to set any of the known parameters
11459 /// which have their own setter method. If done anyway, the request will fail.
11460 ///
11461 /// # Additional Parameters
11462 ///
11463 /// * *$.xgafv* (query-string) - V1 error format.
11464 /// * *access_token* (query-string) - OAuth access token.
11465 /// * *alt* (query-string) - Data format for response.
11466 /// * *callback* (query-string) - JSONP
11467 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11468 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11469 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11470 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11471 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11472 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11473 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11474 pub fn param<T>(mut self, name: T, value: T) -> AccountSiteListCall<'a, C>
11475 where
11476 T: AsRef<str>,
11477 {
11478 self._additional_params
11479 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11480 self
11481 }
11482
11483 /// Identifies the authorization scope for the method you are building.
11484 ///
11485 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11486 /// [`Scope::Readonly`].
11487 ///
11488 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11489 /// tokens for more than one scope.
11490 ///
11491 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11492 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11493 /// sufficient, a read-write scope will do as well.
11494 pub fn add_scope<St>(mut self, scope: St) -> AccountSiteListCall<'a, C>
11495 where
11496 St: AsRef<str>,
11497 {
11498 self._scopes.insert(String::from(scope.as_ref()));
11499 self
11500 }
11501 /// Identifies the authorization scope(s) for the method you are building.
11502 ///
11503 /// See [`Self::add_scope()`] for details.
11504 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountSiteListCall<'a, C>
11505 where
11506 I: IntoIterator<Item = St>,
11507 St: AsRef<str>,
11508 {
11509 self._scopes
11510 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11511 self
11512 }
11513
11514 /// Removes all scopes, and no default scope will be used either.
11515 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11516 /// for details).
11517 pub fn clear_scopes(mut self) -> AccountSiteListCall<'a, C> {
11518 self._scopes.clear();
11519 self
11520 }
11521}
11522
11523/// Gets information about the selected AdSense account.
11524///
11525/// A builder for the *get* method supported by a *account* resource.
11526/// It is not used directly, but through a [`AccountMethods`] instance.
11527///
11528/// # Example
11529///
11530/// Instantiate a resource method builder
11531///
11532/// ```test_harness,no_run
11533/// # extern crate hyper;
11534/// # extern crate hyper_rustls;
11535/// # extern crate google_adsense2 as adsense2;
11536/// # async fn dox() {
11537/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11538///
11539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11540/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11541/// # .with_native_roots()
11542/// # .unwrap()
11543/// # .https_only()
11544/// # .enable_http2()
11545/// # .build();
11546///
11547/// # let executor = hyper_util::rt::TokioExecutor::new();
11548/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11549/// # secret,
11550/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11551/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11552/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11553/// # ),
11554/// # ).build().await.unwrap();
11555///
11556/// # let client = hyper_util::client::legacy::Client::builder(
11557/// # hyper_util::rt::TokioExecutor::new()
11558/// # )
11559/// # .build(
11560/// # hyper_rustls::HttpsConnectorBuilder::new()
11561/// # .with_native_roots()
11562/// # .unwrap()
11563/// # .https_or_http()
11564/// # .enable_http2()
11565/// # .build()
11566/// # );
11567/// # let mut hub = Adsense::new(client, auth);
11568/// // You can configure optional parameters by calling the respective setters at will, and
11569/// // execute the final call using `doit()`.
11570/// // Values shown here are possibly random and not representative !
11571/// let result = hub.accounts().get("name")
11572/// .doit().await;
11573/// # }
11574/// ```
11575pub struct AccountGetCall<'a, C>
11576where
11577 C: 'a,
11578{
11579 hub: &'a Adsense<C>,
11580 _name: String,
11581 _delegate: Option<&'a mut dyn common::Delegate>,
11582 _additional_params: HashMap<String, String>,
11583 _scopes: BTreeSet<String>,
11584}
11585
11586impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
11587
11588impl<'a, C> AccountGetCall<'a, C>
11589where
11590 C: common::Connector,
11591{
11592 /// Perform the operation you have build so far.
11593 pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
11594 use std::borrow::Cow;
11595 use std::io::{Read, Seek};
11596
11597 use common::{url::Params, ToParts};
11598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11599
11600 let mut dd = common::DefaultDelegate;
11601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11602 dlg.begin(common::MethodInfo {
11603 id: "adsense.accounts.get",
11604 http_method: hyper::Method::GET,
11605 });
11606
11607 for &field in ["alt", "name"].iter() {
11608 if self._additional_params.contains_key(field) {
11609 dlg.finished(false);
11610 return Err(common::Error::FieldClash(field));
11611 }
11612 }
11613
11614 let mut params = Params::with_capacity(3 + self._additional_params.len());
11615 params.push("name", self._name);
11616
11617 params.extend(self._additional_params.iter());
11618
11619 params.push("alt", "json");
11620 let mut url = self.hub._base_url.clone() + "v2/{+name}";
11621 if self._scopes.is_empty() {
11622 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11623 }
11624
11625 #[allow(clippy::single_element_loop)]
11626 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11627 url = params.uri_replacement(url, param_name, find_this, true);
11628 }
11629 {
11630 let to_remove = ["name"];
11631 params.remove_params(&to_remove);
11632 }
11633
11634 let url = params.parse_with_url(&url);
11635
11636 loop {
11637 let token = match self
11638 .hub
11639 .auth
11640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11641 .await
11642 {
11643 Ok(token) => token,
11644 Err(e) => match dlg.token(e) {
11645 Ok(token) => token,
11646 Err(e) => {
11647 dlg.finished(false);
11648 return Err(common::Error::MissingToken(e));
11649 }
11650 },
11651 };
11652 let mut req_result = {
11653 let client = &self.hub.client;
11654 dlg.pre_request();
11655 let mut req_builder = hyper::Request::builder()
11656 .method(hyper::Method::GET)
11657 .uri(url.as_str())
11658 .header(USER_AGENT, self.hub._user_agent.clone());
11659
11660 if let Some(token) = token.as_ref() {
11661 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11662 }
11663
11664 let request = req_builder
11665 .header(CONTENT_LENGTH, 0_u64)
11666 .body(common::to_body::<String>(None));
11667
11668 client.request(request.unwrap()).await
11669 };
11670
11671 match req_result {
11672 Err(err) => {
11673 if let common::Retry::After(d) = dlg.http_error(&err) {
11674 sleep(d).await;
11675 continue;
11676 }
11677 dlg.finished(false);
11678 return Err(common::Error::HttpError(err));
11679 }
11680 Ok(res) => {
11681 let (mut parts, body) = res.into_parts();
11682 let mut body = common::Body::new(body);
11683 if !parts.status.is_success() {
11684 let bytes = common::to_bytes(body).await.unwrap_or_default();
11685 let error = serde_json::from_str(&common::to_string(&bytes));
11686 let response = common::to_response(parts, bytes.into());
11687
11688 if let common::Retry::After(d) =
11689 dlg.http_failure(&response, error.as_ref().ok())
11690 {
11691 sleep(d).await;
11692 continue;
11693 }
11694
11695 dlg.finished(false);
11696
11697 return Err(match error {
11698 Ok(value) => common::Error::BadRequest(value),
11699 _ => common::Error::Failure(response),
11700 });
11701 }
11702 let response = {
11703 let bytes = common::to_bytes(body).await.unwrap_or_default();
11704 let encoded = common::to_string(&bytes);
11705 match serde_json::from_str(&encoded) {
11706 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11707 Err(error) => {
11708 dlg.response_json_decode_error(&encoded, &error);
11709 return Err(common::Error::JsonDecodeError(
11710 encoded.to_string(),
11711 error,
11712 ));
11713 }
11714 }
11715 };
11716
11717 dlg.finished(true);
11718 return Ok(response);
11719 }
11720 }
11721 }
11722 }
11723
11724 /// Required. Account to get information about. Format: accounts/{account}
11725 ///
11726 /// Sets the *name* path property to the given value.
11727 ///
11728 /// Even though the property as already been set when instantiating this call,
11729 /// we provide this method for API completeness.
11730 pub fn name(mut self, new_value: &str) -> AccountGetCall<'a, C> {
11731 self._name = new_value.to_string();
11732 self
11733 }
11734 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11735 /// while executing the actual API request.
11736 ///
11737 /// ````text
11738 /// It should be used to handle progress information, and to implement a certain level of resilience.
11739 /// ````
11740 ///
11741 /// Sets the *delegate* property to the given value.
11742 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
11743 self._delegate = Some(new_value);
11744 self
11745 }
11746
11747 /// Set any additional parameter of the query string used in the request.
11748 /// It should be used to set parameters which are not yet available through their own
11749 /// setters.
11750 ///
11751 /// Please note that this method must not be used to set any of the known parameters
11752 /// which have their own setter method. If done anyway, the request will fail.
11753 ///
11754 /// # Additional Parameters
11755 ///
11756 /// * *$.xgafv* (query-string) - V1 error format.
11757 /// * *access_token* (query-string) - OAuth access token.
11758 /// * *alt* (query-string) - Data format for response.
11759 /// * *callback* (query-string) - JSONP
11760 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11761 /// * *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.
11762 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11763 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11764 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
11765 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11766 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11767 pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
11768 where
11769 T: AsRef<str>,
11770 {
11771 self._additional_params
11772 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11773 self
11774 }
11775
11776 /// Identifies the authorization scope for the method you are building.
11777 ///
11778 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11779 /// [`Scope::Readonly`].
11780 ///
11781 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11782 /// tokens for more than one scope.
11783 ///
11784 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11785 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11786 /// sufficient, a read-write scope will do as well.
11787 pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
11788 where
11789 St: AsRef<str>,
11790 {
11791 self._scopes.insert(String::from(scope.as_ref()));
11792 self
11793 }
11794 /// Identifies the authorization scope(s) for the method you are building.
11795 ///
11796 /// See [`Self::add_scope()`] for details.
11797 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
11798 where
11799 I: IntoIterator<Item = St>,
11800 St: AsRef<str>,
11801 {
11802 self._scopes
11803 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11804 self
11805 }
11806
11807 /// Removes all scopes, and no default scope will be used either.
11808 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11809 /// for details).
11810 pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
11811 self._scopes.clear();
11812 self
11813 }
11814}
11815
11816/// Gets the ad blocking recovery tag of an account.
11817///
11818/// A builder for the *getAdBlockingRecoveryTag* method supported by a *account* resource.
11819/// It is not used directly, but through a [`AccountMethods`] instance.
11820///
11821/// # Example
11822///
11823/// Instantiate a resource method builder
11824///
11825/// ```test_harness,no_run
11826/// # extern crate hyper;
11827/// # extern crate hyper_rustls;
11828/// # extern crate google_adsense2 as adsense2;
11829/// # async fn dox() {
11830/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11831///
11832/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11833/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11834/// # .with_native_roots()
11835/// # .unwrap()
11836/// # .https_only()
11837/// # .enable_http2()
11838/// # .build();
11839///
11840/// # let executor = hyper_util::rt::TokioExecutor::new();
11841/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11842/// # secret,
11843/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11844/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11845/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11846/// # ),
11847/// # ).build().await.unwrap();
11848///
11849/// # let client = hyper_util::client::legacy::Client::builder(
11850/// # hyper_util::rt::TokioExecutor::new()
11851/// # )
11852/// # .build(
11853/// # hyper_rustls::HttpsConnectorBuilder::new()
11854/// # .with_native_roots()
11855/// # .unwrap()
11856/// # .https_or_http()
11857/// # .enable_http2()
11858/// # .build()
11859/// # );
11860/// # let mut hub = Adsense::new(client, auth);
11861/// // You can configure optional parameters by calling the respective setters at will, and
11862/// // execute the final call using `doit()`.
11863/// // Values shown here are possibly random and not representative !
11864/// let result = hub.accounts().get_ad_blocking_recovery_tag("name")
11865/// .doit().await;
11866/// # }
11867/// ```
11868pub struct AccountGetAdBlockingRecoveryTagCall<'a, C>
11869where
11870 C: 'a,
11871{
11872 hub: &'a Adsense<C>,
11873 _name: String,
11874 _delegate: Option<&'a mut dyn common::Delegate>,
11875 _additional_params: HashMap<String, String>,
11876 _scopes: BTreeSet<String>,
11877}
11878
11879impl<'a, C> common::CallBuilder for AccountGetAdBlockingRecoveryTagCall<'a, C> {}
11880
11881impl<'a, C> AccountGetAdBlockingRecoveryTagCall<'a, C>
11882where
11883 C: common::Connector,
11884{
11885 /// Perform the operation you have build so far.
11886 pub async fn doit(mut self) -> common::Result<(common::Response, AdBlockingRecoveryTag)> {
11887 use std::borrow::Cow;
11888 use std::io::{Read, Seek};
11889
11890 use common::{url::Params, ToParts};
11891 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11892
11893 let mut dd = common::DefaultDelegate;
11894 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11895 dlg.begin(common::MethodInfo {
11896 id: "adsense.accounts.getAdBlockingRecoveryTag",
11897 http_method: hyper::Method::GET,
11898 });
11899
11900 for &field in ["alt", "name"].iter() {
11901 if self._additional_params.contains_key(field) {
11902 dlg.finished(false);
11903 return Err(common::Error::FieldClash(field));
11904 }
11905 }
11906
11907 let mut params = Params::with_capacity(3 + self._additional_params.len());
11908 params.push("name", self._name);
11909
11910 params.extend(self._additional_params.iter());
11911
11912 params.push("alt", "json");
11913 let mut url = self.hub._base_url.clone() + "v2/{+name}/adBlockingRecoveryTag";
11914 if self._scopes.is_empty() {
11915 self._scopes.insert(Scope::Readonly.as_ref().to_string());
11916 }
11917
11918 #[allow(clippy::single_element_loop)]
11919 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11920 url = params.uri_replacement(url, param_name, find_this, true);
11921 }
11922 {
11923 let to_remove = ["name"];
11924 params.remove_params(&to_remove);
11925 }
11926
11927 let url = params.parse_with_url(&url);
11928
11929 loop {
11930 let token = match self
11931 .hub
11932 .auth
11933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11934 .await
11935 {
11936 Ok(token) => token,
11937 Err(e) => match dlg.token(e) {
11938 Ok(token) => token,
11939 Err(e) => {
11940 dlg.finished(false);
11941 return Err(common::Error::MissingToken(e));
11942 }
11943 },
11944 };
11945 let mut req_result = {
11946 let client = &self.hub.client;
11947 dlg.pre_request();
11948 let mut req_builder = hyper::Request::builder()
11949 .method(hyper::Method::GET)
11950 .uri(url.as_str())
11951 .header(USER_AGENT, self.hub._user_agent.clone());
11952
11953 if let Some(token) = token.as_ref() {
11954 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11955 }
11956
11957 let request = req_builder
11958 .header(CONTENT_LENGTH, 0_u64)
11959 .body(common::to_body::<String>(None));
11960
11961 client.request(request.unwrap()).await
11962 };
11963
11964 match req_result {
11965 Err(err) => {
11966 if let common::Retry::After(d) = dlg.http_error(&err) {
11967 sleep(d).await;
11968 continue;
11969 }
11970 dlg.finished(false);
11971 return Err(common::Error::HttpError(err));
11972 }
11973 Ok(res) => {
11974 let (mut parts, body) = res.into_parts();
11975 let mut body = common::Body::new(body);
11976 if !parts.status.is_success() {
11977 let bytes = common::to_bytes(body).await.unwrap_or_default();
11978 let error = serde_json::from_str(&common::to_string(&bytes));
11979 let response = common::to_response(parts, bytes.into());
11980
11981 if let common::Retry::After(d) =
11982 dlg.http_failure(&response, error.as_ref().ok())
11983 {
11984 sleep(d).await;
11985 continue;
11986 }
11987
11988 dlg.finished(false);
11989
11990 return Err(match error {
11991 Ok(value) => common::Error::BadRequest(value),
11992 _ => common::Error::Failure(response),
11993 });
11994 }
11995 let response = {
11996 let bytes = common::to_bytes(body).await.unwrap_or_default();
11997 let encoded = common::to_string(&bytes);
11998 match serde_json::from_str(&encoded) {
11999 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12000 Err(error) => {
12001 dlg.response_json_decode_error(&encoded, &error);
12002 return Err(common::Error::JsonDecodeError(
12003 encoded.to_string(),
12004 error,
12005 ));
12006 }
12007 }
12008 };
12009
12010 dlg.finished(true);
12011 return Ok(response);
12012 }
12013 }
12014 }
12015 }
12016
12017 /// Required. The name of the account to get the tag for. Format: accounts/{account}
12018 ///
12019 /// Sets the *name* path property to the given value.
12020 ///
12021 /// Even though the property as already been set when instantiating this call,
12022 /// we provide this method for API completeness.
12023 pub fn name(mut self, new_value: &str) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
12024 self._name = new_value.to_string();
12025 self
12026 }
12027 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12028 /// while executing the actual API request.
12029 ///
12030 /// ````text
12031 /// It should be used to handle progress information, and to implement a certain level of resilience.
12032 /// ````
12033 ///
12034 /// Sets the *delegate* property to the given value.
12035 pub fn delegate(
12036 mut self,
12037 new_value: &'a mut dyn common::Delegate,
12038 ) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
12039 self._delegate = Some(new_value);
12040 self
12041 }
12042
12043 /// Set any additional parameter of the query string used in the request.
12044 /// It should be used to set parameters which are not yet available through their own
12045 /// setters.
12046 ///
12047 /// Please note that this method must not be used to set any of the known parameters
12048 /// which have their own setter method. If done anyway, the request will fail.
12049 ///
12050 /// # Additional Parameters
12051 ///
12052 /// * *$.xgafv* (query-string) - V1 error format.
12053 /// * *access_token* (query-string) - OAuth access token.
12054 /// * *alt* (query-string) - Data format for response.
12055 /// * *callback* (query-string) - JSONP
12056 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12057 /// * *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.
12058 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12059 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12060 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12061 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12062 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12063 pub fn param<T>(mut self, name: T, value: T) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
12064 where
12065 T: AsRef<str>,
12066 {
12067 self._additional_params
12068 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12069 self
12070 }
12071
12072 /// Identifies the authorization scope for the method you are building.
12073 ///
12074 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12075 /// [`Scope::Readonly`].
12076 ///
12077 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12078 /// tokens for more than one scope.
12079 ///
12080 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12081 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12082 /// sufficient, a read-write scope will do as well.
12083 pub fn add_scope<St>(mut self, scope: St) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
12084 where
12085 St: AsRef<str>,
12086 {
12087 self._scopes.insert(String::from(scope.as_ref()));
12088 self
12089 }
12090 /// Identifies the authorization scope(s) for the method you are building.
12091 ///
12092 /// See [`Self::add_scope()`] for details.
12093 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetAdBlockingRecoveryTagCall<'a, C>
12094 where
12095 I: IntoIterator<Item = St>,
12096 St: AsRef<str>,
12097 {
12098 self._scopes
12099 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12100 self
12101 }
12102
12103 /// Removes all scopes, and no default scope will be used either.
12104 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12105 /// for details).
12106 pub fn clear_scopes(mut self) -> AccountGetAdBlockingRecoveryTagCall<'a, C> {
12107 self._scopes.clear();
12108 self
12109 }
12110}
12111
12112/// Lists all accounts available to this user.
12113///
12114/// A builder for the *list* method supported by a *account* resource.
12115/// It is not used directly, but through a [`AccountMethods`] instance.
12116///
12117/// # Example
12118///
12119/// Instantiate a resource method builder
12120///
12121/// ```test_harness,no_run
12122/// # extern crate hyper;
12123/// # extern crate hyper_rustls;
12124/// # extern crate google_adsense2 as adsense2;
12125/// # async fn dox() {
12126/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12127///
12128/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12129/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12130/// # .with_native_roots()
12131/// # .unwrap()
12132/// # .https_only()
12133/// # .enable_http2()
12134/// # .build();
12135///
12136/// # let executor = hyper_util::rt::TokioExecutor::new();
12137/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12138/// # secret,
12139/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12140/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12141/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12142/// # ),
12143/// # ).build().await.unwrap();
12144///
12145/// # let client = hyper_util::client::legacy::Client::builder(
12146/// # hyper_util::rt::TokioExecutor::new()
12147/// # )
12148/// # .build(
12149/// # hyper_rustls::HttpsConnectorBuilder::new()
12150/// # .with_native_roots()
12151/// # .unwrap()
12152/// # .https_or_http()
12153/// # .enable_http2()
12154/// # .build()
12155/// # );
12156/// # let mut hub = Adsense::new(client, auth);
12157/// // You can configure optional parameters by calling the respective setters at will, and
12158/// // execute the final call using `doit()`.
12159/// // Values shown here are possibly random and not representative !
12160/// let result = hub.accounts().list()
12161/// .page_token("ea")
12162/// .page_size(-15)
12163/// .doit().await;
12164/// # }
12165/// ```
12166pub struct AccountListCall<'a, C>
12167where
12168 C: 'a,
12169{
12170 hub: &'a Adsense<C>,
12171 _page_token: Option<String>,
12172 _page_size: Option<i32>,
12173 _delegate: Option<&'a mut dyn common::Delegate>,
12174 _additional_params: HashMap<String, String>,
12175 _scopes: BTreeSet<String>,
12176}
12177
12178impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
12179
12180impl<'a, C> AccountListCall<'a, C>
12181where
12182 C: common::Connector,
12183{
12184 /// Perform the operation you have build so far.
12185 pub async fn doit(mut self) -> common::Result<(common::Response, ListAccountsResponse)> {
12186 use std::borrow::Cow;
12187 use std::io::{Read, Seek};
12188
12189 use common::{url::Params, ToParts};
12190 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12191
12192 let mut dd = common::DefaultDelegate;
12193 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12194 dlg.begin(common::MethodInfo {
12195 id: "adsense.accounts.list",
12196 http_method: hyper::Method::GET,
12197 });
12198
12199 for &field in ["alt", "pageToken", "pageSize"].iter() {
12200 if self._additional_params.contains_key(field) {
12201 dlg.finished(false);
12202 return Err(common::Error::FieldClash(field));
12203 }
12204 }
12205
12206 let mut params = Params::with_capacity(4 + self._additional_params.len());
12207 if let Some(value) = self._page_token.as_ref() {
12208 params.push("pageToken", value);
12209 }
12210 if let Some(value) = self._page_size.as_ref() {
12211 params.push("pageSize", value.to_string());
12212 }
12213
12214 params.extend(self._additional_params.iter());
12215
12216 params.push("alt", "json");
12217 let mut url = self.hub._base_url.clone() + "v2/accounts";
12218 if self._scopes.is_empty() {
12219 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12220 }
12221
12222 let url = params.parse_with_url(&url);
12223
12224 loop {
12225 let token = match self
12226 .hub
12227 .auth
12228 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12229 .await
12230 {
12231 Ok(token) => token,
12232 Err(e) => match dlg.token(e) {
12233 Ok(token) => token,
12234 Err(e) => {
12235 dlg.finished(false);
12236 return Err(common::Error::MissingToken(e));
12237 }
12238 },
12239 };
12240 let mut req_result = {
12241 let client = &self.hub.client;
12242 dlg.pre_request();
12243 let mut req_builder = hyper::Request::builder()
12244 .method(hyper::Method::GET)
12245 .uri(url.as_str())
12246 .header(USER_AGENT, self.hub._user_agent.clone());
12247
12248 if let Some(token) = token.as_ref() {
12249 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12250 }
12251
12252 let request = req_builder
12253 .header(CONTENT_LENGTH, 0_u64)
12254 .body(common::to_body::<String>(None));
12255
12256 client.request(request.unwrap()).await
12257 };
12258
12259 match req_result {
12260 Err(err) => {
12261 if let common::Retry::After(d) = dlg.http_error(&err) {
12262 sleep(d).await;
12263 continue;
12264 }
12265 dlg.finished(false);
12266 return Err(common::Error::HttpError(err));
12267 }
12268 Ok(res) => {
12269 let (mut parts, body) = res.into_parts();
12270 let mut body = common::Body::new(body);
12271 if !parts.status.is_success() {
12272 let bytes = common::to_bytes(body).await.unwrap_or_default();
12273 let error = serde_json::from_str(&common::to_string(&bytes));
12274 let response = common::to_response(parts, bytes.into());
12275
12276 if let common::Retry::After(d) =
12277 dlg.http_failure(&response, error.as_ref().ok())
12278 {
12279 sleep(d).await;
12280 continue;
12281 }
12282
12283 dlg.finished(false);
12284
12285 return Err(match error {
12286 Ok(value) => common::Error::BadRequest(value),
12287 _ => common::Error::Failure(response),
12288 });
12289 }
12290 let response = {
12291 let bytes = common::to_bytes(body).await.unwrap_or_default();
12292 let encoded = common::to_string(&bytes);
12293 match serde_json::from_str(&encoded) {
12294 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12295 Err(error) => {
12296 dlg.response_json_decode_error(&encoded, &error);
12297 return Err(common::Error::JsonDecodeError(
12298 encoded.to_string(),
12299 error,
12300 ));
12301 }
12302 }
12303 };
12304
12305 dlg.finished(true);
12306 return Ok(response);
12307 }
12308 }
12309 }
12310 }
12311
12312 /// A page token, received from a previous `ListAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAccounts` must match the call that provided the page token.
12313 ///
12314 /// Sets the *page token* query property to the given value.
12315 pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C> {
12316 self._page_token = Some(new_value.to_string());
12317 self
12318 }
12319 /// The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
12320 ///
12321 /// Sets the *page size* query property to the given value.
12322 pub fn page_size(mut self, new_value: i32) -> AccountListCall<'a, C> {
12323 self._page_size = Some(new_value);
12324 self
12325 }
12326 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12327 /// while executing the actual API request.
12328 ///
12329 /// ````text
12330 /// It should be used to handle progress information, and to implement a certain level of resilience.
12331 /// ````
12332 ///
12333 /// Sets the *delegate* property to the given value.
12334 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
12335 self._delegate = Some(new_value);
12336 self
12337 }
12338
12339 /// Set any additional parameter of the query string used in the request.
12340 /// It should be used to set parameters which are not yet available through their own
12341 /// setters.
12342 ///
12343 /// Please note that this method must not be used to set any of the known parameters
12344 /// which have their own setter method. If done anyway, the request will fail.
12345 ///
12346 /// # Additional Parameters
12347 ///
12348 /// * *$.xgafv* (query-string) - V1 error format.
12349 /// * *access_token* (query-string) - OAuth access token.
12350 /// * *alt* (query-string) - Data format for response.
12351 /// * *callback* (query-string) - JSONP
12352 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12353 /// * *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.
12354 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12355 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12356 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12357 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12358 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12359 pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
12360 where
12361 T: AsRef<str>,
12362 {
12363 self._additional_params
12364 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12365 self
12366 }
12367
12368 /// Identifies the authorization scope for the method you are building.
12369 ///
12370 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12371 /// [`Scope::Readonly`].
12372 ///
12373 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12374 /// tokens for more than one scope.
12375 ///
12376 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12377 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12378 /// sufficient, a read-write scope will do as well.
12379 pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
12380 where
12381 St: AsRef<str>,
12382 {
12383 self._scopes.insert(String::from(scope.as_ref()));
12384 self
12385 }
12386 /// Identifies the authorization scope(s) for the method you are building.
12387 ///
12388 /// See [`Self::add_scope()`] for details.
12389 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
12390 where
12391 I: IntoIterator<Item = St>,
12392 St: AsRef<str>,
12393 {
12394 self._scopes
12395 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12396 self
12397 }
12398
12399 /// Removes all scopes, and no default scope will be used either.
12400 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12401 /// for details).
12402 pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
12403 self._scopes.clear();
12404 self
12405 }
12406}
12407
12408/// Lists all accounts directly managed by the given AdSense account.
12409///
12410/// A builder for the *listChildAccounts* method supported by a *account* resource.
12411/// It is not used directly, but through a [`AccountMethods`] instance.
12412///
12413/// # Example
12414///
12415/// Instantiate a resource method builder
12416///
12417/// ```test_harness,no_run
12418/// # extern crate hyper;
12419/// # extern crate hyper_rustls;
12420/// # extern crate google_adsense2 as adsense2;
12421/// # async fn dox() {
12422/// # use adsense2::{Adsense, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12423///
12424/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12425/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12426/// # .with_native_roots()
12427/// # .unwrap()
12428/// # .https_only()
12429/// # .enable_http2()
12430/// # .build();
12431///
12432/// # let executor = hyper_util::rt::TokioExecutor::new();
12433/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12434/// # secret,
12435/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12436/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12437/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12438/// # ),
12439/// # ).build().await.unwrap();
12440///
12441/// # let client = hyper_util::client::legacy::Client::builder(
12442/// # hyper_util::rt::TokioExecutor::new()
12443/// # )
12444/// # .build(
12445/// # hyper_rustls::HttpsConnectorBuilder::new()
12446/// # .with_native_roots()
12447/// # .unwrap()
12448/// # .https_or_http()
12449/// # .enable_http2()
12450/// # .build()
12451/// # );
12452/// # let mut hub = Adsense::new(client, auth);
12453/// // You can configure optional parameters by calling the respective setters at will, and
12454/// // execute the final call using `doit()`.
12455/// // Values shown here are possibly random and not representative !
12456/// let result = hub.accounts().list_child_accounts("parent")
12457/// .page_token("eos")
12458/// .page_size(-68)
12459/// .doit().await;
12460/// # }
12461/// ```
12462pub struct AccountListChildAccountCall<'a, C>
12463where
12464 C: 'a,
12465{
12466 hub: &'a Adsense<C>,
12467 _parent: String,
12468 _page_token: Option<String>,
12469 _page_size: Option<i32>,
12470 _delegate: Option<&'a mut dyn common::Delegate>,
12471 _additional_params: HashMap<String, String>,
12472 _scopes: BTreeSet<String>,
12473}
12474
12475impl<'a, C> common::CallBuilder for AccountListChildAccountCall<'a, C> {}
12476
12477impl<'a, C> AccountListChildAccountCall<'a, C>
12478where
12479 C: common::Connector,
12480{
12481 /// Perform the operation you have build so far.
12482 pub async fn doit(mut self) -> common::Result<(common::Response, ListChildAccountsResponse)> {
12483 use std::borrow::Cow;
12484 use std::io::{Read, Seek};
12485
12486 use common::{url::Params, ToParts};
12487 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12488
12489 let mut dd = common::DefaultDelegate;
12490 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12491 dlg.begin(common::MethodInfo {
12492 id: "adsense.accounts.listChildAccounts",
12493 http_method: hyper::Method::GET,
12494 });
12495
12496 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12497 if self._additional_params.contains_key(field) {
12498 dlg.finished(false);
12499 return Err(common::Error::FieldClash(field));
12500 }
12501 }
12502
12503 let mut params = Params::with_capacity(5 + self._additional_params.len());
12504 params.push("parent", self._parent);
12505 if let Some(value) = self._page_token.as_ref() {
12506 params.push("pageToken", value);
12507 }
12508 if let Some(value) = self._page_size.as_ref() {
12509 params.push("pageSize", value.to_string());
12510 }
12511
12512 params.extend(self._additional_params.iter());
12513
12514 params.push("alt", "json");
12515 let mut url = self.hub._base_url.clone() + "v2/{+parent}:listChildAccounts";
12516 if self._scopes.is_empty() {
12517 self._scopes.insert(Scope::Readonly.as_ref().to_string());
12518 }
12519
12520 #[allow(clippy::single_element_loop)]
12521 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12522 url = params.uri_replacement(url, param_name, find_this, true);
12523 }
12524 {
12525 let to_remove = ["parent"];
12526 params.remove_params(&to_remove);
12527 }
12528
12529 let url = params.parse_with_url(&url);
12530
12531 loop {
12532 let token = match self
12533 .hub
12534 .auth
12535 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12536 .await
12537 {
12538 Ok(token) => token,
12539 Err(e) => match dlg.token(e) {
12540 Ok(token) => token,
12541 Err(e) => {
12542 dlg.finished(false);
12543 return Err(common::Error::MissingToken(e));
12544 }
12545 },
12546 };
12547 let mut req_result = {
12548 let client = &self.hub.client;
12549 dlg.pre_request();
12550 let mut req_builder = hyper::Request::builder()
12551 .method(hyper::Method::GET)
12552 .uri(url.as_str())
12553 .header(USER_AGENT, self.hub._user_agent.clone());
12554
12555 if let Some(token) = token.as_ref() {
12556 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12557 }
12558
12559 let request = req_builder
12560 .header(CONTENT_LENGTH, 0_u64)
12561 .body(common::to_body::<String>(None));
12562
12563 client.request(request.unwrap()).await
12564 };
12565
12566 match req_result {
12567 Err(err) => {
12568 if let common::Retry::After(d) = dlg.http_error(&err) {
12569 sleep(d).await;
12570 continue;
12571 }
12572 dlg.finished(false);
12573 return Err(common::Error::HttpError(err));
12574 }
12575 Ok(res) => {
12576 let (mut parts, body) = res.into_parts();
12577 let mut body = common::Body::new(body);
12578 if !parts.status.is_success() {
12579 let bytes = common::to_bytes(body).await.unwrap_or_default();
12580 let error = serde_json::from_str(&common::to_string(&bytes));
12581 let response = common::to_response(parts, bytes.into());
12582
12583 if let common::Retry::After(d) =
12584 dlg.http_failure(&response, error.as_ref().ok())
12585 {
12586 sleep(d).await;
12587 continue;
12588 }
12589
12590 dlg.finished(false);
12591
12592 return Err(match error {
12593 Ok(value) => common::Error::BadRequest(value),
12594 _ => common::Error::Failure(response),
12595 });
12596 }
12597 let response = {
12598 let bytes = common::to_bytes(body).await.unwrap_or_default();
12599 let encoded = common::to_string(&bytes);
12600 match serde_json::from_str(&encoded) {
12601 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12602 Err(error) => {
12603 dlg.response_json_decode_error(&encoded, &error);
12604 return Err(common::Error::JsonDecodeError(
12605 encoded.to_string(),
12606 error,
12607 ));
12608 }
12609 }
12610 };
12611
12612 dlg.finished(true);
12613 return Ok(response);
12614 }
12615 }
12616 }
12617 }
12618
12619 /// Required. The parent account, which owns the child accounts. Format: accounts/{account}
12620 ///
12621 /// Sets the *parent* path property to the given value.
12622 ///
12623 /// Even though the property as already been set when instantiating this call,
12624 /// we provide this method for API completeness.
12625 pub fn parent(mut self, new_value: &str) -> AccountListChildAccountCall<'a, C> {
12626 self._parent = new_value.to_string();
12627 self
12628 }
12629 /// A page token, received from a previous `ListChildAccounts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListChildAccounts` must match the call that provided the page token.
12630 ///
12631 /// Sets the *page token* query property to the given value.
12632 pub fn page_token(mut self, new_value: &str) -> AccountListChildAccountCall<'a, C> {
12633 self._page_token = Some(new_value.to_string());
12634 self
12635 }
12636 /// The maximum number of accounts to include in the response, used for paging. If unspecified, at most 10000 accounts will be returned. The maximum value is 10000; values above 10000 will be coerced to 10000.
12637 ///
12638 /// Sets the *page size* query property to the given value.
12639 pub fn page_size(mut self, new_value: i32) -> AccountListChildAccountCall<'a, C> {
12640 self._page_size = Some(new_value);
12641 self
12642 }
12643 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12644 /// while executing the actual API request.
12645 ///
12646 /// ````text
12647 /// It should be used to handle progress information, and to implement a certain level of resilience.
12648 /// ````
12649 ///
12650 /// Sets the *delegate* property to the given value.
12651 pub fn delegate(
12652 mut self,
12653 new_value: &'a mut dyn common::Delegate,
12654 ) -> AccountListChildAccountCall<'a, C> {
12655 self._delegate = Some(new_value);
12656 self
12657 }
12658
12659 /// Set any additional parameter of the query string used in the request.
12660 /// It should be used to set parameters which are not yet available through their own
12661 /// setters.
12662 ///
12663 /// Please note that this method must not be used to set any of the known parameters
12664 /// which have their own setter method. If done anyway, the request will fail.
12665 ///
12666 /// # Additional Parameters
12667 ///
12668 /// * *$.xgafv* (query-string) - V1 error format.
12669 /// * *access_token* (query-string) - OAuth access token.
12670 /// * *alt* (query-string) - Data format for response.
12671 /// * *callback* (query-string) - JSONP
12672 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12673 /// * *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.
12674 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12675 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12676 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
12677 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12678 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12679 pub fn param<T>(mut self, name: T, value: T) -> AccountListChildAccountCall<'a, C>
12680 where
12681 T: AsRef<str>,
12682 {
12683 self._additional_params
12684 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12685 self
12686 }
12687
12688 /// Identifies the authorization scope for the method you are building.
12689 ///
12690 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12691 /// [`Scope::Readonly`].
12692 ///
12693 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12694 /// tokens for more than one scope.
12695 ///
12696 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12697 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12698 /// sufficient, a read-write scope will do as well.
12699 pub fn add_scope<St>(mut self, scope: St) -> AccountListChildAccountCall<'a, C>
12700 where
12701 St: AsRef<str>,
12702 {
12703 self._scopes.insert(String::from(scope.as_ref()));
12704 self
12705 }
12706 /// Identifies the authorization scope(s) for the method you are building.
12707 ///
12708 /// See [`Self::add_scope()`] for details.
12709 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListChildAccountCall<'a, C>
12710 where
12711 I: IntoIterator<Item = St>,
12712 St: AsRef<str>,
12713 {
12714 self._scopes
12715 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12716 self
12717 }
12718
12719 /// Removes all scopes, and no default scope will be used either.
12720 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12721 /// for details).
12722 pub fn clear_scopes(mut self) -> AccountListChildAccountCall<'a, C> {
12723 self._scopes.clear();
12724 self
12725 }
12726}